:root {
  --navy: #0b2239;
  --navy-2: #123a5c;
  --navy-3: #1b4f78;
  --gold: #c8a24a;
  --gold-soft: #f3e7c8;
  --bg: #eef2f7;
  --card: #ffffff;
  --text: #1c2b3a;
  --muted: #5f7183;
  --line: #e3e8ef;
  --green: #1f8a5b;
  --green-soft: #e6f5ee;
  --red: #b23b3b;
  --red-soft: #fbeaea;
  --amber: #b7791f;
  --amber-soft: #fdf3e2;
  --shadow: 0 1px 2px rgba(16, 42, 67, .06), 0 10px 28px rgba(16, 42, 67, .05);
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Tahoma, "Noto Naskh Arabic", "Dubai", "Arial", sans-serif;
  font-size: 14px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--navy-2); text-decoration: none; }
a:hover { color: var(--navy-3); }
h1, h2, h3, h4 { margin: 0; font-weight: 700; color: var(--navy); line-height: 1.35; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.strong { font-weight: 700; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.neg { color: var(--red) !important; }
.pos { color: var(--green) !important; }
.code { font-family: "Consolas", "Courier New", monospace; letter-spacing: .2px; }
.num {
  direction: ltr;
  text-align: left;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.money-amount {
  display: inline-flex;
  align-items: center;
  gap: .22em;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.riyal-symbol {
  width: .81em;
  height: .91em;
  vertical-align: -.09em;
}
.money-value:empty::before { content: "—"; }
.money-value:empty + .riyal-symbol { display: none; }

/* ---------- Shell ---------- */
.app-shell { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset-block: 0;
  inset-inline-start: 0;
  width: 262px;
  background: linear-gradient(180deg, #0b2239 0%, #0e2c49 55%, #0b2239 100%);
  color: #dbe6f1;
  display: flex;
  flex-direction: column;
  padding: 20px 16px 16px;
  z-index: 20;
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 4px 6px 18px; border-bottom: 1px solid rgba(255,255,255,.09); }
.brand-mark {
  width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(145deg, var(--gold), #a9822f);
  color: #10263d; font-weight: 800; font-size: 22px;
  display: grid; place-items: center; flex: 0 0 auto;
  box-shadow: 0 6px 16px rgba(200,162,74,.28);
}
.brand-mark.large { width: 64px; height: 64px; font-size: 30px; border-radius: 18px; margin-bottom: 14px; }
.brand-mark--logo { background: #fff; box-shadow: none; border: 1px solid var(--line); padding: 4px; }
.brand-mark--logo img { display: block; width: 100%; height: 100%; object-fit: contain; }
.brand-mark.mobile-brand-mark { display: none; }
.auth-brand .brand-mark--logo { width: 128px; }
.invoice-brand .brand-mark--logo { width: 84px; height: 64px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.3; }
.brand-text strong { color: #fff; font-size: 16px; }
.brand-text span { color: #9fb4c9; font-size: 11px; }

.nav { display: flex; flex-direction: column; gap: 2px; padding-top: 14px; flex: 1; }
.nav-group {
  color: #7f97ae; font-size: 10.5px; font-weight: 700;
  letter-spacing: .4px; margin: 14px 10px 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  color: #c9d7e5; padding: 9px 12px; border-radius: 9px;
  font-size: 13.5px; transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: rgba(200,162,74,.16); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.nav-dot { width: 5px; height: 5px; border-radius: 50%; background: #5f7a93; flex: 0 0 auto; }
.nav-item.active .nav-dot { background: var(--gold); }

.sidebar-foot { border-top: 1px solid rgba(255,255,255,.09); padding-top: 12px; margin-top: 12px; }
.user-chip { display: flex; align-items: center; gap: 9px; padding: 4px 6px 10px; }
.user-chip .avatar {
  width: 34px; height: 34px; border-radius: 50%; background: rgba(200,162,74,.2);
  color: var(--gold); display: grid; place-items: center; font-weight: 700;
}
.user-chip strong { display: block; color: #fff; font-size: 12.5px; }
.user-chip small { color: #93a9be; font-size: 11px; }
.logout { display: block; text-align: center; color: #c9d7e5; font-size: 12px; padding: 7px; border-radius: 8px; border: 1px solid rgba(255,255,255,.12); }
.logout:hover { background: rgba(255,255,255,.07); color: #fff; }
.logout { background: transparent; width: 100%; font: inherit; cursor: pointer; }

.main { margin-inline-start: 262px; padding: 26px 30px 40px; min-height: 100vh; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.eyebrow { color: var(--gold); font-size: 11px; font-weight: 700; letter-spacing: .5px; margin-bottom: 2px; }
.page-title { font-size: 24px; }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.app-footer { margin-top: 26px; color: #8a9aab; font-size: 11px; text-align: center; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 9px; border: 1px solid transparent;
  font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: transform .12s, box-shadow .12s, background .12s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(180deg, var(--navy-2), var(--navy)); color: #fff; box-shadow: 0 6px 14px rgba(11,34,57,.18); }
.btn-primary:hover { color: #fff; box-shadow: 0 8px 18px rgba(11,34,57,.24); }
.btn-ghost { background: #fff; border-color: #d5dfe9; color: var(--navy-2); }
.btn-ghost:hover { background: #f7fafc; color: var(--navy); }
.btn-block { width: 100%; }
.mini {
  display: inline-block; padding: 4px 9px; border-radius: 7px; border: 1px solid #d5dfe9;
  background: #fff; color: var(--navy-2); font-family: inherit; font-size: 11.5px;
  font-weight: 600; cursor: pointer; white-space: nowrap;
}
.mini:hover { background: #f4f8fb; }
.mini.danger { color: var(--red); border-color: #efcaca; }
.mini.danger:hover { background: var(--red-soft); }
.mini.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.link { color: var(--navy-2); font-weight: 600; }
.link:hover { text-decoration: underline; }

/* ---------- Cards & tables ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; margin-bottom: 18px; min-width: 0; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2 { font-size: 16px; }
.table-wrap { overflow-x: auto; border-radius: 10px; max-width: 100%; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  background: #f6f9fc; color: #5b6b7c; font-size: 11.5px; font-weight: 700;
  text-align: right; padding: 11px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 11px 10px; border-bottom: 1px solid #eef2f7; vertical-align: middle; }
.table tbody tr:hover { background: #fafcff; }
.table tfoot td { background: #f1f5fa; font-weight: 700; border-top: 2px solid #d8e2ee; border-bottom: none; }
.table-compact td, .table-compact th { padding: 8px 10px; }
.row-parent td { background: #fbfcfe; font-weight: 700; }
.actions-col { white-space: nowrap; }
.actions-col form { display: inline; }
.empty { text-align: center; color: var(--muted); padding: 26px 10px !important; }
.tag { display: inline-block; background: #eef3f8; color: #4a5d70; border-radius: 6px; padding: 2px 8px; font-size: 11px; font-weight: 600; }
.badge { display: inline-block; border-radius: 999px; padding: 3px 10px; font-size: 11px; font-weight: 700; }
.badge-paid { background: var(--green-soft); color: var(--green); }
.badge-unpaid { background: var(--red-soft); color: var(--red); }
.badge-partial { background: var(--amber-soft); color: var(--amber); }

/* ---------- KPI ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kpi { border-radius: var(--radius); padding: 16px 18px; color: #fff; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.kpi::after { content: ""; position: absolute; inset-inline-end: -30px; top: -30px; width: 100px; height: 100px; border-radius: 50%; background: rgba(255,255,255,.08); }
.kpi-label { display: block; font-size: 12px; opacity: .85; }
.kpi-value { display: block; font-size: 24px; font-weight: 800; margin: 4px 0 2px; direction: ltr; text-align: right; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 10.5px; opacity: .7; }
.kpi-navy { background: linear-gradient(145deg, #123a5c, #0b2239); }
.kpi-red { background: linear-gradient(145deg, #a94a4a, #7f2f2f); }
.kpi-green { background: linear-gradient(145deg, #2a9a6b, #176b47); }
.kpi-gold { background: linear-gradient(145deg, #c8a24a, #9a7628); }
.kpi-amber { background: linear-gradient(145deg, #c08a35, #8f621f); }
.kpi-soft { background: linear-gradient(145deg, #ffffff, #eef3f8); color: var(--navy); border: 1px solid #e1e9f1; }
.kpi-soft .kpi-label, .kpi-soft .kpi-sub { color: var(--muted); opacity: 1; }
.kpi-soft::after { background: rgba(18,58,92,.05); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-2 > * { min-width: 0; }
.quick-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.quick { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; display: flex; flex-direction: column; gap: 4px; border: 1px solid transparent; transition: transform .15s, border-color .15s; }
.quick:hover { transform: translateY(-2px); border-color: #d7e3ef; }
.quick-icon { width: 34px; height: 34px; border-radius: 10px; background: var(--gold-soft); color: #8a6a22; display: grid; place-items: center; font-weight: 800; margin-bottom: 4px; }
.quick strong { color: var(--navy); font-size: 13.5px; }
.quick small { color: var(--muted); font-size: 11.5px; }

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.grid-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 14px; font-weight: 600; color: #2f4152; }
.field .req { color: var(--red); font-style: normal; }
.field.span-2 { grid-column: span 2; }
.logo-setting.field { display: flex; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 14px; }
.logo-setting-fields { flex: 1 1 220px; min-width: 0; }
.company-logo-preview { width: 88px; height: 72px; border: 1px solid var(--line); padding: 6px; border-radius: 10px; object-fit: contain; background: #fff; }
.logo-remove { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.logo-remove input { width: auto; }
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #d5dfe9; border-radius: 9px;
  background: #fff; color: var(--text); font-family: inherit; font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--navy-3); box-shadow: 0 0 0 3px rgba(27,79,120,.12); }
input[dir="ltr"] { text-align: left; }
.form-actions { display: flex; gap: 8px; align-items: center; grid-column: span 2; padding-top: 4px; }
.inline { display: inline; }
.inline-form { display: flex; gap: 5px; align-items: center; }
.inline-form input, .inline-form select { padding: 5px 8px; font-size: 11.5px; width: auto; }
.money-input { font-variant-numeric: tabular-nums; }
.money-field { position: relative; display: block; }
.money-field > input { width: 100%; padding-inline-start: 2em; }
.money-field > .riyal-symbol {
  position: absolute;
  inset-inline-start: .75em;
  inset-block-start: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}
.entry-tools { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.totals-inline { display: flex; gap: 16px; align-items: center; font-size: 12.5px; color: #4a5d70; flex-wrap: wrap; }
.totals-inline strong { color: var(--navy); direction: ltr; display: inline-block; }
.commission-box { display: flex; align-items: center; justify-content: space-between; gap: 16px; background: #f7fafc; border: 1px solid #e1e9f1; border-radius: 12px; padding: 14px 18px; flex-wrap: wrap; }
.commission-box > div:first-child { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.commission-box > div:first-child > span { color: var(--muted); font-size: 12px; }
.commission-box strong { font-size: 24px; color: var(--navy); direction: ltr; }
.commission-rate { color: var(--muted); font-size: 12px; margin-inline-start: 8px; }
.commission-rate b { color: var(--navy); direction: ltr; }
.commission-box .flash { margin: 0; flex: 1; min-width: 240px; }

/* ---------- Flash ---------- */
.flash-wrap { margin-bottom: 16px; display: flex; flex-direction: column; gap: 8px; }
.flash { padding: 10px 14px; border-radius: 10px; font-size: 13px; border: 1px solid transparent; }
.flash.success { background: var(--green-soft); color: #176b47; border-color: #c6e8d8; }
.flash.error { background: var(--red-soft); color: #8f2f2f; border-color: #f0cccc; }

/* ---------- Invoice summary ---------- */
.invoice-summary { margin-inline-start: auto; width: min(360px, 100%); display: flex; flex-direction: column; gap: 6px; background: #f7fafc; border: 1px solid #e1e9f1; border-radius: 12px; padding: 14px 18px; }
.invoice-summary > div { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.invoice-summary strong { direction: ltr; font-variant-numeric: tabular-nums; }
.invoice-summary .grand { border-top: 1px solid #d8e2ee; padding-top: 8px; margin-top: 4px; font-size: 15px; color: var(--navy); }
.invoice-summary .grand strong { font-size: 18px; }

/* ---------- Reports ---------- */
.filter-bar { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 18px; margin-bottom: 18px; }
.filter-bar label { display: flex; flex-direction: column; gap: 4px; font-size: 11.5px; color: #4a5d70; font-weight: 600; }
.filter-bar input, .filter-bar select { width: auto; min-width: 150px; }
.report-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; border-bottom: 3px solid var(--navy); padding-bottom: 12px; margin-bottom: 16px; }
.report-head h2 { font-size: 20px; }
.report-stamp { background: #f1f5fa; border: 1px solid #dbe5ef; border-radius: 8px; padding: 6px 12px; font-size: 11px; color: #4a5d70; white-space: nowrap; }
.report-section { margin-bottom: 18px; }
.report-section h3 { font-size: 14px; margin-bottom: 8px; color: var(--navy-2); }
.report-table { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.balance-check { margin-top: 14px; padding: 12px 16px; border-radius: 10px; font-weight: 600; font-size: 13px; }
.balance-check.ok { background: var(--green-soft); color: #176b47; border: 1px solid #c6e8d8; }
.balance-check.bad { background: var(--red-soft); color: #8f2f2f; border: 1px solid #f0cccc; }
.net-box { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 18px; border-radius: 12px; margin-top: 12px; font-weight: 700; }
.net-box.ok { background: var(--navy); color: #fff; }
.net-box.bad { background: #7f2f2f; color: #fff; }
.net-box strong { font-size: 20px; direction: ltr; }
.opening-row td { background: #f7fafc; font-weight: 600; color: #4a5d70; }
.report-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.report-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; border: 1px solid transparent; transition: transform .15s, border-color .15s; }
.report-card:hover { transform: translateY(-2px); border-color: #d7e3ef; }
.report-num { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--gold-soft); color: #8a6a22; font-weight: 800; margin-bottom: 10px; }
.report-card h3 { font-size: 15px; margin-bottom: 4px; }
.report-card p { color: #4a5d70; font-size: 13px; margin: 0; }

/* ---------- Statements ---------- */
.statement-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.statement-balance { text-align: left; }
.statement-balance > span { display: block; color: var(--muted); font-size: 11.5px; }
.statement-balance strong { font-size: 24px; color: var(--navy); direction: ltr; }

/* ---------- Invoice detail ---------- */
.invoice-detail-head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.invoice-brand { display: flex; gap: 12px; align-items: flex-start; }
.invoice-brand h1, .invoice-brand h2 { font-size: 18px; }
.invoice-brand p { margin: 1px 0; }
.invoice-meta-box { display: flex; flex-direction: column; gap: 6px; background: #f7fafc; border: 1px solid #e1e9f1; border-radius: 10px; padding: 12px 16px; min-width: 200px; }
.invoice-meta-box > div { display: flex; justify-content: space-between; gap: 12px; font-size: 12.5px; }
.invoice-meta-box > div > span { color: var(--muted); }
.invoice-status-actions { text-align: left; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.row-actions.center { justify-content: center; }
.qr-card { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.qr-image { image-rendering: pixelated; border: 1px solid #e1e9f1; border-radius: 8px; padding: 6px; background: #fff; }
.info-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.info-grid > div { background: #f7fafc; border: 1px solid #e1e9f1; border-radius: 10px; padding: 12px 14px; }
.info-grid > div > span { display: block; color: var(--muted); font-size: 11.5px; }
.info-grid strong { color: var(--navy); font-size: 13px; }

/* ---------- Auth ---------- */
.auth-body { background: radial-gradient(1200px 600px at 80% -10%, #1b4f78 0%, #0b2239 55%, #071a2c 100%); min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 30px 18px; }
.auth-shell { width: min(1180px, 100%); margin: 0 auto; display: grid; grid-template-columns: 1.05fr .95fr; gap: 0; background: #fff; border-radius: 22px; overflow: hidden; box-shadow: 0 30px 80px rgba(0,0,0,.35); }
.auth-shell.single { grid-template-columns: 1fr; max-width: 520px; }
.auth-brand { background: linear-gradient(160deg, #123a5c, #0b2239); color: #dbe6f1; padding: 58px 52px; display: flex; flex-direction: column; justify-content: center; }
.auth-brand h1 { color: #fff; font-size: 28px; margin-bottom: 10px; }
.auth-brand p { color: #eef4f9; font-size: 15.5px; }
.auth-points { list-style: none; padding: 0; margin: 22px 0 0; display: flex; flex-direction: column; gap: 9px; }
.auth-points li { position: relative; padding-inline-start: 20px; color: #f5f9fc; font-size: 15px; }
.auth-points li::before { content: ""; position: absolute; inset-inline-start: 0; top: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); }
.auth-card { padding: 54px 50px; display: flex; flex-direction: column; justify-content: center; }
.auth-card.center { text-align: center; align-items: center; }
.auth-card-head h2 { font-size: 26px; }
.auth-card-head p { color: #4a5d70; font-size: 15px; margin-top: 2px; }
.auth-card .form { margin-top: 18px; }
.auth-note { color: #3f5163; font-size: 14px; text-align: center; margin-top: 14px; }
.auth-footer { text-align: center; color: #e2ebf3; font-size: 13.5px; margin-top: 22px; line-height: 1.9; max-width: 900px; margin-inline: auto; }
.auth-footer span { display: block; }
.error-code { font-size: 64px; font-weight: 800; color: var(--navy); line-height: 1; margin-bottom: 8px; }
.auth-card .btn { margin-top: 8px; }

/* ---------- Print ---------- */
.print-body { background: #e9eef4; margin: 0; padding: 0; }
.print-toolbar { display: flex; gap: 8px; justify-content: center; padding: 16px; }
.invoice-sheet { width: 210mm; margin: 0 auto 30px; background: #fff; padding: 16mm 15mm; box-shadow: 0 10px 40px rgba(0,0,0,.12); font-size: 12.5px; color: #1c2b3a; }
.invoice-header { display: flex; justify-content: space-between; gap: 20px; border-bottom: 3px solid var(--navy); padding-bottom: 14px; }
.invoice-header h1 { font-size: 19px; }
.invoice-header p { margin: 1px 0; font-size: 11.5px; color: #4a5d70; }
.invoice-header .phones { color: var(--navy-2); font-weight: 600; }
.invoice-meta { text-align: left; min-width: 190px; }
.invoice-meta h2 { font-size: 18px; color: var(--navy); margin-bottom: 6px; }
.invoice-meta table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.invoice-meta td { padding: 2px 0; }
.invoice-meta td:first-child { color: var(--muted); }
.invoice-meta td:last-child { text-align: left; font-weight: 600; }
.invoice-parties { display: flex; justify-content: space-between; gap: 20px; background: #f7fafc; border: 1px solid #e1e9f1; border-radius: 8px; padding: 12px 16px; margin: 16px 0; }
.invoice-parties h3 { font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.invoice-parties p { margin: 1px 0; font-size: 11.5px; }
.invoice-qr { text-align: center; }
.invoice-qr img { image-rendering: pixelated; }
.invoice-qr span { display: block; font-size: 9.5px; color: var(--muted); }
.invoice-table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.invoice-table th { background: var(--navy); color: #fff; font-size: 11px; padding: 8px 9px; text-align: right; }
.invoice-table td { padding: 8px 9px; border-bottom: 1px solid #e3e8ef; font-size: 11.5px; }
.invoice-table tbody tr:nth-child(even) { background: #fafcff; }
.invoice-totals { display: flex; justify-content: flex-start; margin-top: 14px; }
.totals-box { width: 330px; margin-inline-start: auto; border: 1px solid #e1e9f1; border-radius: 8px; overflow: hidden; }
.totals-box > div { display: flex; justify-content: space-between; gap: 12px; padding: 7px 12px; font-size: 11.5px; border-bottom: 1px solid #eef2f7; }
.totals-box > div:last-child { border-bottom: none; }
.totals-box .grand { background: var(--navy); color: #fff; font-size: 13px; font-weight: 700; }
.totals-box strong { direction: ltr; }
.invoice-note { margin-top: 14px; font-size: 11px; color: #4a5d70; }
.invoice-footer { margin-top: 28px; border-top: 1px solid #e3e8ef; padding-top: 10px; font-size: 10.5px; color: #6b7c8f; text-align: center; }
.invoice-footer p { margin: 2px 0; }

@media print {
  @page { size: A4; margin: 10mm; }
  body { background: #fff !important; }
  .no-print, .sidebar, .topbar, .app-footer, .flash-wrap, .print-toolbar { display: none !important; }
  .main { margin: 0 !important; padding: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #dfe6ee; break-inside: avoid; }
  .print-area { width: 100%; }
  .invoice-sheet { width: auto; min-height: auto; margin: 0; padding: 0; box-shadow: none; }
  .table { font-size: 11px; }
  a { color: inherit; text-decoration: none; }
}

.menu-toggle { display: none; }

@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .menu-toggle { display: inline-flex; }
  .sidebar { display: none; position: static; width: auto; inset: auto; padding: 14px; }
  .sidebar.open { display: flex; }
  .table-wrap .table { min-width: 640px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav-group { width: 100%; margin: 8px 4px 0; }
  .nav-item { padding: 7px 10px; }
  .sidebar-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
  .user-chip { padding: 0; }
  .logout { width: auto; padding: 6px 14px; }
  .main { margin: 0; padding: 18px 14px 30px; }
  .grid-2, .grid-form, .info-grid { grid-template-columns: 1fr; }
  .field.span-2, .form-actions { grid-column: auto; }
  .auth-shell { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .brand-mark.mobile-brand-mark { display: inline-grid; width: 128px; }
  .topbar { flex-direction: column; align-items: flex-start; }
  .invoice-sheet { width: 100%; padding: 18px; }
}
@media (max-width: 560px) {
  .kpi-grid, .quick-grid { grid-template-columns: 1fr; }
  .page-title { font-size: 20px; }
  .card { padding: 16px; }
  .statement-head, .qr-card { flex-direction: column; align-items: flex-start; }
}

.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 16px; }
.linked-list { list-style: none; padding: 0; margin: 12px 0 0; }
.linked-list li { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.linked-list li > span { color: var(--muted); }
.settlement-form { margin-top: 18px; }
.notice { padding: 10px 12px; background: var(--amber-soft); color: #684710; border-radius: 8px; margin: 12px 0; }
.invoice-lines { display: grid; gap: 10px; }
.invoice-line { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) auto; gap: 12px; align-items: end; padding: 12px; background: #f6f9fc; border: 1px solid var(--line); border-radius: 10px; }
.line-result { display: grid; gap: 5px; padding-block: 4px; }
.line-result > span { color: var(--muted); font-size: 12px; }
.line-result output { font-variant-numeric: tabular-nums; font-weight: 700; width: fit-content; }
.invoice-line .remove-item { min-height: 36px; }
.btn:focus-visible, .mini:focus-visible, .nav-item:focus-visible, .link:focus-visible { outline: 2px solid var(--navy-3); outline-offset: 3px; }

@media (max-width: 700px) {
  .invoice-line { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .invoice-line .field:first-child { grid-column: 1 / -1; }
  .invoice-line .remove-item { justify-self: end; min-height: 40px; }
  .filter-bar label { flex: 1 1 140px; min-width: 0; }
  .filter-bar input, .filter-bar select { width: 100%; min-width: 0; }
  .app-shell .btn { min-height: 42px; }
  .invoice-header, .invoice-parties { flex-wrap: wrap; }
}

