/* LIS Accounts: ledger-style UI on top of Bootstrap 5 */
:root {
  --ink: #1E2240;          /* sidebar, headings */
  --ink-2: #2A2F55;
  --ink-3: #9BA1C7;
  --red: #B0282E;          /* primary actions, from the red bahi khata */
  --red-dark: #8E1F24;
  --red-soft: #FBEDEE;
  --paper: #F5F6F8;
  --card: #FFFFFF;
  --line: #E3E5EC;
  --rule: #C9CCD8;
  --text: #1B1D29;
  --muted: #646a80;
  --green: #1E7A4C;
  --green-soft: #E7F4EC;
  --amber: #A86A12;
  --amber-soft: #FDF3E1;
  --blue: #2B59C3;
  --blue-soft: #EAF0FC;
  --sidebar-w: 248px;
  --top-h: 58px;
  --radius: 10px;
  --bs-body-font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --bs-body-bg: var(--paper);
  --bs-body-color: var(--text);
  --bs-border-color: var(--line);
  --bs-primary: var(--red);
  --bs-primary-rgb: 176, 40, 46;
  --bs-link-color: var(--blue);
  --bs-link-color-rgb: 43, 89, 195;
}
html, body { height: 100%; }
body { font-size: 14px; background: var(--paper); color: var(--text); }
h1, h2, h3, h4, h5 { color: var(--ink); letter-spacing: -0.01em; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.num, .money, td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Buttons */
.btn { border-radius: 8px; font-weight: 500; background-image: none; }
.btn-primary { --bs-btn-bg: var(--red); --bs-btn-border-color: var(--red); --bs-btn-hover-bg: var(--red-dark); --bs-btn-hover-border-color: var(--red-dark); --bs-btn-active-bg: var(--red-dark); --bs-btn-active-border-color: var(--red-dark); --bs-btn-disabled-bg: var(--red); --bs-btn-disabled-border-color: var(--red); }
.btn-ink { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn-ink:hover { background: var(--ink-2); color: #fff; }
.btn-light { --bs-btn-bg: #fff; --bs-btn-border-color: var(--line); --bs-btn-hover-bg: #F0F1F5; --bs-btn-hover-border-color: var(--rule); }
.btn-outline-primary { --bs-btn-color: var(--red); --bs-btn-border-color: var(--red); --bs-btn-hover-bg: var(--red); --bs-btn-hover-border-color: var(--red); --bs-btn-active-bg: var(--red-dark); }
.form-control, .form-select { border-radius: 8px; border-color: var(--line); }
.form-control:focus, .form-select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(43, 89, 195, .15); }
.form-label { font-weight: 500; color: #3a3f55; margin-bottom: 4px; font-size: 13px; }

/* Shell */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); background: var(--ink); color: #D9DCF0; position: fixed; inset: 0 auto 0 0; z-index: 1030;
  display: flex; flex-direction: column; transition: transform .2s ease;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 18px; height: var(--top-h); color: #fff; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,.08); flex-shrink: 0; }
.brand-mark { width: 30px; height: 30px; border-radius: 7px; background: var(--red); display: grid; place-items: center; font-weight: 700; font-size: 15px; color: #fff; box-shadow: inset 0 -3px 0 rgba(0,0,0,.18); }
.brand-name { font-weight: 650; font-size: 15px; display: block; line-height: 1.2; }
.brand-text { min-width: 0; display: flex; flex-direction: column; }
.brand-sub { font-size: 11.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 170px; }
.brand-mark.has-logo { background: #fff; width: 38px; height: 38px; padding: 3px; box-shadow: none; flex-shrink: 0; }
.brand-mark.has-logo img { max-width: 100%; max-height: 100%; object-fit: contain; }
.btn-pay { background: var(--green); color: #fff; border-color: var(--green); }
.btn-pay:hover { background: #17633d; color: #fff; }
.lic-banner { background: var(--amber-soft); color: #6b4a0e; padding: 8px 20px; font-size: 13px; border-bottom: 1px solid #F3E2B3; }
.lic-banner a { color: inherit; font-weight: 600; }
.install-id { background: var(--paper); border: 1px dashed var(--rule); border-radius: 10px; padding: 12px; }
.theme-pick { display: flex; gap: 10px; flex-wrap: wrap; }
.theme-pick label { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; cursor: pointer; }
.theme-pick input { position: absolute; opacity: 0; }
.theme-pick .sw { width: 54px; height: 36px; border-radius: 8px; overflow: hidden; display: flex; border: 2px solid transparent; }
.theme-pick .sw span { flex: 1; }
.theme-pick input:checked + .sw { border-color: var(--text); box-shadow: 0 0 0 2px #fff inset; }
.theme-pick input:focus-visible + .sw { outline: 2px solid var(--blue); outline-offset: 2px; }
.nav-scroll { overflow-y: auto; flex: 1; padding: 10px 10px 24px; scrollbar-width: thin; scrollbar-color: #3a4070 transparent; }
.nav-group { margin-bottom: 2px; }
.nav-group > button, .nav-link-top {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 9px 12px; border: 0; background: none; color: #D9DCF0;
  border-radius: 8px; font-size: 14px; text-align: left; text-decoration: none;
}
.nav-group > button:hover, .nav-link-top:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-group > button .bi:first-child, .nav-link-top .bi { font-size: 17px; width: 20px; color: var(--ink-3); }
.nav-group > button .chev { margin-left: auto; font-size: 11px; transition: transform .15s; color: var(--ink-3); }
.nav-group.open > button .chev { transform: rotate(90deg); }
.nav-group.active > button, .nav-link-top.active { color: #fff; }
.nav-group.active > button .bi:first-child, .nav-link-top.active .bi { color: #fff; }
.nav-link-top.active { background: rgba(255,255,255,.1); }
.subnav { display: none; padding: 2px 0 6px 44px; margin: 0; list-style: none; }
.nav-group.open .subnav { display: block; }
.subnav a { display: block; padding: 6px 10px; color: #B5BADA; text-decoration: none; border-radius: 6px; font-size: 13.5px; position: relative; }
.subnav a:hover { color: #fff; background: rgba(255,255,255,.05); }
.subnav a.active { color: #fff; background: color-mix(in srgb, var(--red) 38%, transparent); }
.subnav a.active::before { content: ""; position: absolute; left: -12px; top: 9px; bottom: 9px; width: 3px; border-radius: 2px; background: var(--red); }
.sidebar-foot { padding: 12px 18px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; color: var(--ink-3); flex-shrink: 0; }
.mode-pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 20px; background: rgba(255,255,255,.08); color: #D9DCF0; font-size: 11.5px; }
.mode-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: #4CC38A; }
.ruled { border-top-color: color-mix(in srgb, var(--red) 70%, transparent) !important; }
.mode-pill.demo .dot { background: #F2B544; }

.main { margin-left: var(--sidebar-w); flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--top-h); background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px;
  padding: 0 20px; position: sticky; top: 0; z-index: 1020;
}
.topbar .menu-btn { display: none; border: 0; background: none; font-size: 22px; color: var(--ink); padding: 4px; }
.global-search { position: relative; flex: 1; max-width: 420px; }
.global-search input { padding-left: 34px; background: var(--paper); border-color: transparent; }
.global-search input:focus { background: #fff; }
.global-search > .bi { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 32px rgba(30,34,64,.14); max-height: 360px; overflow: auto; display: none; z-index: 5; }
.search-results.show { display: block; }
.search-results a { display: flex; justify-content: space-between; gap: 10px; padding: 9px 14px; color: var(--text); text-decoration: none; border-bottom: 1px solid var(--paper); }
.search-results a:hover, .search-results a.hl { background: var(--paper); }
.search-results small { color: var(--muted); }
.quick-actions { display: flex; gap: 8px; margin-left: auto; align-items: center; }
.user-chip { display: flex; align-items: center; gap: 8px; border: 0; background: none; padding: 4px 6px; border-radius: 8px; color: var(--text); }
.user-chip:hover { background: var(--paper); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 13px; text-transform: uppercase; }
.user-chip .who { line-height: 1.15; text-align: left; }
.user-chip .who small { color: var(--muted); display: block; font-size: 11.5px; }

.content { padding: 22px 24px 48px; max-width: 1480px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; font-weight: 650; margin: 0; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumb { font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.crumb a { color: var(--muted); text-decoration: none; }
.crumb a:hover { color: var(--blue); }

/* Panels */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.panel + .panel { margin-top: 16px; }
.panel-title { font-size: 15px; font-weight: 600; color: var(--ink); margin: 0 0 12px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.panel-title a { font-size: 13px; font-weight: 500; text-decoration: none; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filters .form-label { font-size: 12px; margin-bottom: 2px; color: var(--muted); }
.filters > div { min-width: 140px; }

/* KPI strip: figures read like a ledger summary line */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; overflow: hidden; }
.kpi { padding: 16px 18px; border-right: 1px solid var(--line); text-decoration: none; color: inherit; display: block; }
.kpi:last-child { border-right: 0; }
a.kpi:hover { background: #FAFAFC; }
.kpi .label { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 24px; font-weight: 650; color: var(--ink); margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.kpi.in .value { color: var(--green); }
.kpi.out .value { color: var(--red); }

/* Ledger tables: the one place with personality */
.table-tools { display: flex; justify-content: space-between; gap: 10px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.search-box { position: relative; min-width: 220px; flex: 0 1 300px; }
.search-box .bi { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 13px; }
.search-box input { padding-left: 30px; }
.ledger-table { margin: 0; font-size: 13.5px; --bs-table-bg: transparent; }
.ledger-table thead th {
  font-weight: 600; color: var(--muted); font-size: 12.5px; background: #FAFAFC; border-bottom: 1px solid var(--rule);
  white-space: nowrap; user-select: none; padding: 9px 10px;
}
.ledger-table thead th[data-sort] { cursor: pointer; }
.ledger-table thead th[data-sort]:hover { color: var(--ink); }
.ledger-table thead th.sorted { color: var(--ink); }
.ledger-table td { padding: 9px 10px; border-color: #EEF0F4; }
.ledger-table tbody tr.clickable { cursor: pointer; }
.ledger-table tbody tr:hover { background: #FAFAFD; }
.ledger-table tfoot td { font-weight: 650; color: var(--ink); border-top: 3px double var(--ink); border-bottom: 0; background: #fff; }
.dr { color: var(--ink); }
.cr { color: var(--green); }
.neg { color: var(--red); }
.pos { color: var(--green); }
.balance-tag { font-size: 11px; color: var(--muted); margin-left: 3px; }
.pager { display: flex; justify-content: flex-end; align-items: center; gap: 10px; color: var(--muted); font-size: 12.5px; margin-top: 10px; }
.pager:empty { display: none; }
.empty { text-align: center; padding: 34px 10px; color: var(--muted); }
.empty .bi { font-size: 28px; color: var(--rule); }
.empty p { margin: 8px 0 12px; }

.status { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.status.paid { background: var(--green-soft); color: var(--green); }
.status.partial { background: var(--amber-soft); color: var(--amber); }
.status.unpaid { background: var(--red-soft); color: var(--red); }
.status.neutral { background: #EEF0F5; color: #4a5070; }
.status.blue { background: var(--blue-soft); color: var(--blue); }

.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.icon-btn { border: 0; background: none; width: 30px; height: 30px; border-radius: 6px; color: var(--muted); display: inline-grid; place-items: center; }
.icon-btn:hover { background: var(--paper); color: var(--ink); }

.local-note { font-size: 12.5px; color: #6b5a2a; background: #FFF8E6; border: 1px solid #F3E2B3; border-radius: 8px; padding: 7px 12px; margin-bottom: 14px; display: inline-flex; gap: 8px; align-items: center; }
.loading { display: grid; place-items: center; padding: 60px 0; }
.error-box { display: flex; gap: 14px; padding: 20px; background: #fff; border: 1px solid #F1C7C9; border-radius: var(--radius); max-width: 640px; }
.error-box > .bi { font-size: 26px; color: var(--red); }
.error-box p { color: var(--muted); margin: 4px 0 12px; }

/* Tabs */
.seg { display: inline-flex; background: #ECEEF3; border-radius: 9px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button, .seg a { border: 0; background: none; padding: 6px 14px; border-radius: 7px; font-size: 13px; color: #4a5070; text-decoration: none; font-weight: 500; }
.seg .on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(30,34,64,.12); }

/* Document editor (invoice / order / quotation) */
.doc-editor .doc-top { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; }
.party-card { background: #FAFAFC; border: 1px dashed var(--rule); border-radius: 8px; padding: 10px 12px; font-size: 13px; color: var(--muted); margin-top: 8px; }
.party-card strong { color: var(--text); }
.lines { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.lines th { font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 6px; border-bottom: 1px solid var(--rule); background: #FAFAFC; white-space: nowrap; }
.lines td { padding: 4px; border-bottom: 1px solid #EEF0F4; vertical-align: top; }
.lines td .form-control, .lines td .form-select { padding: 5px 7px; font-size: 13.5px; border-radius: 6px; }
.lines td.calc { padding: 9px 8px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--ink); }
.lines .sn { width: 34px; color: var(--muted); text-align: center; padding-top: 10px; }
.lines .extra { font-size: 12px; }
.lines .extra .form-control { font-size: 12px; padding: 3px 6px; }
.item-pick { position: relative; min-width: 220px; }
.item-menu { position: absolute; left: 0; right: -80px; top: 100%; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 12px 28px rgba(30,34,64,.15); z-index: 20; max-height: 260px; overflow: auto; display: none; }
.item-menu.show { display: block; }
.item-menu button { display: flex; width: 100%; justify-content: space-between; gap: 8px; border: 0; background: none; padding: 7px 10px; text-align: left; font-size: 13px; }
.item-menu button:hover, .item-menu button.hl { background: var(--paper); }
.item-menu small { color: var(--muted); }
.totals { width: 100%; max-width: 380px; margin-left: auto; font-size: 14px; }
.totals td { padding: 5px 0; }
.totals td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.totals .grand td { font-size: 18px; font-weight: 700; color: var(--ink); border-top: 3px double var(--ink); padding-top: 8px; }
.totals .muted td { color: var(--muted); font-size: 13px; }
.doc-actions { position: sticky; bottom: 0; background: rgba(245,246,248,.94); backdrop-filter: blur(4px); padding: 12px 0; margin-top: 16px; display: flex; gap: 8px; justify-content: flex-end; border-top: 1px solid var(--line); z-index: 5; }
.flow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); margin-bottom: 14px; }
.flow span { padding: 3px 10px; border-radius: 20px; background: #ECEEF3; }
.flow span.here { background: var(--ink); color: #fff; }
.flow .bi { font-size: 11px; }

/* Invoice print view */
.invoice-sheet { background: #fff; border: 1px solid var(--line); border-radius: 4px; max-width: 900px; margin: 0 auto; padding: 32px 36px; color: #111827; font-size: 13px; }
.inv-head { display: flex; justify-content: space-between; gap: 20px; border-bottom: 2px solid var(--ink); padding-bottom: 14px; }
.inv-head h2 { margin: 0 0 4px; font-size: 22px; }
.inv-title { text-align: right; }
.inv-title .doc { font-size: 13px; letter-spacing: .04em; color: var(--red); font-weight: 700; }
.inv-title .no { font-size: 18px; font-weight: 700; color: var(--ink); }
.inv-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.inv-parties h3 { font-size: 12px; color: var(--muted); font-weight: 600; margin: 0 0 4px; }
.inv-table { width: 100%; border-collapse: collapse; margin-top: 14px; }
.inv-table th { background: #F2F3F7; font-size: 12px; padding: 7px 6px; text-align: left; border-bottom: 1px solid var(--rule); }
.inv-table td { padding: 7px 6px; border-bottom: 1px solid #EEF0F4; vertical-align: top; }
.inv-table .r { text-align: right; font-variant-numeric: tabular-nums; }
.inv-foot { display: grid; grid-template-columns: 1fr 320px; gap: 24px; margin-top: 16px; }
.inv-sign { margin-top: 40px; text-align: right; font-size: 12px; color: var(--muted); }
.inv-qr { display: flex; gap: 12px; align-items: center; margin-top: 12px; }
.inv-qr canvas, .inv-qr img { width: 96px !important; height: 96px !important; }
.watermark-paid { display: inline-block; border: 2px solid var(--green); color: var(--green); padding: 2px 10px; border-radius: 6px; font-weight: 700; transform: rotate(-6deg); }

/* Dashboard */
.dash-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.dash-grid .panel { margin-top: 0; }
.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 170px; padding-top: 10px; border-bottom: 1px solid var(--rule); }
.bar-chart .bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; height: 100%; min-width: 0; }
.bar-chart .stack { width: 100%; max-width: 28px; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; gap: 2px; }
.bar-chart .s { background: var(--ink); border-radius: 3px 3px 0 0; min-height: 2px; }
.bar-chart .p { background: var(--rule); border-radius: 3px 3px 0 0; min-height: 0; }
.bar-labels { display: flex; gap: 6px; font-size: 10.5px; color: var(--muted); margin-top: 4px; }
.bar-labels span { flex: 1; text-align: center; min-width: 0; overflow: hidden; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid #EEF0F4; font-size: 13.5px; }
.mini-list li:last-child { border-bottom: 0; }
.mini-list .meter { height: 4px; background: #ECEEF3; border-radius: 4px; margin-top: 5px; overflow: hidden; }
.mini-list .meter span { display: block; height: 100%; background: var(--red); }

/* Permissions grid */
.perm-table td, .perm-table th { text-align: center; }
.perm-table td:first-child, .perm-table th:first-child { text-align: left; }

/* Toasts */
.toast-stack { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 2000; }
.lis-toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 9px; display: flex; gap: 10px; align-items: center; box-shadow: 0 10px 30px rgba(0,0,0,.2); max-width: 380px; font-size: 13.5px; animation: tin .18s ease-out; }
.lis-toast.error { background: var(--red); }
.lis-toast.warn { background: #7a4d0b; }
.lis-toast.out { opacity: 0; transform: translateY(6px); transition: .3s; }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }

/* Login */
.login-page { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); background: #fff; }
.login-side { background: var(--ink); color: #D9DCF0; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-side h1 { color: #fff; font-size: 34px; line-height: 1.15; max-width: 420px; margin-top: 40px; }
.login-side p { max-width: 400px; color: var(--ink-3); font-size: 15px; }
.ruled { position: absolute; inset: auto 0 0 0; height: 46%; background: repeating-linear-gradient(to bottom, transparent 0 27px, rgba(255,255,255,.07) 27px 28px); border-top: 3px double rgba(176,40,46,.7); }
.ruled::before { content: ""; position: absolute; top: 0; bottom: 0; left: 64px; width: 1px; background: rgba(176,40,46,.55); }
.login-form { display: flex; align-items: center; justify-content: center; padding: 32px; }
.login-form form { width: 100%; max-width: 380px; }
.login-form h2 { font-size: 24px; margin-bottom: 4px; }

/* Responsive */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi:nth-child(2) { border-right: 0; }
  .kpi:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .dash-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .main { margin-left: 0; }
  .topbar .menu-btn { display: block; }
  .doc-editor .doc-top { grid-template-columns: 1fr; }
  .login-page { grid-template-columns: 1fr; }
  .login-side { display: none; }
  .quick-actions .btn .lbl, .user-chip .who { display: none; }
}
@media (max-width: 600px) {
  .content { padding: 16px 16px 40px; }
  .topbar { padding: 0 12px; gap: 8px; }
  .kpis { grid-template-columns: 1fr; }
  .kpi { border-right: 0; border-bottom: 1px solid var(--line); }
  .invoice-sheet { padding: 18px; }
  .inv-parties, .inv-foot { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 19px; }
  .doc-actions { gap: 6px; }
  .doc-actions .btn { padding: 6px 10px; font-size: 13px; white-space: nowrap; }
  .doc-actions [data-save="new"], .doc-actions a.btn-light { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Logo */
.logo-box { width: 260px; height: 110px; border: 1px dashed var(--rule); border-radius: 10px; display: grid; place-items: center; background: #fff; padding: 8px; }
.logo-box img { max-width: 100%; max-height: 100%; object-fit: contain; }
.login-logo { max-width: 180px; max-height: 70px; object-fit: contain; background: #fff; border-radius: 8px; padding: 6px; }
.print-head { display: none; }
.brand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 170px; }

/* Print: only the content area */
@media print {
  .sidebar, .topbar, .page-actions, .table-tools, .pager, .doc-actions, .filters, .no-print, .toast-stack, .local-note, .flow { display: none !important; }
  .main { margin: 0; }
  .content { padding: 0; max-width: none; }
  .panel, .invoice-sheet { border: 0; padding: 0; }
  .print-head { display: flex; gap: 14px; align-items: center; border-bottom: 2px solid #1E2240; padding-bottom: 8px; margin-bottom: 12px; font-size: 11px; }
  .print-head img { max-height: 48px; max-width: 140px; object-fit: contain; }
  .print-head .ph-date { margin-left: auto; color: #555; }
  body[data-page="invoice"] .print-head { display: none; }
  body { background: #fff; font-size: 12px; }
  a { color: inherit; text-decoration: none; }
}

/* Floating search dropdown */
.combo-menu { position: fixed; z-index: 2100; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 14px 34px rgba(30,34,64,.18); overflow: auto; display: none; padding: 4px; }
.combo-menu.show { display: block; }
.combo-menu button { display: flex; width: 100%; justify-content: space-between; align-items: center; gap: 10px; border: 0; background: none; padding: 7px 10px; text-align: left; font-size: 13.5px; border-radius: 7px; color: var(--text); }
.combo-menu button:hover, .combo-menu button.hl { background: var(--paper); }
.combo-menu small, .combo-menu .sub { color: var(--muted); font-size: 12px; }
.combo-menu .combo-foot { border-top: 1px solid var(--line); border-radius: 0 0 7px 7px; color: var(--blue); font-weight: 500; justify-content: flex-start; }
.combo-empty { padding: 10px; color: var(--muted); font-size: 13px; }
.combo-menu .r { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.combo-menu .low { color: var(--red); }

/* Bill tabs */
.bill-tabs { display: flex; gap: 4px; align-items: flex-end; border-bottom: 1px solid var(--rule); margin-bottom: 14px; overflow-x: auto; scrollbar-width: thin; }
.bill-tab { display: inline-flex; align-items: center; gap: 8px; padding: 8px 10px 8px 14px; border: 1px solid transparent; border-bottom: 0; border-radius: 9px 9px 0 0; background: #ECEEF3; color: #4a5070; font-size: 13.5px; white-space: nowrap; cursor: pointer; position: relative; top: 1px; }
.bill-tab.on { background: #fff; color: var(--ink); border-color: var(--rule); font-weight: 600; }
.bill-tab .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); }
.bill-tab .x { border: 0; background: none; color: var(--muted); padding: 0 2px; line-height: 1; font-size: 16px; }
.bill-tab .x:hover { color: var(--red); }
.bill-add { border: 1px dashed var(--rule); background: #fff; color: var(--blue); border-radius: 9px 9px 0 0; padding: 7px 12px; font-size: 13.5px; font-weight: 500; white-space: nowrap; }
.bill-add:hover { background: var(--blue-soft); }
.confirm-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; background: var(--blue-soft, #e8effc); color: #1d3b6e; border-radius: 8px; padding: 8px 12px; font-size: 14px; font-weight: 600; margin-right: auto; }
.unsaved-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; background: var(--amber-soft); color: #6b4a0e; border-radius: 8px; padding: 8px 12px; font-size: 13px; margin-right: auto; }
.inv-logo { max-width: 120px; max-height: 64px; object-fit: contain; }
.lines tr.flash td { background: var(--green-soft); transition: background .2s; }

.feature-row { display: flex; gap: 14px; align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--line); }
.feature-row .form-switch .form-check-input { width: 2.6em; height: 1.4em; margin-top: 2px; cursor: pointer; }
.feature-row label { cursor: pointer; }

/* item import */
.import-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.import-step { display: flex; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.import-step .n { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--red); color: #fff; font-weight: 600; }
.col-chip { display: inline-block; padding: 2px 8px; margin: 0 4px 4px 0; border-radius: 999px; background: var(--paper); border: 1px solid var(--line); font-size: .8rem; }
.col-chip.req { color: #c00000; font-weight: 600; background: var(--red-soft); border-color: #f3c6c8; }
.kpis.kpis-sm .kpi { padding: 10px 14px; } .kpis.kpis-sm .value { font-size: 1.3rem; }

/* split payment */
.pay-row { display: grid; grid-template-columns: minmax(110px, 130px) minmax(90px, 120px) 1fr auto; gap: 6px; align-items: center; margin-bottom: 6px; }
.pay-row .pay-cheque { grid-column: 1 / -1; display: grid; grid-template-columns: 150px 1fr; gap: 6px; padding-left: 0; }
.pay-split .pay-sum { min-height: 1.2em; }
@media (max-width: 420px) { .pay-row { grid-template-columns: 1fr 1fr auto; } .pay-row > [data-pf=ref] { grid-column: 1 / 3; } .pay-row > span:empty { display: none; } }

/* party balance under "Received from" / "Paid to" */
.party-bal { margin-top: 6px; font-size: 13.5px; }
.party-bal .bal-recv { color: #1a7f45; font-weight: 700; }
.party-bal .bal-pay { color: #c0262d; font-weight: 700; }
.party-bal .bal-zero { color: #5b6170; font-weight: 600; }

/* multi-shop platform notice (plan ending, read-only) */
#shopBanner { background: #fff6e0; color: #6b4a0e; }
#shopBanner.readonly { background: #fde2e3; color: #8f1d24; }
