:root {
  --navy: #122449;
  --navy-2: #1c3768;
  --navy-3: #0c1a36;
  --green: #5E8C1F;
  --green-d: #4C7416;
  --green-l: #7BA428;
  --green-bg: #EEF5E1;
  --yellow: #F5B301;
  --yellow-bg: #FFF6D9;
  --cream: #FAFBE9;
  --bg: #F3F5F8;
  --card: #FFFFFF;
  --ink: #1B2433;
  --muted: #667085;
  --line: #E4E7EC;
  --line-2: #EEF0F4;
  --red: #C2362B;
  --red-bg: #FDECEA;
  --blue: #1F5FBF;
  --blue-bg: #E7F0FD;
  --amber: #B45309;
  --amber-bg: #FEF1D8;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 14px rgba(16, 24, 40, .05);
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, .18);
  --side-w: 256px;
  --top-h: 64px;
  font-family: Inter, 'Segoe UI', system-ui, -apple-system, Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); font-size: 14.5px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
body.modal-open { overflow: hidden; }
h1, h2, h3, h4, p { margin: 0; }
a { color: var(--navy-2); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.ico { flex: none; vertical-align: middle; }
.right { text-align: right; } .center { text-align: center; }
.nowrap { white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: linear-gradient(180deg, var(--navy) 0%, var(--navy-3) 100%); color: #D5DCEB; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; z-index: 40; transition: transform .25s ease, width .2s; }
.side-brand { padding: 20px 20px 10px; display: flex; align-items: center; gap: 10px; color: #fff; }
.side-brand .mark { width: 36px; height: 36px; border-radius: 10px; background: var(--yellow); display: grid; place-items: center; color: var(--navy); }
.side-brand b { font-size: 15px; letter-spacing: .3px; line-height: 1.15; }
.side-brand small { display: block; color: #9FB0D3; font-weight: 500; font-size: 11px; }
.nav { padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 10px; color: #C4CEE4; font-weight: 500; text-decoration: none; min-height: 44px; position: relative; }
.nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav a.active { background: rgba(255,255,255,.12); color: #fff; }
.nav a.active::before { content: ''; position: absolute; left: -12px; top: 10px; bottom: 10px; width: 4px; border-radius: 0 4px 4px 0; background: var(--yellow); }
.side-foot { padding: 14px; }
.logo-card { background: var(--cream); border-radius: 14px; padding: 6px; text-align: center; }
.logo-card img { width: 100%; height: auto; display: block; border-radius: 10px; }
.side-foot .co { text-align: center; color: #fff; font-weight: 700; letter-spacing: .6px; font-size: 12px; margin-top: 10px; }
.side-foot .ver { text-align: center; color: #7F90B5; font-size: 11px; margin-top: 2px; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; height: var(--top-h); background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 14px; padding: 0 28px; }
.top-title { font-weight: 800; color: var(--navy); letter-spacing: .4px; font-size: 15px; white-space: nowrap; display: none; }
.global-search { flex: 1; max-width: 560px; position: relative; }
.global-search input { width: 100%; height: 42px; border-radius: 12px; border: 1px solid var(--line); background: #F7F8FA; padding: 0 44px 0 42px; outline: none; }
.global-search input:focus { background: #fff; border-color: var(--green); box-shadow: 0 0 0 3px rgba(94,140,31,.15); }
.global-search .ico { position: absolute; left: 13px; top: 12px; color: var(--muted); }
.global-search kbd { position: absolute; right: 10px; top: 10px; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 0 7px; font-size: 12px; color: var(--muted); line-height: 20px; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn { width: 40px; height: 40px; border-radius: 10px; border: 1px solid transparent; background: transparent; display: inline-grid; place-items: center; color: var(--muted); position: relative; text-decoration: none; }
.icon-btn:hover { background: #EEF1F5; color: var(--ink); text-decoration: none; }
.icon-btn.sm { width: 32px; height: 32px; }
.icon-btn.back { border-color: var(--line); background: #fff; }
.bell-dot { position: absolute; top: 5px; right: 4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; border: 2px solid #fff; }
.user-btn { display: flex; align-items: center; gap: 10px; border: 0; background: transparent; padding: 4px 8px 4px 4px; border-radius: 12px; min-height: 44px; }
.user-btn:hover { background: #EEF1F5; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--navy); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.user-btn .u-name { font-weight: 600; font-size: 13.5px; line-height: 1.2; text-align: left; }
.user-btn .u-role { font-size: 11.5px; color: var(--muted); text-align: left; text-transform: capitalize; }
#view { padding: 26px 28px 60px; max-width: 1480px; width: 100%; margin: 0 auto; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.scrim { display: none; }
.menu-btn { display: none; }

/* ---------- page header ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.ph-left { display: flex; gap: 12px; align-items: flex-start; }
.page-head h1 { font-size: 24px; font-weight: 800; color: var(--navy); letter-spacing: -.2px; line-height: 1.25; }
.page-head .sub { color: var(--muted); margin-top: 2px; }
.ph-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line-2); }
.card-head h3 { font-size: 15.5px; font-weight: 700; color: var(--navy); }
.card-head .link { font-size: 13px; font-weight: 600; }
.grid { display: grid; gap: 18px; }
.grid > * { min-width: 0; }
.stack { display: grid; gap: 18px; min-width: 0; grid-template-columns: minmax(0, 1fr); align-content: start; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cols-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (min-width: 1760px) { .cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.main-side { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line); background: #fff; font-weight: 600; font-size: 14px; white-space: nowrap; text-decoration: none; color: var(--ink); transition: background .12s, box-shadow .12s, transform .05s; }
.btn:hover { background: #F5F7FA; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--green-d); border-color: var(--green-d); color: #fff; }
.btn.primary:hover { background: #3F6212; }
.btn.navy { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.navy:hover { background: var(--navy-2); }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger:hover { background: #A52C22; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: #EEF1F5; }
.btn.sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn.lg { height: 48px; font-size: 15px; padding: 0 22px; }
.btn.block { width: 100%; }
.btn.icon-only { width: 42px; padding: 0; flex: 0 0 auto !important; }
.btn:disabled, .btn.busy { opacity: .6; cursor: not-allowed; }
.btn.busy::after { content: ''; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
.btn:focus-visible, .icon-btn:focus-visible, .nav a:focus-visible, input:focus-visible { outline: 3px solid rgba(94,140,31,.35); outline-offset: 1px; }
.btn.warn { background: var(--yellow); border-color: var(--yellow); color: #3b2c00; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; position: relative; }
.field > label, .lbl { font-size: 12.5px; font-weight: 600; color: #475467; }
.field > label .req { color: var(--red); }
.input, .field input, .field select, .field textarea, select.input, input.input, textarea.input {
  width: 100%; height: 42px; border: 1px solid #D0D5DD; border-radius: 10px; padding: 0 12px; background: #fff; outline: none; transition: border-color .12s, box-shadow .12s;
}
.field textarea, textarea.input { height: auto; min-height: 76px; padding: 10px 12px; resize: vertical; line-height: 1.45; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(94,140,31,.16); }
.field input[readonly] { background: #F5F6F8; color: #475467; }
.has-error > input, .has-error > select, .has-error > textarea, input.has-error, select.has-error, textarea.has-error { border-color: var(--red) !important; box-shadow: 0 0 0 3px rgba(194,54,43,.12) !important; }
.field-error { color: var(--red); font-size: 12.5px; font-weight: 500; }
.field-error.in-cell { font-size: 11px; line-height: 1.2; margin-top: 2px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.hint { font-size: 12.5px; color: var(--muted); }
.check { display: flex; align-items: center; gap: 9px; font-size: 14px; cursor: pointer; min-height: 32px; }
.check input { width: 18px; height: 18px; accent-color: var(--green-d); }
.input-group { display: flex; }
.input-group > input { border-top-right-radius: 0; border-bottom-right-radius: 0; flex: 1; min-width: 0; }
.input-group > select { width: 64px; flex: none; border-top-left-radius: 0; border-bottom-left-radius: 0; border-left: 0; padding: 0 6px; }
.seg { display: inline-flex; background: #EEF1F5; border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 7px 14px; border-radius: 8px; font-weight: 600; font-size: 13px; color: var(--muted); min-height: 34px; }
.seg button.on { background: #fff; color: var(--navy); box-shadow: 0 1px 3px rgba(16,24,40,.12); }
.form-section { margin-top: 20px; }
.form-section > h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--green); margin-bottom: 10px; }

/* ---------- toolbar / tables ---------- */
.list-card { overflow: hidden; }
.toolbar { display: flex; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line-2); flex-wrap: wrap; align-items: center; }
.search-box { position: relative; flex: 1 1 240px; max-width: 380px; }
.search-box .ico { position: absolute; left: 12px; top: 12px; color: var(--muted); }
.search-box input { width: 100%; height: 42px; border: 1px solid #D0D5DD; border-radius: 10px; padding: 0 12px 0 40px; outline: none; background: #fff; }
.search-box input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(94,140,31,.16); }
.filter.date { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: #475467; }
.filter select, .filter input { height: 42px; border: 1px solid #D0D5DD; border-radius: 10px; padding: 0 10px; background: #fff; min-width: 130px; outline: none; }
.filter select:focus, .filter input:focus { border-color: var(--green); }
.table-wrap { overflow-x: auto; transition: opacity .15s; }
.table-wrap.loading { opacity: .55; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 700; padding: 11px 16px; background: #FAFBFC; border-bottom: 1px solid var(--line); white-space: nowrap; user-select: none; }
.table th.sortable { cursor: pointer; }
.table th.sortable:hover { color: var(--navy); }
.sort-ind { margin-left: 5px; font-size: 10px; opacity: .45; } .sort-ind.on { opacity: 1; color: var(--green-d); }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table.clickable tbody tr { cursor: pointer; }
.table tbody tr:hover { background: #FAFBF7; }
.table .right, .table th.right { text-align: right; }
.table .center { text-align: center; }
.table td.act, .table th.act { width: 52px; text-align: right; padding-right: 10px; }
.table tr.row-overdue { background: #FFF7F6; }
.cell-main { font-weight: 600; color: var(--navy); }
.cell-sub { font-size: 12.5px; color: var(--muted); }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line-2); flex-wrap: wrap; }
.pager:empty { display: none; }
.pager-btns { display: flex; align-items: center; gap: 10px; }
.page-ind { font-size: 13px; color: var(--muted); }
.list-summary { padding: 12px 18px; border-top: 1px solid var(--line-2); background: #FAFBFC; display: flex; gap: 22px; flex-wrap: wrap; justify-content: flex-end; font-size: 14px; }
.list-summary b { color: var(--navy); }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.green { background: var(--green-bg); color: #3B6B0F; }
.badge.red { background: var(--red-bg); color: #B42318; }
.badge.blue { background: var(--blue-bg); color: #1849A9; }
.badge.amber { background: var(--amber-bg); color: #93400D; }
.badge.grey { background: #EEF0F3; color: #475467; }
.badge.grey-dark { background: #E4E7EC; color: #344054; }
.badge.navy { background: #E3E8F4; color: var(--navy); }
.chip { display: inline-block; padding: 2px 9px; border-radius: 6px; background: #EEF1F5; font-size: 12px; font-weight: 600; color: #475467; }

/* ---------- states ---------- */
.state { text-align: center; padding: 56px 20px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.state h4 { color: var(--ink); font-size: 16px; }
.state .btn { margin-top: 10px; }
.state-ico { width: 60px; height: 60px; border-radius: 18px; background: var(--green-bg); color: var(--green-d); display: grid; place-items: center; margin-bottom: 4px; }
.state-ico.red { background: var(--red-bg); color: var(--red); }
.spin { width: 30px; height: 30px; border-radius: 50%; border: 3px solid #DDE3EA; border-top-color: var(--green-d); animation: spin .8s linear infinite; }

/* ---------- dashboard ---------- */
.stat-card { padding: 16px 18px; display: flex; gap: 14px; align-items: center; text-decoration: none; color: inherit; transition: transform .12s, box-shadow .12s; }
a.stat-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(16,24,40,.1); text-decoration: none; }
.stat-ico { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex: none; background: var(--green-bg); color: var(--green-d); }
.stat-ico.navy { background: #E3E8F4; color: var(--navy); } .stat-ico.yellow { background: var(--yellow-bg); color: #8A6100; } .stat-ico.red { background: var(--red-bg); color: var(--red); } .stat-ico.blue { background: var(--blue-bg); color: var(--blue); }
.stat-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.stat-val { font-size: 22px; font-weight: 800; color: var(--navy); letter-spacing: -.3px; line-height: 1.2; white-space: nowrap; }
.quick { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin: 18px 0; }
.quick button, .quick a { display: flex; align-items: center; gap: 12px; padding: 15px 18px; border-radius: var(--radius); border: 1px solid var(--line); background: #fff; font-weight: 700; color: var(--navy); box-shadow: var(--shadow); text-align: left; text-decoration: none; min-height: 64px; }
.quick button:hover, .quick a:hover { border-color: var(--green); background: #FBFDF7; text-decoration: none; }
.quick .q-ico { width: 38px; height: 38px; border-radius: 10px; background: var(--navy); color: #fff; display: grid; place-items: center; flex: none; }
.quick .q-ico.g { background: var(--green-d); } .quick .q-ico.y { background: var(--yellow); color: var(--navy); } .quick .q-ico.b { background: var(--blue); }
.pay-sum { display: grid; gap: 14px; padding: 18px 20px; }
.pay-row { display: flex; justify-content: space-between; align-items: baseline; }
.pay-row span { color: var(--muted); font-weight: 600; font-size: 13px; }
.pay-row b { font-size: 18px; color: var(--navy); }
.pay-row.red b { color: var(--red); } .pay-row.green b { color: var(--green-d); }
.bar { height: 9px; border-radius: 9px; background: #EDF0F4; overflow: hidden; display: flex; }
.bar i { display: block; height: 100%; background: var(--green-l); } .bar i.y { background: var(--yellow); } .bar i.r { background: #E4574B; }
.chart { padding: 14px 18px 16px; }
.chart svg { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); padding: 0 18px 14px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.mini-list { list-style: none; margin: 0; padding: 4px 8px 8px; }
.mini-list li { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 10px; }
.mini-list li:hover { background: #FAFBF7; }

/* ---------- customer / doc view ---------- */
.kv { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 8px 14px; font-size: 14px; }
.kv dt { color: var(--muted); font-weight: 600; font-size: 13px; } .kv dd { margin: 0; word-break: break-word; }
.profile-head { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.avatar.lg { width: 60px; height: 60px; font-size: 20px; background: var(--green-d); }
.contact-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a, .tabs button { padding: 12px 16px; border: 0; background: none; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; text-decoration: none; margin-bottom: -1px; min-height: 44px; }
.tabs a:hover, .tabs button:hover { color: var(--navy); text-decoration: none; }
.tabs .on { color: var(--navy); border-bottom-color: var(--green-l); }
.totals { width: 100%; font-size: 14px; }
.totals td { padding: 6px 0; } .totals td:last-child { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.totals tr.grand td { border-top: 2px solid var(--navy); padding-top: 12px; font-size: 18px; font-weight: 800; color: var(--navy); }
.totals tr.neg td:last-child { color: var(--red); }
.note-box { background: var(--yellow-bg); border: 1px solid #F3DC9A; border-radius: 10px; padding: 12px 14px; font-size: 13.5px; color: #6B4E00; }
.info-box { background: var(--blue-bg); border: 1px solid #C3D8F7; border-radius: 10px; padding: 12px 14px; font-size: 13.5px; color: #1849A9; }
.pre { white-space: pre-line; }
.balance-box { padding: 16px 18px; border-radius: 12px; background: var(--navy); color: #fff; display: grid; gap: 8px; }
.balance-box .r { display: flex; justify-content: space-between; font-size: 13.5px; color: #C7D2E8; } .balance-box .r b { color: #fff; font-size: 15px; }
.balance-box .due { border-top: 1px solid rgba(255,255,255,.2); padding-top: 10px; font-size: 14px; } .balance-box .due b { font-size: 22px; color: var(--yellow); }
.balance-box.paid .due b { color: #A3E635; }

/* ---------- document editor ---------- */
.editor .card { margin-bottom: 18px; }
.items-table { width: 100%; border-collapse: collapse; min-width: 1120px; }
.items-table th { background: #FAFBFC; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); padding: 9px 6px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.items-table td { padding: 7px 5px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.items-table td input, .items-table td select, .items-table td textarea { width: 100%; height: 38px; border: 1px solid #D9DEE5; border-radius: 8px; padding: 0 8px; outline: none; background: #fff; font-size: 13.5px; }
.items-table td textarea { height: 38px; padding: 8px; min-height: 38px; resize: vertical; line-height: 1.3; }
.items-table td input:focus, .items-table td select:focus, .items-table td textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(94,140,31,.14); }
.items-table td .ro { height: 38px; display: flex; align-items: center; justify-content: flex-end; font-variant-numeric: tabular-nums; font-weight: 600; padding: 0 4px; white-space: nowrap; }
.items-table td.n { text-align: center; color: var(--muted); padding-top: 14px; font-weight: 600; }
.items-table td input[type=number] { text-align: right; }
.items-table .row-actions { display: flex; gap: 2px; }
.items-table .disc { display: flex; } .items-table .disc input { border-radius: 8px 0 0 8px; min-width: 0; } .items-table .disc select { width: 52px; border-radius: 0 8px 8px 0; border-left: 0; padding: 0 2px; flex: none; }
.add-row { padding: 12px 16px; border-top: 1px dashed var(--line); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.editor-bar { position: sticky; bottom: 0; z-index: 20; background: rgba(255,255,255,.96); backdrop-filter: blur(6px); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 -4px 20px rgba(16,24,40,.08); padding: 12px 16px; display: flex; gap: 10px; justify-content: space-between; align-items: center; flex-wrap: wrap; }
.editor-bar .tot { font-size: 13px; color: var(--muted); } .editor-bar .tot b { font-size: 18px; color: var(--navy); margin-left: 6px; }
.terms-grid { display: grid; grid-template-columns: 1fr 120px 150px 40px; gap: 8px; align-items: center; margin-bottom: 8px; }
.terms-grid input { height: 38px; border: 1px solid #D9DEE5; border-radius: 8px; padding: 0 10px; outline: none; width: 100%; } .terms-grid input:focus { border-color: var(--green); }
.terms-grid .amt { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip-btn { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 5px 13px; font-size: 13px; font-weight: 600; color: var(--navy); min-height: 34px; }
.chip-btn:hover { border-color: var(--green); background: var(--green-bg); }
.chip-btn.on { background: var(--navy); color: #fff; border-color: var(--navy); }

/* ---------- menu / typeahead ---------- */
.menu { position: fixed; z-index: 200; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; max-height: min(420px, 70vh); overflow-y: auto; animation: pop .12s ease; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border: 0; background: transparent; border-radius: 8px; text-align: left; font-size: 14px; min-height: 40px; }
.menu-item:hover, .menu-item.active { background: #F1F5EA; }
.menu-item.danger { color: var(--red); } .menu-item.danger:hover { background: var(--red-bg); }
.menu-sep { height: 1px; background: var(--line-2); margin: 5px 4px; }
.menu-empty { padding: 14px; color: var(--muted); text-align: center; font-size: 13.5px; }
.typeahead { padding: 4px; z-index: 300; }
.ta-item { align-items: flex-start; justify-content: space-between; }
.ta-main { display: flex; flex-direction: column; min-width: 0; } .ta-main small { color: var(--muted); font-size: 12px; white-space: normal; }
.ta-right { font-weight: 700; color: var(--navy); white-space: nowrap; font-size: 13px; }
.ta-footer { color: var(--green-d); font-weight: 600; }
.search-pop { position: absolute; top: 48px; left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); max-height: 70vh; overflow-y: auto; z-index: 100; padding: 8px; }
.sp-group { padding: 8px 10px 4px; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .8px; color: var(--green); }
.sp-item { display: flex; gap: 10px; align-items: center; padding: 9px 10px; border-radius: 9px; color: var(--ink); text-decoration: none; min-height: 44px; }
.sp-item:hover, .sp-item.active { background: #F1F5EA; text-decoration: none; }
.sp-item small { display: block; color: var(--muted); font-size: 12px; }
.notif-pop { position: fixed; z-index: 200; width: 380px; max-width: calc(100vw - 16px); background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden; }
.notif-pop header { padding: 14px 16px; font-weight: 700; color: var(--navy); border-bottom: 1px solid var(--line-2); }
.notif { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line-2); text-decoration: none; color: var(--ink); } .notif:hover { background: #FAFBF7; text-decoration: none; } .notif:last-child { border: 0; }
.notif .dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 6px; flex: none; background: var(--blue); } .notif .dot.danger { background: var(--red); } .notif .dot.warn { background: var(--yellow); }
.notif b { display: block; font-size: 14px; } .notif span { font-size: 12.5px; color: var(--muted); }

/* ---------- modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(12, 26, 54, .55); backdrop-filter: blur(2px); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; overflow-y: auto; animation: fadeb .15s ease; }
@keyframes fadeb { from { opacity: 0; } to { opacity: 1; } }
.modal { background: #fff; border-radius: 18px; width: 100%; max-width: 640px; box-shadow: var(--shadow-lg); animation: pop .18s ease; display: flex; flex-direction: column; max-height: 90vh; }
.modal.sm { max-width: 440px; } .modal.lg { max-width: 820px; } .modal.xl { max-width: 980px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line-2); }
.modal-head h3 { font-size: 17px; color: var(--navy); }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line-2); display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; background: #FAFBFC; border-radius: 0 0 18px 18px; }
.confirm-msg { color: #475467; line-height: 1.55; }
.pdf-modal .modal-body { padding: 0; } .pdf-frame { width: 100%; height: 72vh; border: 0; display: block; background: #E4E7EC; }

/* ---------- whatsapp options ---------- */
.wa-opts { display: grid; gap: 10px; margin-top: 16px; }
.wa-opt { display: flex; gap: 12px; align-items: flex-start; text-align: left; padding: 13px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; width: 100%; }
.wa-opt:hover { border-color: var(--green); background: #FBFDF7; }
.wa-opt.primary { border-color: var(--green-d); background: var(--green-bg); }
.wa-opt .ico { margin-top: 2px; color: var(--green-d); }
.wa-opt small { display: block; color: var(--muted); font-size: 12.5px; line-height: 1.4; margin-top: 2px; }
.wa-opt.busy { opacity: .6; }

/* ---------- toast ---------- */
#toasts { position: fixed; right: 18px; bottom: 18px; z-index: 500; display: flex; flex-direction: column; gap: 10px; max-width: min(420px, calc(100vw - 36px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; background: #fff; border: 1px solid var(--line); border-left: 5px solid var(--green-l); padding: 12px 12px 12px 14px; border-radius: 12px; box-shadow: var(--shadow-lg); animation: slidein .22s ease; font-size: 14px; }
.toast.error { border-left-color: var(--red); } .toast.info { border-left-color: var(--blue); }
.toast .t-ico { color: var(--green-d); margin-top: 1px; } .toast.error .t-ico { color: var(--red); } .toast.info .t-ico { color: var(--blue); }
.toast .t-x { margin-left: auto; border: 0; background: none; color: var(--muted); padding: 2px; }
.toast.out { opacity: 0; transform: translateX(20px); transition: .2s; }
@keyframes slidein { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.login-hero { background: linear-gradient(160deg, var(--navy) 0%, var(--navy-3) 100%); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-hero::after { content: ''; position: absolute; width: 520px; height: 520px; border-radius: 50%; right: -180px; bottom: -180px; background: radial-gradient(circle at 30% 30%, rgba(245,179,1,.55), rgba(245,179,1,0) 65%); }
.login-hero h2 { font-size: 34px; line-height: 1.2; font-weight: 800; max-width: 440px; }
.login-hero h2 em { font-style: normal; color: var(--yellow); }
.login-hero p { color: #B6C3DE; max-width: 420px; margin-top: 14px; font-size: 15.5px; }
.login-hero .pts { display: grid; gap: 12px; margin-top: 30px; position: relative; z-index: 1; }
.login-hero .pts div { display: flex; gap: 10px; align-items: center; color: #D5DCEB; }
.login-hero .pts .ico { color: var(--yellow); }
.login-hero .brand-line { font-size: 12px; letter-spacing: 2px; color: #8EA0C6; text-transform: uppercase; }
.login-form { display: flex; align-items: center; justify-content: center; padding: 32px 20px; background: #fff; }
.login-box { width: 100%; max-width: 400px; }
.login-box .logo { width: 220px; max-width: 70%; border-radius: 16px; display: block; margin: 0 auto 22px; }
.login-box h1 { font-size: 24px; color: var(--navy); text-align: center; }
.login-box .sub { color: var(--muted); text-align: center; margin: 4px 0 24px; }
.login-box .form-grid { grid-template-columns: 1fr; }
.pw-wrap { position: relative; } .pw-wrap input { padding-right: 44px; } .pw-wrap button { position: absolute; right: 4px; top: 3px; }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; font-size: 14px; }
.alert.error { background: var(--red-bg); color: #912018; border: 1px solid #F8C7C2; } .alert.ok { background: var(--green-bg); color: #3B6B0F; }

/* ---------- reports ---------- */
.rep-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.rep-filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 14px 16px; border-bottom: 1px solid var(--line-2); }
.rep-sum { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line-2); }
.rep-sum div { background: #FAFBFC; border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 14px; } .rep-sum small { color: var(--muted); font-weight: 600; display: block; } .rep-sum b { font-size: 18px; color: var(--navy); }
.rep-sum .red b { color: var(--red); }
tfoot td { font-weight: 800; background: #F2F5EA; border-top: 2px solid var(--navy); padding: 12px 16px; }
.print-only { display: none; }

/* ---------- settings ---------- */
.set-grid { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 22px; align-items: start; }
.set-nav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 84px; }
.set-nav a { padding: 11px 14px; border-radius: 10px; color: #475467; font-weight: 600; text-decoration: none; display: flex; gap: 10px; align-items: center; min-height: 44px; }
.set-nav a:hover { background: #fff; text-decoration: none; } .set-nav a.on { background: #fff; color: var(--navy); box-shadow: var(--shadow); }
.logo-edit { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.logo-edit img { width: 200px; border-radius: 12px; border: 1px solid var(--line); }
.status-row { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line-2); }
.status-row:last-child { border: 0; } .status-row .grow { flex: 1; } .status-row small { color: var(--muted); display: block; }
.perm-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px 10px; }
code, .code { background: #EEF1F5; padding: 1px 6px; border-radius: 5px; font-size: 12.5px; }

/* ---------- responsive ---------- */
@media (max-width: 1280px) {
  .cols-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .main-side { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1080px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 280px; transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .nav-open .sidebar { transform: none; }
  .nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(12,26,54,.5); z-index: 35; }
  .menu-btn { display: inline-grid; }
  .top-title { display: block; }
  .topbar, #view { padding-left: 18px; padding-right: 18px; }
  .topbar { padding-top: 0; padding-bottom: 0; }
  .login-wrap { grid-template-columns: 1fr; } .login-hero { display: none; }
  .set-grid { grid-template-columns: 1fr; } .set-nav { flex-direction: row; overflow-x: auto; position: static; background: #fff; padding: 6px; border-radius: 12px; border: 1px solid var(--line); } .set-nav a { white-space: nowrap; }
  .grid.cols-3 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  body { font-size: 15px; }
  #view { padding: 16px 12px 50px; }
  .topbar { padding: 0 10px; gap: 8px; }
  .top-title { display: none; } .global-search kbd, .user-btn .u-meta { display: none; }
  .cols-2, .cols-4, .cols-6 { grid-template-columns: 1fr 1fr; }
  .form-grid, .form-grid.c3, .form-grid.c4 { grid-template-columns: 1fr; }
  .quick { grid-template-columns: 1fr 1fr; gap: 10px; } .quick button, .quick a { padding: 12px; gap: 8px; font-size: 13.5px; }
  .page-head h1 { font-size: 20px; }
  .ph-actions { width: 100%; } .ph-actions .btn { flex: 1 1 auto; } .ph-actions .btn.icon-only { flex: 0 0 auto; }
  .kv { grid-template-columns: 100px 1fr; }
  .stat-val { font-size: 18px; }
  .stat-card { padding: 12px; gap: 10px; } .stat-ico { width: 38px; height: 38px; }
  .modal-backdrop { padding: 0; align-items: flex-end; } .modal, .modal.sm, .modal.lg, .modal.xl { max-width: 100%; max-height: 94vh; border-radius: 18px 18px 0 0; }
  .toolbar .filter, .toolbar .filter select, .toolbar .filter input { width: 100%; } .toolbar .filter { flex: 1 1 140px; } .search-box { max-width: none; flex-basis: 100%; }
  .perm-grid { grid-template-columns: 1fr 1fr; }
  .terms-grid { grid-template-columns: 1fr 80px 100px 36px; }
  /* items table becomes stacked cards */
  .items-wrap { overflow: visible !important; }
  .items-table { min-width: 0; display: block; } .items-table thead { display: none; } .items-table tbody { display: block; }
  .items-table tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; padding: 12px; margin: 10px; border: 1px solid var(--line); border-radius: 12px; background: #FCFCFD; }
  .items-table td { display: block; padding: 0; border: 0; }
  .items-table td::before { content: attr(data-label); display: block; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; margin-bottom: 3px; }
  .items-table td.n { grid-column: 1 / -1; text-align: left; padding: 0; } .items-table td.n::before { content: 'Item '; display: inline; }
  .items-table td[data-wide], .items-table td.act-cell { grid-column: 1 / -1; }
  .items-table td.act-cell::before { display: none; } .items-table td .ro { justify-content: flex-start; }
  .table.stack thead { display: none; }
}
@media (max-width: 480px) {
  .cols-2 { grid-template-columns: 1fr; }
  .cols-4, .cols-6 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 12px; flex-direction: column; align-items: flex-start; gap: 8px; }
  .stat-val { font-size: 16.5px; }
  .quick { grid-template-columns: 1fr 1fr; }
}

/* ---------- print ---------- */
@media print {
  body { background: #fff; }
  .sidebar, .topbar, .no-print, .toolbar, .pager, .page-head .ph-actions, .rep-tabs, .rep-filters, #toasts, .scrim { display: none !important; }
  .app { display: block; } #view { padding: 0; max-width: none; animation: none; }
  .card { box-shadow: none; border: 0; } .table-wrap { overflow: visible; }
  .print-only { display: block; margin-bottom: 14px; }
  .table th, tfoot td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .table td, .table th { padding: 6px 8px; font-size: 11px; }
}
