
/* =====================================================================
   Rawasi Cloud ERP — World-Class Enterprise Contracting Operating System
   Theme tokens, Full-Width Layout, Responsive Left Sidebar & Top Navigation
   ===================================================================== */
:root,
:root[data-theme="light"] {
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --surface-alt: #F1F5F9;
  --line: #E2E8F0;
  --line-subtle: #EDF2F7;
  --fg: #0F172A;
  --text: #0F172A;
  --muted: #475569;
  --dim: #64748B;
  --accent: #2563EB;
  --accent-hover: #1D4ED8;
  --accent-fg: #FFFFFF;
  --accent-glow: rgba(37, 99, 235, 0.15);
  --overdue: #DC2626;
  --overdue-bg: #FEF2F2;
  --overdue-border: #FECACA;
  --due: #D97706;
  --due-bg: #FFFBEB;
  --due-border: #FDE68A;
  --paid: #059669;
  --paid-bg: #ECFDF5;
  --paid-border: #A7F3D0;
  --font-body: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-head: 'IBM Plex Sans Condensed', 'IBM Plex Sans', system-ui, sans-serif;
  --font-num: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0B111A;
  --surface: #131D2A;
  --surface-alt: #182535;
  --line: #1E2E42;
  --line-subtle: #162436;
  --fg: #F8FAFC;
  --text: #F8FAFC;
  --muted: #94A3B8;
  --dim: #64748B;
  --accent: #38BDF8;
  --accent-hover: #0EA5E9;
  --accent-fg: #0B111A;
  --accent-glow: rgba(56, 189, 248, 0.2);
  --overdue: #F87171;
  --overdue-bg: #450A0A;
  --overdue-border: #7F1D1D;
  --due: #FBBF24;
  --due-bg: #451A03;
  --due-border: #78350F;
  --paid: #34D399;
  --paid-bg: #064E3B;
  --paid-border: #065F46;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --bg: #0B111A;
    --surface: #131D2A;
    --surface-alt: #182535;
    --line: #1E2E42;
    --line-subtle: #162436;
    --fg: #F8FAFC;
    --text: #F8FAFC;
    --muted: #94A3B8;
    --dim: #64748B;
    --accent: #38BDF8;
    --accent-hover: #0EA5E9;
    --accent-fg: #0B111A;
    --accent-glow: rgba(56, 189, 248, 0.2);
    --overdue: #F87171;
    --overdue-bg: #450A0A;
    --overdue-border: #7F1D1D;
    --due: #FBBF24;
    --due-bg: #451A03;
    --due-border: #78350F;
    --paid: #34D399;
    --paid-bg: #064E3B;
    --paid-border: #065F46;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body {
  width: 100%;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
}

/* Full Width Fluid Device Wrapper */
.wrap {
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
h1, h2 { font-family: var(--font-head); margin: 0; letter-spacing: 0.01em; text-wrap: balance; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 600; }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

header { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: flex-end; justify-content: space-between; }
header .sub { color: var(--muted); margin-top: 2px; }
.asof { display: flex; flex-direction: column; gap: 4px; }
.asof .rule { font-size: 12px; color: var(--muted); }
label.lbl { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
input[type=text], input[type=date], input[type=number], input[type=email], input[type=password] {
  font: inherit; color: var(--fg); background: var(--surface); border: 1px solid var(--line); border-radius: 4px;
  padding: 7px 9px; min-width: 0; width: 100%;
}
input::placeholder { color: var(--muted); opacity: 0.8; }
button {
  font: inherit; font-weight: 500; cursor: pointer; border-radius: 4px; padding: 7px 12px;
  border: 1px solid var(--line); background: var(--surface); color: var(--fg);
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
button.link { border: 0; background: none; color: var(--muted); padding: 2px 6px; font-size: 12px; }
button.link:hover { color: var(--overdue); }
button.link.armed { color: var(--overdue); font-weight: 600; }

.tabs { display: flex; flex-wrap: wrap; gap: 8px; align-items: stretch; }
.tab { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left; padding: 8px 12px; min-width: 150px; }
.tab .name { font-weight: 600; }
.tab .meta { font-size: 12px; color: var(--muted); }
.tab.on { border-color: var(--accent); box-shadow: inset 0 -3px 0 var(--accent); }
.tab .meta.bad { color: var(--overdue); font-weight: 600; }
.newcust { display: flex; gap: 6px; align-items: center; margin-left: auto; }
.newcust input { width: 200px; }

/* Modern Responsive Overdue Customer Navigation Panel */
.od-nav-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.od-nav-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.od-search-box {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 220px;
  max-width: 320px;
}
.od-search-icon {
  position: absolute;
  left: 9px;
  font-size: 13px;
  color: var(--muted);
  pointer-events: none;
}
.od-search-box input {
  width: 100%;
  padding: 6px 28px 6px 28px;
  font-size: 13px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--fg);
}
.od-search-box input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(42, 90, 140, 0.15);
}
.od-clear-btn {
  position: absolute;
  right: 6px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  padding: 0 4px;
}
.od-filter-pills {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}
.od-pill {
  border-radius: 20px;
  padding: 4px 11px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s ease;
}
.od-pill:hover {
  border-color: var(--accent);
  color: var(--fg);
}
.od-pill.on {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
  font-weight: 600;
}
.od-pill.bad.on {
  background: var(--overdue);
  color: #fff;
  border-color: var(--overdue);
}
.od-pill.warn.on {
  background: var(--due);
  color: #fff;
  border-color: var(--due);
}
.od-pill.ok.on {
  background: var(--paid);
  color: #fff;
  border-color: var(--paid);
}
.od-mobile-select-wrap {
  display: none;
  flex: 1 1 100%;
}
.od-mobile-select {
  width: 100%;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--fg);
  font-size: 13.5px;
  font-weight: 600;
}
.od-newcust-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}
.od-chips-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}
.od-chips-strip::-webkit-scrollbar {
  height: 6px;
}
.od-chips-strip::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.04);
  border-radius: 3px;
}
.od-chips-strip::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 3px;
}
.od-chip {
  flex: 0 0 auto;
  min-width: 180px;
  max-width: 260px;
  padding: 9px 12px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.od-chip:hover {
  border-color: var(--accent);
}
.od-chip.on {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1.5px var(--accent), 0 2px 6px rgba(0, 0, 0, 0.06);
  background: rgba(42, 90, 140, 0.05);
}
.od-chip .name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.od-chip .meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 11.5px;
}
.od-chip .meta .badge {
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
}
.od-chip .meta .badge.bad {
  background: var(--overdue-bg);
  color: var(--overdue);
}
.od-chip .meta .badge.warn {
  background: var(--due-bg);
  color: var(--due);
}
.od-chip .meta .badge.ok {
  background: var(--paid-bg);
  color: var(--paid);
}
.od-chip .meta .cnt {
  color: var(--muted);
  font-size: 11px;
}
.live-badge {
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
  border: 1px solid rgba(16, 185, 129, 0.3);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
}

@media (max-width: 768px) {
  .od-mobile-select-wrap {
    display: block;
  }
  .od-chips-strip {
    display: none;
  }
  .od-search-box {
    max-width: 100%;
    width: 100%;
  }
}

.summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; min-width: 0; }
.tile .k { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.tile .v { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-size: 22px; font-weight: 500; margin-top: 4px; overflow-wrap: anywhere; }
.tile .v small { font-size: 12px; color: var(--muted); margin-right: 4px; }
.tile .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tile.over { background: var(--overdue-bg); border-color: var(--overdue); }
.tile.over .v, .tile.over .k { color: var(--overdue); }
.tile.ok { background: var(--paid-bg); border-color: var(--paid); }
.tile.ok .v, .tile.ok .k { color: var(--paid); }

.cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 340px); gap: 16px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; min-width: 0; }
.panel > .hd { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.seg { display: flex; }
.seg button { border-radius: 0; margin-left: -1px; padding: 5px 10px; font-size: 12px; }
.seg button:first-child { border-radius: 4px 0 0 4px; margin-left: 0; }
.seg button:last-child { border-radius: 0 4px 4px 0; }
.seg button.on { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 640px; }
th { text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th.r, td.r { text-align: right; }
tr:last-child td { border-bottom: 0; }
tr.overdue td:first-child { box-shadow: inset 3px 0 0 var(--overdue); }
tr.paid td { color: var(--muted); }
.pill { display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.pill.overdue { background: var(--overdue-bg); color: var(--overdue); }
.pill.due { background: var(--due-bg); color: var(--due); }
.pill.paid { background: var(--paid-bg); color: var(--paid); }
.part { font-size: 11px; color: var(--muted); display: block; }
.empty { padding: 22px 14px; color: var(--muted); }
.note { padding: 10px 14px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); }

.form { display: grid; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--line); }
.form .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; align-items: end; }
.form .f { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.err { color: var(--overdue); font-size: 12px; min-height: 16px; }

.pay { display: flex; justify-content: space-between; gap: 8px; padding: 9px 14px; border-bottom: 1px solid var(--line); align-items: center; }
.pay .l { min-width: 0; }
.pay .d { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.pay .a { font-family: var(--font-num); font-variant-numeric: tabular-nums; white-space: nowrap; }

details.data { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 10px 14px; }
details.data summary { cursor: pointer; font-weight: 600; }
details.data p { color: var(--muted); font-size: 12px; margin: 8px 0; }
textarea { width: 100%; min-height: 90px; font-family: var(--font-num); font-size: 12px; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 8px; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.flash { color: var(--paid); font-size: 12px; align-self: center; }

@media (max-width: 960px) { .cols { grid-template-columns: minmax(0, 1fr); } .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); } .newcust { margin-left: 0; width: 100%; } .newcust input { width: auto; flex: 1; } }
@media (max-width: 460px) { .tile .v { font-size: 18px; } .tab { min-width: 0; flex: 1 1 140px; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

.topbar { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: flex-end; justify-content: space-between; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.co { font-size: 22px; font-weight: 700; }
.seg.big button { padding: 8px 14px; font-size: 13px; }
.pill.in { background: var(--paid-bg); color: var(--paid); }
.pill.out { background: var(--due-bg); color: var(--due); }
.amt-in { color: var(--paid); }
.amt-out { color: var(--due); }
.types { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.types button.on { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
select { font: inherit; color: var(--fg); background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 6px 8px; min-width: 0; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.bars { padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.bars .t { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.bars .track { height: 6px; background: var(--bg); border-radius: 3px; margin-top: 4px; overflow: hidden; }
.bars .fill { height: 100%; background: var(--accent); border-radius: 3px; }
.totals { display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 10px 14px; border-top: 1px solid var(--line); font-size: 13px; }
.det { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.f select { width: 100%; }
.namebtn { background: none; border: 0; padding: 0; font-weight: 600; color: var(--accent); cursor: pointer; text-align: left; }
.namebtn:hover { text-decoration: underline; }
.acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.acts button { padding: 4px 8px; font-size: 12px; }
.msg { color: var(--due); font-size: 12px; padding: 8px 14px 0; min-height: 16px; }
#view-people .wrap, #view-accounts .wrap { gap: 16px; }
@media (max-width: 960px) { .acc .side { order: -1; } }

.brandmark { height: 40px; width: auto; display: block; }
.dhead { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; }
.dbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.dnote { font-size: 12px; color: var(--muted); }
.d-grid { display: grid; grid-template-columns: minmax(0, 360px) minmax(0, 1fr); gap: 16px; align-items: start; margin-top: 12px; }
.d-form { padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.d-form h3 { font-family: var(--font-head); font-size: 13px; margin: 6px 0 0; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.d-form .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.d-form .f { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.d-form textarea, .data textarea.tall { min-height: 64px; }
.d-form select { width: 100%; }
.litem { border: 1px solid var(--line); border-radius: 4px; padding: 8px; display: grid; gap: 6px; background: var(--bg); }
.litem .row3 { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 6px; align-items: end; }
.litem textarea { min-height: 48px; }
.chk { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.chk input { width: auto; }
.d-prev { min-width: 0; background: var(--line); border-radius: 6px; padding: 12px; overflow: hidden; }
.d-zoom { width: 794px; transform-origin: top left; }
.docstat { font-size: 11px; }
.rowbtn { cursor: pointer; }
.rowbtn:hover td { background: var(--bg); }
@media (max-width: 960px) { .d-grid { grid-template-columns: minmax(0, 1fr); } .d-prev { padding: 6px; } }

/* The paper. Fixed light palette so it prints the same in either theme. */
.sheet { --p-ink: #1B2230; --p-muted: #5F6B7A; --p-line: #D5DAE1; --p-accent: #9C2B2B; --p-slate: #2B3345; --p-wash: #F3F5F8;
  position: relative; width: 794px; min-height: 1123px; background: #fff; color: var(--p-ink); font-family: var(--font-body), 'IBM Plex Sans Arabic', system-ui, sans-serif; font-size: 11.5px; line-height: 1.45;
  padding: 40px 44px 28px; display: flex; flex-direction: column; box-shadow: 0 1px 6px rgba(0,0,0,0.25); overflow: hidden; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.sheet * { box-sizing: border-box; }
.sheet .ar { font-family: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, sans-serif; direction: rtl; unicode-bidi: isolate; }
.sheet .wm { position: absolute; left: 50%; top: 52%; width: 520px; transform: translate(-50%, -50%); opacity: 0.09; pointer-events: none; z-index: 0; }
.sheet > *:not(.wm) { position: relative; z-index: 1; }
.sh-top { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; }
.sh-brand { display: flex; gap: 12px; align-items: center; min-width: 0; }
.sh-brand img { height: 58px; width: auto; max-width: 110px; object-fit: contain; }
.sh-co { font-family: var(--font-head); font-weight: 700; font-size: 15px; line-height: 1.15; color: var(--p-slate); }
.sh-sub { color: var(--p-muted); font-size: 10.5px; margin-top: 3px; max-width: 360px; }
.sh-title { text-align: right; flex: none; }
.sh-brand { flex: 1 1 auto; }
.sh-title .en { font-family: var(--font-head); font-weight: 700; font-size: 24px; letter-spacing: 0.04em; color: var(--p-accent); line-height: 1; white-space: nowrap; }
.sh-title .ar { font-size: 17px; font-weight: 600; color: var(--p-slate); margin-top: 4px; }
.sh-bar { margin-top: 12px; display: flex; justify-content: space-between; gap: 12px; background: var(--p-slate); color: #fff; padding: 6px 12px; font-size: 12.5px; font-weight: 600; line-height: 1.4; letter-spacing: 0.03em; border-bottom: 3px solid var(--p-accent); }
.sheet table { min-width: 0; }
.sheet td, .sheet th { white-space: normal; }
.sh-cols { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 14px; margin-top: 14px; }
.sh-box { border: 1px solid var(--p-line); background: rgba(255,255,255,0.7); }
.sh-box .bh { background: var(--p-wash); padding: 4px 10px; font-size: 10px; font-weight: 600; letter-spacing: 0.1em; color: var(--p-muted); display: flex; justify-content: space-between; text-transform: uppercase; border-bottom: 1px solid var(--p-line); }
.sh-box .bh .ar { letter-spacing: 0; text-transform: none; font-size: 11px; }
.sh-box .bb { padding: 8px 10px; min-height: 70px; }
.sh-box .nm { font-weight: 700; font-size: 13px; color: var(--p-slate); }
.sh-meta { width: 100%; border-collapse: collapse; }
.sh-meta td { padding: 4px 10px; border-bottom: 1px solid var(--p-line); vertical-align: top; }
.sh-meta tr:last-child td { border-bottom: 0; }
.sh-meta td:first-child { color: var(--p-muted); width: 44%; font-size: 10.5px; }
.sh-meta td:first-child .ar { display: block; font-size: 10px; text-align: left; }
.sh-meta td:last-child { font-weight: 600; }
.sh-items { width: 100%; border-collapse: collapse; margin-top: 14px; }
.sh-items th { background: var(--p-slate); color: #fff; font-weight: 700; font-size: 12px; letter-spacing: 0.04em; padding: 7px 8px; text-align: center; line-height: 1.3; border: 0; text-transform: none; }
.sh-items th .ar { display: block; font-size: 12px; font-weight: 600; opacity: 0.95; letter-spacing: 0; }
.sh-items td { padding: 7px 8px; border-bottom: 1px solid var(--p-line); vertical-align: top; }
.sh-items tr:nth-child(even) td { background: rgba(243,245,248,0.75); }
.sh-items .c { text-align: center; } .sh-items .r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap !important; }
.sh-items .d { width: 100%; }
.sh-lower { display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 18px; margin-top: 12px; align-items: start; }
.sh-words { font-size: 10.5px; color: var(--p-muted); }
.sh-words b { color: var(--p-ink); display: block; font-size: 11.5px; margin-top: 2px; }
.sh-tot { width: 100%; border-collapse: collapse; }
.sh-tot td { padding: 4px 8px; border-bottom: 1px solid var(--p-line); }
.sh-tot td:last-child { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap !important; }
.sh-tot td .ar { color: var(--p-muted); font-size: 10px; margin-left: 8px; }
.sh-tot tr.g td { background: var(--p-slate); color: #fff; font-weight: 700; font-size: 14px; border: 0; padding: 8px 8px; }
.sh-tot tr.g td .ar { color: #fff; }
.sh-sec { margin-top: 14px; }
.sh-sec h4 { margin: 0 0 4px; font-family: var(--font-head); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--p-accent); display: flex; justify-content: space-between; border-bottom: 1px solid var(--p-line); padding-bottom: 3px; }
.sh-sec h4 .ar { letter-spacing: 0; text-transform: none; font-size: 11.5px; }
.sh-sec .tx { white-space: pre-wrap; font-size: 10.5px; line-height: 1.5; }
.sh-bank { display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; font-size: 10.5px; }
.sh-bank span:nth-child(odd) { color: var(--p-muted); }
.sh-pay { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: end; }
.sh-qr { text-align: center; font-size: 9px; color: var(--p-muted); }
.sh-qr svg { width: 104px; height: 104px; display: block; margin: 0 auto 2px; }
.sh-sign { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; margin-top: 40px; }
.sh-sign .sg { border-top: 1px solid var(--p-ink); padding-top: 4px; font-size: 10.5px; color: var(--p-muted); min-height: 54px; }
.sh-sign .sg b { color: var(--p-ink); display: block; }
.sh-sign .sg b .ar { font-weight: 500; color: var(--p-muted); margin-left: 8px; }
.sh-foot { margin-top: auto; padding-top: 14px; }
.sh-foot .in { border-top: 2px solid var(--p-accent); padding-top: 6px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 14px; font-size: 10px; color: var(--p-muted); }
.sh-chain { font-size: 10.5px; color: var(--p-muted); margin-top: 8px; }

@media print {
  @page { size: A4; margin: 0; }
  html, body { background: #fff !important; padding: 0 !important; margin: 0 !important; }
  .np { display: none !important; }
  .wrap { max-width: none !important; margin: 0 !important; display: block !important; gap: 0 !important; }
  .d-grid { display: block !important; margin: 0 !important; }
  .d-prev { padding: 0 !important; background: none !important; border-radius: 0 !important; overflow: visible !important; }
  .d-zoom { zoom: 1 !important; width: 210mm !important; transform: none !important; }
  .sheet { width: 210mm !important; min-height: 297mm !important; box-shadow: none !important; overflow: visible !important; }
  .sheet .wm { position: fixed !important; top: 50% !important; }
  .sh-items tr, .sh-sign, .sh-lower { break-inside: avoid; }
  .sh-bar { font-size: 12.5px !important; font-weight: 600 !important; color: #fff !important; }
  .sh-items th { font-size: 12px !important; font-weight: 700 !important; color: #fff !important; }
  .sh-items th .ar { font-size: 12px !important; font-weight: 600 !important; }
  body .np, body .wrap .np { display: none !important; }
}

/* ===== connected build: sign-in, user bar, owner area, read-only mode ===== */
[hidden] { display: none !important; }
.boot { padding: 60px 16px; text-align: center; color: var(--muted); }
#login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.loginbox { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 26px 24px; display: flex; flex-direction: column; gap: 14px; }
.loginbox img { height: 54px; align-self: flex-start; }
.loginbox h1 { font-size: 16px; margin: 0; font-family: var(--font-head); line-height: 1.3; }
.loginbox input { width: 100%; }
.loginbox button.primary { width: 100%; padding: 10px; }
.login-sep { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 2px 0; }
.login-sep::before, .login-sep::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.google-btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); color: var(--fg); font-weight: 500; text-decoration: none; cursor: pointer; }
.google-btn:hover { border-color: var(--accent); background: var(--bg); }
.userbar { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; justify-content: flex-end; font-size: 12px; color: var(--muted); }
.userbar #who { color: var(--fg); font-weight: 600; }
.rolepill { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; border: 1px solid var(--line); border-radius: 10px; padding: 1px 7px; }
.syncstat { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; }
.syncstat.ok { background: var(--paid-bg); color: var(--paid); }
.syncstat.busy { background: var(--due-bg); color: var(--due); }
.syncstat.bad { background: var(--overdue-bg); color: var(--overdue); }
.banner { position: sticky; top: 0; z-index: 50; display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; background: var(--due-bg); color: var(--fg); border-bottom: 2px solid var(--due); padding: 10px 16px; font-size: 13px; }
.banner .bt { flex: 1 1 280px; }
.topright { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }

/* read-only users */
.ro form, .ro [data-act^="del"], .ro [data-aact="del"], .ro [data-pact="delemp"], .ro [data-pact="adv"], .ro [data-pact="fund"], .ro [data-pact="spend"],
.ro [data-cact], .ro #d-new, .ro [data-dnext], .ro [data-dact="del"], .ro [data-dact="dup"], .ro [data-dact="addline"], .ro [data-dact="rmline"], .ro [data-dact="rmlogo"] { display: none !important; }
#view-docs.ro #d-form input, #view-docs.ro #d-form textarea, #view-docs.ro #d-form select { pointer-events: none; opacity: .85; }
#view-accounts.ro #a-form, #view-overdue.ro .newcust { display: none !important; }
body.no-settings #d-settings { display: none !important; }

/* owner area */
#view-admin .tabs2 { display: flex; flex-wrap: wrap; gap: 6px; }
#view-admin .tabs2 button.on { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
#view-admin .box { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
#view-admin .box p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
#view-admin .box h3 { margin: 4px 0 0; font-size: 14px; font-family: var(--font-head); }
#view-admin .tw { overflow-x: auto; }
#view-admin td select, #view-admin td input[type=text] { width: 100%; min-width: 96px; }
#view-admin .small { font-size: 12px; color: var(--muted); }
#view-admin .detail { font-family: var(--font-num); font-size: 11px; white-space: pre-wrap; color: var(--muted); max-width: 520px; }
#view-admin .ok { color: var(--paid); } #view-admin .bad { color: var(--overdue); }
#view-admin .imp textarea { min-height: 70px; }
#view-admin .grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
#view-admin .rep td, #view-admin .rep th { padding: 6px 10px; }
@media print { #login, #banner, .userbar, #view-admin { display: none !important; } }

/* reports tab shares the owner-area look */
#view-reports .tabs2 { display: flex; flex-wrap: wrap; gap: 6px; }
#view-reports .tabs2 button.on { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
#view-reports .box { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
#view-reports .box p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
#view-reports .box h3 { margin: 4px 0 0; font-size: 14px; font-family: var(--font-head); }
#view-reports .tw { overflow-x: auto; }
#view-reports .small { font-size: 12px; color: var(--muted); }
#view-reports .detail { font-family: var(--font-num); font-size: 11px; white-space: pre-wrap; color: var(--muted); max-width: 520px; }
#view-reports .ok { color: var(--paid); } #view-reports .bad { color: var(--overdue); }
#view-reports .grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
#view-reports .rep td, #view-reports .rep th { padding: 6px 10px; }
#view-reports tr.sel td { background: var(--soft, rgba(128,128,128,.12)); }
#view-reports tfoot th { border-top: 2px solid var(--line, #888); }
#view-reports .row { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
#view-reports button.armed { color: var(--overdue); font-weight: 600; }
@media print { #view-reports { display: none !important; } }

.sh-coar { font-family: 'IBM Plex Sans Arabic', sans-serif; font-size: 12.5px; font-weight: 600; margin-top: 1px; text-align: right; }

/* customer statement (Overdue tab): full-screen preview, prints as A4 */
.od-ov { position: fixed; inset: 0; z-index: 60; background: rgba(20,24,32,0.78); overflow: auto; }
.od-bar { position: sticky; top: 0; z-index: 2; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 12px; background: var(--panel, #fff); border-bottom: 1px solid var(--line, #ccc); }
.od-bar .small { font-size: 12px; color: var(--muted); }
.od-scroll { display: flex; justify-content: center; padding: 12px; }
@media print {
  body.od-stmt > *:not(#od-ov) { display: none !important; }
  .od-ov { position: static !important; background: none !important; overflow: visible !important; }
  .od-scroll { display: block !important; padding: 0 !important; }
  #od-zoom { zoom: 1 !important; }
  .sheet tfoot td { border-top: 2px solid #2B3345; }
}

/* ===== improved two-tier navigation bar, documentation & interactive tooltips ===== */
.navbar {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px;
}
.nav-group { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.nav-right { margin-left: auto; border-left: 1px solid var(--line); padding-left: 8px; }
.nav-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; font-size: 13px; font-weight: 500;
  border-radius: 4px; border: 1px solid transparent; background: transparent; color: var(--fg); transition: background .12s, border-color .12s;
}
.nav-btn:hover { background: var(--bg); border-color: var(--line); }
.nav-btn.on { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-weight: 600; }
.nav-btn .nav-ico { font-size: 12px; opacity: 0.85; line-height: 1; }
.nav-btn.nav-admin { border-color: var(--line); }
.tip-pill { border: 1px solid var(--line) !important; border-radius: 10px !important; padding: 1px 8px !important; background: var(--surface) !important; }
.tip-pill.on { background: var(--paid-bg) !important; color: var(--paid) !important; border-color: var(--paid) !important; font-weight: 600; }
@media (max-width: 820px) {
  .nav-right { border-left: 0; padding-left: 0; margin-left: 0; width: 100%; border-top: 1px solid var(--line); padding-top: 6px; }
}

/* documentation view */
#view-guide .tabs2 { display: flex; flex-wrap: wrap; gap: 6px; }
#view-guide .tabs2 button.on { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
#view-guide .box { padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; }
#view-guide .box h3 { margin: 8px 0 2px; font-size: 15px; font-family: var(--font-head); color: var(--accent); }
#view-guide .box p, #view-guide .box li { color: var(--fg); font-size: 13.5px; line-height: 1.6; margin: 0; }
#view-guide .box ul, #view-guide .box ol { margin: 4px 0 8px; padding-left: 20px; display: grid; gap: 4px; }
#view-guide .doc-card { border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; background: var(--bg); display: grid; gap: 6px; }
#view-guide .doc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
#view-guide code { font-family: var(--font-num); font-size: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 3px; padding: 1px 5px; }
@media print { #view-guide, .navbar, #ocs-tooltip, #ocs-tour { display: none !important; } }

/* contextual hover/focus tooltip & first-time user guided tour */
#ocs-tooltip {
  position: fixed; z-index: 95; max-width: 310px; background: #17202B; color: #FFFFFF;
  border: 1px solid #3B4A5E; border-radius: 6px; padding: 8px 11px; font-size: 12px; line-height: 1.45;
  box-shadow: 0 4px 16px rgba(0,0,0,0.28); pointer-events: none;
}
#ocs-tooltip .tt-tag { display: inline-block; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: #7FB0E3; margin-bottom: 2px; }
.ocs-tour-highlight { outline: 3px solid var(--accent) !important; outline-offset: 3px !important; border-radius: 4px; transition: outline .15s; }
#ocs-tour {
  position: fixed; right: 20px; bottom: 20px; z-index: 96; width: 360px; max-width: calc(100vw - 32px);
  background: var(--surface); color: var(--fg); border: 2px solid var(--accent); border-radius: 8px;
  padding: 14px 16px; box-shadow: 0 8px 28px rgba(0,0,0,0.32); display: flex; flex-direction: column; gap: 10px;
}
#ocs-tour .tr-hd { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-family: var(--font-head); font-weight: 700; font-size: 14px; color: var(--accent); }
#ocs-tour .tr-bd { font-size: 13px; line-height: 1.5; color: var(--fg); }
#ocs-tour .tr-ft { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 8px; }

/* ===== ERP List Filter Bar, 2-Option (New / List) Sub-Bar & Action Icons ===== */
.doc-submode {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}
.mode-pills { display: inline-flex; }
.mode-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; font-weight: 500; font-size: 13px;
  border-radius: 0; margin-left: -1px; border: 1px solid var(--line); background: var(--surface); color: var(--fg); cursor: pointer;
}
.mode-btn:first-child { border-radius: 4px 0 0 4px; margin-left: 0; }
.mode-btn:last-child { border-radius: 0 4px 4px 0; }
.mode-btn.on { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-weight: 600; }

.erp-filter-box {
  background: var(--bg); border-bottom: 1px solid var(--line);
  padding: 12px 14px; display: flex; flex-direction: column; gap: 10px;
}
.erp-filter-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 8px 10px; align-items: end;
}
.erp-filter-grid .f label.lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.erp-filter-grid input, .erp-filter-grid select {
  padding: 6px 8px;
  font-size: 13px;
  text-align: left;
  letter-spacing: normal;
  text-transform: none;
}
.erp-filter-grid input::placeholder {
  letter-spacing: normal;
  text-transform: none;
  text-align: left;
}
.erp-acts { display: inline-flex; gap: 3px; align-items: center; flex-wrap: nowrap; }
.erp-act {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 23px; padding: 0 !important; border-radius: 4px; border: 1px solid transparent !important;
  font-size: 11.5px; line-height: 1; cursor: pointer; color: #fff !important; font-weight: 600;
  transition: transform .08s, opacity .12s;
}
.erp-act:hover { opacity: 0.88; transform: translateY(-1px); }
.erp-act.edit { background: #D97706 !important; color: #FFFFFF !important; }
.erp-act.print { background: var(--accent) !important; }
.erp-act.view { background: #4B5563 !important; }
.erp-act.pay { background: var(--paid) !important; }
.erp-act.hist { background: #6366F1 !important; }
.erp-act.dup { background: #0284C7 !important; }
.erp-act.del { background: var(--overdue) !important; }
.erp-act.del.armed { width: auto; padding: 0 6px !important; font-size: 10.5px; }

/* ===== Responsive Full-Width ERP Table (No Horizontal Scrollbar) ===== */
.tscroll.no-hscroll { overflow-x: visible; }
table.erp-table {
  width: 100% !important;
  min-width: 0 !important;
  border-collapse: collapse;
  font-size: 11.5px;
  table-layout: auto;
}
table.erp-table th,
table.erp-table td {
  padding: 6px 5px;
  vertical-align: middle;
  line-height: 1.3;
}
table.erp-table th {
  font-size: 10px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
table.erp-table .col-invno {
  white-space: nowrap;
  font-weight: 700;
}
table.erp-table .col-date {
  white-space: nowrap;
  font-size: 11px;
}
table.erp-table .col-by {
  max-width: 130px;
  line-height: 1.25;
  font-size: 11px;
}
table.erp-table .col-party {
  max-width: 165px;
  line-height: 1.25;
}
table.erp-table .pill {
  padding: 2px 6px;
  font-size: 10px;
}

/* ===== Centered Responsive Overlay Modals (.modal / .mbox) ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(15, 21, 28, 0.72);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
}
.modal[hidden] { display: none !important; }
.modal .mbox {
  margin: auto;
  max-width: min(920px, 96vw);
  max-height: 92vh;
  overflow-y: auto;
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.38);
}
#ocs-docprev-modal .sheet {
  width: 100% !important;
  max-width: 210mm;
  min-height: auto;
  margin: 0 auto;
  box-sizing: border-box;
}

/* ===== Admin / CEO Approval Badges, Buttons & Queue Banner ===== */
.appr-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
}
.appr-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 20px;
  padding: 0 6px !important;
  font-size: 10.5px;
  font-weight: 700;
  border-radius: 3px;
  border: 1px solid transparent !important;
  cursor: pointer;
  line-height: 1;
  white-space: nowrap;
}
.appr-btn.ok {
  background: var(--paid) !important;
  color: #fff !important;
}
.appr-btn.no {
  background: var(--overdue) !important;
  color: #fff !important;
}
.appr-btn:hover { opacity: 0.88; }
.appr-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: var(--due-bg);
  border-bottom: 1px solid var(--due);
  color: var(--fg);
  font-size: 13px;
}

.summary-grid-13 {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px;
}
@media (max-width: 960px) {
  .summary-grid-13 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tscroll.no-hscroll { overflow-x: auto; }
}
@media (max-width: 560px) {
  .summary-grid-13 { grid-template-columns: 1fr; }
}

/* ===== Full-Width Table & Side Panel Toggle (Accounts, Projects, Labour) ===== */
.cols.full-width {
  grid-template-columns: minmax(0, 1fr) !important;
}
.cols.full-width > .side {
  display: none !important;
}
.side-toggle-btn, .filter-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  font-weight: 600;
  transition: all 0.15s ease;
  user-select: none;
}
.side-toggle-btn:hover, .filter-toggle-btn:hover {
  background: var(--bg);
  border-color: var(--accent);
}
.side-toggle-btn.active, .filter-toggle-btn.active {
  background: rgba(156,43,43,0.12);
  color: var(--accent);
  border-color: var(--accent);
}
.filters-collapsible {
  transition: all 0.2s ease;
}
.filters-collapsible.collapsed {
  display: none !important;
}

/* Live Searchable Item Picker in Line Items */
.item-search-box {
  transition: border-color 0.15s, box-shadow 0.15s;
}
.item-search-box:focus {
  outline: none;
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 2px rgba(156,43,43,0.18);
}

/* Customer Drilldown in Reports */
.rep-drill-row td {
  background: var(--bg) !important;
  padding: 10px 14px !important;
}
.rep-drill-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.04);
}

/* =====================================================================
   Enterprise ERP 2-Tier Layout System (Left Sidebar + Top Navigation)
   ===================================================================== */
#app {
  width: 100%;
  min-height: 100vh;
}

.erp-layout {
  display: flex;
  width: 100%;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
}

/* --- Left Sidebar Menu --- */
.erp-sidebar {
  width: 260px;
  min-width: 260px;
  max-width: 260px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  z-index: 1000;
  transition: width 0.22s cubic-bezier(0.4, 0, 0.2, 1), min-width 0.22s, max-width 0.22s;
  overflow: hidden;
}

.erp-sidebar.collapsed {
  width: 72px;
  min-width: 72px;
  max-width: 72px;
}

.sidebar-header {
  height: 64px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  gap: 10px;
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--fg);
  min-width: 0;
  flex: 1;
}

.sidebar-brand-img {
  width: 34px;
  height: 34px;
  object-fit: contain;
  border-radius: 6px;
  flex-shrink: 0;
  background: var(--surface-alt);
}

.sidebar-brand-fallback {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-fg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
}

.sidebar-brand-text {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}

.sidebar-brand-title {
  font-family: var(--font-head);
  font-size: 15px;
  font-weight: 700;
  color: var(--fg);
  line-height: 1.2;
  text-overflow: ellipsis;
  overflow: hidden;
}

.sidebar-brand-sub {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.sidebar-toggle-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  font-size: 14px;
  transition: all 0.15s;
}

.sidebar-toggle-btn:hover {
  background: var(--bg);
  color: var(--fg);
  border-color: var(--accent);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-section-title {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 10px 10px 4px;
  white-space: nowrap;
}

.erp-sidebar.collapsed .sidebar-section-title,
.erp-sidebar.collapsed .sidebar-brand-text,
.erp-sidebar.collapsed .sidebar-nav-btn span,
.erp-sidebar.collapsed .sidebar-badge {
  display: none !important;
}

.erp-sidebar.collapsed .sidebar-nav-btn {
  justify-content: center;
  padding: 10px 0;
}

.sidebar-nav-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--fg);
  font-weight: 500;
  font-size: 13.5px;
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.sidebar-nav-btn .icon {
  font-size: 17px;
  width: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-nav-btn:hover {
  background: var(--surface-alt);
  color: var(--accent);
  border-color: var(--line-subtle);
}

.sidebar-nav-btn.on {
  background: rgba(37, 99, 235, 0.1);
  color: var(--accent);
  border-color: rgba(37, 99, 235, 0.25);
  font-weight: 600;
}

:root[data-theme="dark"] .sidebar-nav-btn.on {
  background: rgba(56, 189, 248, 0.12);
  color: var(--accent);
  border-color: rgba(56, 189, 248, 0.3);
}

.sidebar-badge {
  margin-left: auto;
  font-size: 10.5px;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 600;
  background: var(--surface-alt);
  color: var(--muted);
  border: 1px solid var(--line);
}

.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-user-info {
  min-width: 0;
  overflow: hidden;
}

.sidebar-user-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 11px;
  color: var(--muted);
}

/* --- Main Workspace & Top Navigation --- */
.erp-workspace {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg);
}

.erp-topbar {
  height: 64px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 950;
  backdrop-filter: blur(8px);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.mobile-menu-btn {
  display: none;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--fg);
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
}

.topbar-brand-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.top-brandmark-img {
  max-height: 36px;
  max-width: 140px;
  object-fit: contain;
}

.top-co-title {
  font-family: var(--font-head);
  font-size: 16px;
  font-weight: 700;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-center {
  flex: 1;
  max-width: 440px;
  display: flex;
  align-items: center;
  position: relative;
}

.erp-search-box {
  width: 100%;
  position: relative;
  display: flex;
  align-items: center;
}

.erp-search-box input {
  padding-left: 32px;
  padding-right: 48px;
  height: 36px;
  border-radius: 6px;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  font-size: 13px;
  color: var(--fg);
}

.erp-search-box input:focus {
  background: var(--surface);
  border-color: var(--accent);
}

.erp-search-icon {
  position: absolute;
  left: 10px;
  color: var(--muted);
  pointer-events: none;
  font-size: 13px;
}

.erp-search-kbd {
  position: absolute;
  right: 8px;
  font-size: 10.5px;
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--font-num);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.currency-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}

.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--fg);
  cursor: pointer;
  transition: all 0.15s;
}

.theme-toggle-btn:hover {
  border-color: var(--accent);
  background: var(--bg);
}

.syncstat {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
}

.syncstat.ok {
  background: var(--paid-bg);
  color: var(--paid);
  border: 1px solid var(--paid-border);
}

.syncstat.syncing {
  background: var(--due-bg);
  color: var(--due);
  border: 1px solid var(--due-border);
}

.syncstat.err {
  background: var(--overdue-bg);
  color: var(--overdue);
  border: 1px solid var(--overdue-border);
}

.rolepill {
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  background: var(--surface-alt);
  color: var(--fg);
  border: 1px solid var(--line);
}

/* --- Fluid Main Content Viewport --- */
.erp-main {
  flex: 1;
  width: 100%;
  padding: 20px 24px 48px;
  box-sizing: border-box;
}

/* Super Admin Session Alert Banner */
.sa-top-banner {
  background: var(--paid-bg);
  border-bottom: 1px solid var(--paid-border);
  color: var(--paid);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 13px;
}

/* Anti-Tamper & Security Warning Toast */
.security-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1E293B;
  color: #F8FAFC;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 12px 18px;
  font-size: 13px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 999999;
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
}

.security-toast.hidden {
  opacity: 0;
  transform: translateY(12px);
}

.secure-grid {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* Mobile Responsive */
@media (max-width: 992px) {
  .erp-sidebar {
    position: fixed;
    left: -260px;
    top: 0;
    bottom: 0;
    z-index: 10000;
    box-shadow: 0 0 30px rgba(0,0,0,0.5);
  }
  .erp-sidebar.mobile-open {
    left: 0;
  }
  .mobile-menu-btn {
    display: inline-flex;
  }
  .erp-main {
    padding: 16px 14px 40px;
  }
}

