/* Parwati ERP — admin styles. Brand: crimson #B51520, wine #2B1216. */
:root {
  --brand: #b51520;
  --brand-dark: #8f1019;
  --brand-soft: #fbeaeb;
  --wine: #2b1216;
  --wine-2: #3a1a1f;
  --ink: #1f1a1b;
  --muted: #6b6264;
  --line: #e6dfe0;
  --bg: #f6f3f3;
  --card: #ffffff;
  --ok: #157347;
  --ok-soft: #e3f4ea;
  --warn: #8a5a00;
  --warn-soft: #fff4d6;
  --err: #b42318;
  --err-soft: #fdecea;
  --calc: #f7f2f2;
  --radius: 8px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); font-size: 14px; color: var(--ink); background: var(--bg); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 10px; }
h3 { font-size: 16px; margin: 0; }
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea {
  border: 1px solid #d6cdcf; border-radius: 6px; padding: 7px 9px; background: #fff; min-width: 0; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(181, 21, 32, 0.25); border-color: var(--brand); }
input:disabled, select:disabled, textarea:disabled { background: #f3f0f0; color: #555; }
input.readonly { background: var(--calc); }
input[type='checkbox'], input[type='radio'] { width: auto; accent-color: var(--brand); }
kbd { font-family: ui-monospace, monospace; font-size: 10.5px; padding: 1px 5px; border-radius: 4px; border: 1px solid currentColor; opacity: 0.6; margin-left: 6px; }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, monospace; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 4px; border: 1px solid #d6cdcf; background: #fff; border-radius: 6px; padding: 7px 14px; cursor: pointer; white-space: nowrap; color: var(--ink); }
.btn:hover { background: #faf6f6; text-decoration: none; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-danger-outline { border-color: #e7b4b8; color: var(--err); }
.btn-ghost { background: transparent; border-color: rgba(255, 255, 255, 0.25); color: #fff; }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.08); }
.btn-sm { padding: 4px 10px; font-size: 12.5px; }
.btn-block { width: 100%; justify-content: center; }
.icon-btn { border: 0; background: transparent; cursor: pointer; font-size: 18px; line-height: 1; padding: 2px 6px; border-radius: 4px; color: var(--muted); }
.icon-btn:hover { background: #f1eaea; }
.icon-btn.danger:hover, .link-btn.danger { color: var(--err); }
.link-btn { border: 0; background: none; padding: 0; color: var(--brand); cursor: pointer; }
.link-btn:hover { text-decoration: underline; }

/* Shell */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 232px; background: var(--wine); color: #f3e9ea; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; flex-shrink: 0; }
.brand { display: flex; gap: 10px; align-items: center; padding: 16px 14px; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
.brand img { width: 34px; height: 34px; object-fit: contain; }
.brand-name { font-weight: 700; font-size: 15px; }
.brand-sub { font-size: 11px; opacity: 0.6; letter-spacing: 0.1em; }
.sidebar nav { flex: 1; overflow-y: auto; padding: 8px 0; }
.nav-link { display: flex; justify-content: space-between; align-items: center; padding: 9px 16px; color: #f3e9ea; border-left: 3px solid transparent; }
.nav-link:hover { background: var(--wine-2); text-decoration: none; }
.nav-link.active { background: var(--wine-2); border-left-color: var(--brand); color: #fff; font-weight: 600; }
.nav-link.sub { padding-left: 30px; font-size: 13.5px; }
.nav-link kbd { opacity: 0.45; }
.nav-group-head { width: 100%; display: flex; justify-content: space-between; background: none; border: 0; color: #f3e9ea; padding: 9px 16px; cursor: pointer; font-weight: 600; text-align: left; }
.nav-group-head:hover { background: var(--wine-2); }
.chev { opacity: 0.6; }
.sidebar-foot { padding: 12px 14px; border-top: 1px solid rgba(255, 255, 255, 0.08); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.user-chip { display: flex; flex-direction: column; font-size: 13px; }
.user-chip span { opacity: 0.6; font-size: 11.5px; text-transform: capitalize; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content { padding: 18px 22px 40px; }
.topbar-mobile { display: none; }

/* Page furniture */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.card.flush { padding: 0; overflow-x: auto; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-2.wide-left { grid-template-columns: 2fr 1fr; }
.row { display: flex; align-items: center; }
.row.gap { gap: 12px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; gap: 8px; margin-top: 14px; }
.toolbar { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar input:not([type]), .toolbar input[type='text'] { max-width: 320px; }
.toolbar select { width: auto; }
label.inline { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
label.inline input, label.inline select { width: auto; }
.empty { padding: 40px; text-align: center; color: var(--muted); background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); }
.alert { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; border: 1px solid transparent; }
.alert-error { background: var(--err-soft); color: var(--err); border-color: #f5c2bd; }
.alert-warn { background: var(--warn-soft); color: var(--warn); border-color: #f1dca0; }
.alert-info { background: #eef4ff; color: #1d4ed8; border-color: #c7d7fe; }
.badge { display: inline-block; font-size: 11.5px; padding: 2px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-dark); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-muted { background: #eee; color: #666; }
.text-due { color: var(--err); font-weight: 600; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.stat span { color: var(--muted); font-size: 13px; }
.stat b { font-size: 21px; }
.stat small { color: var(--muted); }

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); background: #faf7f7; font-weight: 600; }
.table th.num, .table td.num { text-align: right; }
.table tr:last-child td { border-bottom: 0; }
.table td.actions { white-space: nowrap; text-align: right; }
.table td.actions > * + * { margin-left: 12px; }
.row-cancelled td { color: #9a9192; text-decoration: line-through; }
.row-cancelled td.actions, .row-cancelled td:last-child { text-decoration: none; }
.input-num { max-width: 150px; text-align: right; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.field-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.field-hint { font-size: 11.5px; color: var(--muted); }
.req { color: var(--brand); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid.three { grid-template-columns: repeat(3, 1fr); }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-3 { grid-column: 1 / -1; }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; margin-bottom: 10px; }

/* Modal + toasts */
.modal-backdrop { position: fixed; inset: 0; background: rgba(30, 10, 14, 0.45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; overflow-y: auto; }
.modal { background: #fff; border-radius: 10px; max-width: 100%; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 16px 18px; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; max-width: min(420px, calc(100vw - 32px)); }
.toast { padding: 10px 14px; border-radius: 8px; background: #2b2425; color: #fff; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2); }
.toast-success { background: var(--ok); }
.toast-error { background: var(--err); }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--wine), #5a1d25); padding: 16px; }
.login-card { background: #fff; border-radius: 12px; padding: 30px; width: 360px; max-width: 100%; text-align: center; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3); }
.login-card .field { text-align: left; }
.login-card p { margin: 4px 0 18px; }
.login-logo { width: 64px; height: 64px; object-fit: contain; margin-bottom: 8px; }

/* ── Sale Bill ───────────────────────────────────────────────────────────── */
.salebill .card { margin-bottom: 10px; }
.sb-head { padding: 12px 16px; }
.sb-head-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 10px 22px; align-items: center; }
.sb-field { display: grid; grid-template-columns: 96px 1fr; align-items: center; gap: 8px; margin: 0; position: relative; }
.sb-field > span { color: #333; font-size: 13.5px; }
.sb-add { grid-column: 2; justify-self: end; font-size: 12.5px; margin-top: -2px; }
.sb-billno b { font-size: 15px; white-space: nowrap; }
.sb-billno small { grid-column: 2; }
.sb-radios { display: flex; gap: 18px; }
.sb-radios .check { margin: 0; }
.sb-scan { grid-column: span 2; }
.sb-scan input { border: 2px dashed var(--brand); background: #fffafa; }
.party-search { position: relative; }
.party-ok { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); color: var(--ok); font-weight: 700; }
.dropdown { position: absolute; top: 100%; left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12); z-index: 20; margin-top: 2px; max-height: 260px; overflow-y: auto; }
.dropdown button { display: flex; justify-content: space-between; width: 100%; border: 0; background: #fff; padding: 8px 10px; cursor: pointer; text-align: left; gap: 10px; }
.dropdown button:hover, .dropdown button.active { background: var(--brand-soft); }
.dropdown span { color: var(--muted); }

.sb-grid-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; }
.sb-grid { border-collapse: collapse; width: 100%; font-size: 13px; }
.sb-grid th { background: var(--brand); color: #fff; font-weight: 600; padding: 8px 4px; border-right: 1px solid rgba(255, 255, 255, 0.2); white-space: nowrap; position: sticky; top: 0; }
.sb-grid td { border: 1px solid #eee3e4; padding: 0; height: 34px; }
.sb-grid td input, .sb-grid td select { border: 0; border-radius: 0; padding: 6px 5px; height: 33px; background: transparent; width: 100%; }
.sb-grid td select { padding: 4px 2px; }
.sb-grid td input:focus, .sb-grid td select:focus { outline: 2px solid var(--brand); outline-offset: -2px; background: #fffafa; }
.sb-grid td input[type='number'] { text-align: right; -moz-appearance: textfield; }
.sb-grid td input[type='number']::-webkit-inner-spin-button { -webkit-appearance: none; }
.sb-grid td input.manual { color: #1d4ed8; font-weight: 600; }
.sb-grid td.calc { background: var(--calc); text-align: right; padding: 0 6px; font-variant-numeric: tabular-nums; }
.sb-grid td.total { font-weight: 700; background: #f1ebf6; }
.sb-grid tr.row-return td { background: #fff6e8; }
.sb-grid tr.row-return td.calc { background: #fbeedd; }
.sb-grid tfoot td { background: #faf7f7; font-weight: 600; padding: 6px; }
.sb-foot { display: grid; grid-template-columns: 1.3fr auto 1.3fr; gap: 16px; align-items: start; }
.sb-mini { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; margin-bottom: 10px; }
.sb-mini div { display: flex; justify-content: space-between; padding: 7px 10px; background: #f4fbfb; }
.sb-mini div + div { border-left: 1px solid var(--line); }
.sb-entries { background: #fff; border: 1px solid var(--line); border-radius: 6px; margin-bottom: 10px; font-size: 13px; }
.sb-entries td { padding: 5px 8px; }
.sb-extra { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; }
.sb-extra .sb-field { grid-template-columns: 104px 1fr; }
.sb-actions-col { display: flex; flex-direction: column; gap: 8px; min-width: 150px; }
.sb-side-btn { justify-content: space-between; }
.sb-summary { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; }
.sb-sum-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.sb-sum-table th { font-size: 11.5px; color: var(--muted); text-align: right; padding: 4px 8px; }
.sb-sum-table td { padding: 5px 8px; border-bottom: 1px solid #f0e9ea; }
.sb-sum-table td:first-child { background: #eefafa; font-weight: 600; }
.sb-sum-table tr.sb-net td { font-weight: 700; }
.sb-closing td { font-weight: 800; font-size: 14.5px; }
.sb-closing.due td { background: #fdecea !important; color: var(--err); }
.sb-closing.credit td { background: #eef4ff !important; color: #1d4ed8; }
.sb-closing.settled td { background: #dcf5df !important; color: var(--ok); }
.sb-buttons { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; align-items: center; }
.salebill.is-cancelled .sb-grid-wrap, .salebill.is-cancelled .sb-head { opacity: 0.7; }

/* Labels */
.label-preview .label, .label-sheet { border: 1px solid #ccc; border-radius: 4px; padding: 2mm 3mm; background: #fff; font-size: 9px; line-height: 1.2; display: flex; flex-direction: column; gap: 1mm; overflow: hidden; }
.label-preview .label { width: 50mm; height: 25mm; }
.label-top { display: flex; justify-content: space-between; font-size: 9px; }
.label-bc { height: 8mm; }
.label-bc svg { width: 100%; height: 100%; display: block; }
.label-no { text-align: center; font-family: ui-monospace, monospace; font-size: 9px; letter-spacing: 0.08em; }
.label-info { display: flex; flex-wrap: wrap; gap: 0 6px; font-size: 8.5px; }
.labels-print { padding: 0; }
.print-hint { padding: 12px; color: var(--muted); }

/* Printed bill */
.bill-print { background: #fff; color: #111; max-width: 210mm; margin: 0 auto; padding: 10mm; font-size: 12.5px; }
.bill-print.size-A5 { max-width: 148mm; font-size: 10.5px; padding: 6mm; }
.print-toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.bp-head { display: flex; justify-content: space-between; border-bottom: 2px solid var(--brand); padding-bottom: 8px; margin-bottom: 8px; gap: 12px; }
.bp-head h1 { color: var(--brand); font-size: 22px; }
.bp-title { text-align: right; }
.bp-title h2 { margin: 0; letter-spacing: 0.08em; }
.bp-cancelled { color: var(--err); font-weight: 800; border: 2px solid var(--err); display: inline-block; padding: 2px 8px; margin-top: 4px; }
.bp-meta { display: flex; justify-content: space-between; margin-bottom: 8px; gap: 12px; }
.bp-meta-right { text-align: right; }
.bp-table { width: 100%; border-collapse: collapse; margin-bottom: 8px; }
.bp-table th, .bp-table td { border: 1px solid #bbb; padding: 4px 5px; }
.bp-table th { background: #f3e6e7; font-size: 11px; }
.bp-sub td { background: #fff3e0; font-weight: 600; }
.bp-bottom { display: flex; gap: 14px; justify-content: space-between; align-items: flex-start; }
.bp-left { flex: 1; }
.bp-box { border: 1px solid #ddd; padding: 6px 8px; margin-bottom: 6px; border-radius: 4px; }
.bp-words { margin: 6px 0; }
.bp-totals { border-collapse: collapse; min-width: 240px; }
.bp-totals td { padding: 3px 8px; border-bottom: 1px solid #eee; }
.bp-grand td { font-weight: 800; border-top: 2px solid #333; }
.bp-foot { margin-top: 14px; border-top: 1px solid #ccc; padding-top: 8px; }
.bp-sign { display: flex; justify-content: space-between; margin-top: 36px; font-weight: 600; }

@media print {
  body { background: #fff; }
  .no-print { display: none !important; }
  .bill-print { padding: 0; max-width: none; }
  .label-sheet { border: 0; border-radius: 0; page-break-after: always; break-after: page; }
}

/* Small screens */
@media (max-width: 1100px) {
  .sb-head-grid { grid-template-columns: 1fr 1fr; }
  .sb-scan { grid-column: span 2; }
  .sb-foot { grid-template-columns: 1fr; }
  .sb-actions-col { flex-direction: row; flex-wrap: wrap; }
  .stats { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .sidebar { position: fixed; left: -240px; z-index: 40; transition: left 0.2s; }
  .shell.nav-open .sidebar { left: 0; }
  .topbar-mobile { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--wine); color: #fff; }
  .topbar-mobile .icon-btn { color: #fff; }
  .content { padding: 14px 12px 32px; }
  .grid-2, .grid-2.wide-left, .form-grid, .form-grid.three, .stats { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .sb-head-grid { grid-template-columns: 1fr; }
  .sb-scan { grid-column: auto; }
  .sb-field { grid-template-columns: 90px 1fr; }
  .sb-extra { grid-template-columns: 1fr; }
}

/* A4 sticker sheets */
.sheet-mode .print-hint { background: #fff; border-bottom: 1px solid var(--line); }
.sheet-mode .a4 { background: #fff; margin: 12px auto; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12); }
.a4-label.outlined { outline: 1px dashed #c9a2a6; outline-offset: -0.5px; }
.a4-label .label-sheet { width: 100%; height: 100%; border: 0; border-radius: 0; padding: 1.2mm 1.6mm; gap: 0.4mm; }
.small-label .label-top, .small-label .label-no { font-size: 6.5px; }
.small-label .label-info { font-size: 6.2px; gap: 0 4px; }
.small-label .label-bc { height: 6.5mm; }
.label-test { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 10px; color: #999; }
@media print {
  .sheet-mode .a4 { margin: 0; box-shadow: none; page-break-after: always; break-after: page; }
  .a4-label.outlined:not(.keep-outline) { outline: none; }
}
