/* =====================================================================
   GST Billing — "Khata" design system
   Slate-teal navigation, white workspace, money-green primary, ledger-red
   accent reserved for negatives / overdue. Figures use tabular numerals and
   amount columns carry the thin double red rule of a paper account book.
   ===================================================================== */
:root {
  --ink: #1B2B28; --ink-2: #51615D; --ink-3: #82918D;
  --line: #DCE3E0; --line-2: #EBF0EE;
  --bg: #F4F6F5; --surface: #FFFFFF; --surface-2: #F8FAF9;
  --nav: #16322D; --nav-2: #1D3F39; --nav-ink: #C9D8D4; --nav-ink-2: #86A39D;
  --primary: #1F6F54; --primary-600: #185A44; --primary-50: #E7F2ED;
  --ledger: #B3261E; --ledger-50: #FBECEA;
  --amber: #9A6100; --amber-50: #FFF4DE;
  --blue: #1E5A8A; --blue-50: #E8F1F8;
  --radius: 10px; --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(22,50,45,.06), 0 4px 16px rgba(22,50,45,.06);
  --shadow-lg: 0 12px 40px rgba(22,50,45,.18);
  --font: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --sidebar-w: 248px; --topbar-h: 60px;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.5 var(--font); color: var(--ink); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
button, input, select, textarea { font: inherit; color: inherit; }
.icon { flex: none; vertical-align: middle; }
.num, .amount, td.num, th.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.neg { color: var(--ledger); }
.muted { color: var(--ink-3); }
.pad { padding: 14px 16px; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content { padding: 24px 28px 48px; max-width: 1480px; width: 100%; }

/* ---------- Sidebar ---------- */
.sidebar { width: var(--sidebar-w); background: var(--nav); color: var(--nav-ink); position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; flex: none; z-index: 40; }
.sidebar-brand { height: var(--topbar-h); display: flex; align-items: center; gap: 10px; padding: 0 18px; border-bottom: 1px solid rgba(255,255,255,.06); }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 700; }
.brand-text { font-weight: 700; color: #fff; letter-spacing: .01em; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-close { display: none; color: var(--nav-ink); }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 10px 20px; scrollbar-width: thin; scrollbar-color: var(--nav-2) transparent; }
.nav-root, .nav-sub { list-style: none; margin: 0; padding: 0; }
.nav-group-link, .nav-group-toggle { display: flex; align-items: center; gap: 11px; width: 100%; padding: 9px 10px; border: 0; background: none;
  color: var(--nav-ink); border-radius: var(--radius-sm); cursor: pointer; text-align: left; font-weight: 500; }
.nav-group-link:hover, .nav-group-toggle:hover { background: var(--nav-2); color: #fff; text-decoration: none; }
.nav-group-link.is-active { background: var(--primary); color: #fff; }
.nav-group-toggle .chev { margin-left: auto; transition: transform .15s; opacity: .7; }
.nav-group.is-open > .nav-group-toggle .chev { transform: rotate(180deg); }
.nav-group.is-open > .nav-group-toggle { color: #fff; }
.nav-sub { display: none; padding: 2px 0 6px 20px; margin-left: 9px; border-left: 1px solid rgba(255,255,255,.08); }
.nav-group.is-open > .nav-sub { display: block; }
.nav-link { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 6px; color: var(--nav-ink-2); font-size: 13.5px; }
.nav-link:hover { color: #fff; background: rgba(255,255,255,.05); text-decoration: none; }
.nav-link.is-active { color: #fff; background: rgba(31,111,84,.55); font-weight: 600; }
.nav-link.is-pending { opacity: .45; cursor: default; }
.nav-link.is-pending:hover { background: none; color: var(--nav-ink-2); }
.phase-badge { margin-left: auto; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 99px; border: 1px solid rgba(255,255,255,.25); }
.sidebar-foot { padding: 10px 18px; font-size: 11px; color: var(--nav-ink-2); border-top: 1px solid rgba(255,255,255,.06); }
.sidebar-backdrop { display: none; }

/* ---------- Topbar ---------- */
.topbar { height: var(--topbar-h); background: var(--surface); border-bottom: 1px solid var(--line); display: flex; align-items: center;
  gap: 16px; padding: 0 20px; position: sticky; top: 0; z-index: 30; }
.menu-toggle { display: none; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.global-search { position: relative; flex: 1; max-width: 460px; display: flex; align-items: center; gap: 8px; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; color: var(--ink-3); }
.global-search:focus-within { border-color: var(--primary); background: #fff; }
.global-search input { border: 0; background: none; outline: none; flex: 1; height: 36px; color: var(--ink); min-width: 0; }
.global-search kbd { font: 11px var(--font); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; color: var(--ink-3); }
.search-results { position: absolute; top: 42px; left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); max-height: 420px; overflow-y: auto; color: var(--ink); }
.search-group { padding: 8px 12px 4px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.search-item { display: flex; justify-content: space-between; gap: 12px; padding: 8px 12px; color: var(--ink); }
.search-item:hover, .search-item.is-focus { background: var(--primary-50); text-decoration: none; }
.search-item small { color: var(--ink-3); }
.branch-switch, .branch-static { display: flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 13px; }
.branch-switch select { border: 1px solid var(--line); border-radius: 8px; height: 36px; padding: 0 8px; background: #fff; max-width: 240px; }
.icon-btn { position: relative; display: inline-grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 8px; background: none;
  color: var(--ink-2); cursor: pointer; }
.icon-btn:hover { background: var(--bg); color: var(--ink); }
.icon-btn .dot { position: absolute; top: 8px; right: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--ledger); border: 2px solid #fff; }
.user-chip { display: flex; align-items: center; gap: 10px; border: 0; background: none; cursor: pointer; padding: 4px 6px; border-radius: 8px; }
.user-chip:hover { background: var(--bg); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary-50); color: var(--primary); display: grid; place-items: center; font-weight: 700; }
.user-meta { display: flex; flex-direction: column; text-align: left; line-height: 1.2; }
.user-meta small { color: var(--ink-3); font-size: 12px; }

/* ---------- Dropdowns ---------- */
.dropdown { position: relative; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 200px; background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; display: none; z-index: 50; }
.dropdown.is-open > .dropdown-menu { display: block; }
.dropdown-wide { width: 360px; padding: 0; }
.dropdown-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; font-weight: 600; border-bottom: 1px solid var(--line-2); }
.dropdown-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: none; border-radius: 6px;
  color: var(--ink); cursor: pointer; text-align: left; }
.dropdown-item:hover { background: var(--bg); text-decoration: none; }
.notif-list { max-height: 380px; overflow-y: auto; }
.notif { display: block; padding: 10px 14px; border-bottom: 1px solid var(--line-2); color: var(--ink); }
.notif.unread { background: var(--primary-50); }
.notif small { display: block; color: var(--ink-3); }
.link-btn { border: 0; background: none; color: var(--primary); cursor: pointer; font-size: 12px; font-weight: 600; padding: 0; }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 16px; border-radius: 8px;
  border: 1px solid var(--line); background: #fff; color: var(--ink); font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-600); }
.btn-danger { background: var(--ledger); border-color: var(--ledger); color: #fff; }
.btn-danger:hover { background: #962019; }
.btn-ghost { border-color: transparent; background: none; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-icon { width: 30px; height: 30px; padding: 0; border-color: transparent; background: none; color: var(--ink-2); }
.btn-icon:hover { background: var(--bg); color: var(--ink); }
.btn-icon.danger:hover { color: var(--ledger); background: var(--ledger-50); }
.btn[disabled], .btn.is-loading { opacity: .6; pointer-events: none; }
.btn.is-loading::after { content: ""; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.card-head h2, .card-head h3 { font-size: 15px; font-weight: 700; }
.card-body { padding: 18px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }

/* Stat tiles: figure sits on a ledger rule */
.stat { padding: 16px 18px; position: relative; }
.stat-label { color: var(--ink-2); font-size: 12.5px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.stat-value { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 6px; letter-spacing: -.01em; }
.stat-sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat::after { content: ""; position: absolute; left: 18px; right: 18px; bottom: 10px; height: 3px;
  border-top: 1px solid rgba(179,38,30,.18); border-bottom: 1px solid rgba(179,38,30,.18); }
.stat { padding-bottom: 22px; }
.stat.is-alert .stat-value { color: var(--ledger); }
.stat a.stat-link { position: absolute; inset: 0; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field .req { color: var(--ledger); }
.input, .select, .textarea, .field input:not([type=checkbox]):not([type=radio]):not([type=file]), .field select, .field textarea {
  width: 100%; height: 38px; padding: 0 11px; border: 1px solid var(--line); border-radius: 8px; background: #fff; outline: none; }
.field textarea, .textarea { height: auto; min-height: 76px; padding: 9px 11px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus, .select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-50); }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--ledger); }
.field-error { color: var(--ledger); font-size: 12px; }
.hint { color: var(--ink-3); font-size: 12px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }
.form-section { font-size: 12px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-3); grid-column: 1 / -1;
  padding-top: 8px; border-top: 1px dashed var(--line); margin-top: 4px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 6px; }
.img-preview { width: 140px; height: 80px; border: 1px dashed var(--line); border-radius: 8px; display: grid; place-items: center; overflow: hidden; background: var(--surface-2); }
.img-preview img { max-width: 100%; max-height: 100%; }

/* ---------- Toolbar + tables ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line-2); }
.toolbar .search { position: relative; flex: 1; min-width: 200px; max-width: 320px; }
.toolbar .search .icon { position: absolute; left: 10px; top: 11px; color: var(--ink-3); }
.toolbar .search input { padding-left: 32px; }
.toolbar .spacer { flex: 1; }
.toolbar select, .toolbar input { height: 36px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; background: #fff; }
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { position: sticky; top: 0; background: var(--surface-2); text-align: left; font-size: 12px; font-weight: 700; letter-spacing: .03em;
  text-transform: uppercase; color: var(--ink-2); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable::after { content: " ↕"; opacity: .35; }
.table th.sort-asc::after { content: " ↑"; opacity: 1; }
.table th.sort-desc::after { content: " ↓"; opacity: 1; }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tbody tr:hover { background: #FAFCFB; }
/* the account-book double rule to the left of money columns */
.table td.num, .table th.num { border-left: 3px double rgba(179,38,30,.22); }
.table .actions { text-align: right; white-space: nowrap; width: 1%; }
.table tfoot td { font-weight: 700; background: var(--surface-2); border-top: 2px solid var(--line); }
.table-empty { padding: 48px 16px; text-align: center; color: var(--ink-3); }
.table-empty .icon { color: var(--line); margin-bottom: 6px; }
.table-loading td { color: var(--ink-3); text-align: center; padding: 32px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; flex-wrap: wrap; color: var(--ink-2); font-size: 13px; }
.pager-pages { display: flex; gap: 4px; }
.pager button { min-width: 32px; height: 32px; border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer; }
.pager button.is-current { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; }
.pager button[disabled] { opacity: .4; cursor: default; }
.pager select { height: 32px; border: 1px solid var(--line); border-radius: 6px; }

/* ---------- Badges / alerts ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--line-2); color: var(--ink-2); }
.badge-green { background: var(--primary-50); color: var(--primary); }
.badge-red { background: var(--ledger-50); color: var(--ledger); }
.badge-amber { background: var(--amber-50); color: var(--amber); }
.badge-blue { background: var(--blue-50); color: var(--blue); }
.alert { display: flex; align-items: flex-start; gap: 10px; padding: 11px 14px; border-radius: 8px; margin-bottom: 16px; border: 1px solid; }
.alert-success { background: var(--primary-50); border-color: #BFDCCF; color: var(--primary-600); }
.alert-danger { background: var(--ledger-50); border-color: #F1C5C1; color: var(--ledger); }
.alert-info { background: var(--blue-50); border-color: #C7DBEB; color: var(--blue); }
.alert-warning { background: #FFF6E0; border-color: #F0D58C; color: #7A5200; }
.alert-warn { background: var(--amber-50); border-color: #EFD9A8; color: var(--amber); }

/* ---------- Modal ---------- */
dialog.modal { border: 0; padding: 0; border-radius: 14px; width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 40px); box-shadow: var(--shadow-lg); color: var(--ink); }
dialog.modal.modal-lg { width: min(960px, calc(100vw - 24px)); }
dialog.modal.modal-sm { width: min(420px, calc(100vw - 24px)); }
dialog.modal::backdrop { background: rgba(16,32,29,.45); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line-2); position: sticky; top: 0; background: #fff; z-index: 1; }
.modal-head h2 { font-size: 17px; }
.modal-body { padding: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line-2); background: var(--surface-2);
  position: sticky; bottom: 0; }

/* ---------- Toasts ---------- */
.toast-stack { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 1000; }
.toast { display: flex; gap: 10px; align-items: flex-start; min-width: 260px; max-width: 400px; background: var(--ink); color: #fff; padding: 12px 14px;
  border-radius: 10px; box-shadow: var(--shadow-lg); animation: toastIn .18s ease-out; }
.toast.toast-error { background: var(--ledger); }
.toast.toast-success { background: var(--primary-600); }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } }

/* ---------- Permission matrix ---------- */
.perm-matrix th, .perm-matrix td { text-align: center; }
.perm-matrix td:first-child, .perm-matrix th:first-child { text-align: left; }
.perm-matrix .group-row td { background: var(--surface-2); font-weight: 700; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); text-align: left; }
.perm-matrix input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }

/* ---------- Charts ---------- */
.chart-box { position: relative; height: 280px; }
.chart-box canvas { width: 100%; height: 100%; display: block; }
.chart-tip { position: absolute; pointer-events: none; background: var(--ink); color: #fff; font-size: 12px; padding: 6px 9px; border-radius: 6px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.list-rows { list-style: none; margin: 0; padding: 0; }
.list-rows li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 18px; border-bottom: 1px solid var(--line-2); }
.list-rows li:last-child { border-bottom: 0; }

/* ---------- Auth pages ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; background: #fff; }
.auth-aside { background: var(--nav); color: var(--nav-ink); padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-aside h2 { color: #fff; font-size: 30px; line-height: 1.2; max-width: 420px; letter-spacing: -.01em; }
.auth-aside p { max-width: 420px; color: var(--nav-ink-2); }
.auth-ledger { position: absolute; inset: 0; opacity: .08; pointer-events: none;
  background-image: repeating-linear-gradient(to bottom, transparent 0 31px, #fff 31px 32px); }
.auth-ledger::before { content: ""; position: absolute; top: 0; bottom: 0; left: 72%; width: 6px; border-left: 1px solid #ff6b60; border-right: 1px solid #ff6b60; opacity: 3; }
.auth-main { display: grid; place-items: center; padding: 32px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h1 { font-size: 24px; margin-bottom: 6px; }
.auth-card .sub { color: var(--ink-2); margin-bottom: 24px; }
.auth-card form { display: grid; gap: 14px; }
.auth-card .btn { height: 42px; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 960px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s; }
  .app.sidebar-open .sidebar { transform: none; }
  .app.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 35; }
  .sidebar-close, .menu-toggle { display: inline-grid; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .user-meta, .global-search kbd { display: none; }
  .auth { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
}
@media (max-width: 640px) {
  .content { padding: 16px 14px 40px; }
  .grid-4, .form-grid, .form-grid.cols-3 { grid-template-columns: 1fr; }
  .branch-switch select { max-width: 130px; }
  .topbar { gap: 8px; padding: 0 10px; }
  .dropdown-wide { width: calc(100vw - 24px); right: -60px; }
}
@media print {
  .sidebar, .topbar, .page-actions, .toolbar, .pager, .actions { display: none !important; }
  .content { padding: 0; } .card { box-shadow: none; border: 0; } body { background: #fff; }
}

/* ---------- Picker / document editor ---------- */
.picker-results { position: absolute; left: 0; right: 0; top: calc(100% + 2px); background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow-lg); max-height: 300px; overflow-y: auto; z-index: 60; min-width: 280px; }
.picker-item { padding: 8px 10px; cursor: pointer; border-bottom: 1px solid var(--line-2); font-size: 13px; }
.picker-item:hover, .picker-item.is-focus { background: var(--primary-50); }
.picker-item small { color: var(--ink-3); }
.picker-empty { padding: 10px; color: var(--ink-3); }
.doc-editor .items-table td { padding: 6px 8px; vertical-align: top; }
.doc-editor .items-table input, .doc-editor .items-table select { width: 100%; height: 34px; border: 1px solid var(--line); border-radius: 6px; padding: 0 8px; background: #fff; }
.doc-editor .items-table input.num { text-align: right; font-variant-numeric: tabular-nums; }
.doc-editor .items-table .prod-cell { min-width: 240px; }
.doc-editor .items-table .muted-line { font-size: 12px; color: var(--ink-3); margin-top: 3px; }
.totals-box { width: 100%; max-width: 380px; margin-left: auto; }
.totals-box div { display: flex; justify-content: space-between; padding: 5px 0; font-variant-numeric: tabular-nums; }
.totals-box .grand { font-size: 20px; font-weight: 700; border-top: 3px double rgba(179,38,30,.35); margin-top: 6px; padding-top: 10px; }
.party-card { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.doc-view dl { display: grid; grid-template-columns: 150px 1fr; gap: 4px 12px; margin: 0; font-size: 13px; }
.doc-view dt { color: var(--ink-3); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.kbd-hint { font-size: 12px; color: var(--ink-3); }
.text-danger { color: var(--danger, #b3261e); }
tr.row-error td { background: #fdecea; }
.report-head { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 12px; }
.report-head .field { margin: 0; }
.report-table td.num, .report-table th.num { white-space: nowrap; }
.report-table tr.group-row td { background: var(--surface-2); font-weight: 600; }
.report-table tr.total-row td { font-weight: 700; border-top: 2px solid var(--line); }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat-row .stat { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.stat-row .stat span { display: block; font-size: 12px; color: var(--ink-3); }
.stat-row .stat strong { font-size: 18px; font-variant-numeric: tabular-nums; }
.lines-table input, .lines-table select { width: 100%; height: 34px; border: 1px solid var(--line); border-radius: 6px; padding: 0 8px; background: #fff; }
@media (max-width: 900px) { #docEditor .grid-2 { grid-template-columns: 1fr !important; } }
