/* ==========================================================
   Castelube Sales — app styles
   ========================================================== */
:root {
  --bg: #f3f5f1;
  --surface: #ffffff;
  --surface-2: #f6f7f4;
  --surface-3: #eef1ea;
  --border: #e6e9e2;
  --border-strong: #d7dcd1;
  --text: #15210f;
  --text-2: #3f4a3a;
  --muted: #727c6d;
  --faint: #a3ab9e;

  --accent: #9fe35f;          /* lime */
  --accent-soft: #e9f8d9;
  --accent-ink: #18300a;
  --accent-strong: #4fa52a;

  --danger: #e5484d;
  --danger-soft: #fdecec;
  --warn: #ef8a1c;
  --warn-soft: #fff2e2;
  --info: #3b6fd8;
  --info-soft: #e9f0fd;
  --ok: #3f9d24;
  --ok-soft: #e7f6dd;

  --fascon: #2f4b8f;
  --citrun: #c40000;
  --gear: #d9a441;

  --radius: 16px;
  --radius-sm: 11px;
  --radius-xs: 8px;
  --shadow: 0 1px 2px rgba(20, 33, 15, .04), 0 1px 1px rgba(20, 33, 15, .03);
  --shadow-lg: 0 18px 50px -12px rgba(20, 33, 15, .25), 0 4px 12px rgba(20, 33, 15, .06);
  --sidebar-w: 248px;
  --font: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
body.no-scroll { overflow: hidden; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
p { margin: 0; }
.ic { flex: none; display: block; }
.tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12px; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.pos { color: var(--ok); }
.neg { color: var(--danger); }
.hidden { display: none !important; }
.strong { font-weight: 700; }

/* ---------- Layout ---------- */
.app { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; z-index: 40;
  padding: 18px 14px 14px;
}
.brand { display: flex; align-items: center; justify-content: space-between; padding: 0 6px 18px; }
.brand-link { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text b { font-size: 19px; font-weight: 800; letter-spacing: -0.02em; }
.brand-text small { font-size: 11px; color: var(--muted); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; margin-top: 2px; }

.nav { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; margin: 0 -4px; padding: 0 4px; }
.nav-group { font-size: 11px; font-weight: 700; color: var(--faint); text-transform: uppercase; letter-spacing: .07em; padding: 14px 12px 6px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px;
  color: var(--text-2); font-weight: 500; position: relative;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.nav a .count {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center;
}
.side-foot { border-top: 1px solid var(--border); padding-top: 10px; margin-top: 10px; display: flex; flex-direction: column; gap: 2px; }
.side-foot a, .side-foot button {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px; color: var(--text-2);
  font-weight: 500; background: none; border: 0; cursor: pointer; text-align: left; width: 100%;
}
.side-foot a:hover, .side-foot button:hover { background: var(--surface-2); }
.side-foot a.active { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.sync-pill { font-size: 12px; color: var(--muted); padding: 6px 12px 0; display: flex; align-items: center; gap: 6px; }
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.sync-dot.ok { background: var(--ok); } .sync-dot.busy { background: var(--warn); } .sync-dot.err { background: var(--danger); }

.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px;
  padding: 14px 28px; background: rgba(243, 245, 241, .86); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
}
.page-title { font-size: 18px; font-weight: 700; flex: none; }
.topbar .menu-btn { display: none; }
.search { position: relative; margin-left: auto; width: min(380px, 40vw); }
.search input {
  width: 100%; height: 40px; border: 1px solid var(--border); background: var(--surface); border-radius: 12px;
  padding: 0 40px 0 38px; font: inherit; color: var(--text); outline: none;
}
.search input:focus { border-color: var(--accent-strong); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-ic { position: absolute; left: 12px; top: 11px; color: var(--muted); pointer-events: none; }
.search-kbd {
  position: absolute; right: 10px; top: 9px; font: 600 11px var(--font); color: var(--muted);
  border: 1px solid var(--border); border-radius: 6px; padding: 2px 7px; background: var(--surface-2);
}
.search-results {
  position: absolute; top: 46px; left: 0; right: 0; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow-lg); max-height: 420px; overflow-y: auto; display: none; z-index: 60; padding: 6px;
}
.search-results.open { display: block; }
.sr-group { font-size: 11px; font-weight: 700; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; padding: 8px 10px 4px; }
.sr-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; cursor: pointer; }
.sr-item:hover, .sr-item.active { background: var(--surface-2); }
.sr-item .sr-sub { color: var(--muted); font-size: 12px; }
.sr-empty { padding: 16px; color: var(--muted); text-align: center; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface);
  display: inline-grid; place-items: center; cursor: pointer; color: var(--text-2); position: relative; flex: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.sm { width: 32px; height: 32px; border-radius: 9px; }
.icon-btn.plain { border-color: transparent; background: transparent; }
.icon-btn.plain:hover { background: var(--surface-2); }
.bell .dot { position: absolute; top: 8px; right: 9px; width: 8px; height: 8px; background: var(--danger); border-radius: 50%; border: 2px solid var(--surface); }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; background: var(--text); color: var(--accent);
  display: grid; place-items: center; font-weight: 800; font-size: 13px; flex: none;
}
.view { padding: 8px 28px 40px; flex: 1; width: 100%; max-width: 1440px; }
.only-mobile { display: none !important; }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 10px 0 20px; flex-wrap: wrap; }
.page-head h2 { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.page-head p { color: var(--muted); margin-top: 4px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px;
  border-radius: 11px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, transform .05s;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--text); color: #fff; border-color: var(--text); }
.btn.primary:hover { background: #26341f; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.accent:hover { background: #93d653; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { background: #cf3a3f; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 9px; gap: 6px; }
.btn.xs { height: 28px; padding: 0 9px; font-size: 12px; border-radius: 8px; gap: 5px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent-strong); font-weight: 600; cursor: pointer; font-size: inherit; }
.link-btn:hover { text-decoration: underline; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.row-actions .icon-btn { width: 32px; height: 32px; border-radius: 9px; }
.row-actions .icon-btn.danger:hover { color: var(--danger); background: var(--danger-soft); border-color: #f6c9ca; }

/* ---------- Cards ---------- */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(12, minmax(0, 1fr)); }
.span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; }
.span-6 { grid-column: span 6; } .span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; }
.span-9 { grid-column: span 9; } .span-12 { grid-column: span 12; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; min-width: 0;
}
.card.flush { padding: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h3 { font-size: 15px; font-weight: 700; }
.card-head .sub { color: var(--muted); font-size: 12px; font-weight: 500; }
.card.flush .card-head { padding: 16px 18px 0; }
.section-gap { margin-top: 16px; }
.stack { display: flex; flex-direction: column; gap: 16px; }

/* KPI */
.kpi-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.kpi-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kpi-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 760px) { .kpi-grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.kpi-head { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13.5px; color: var(--text-2); }
.kpi-ic { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.kpi-body { background: var(--surface-2); border-radius: 12px; padding: 14px; display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; min-height: 92px; }
.kpi-val { font-size: 25px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-val .unit { font-size: 14px; font-weight: 600; color: var(--muted); margin-left: 3px; letter-spacing: 0; }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 6px; display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }
.kpi-spark { flex: none; }
.delta { font-weight: 700; display: inline-flex; align-items: center; gap: 2px; }
.delta.up { color: var(--ok); } .delta.down { color: var(--danger); } .delta.flat { color: var(--muted); }
.kpi.tone-danger .kpi-body { background: var(--danger-soft); }
.kpi.tone-danger .kpi-val { color: #b8262b; }
.kpi.tone-warn .kpi-body { background: var(--warn-soft); }
.kpi.clickable { cursor: pointer; transition: border-color .12s, transform .12s; }
.kpi.clickable:hover { border-color: var(--border-strong); }

/* Dark highlight card (like reference "My Cards") */
.dark-card {
  position: relative; overflow: hidden; border-radius: 18px; padding: 20px; color: #fff; min-height: 100%;
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(159, 227, 95, .55) 0%, rgba(159, 227, 95, 0) 55%),
    radial-gradient(90% 80% at 0% 100%, rgba(80, 160, 60, .35) 0%, rgba(80, 160, 60, 0) 60%),
    linear-gradient(150deg, #1d2b18 0%, #0f150c 100%);
  display: flex; flex-direction: column; gap: 14px;
}
.dark-card .dc-label { font-size: 13px; font-weight: 600; color: rgba(255,255,255,.72); display: flex; align-items: center; gap: 8px; }
.dark-card .dc-value { font-size: 32px; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1.05; }
.dark-card .dc-row { display: flex; gap: 18px; flex-wrap: wrap; }
.dark-card .dc-row div { display: flex; flex-direction: column; gap: 2px; }
.dark-card .dc-row small { font-size: 11px; color: rgba(255,255,255,.6); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.dark-card .dc-row b { font-size: 14px; font-variant-numeric: tabular-nums; }
.dark-card .btn { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.18); color: #fff; }
.dark-card .btn:hover { background: rgba(255,255,255,.2); }
.dark-card .btn.accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.dark-card .dc-foot { margin-top: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.progress { height: 8px; background: rgba(255,255,255,.14); border-radius: 6px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 6px; }
.progress.light { background: var(--surface-3); }

/* Bars chart */
.chart-legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); font-weight: 500; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg-sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.lg-a { background: repeating-linear-gradient(135deg, #d9ddd5 0 2px, #f1f3ef 2px 5px); border: 1px solid #d9ddd5; }
.lg-b { background: var(--accent); }
.bars { position: relative; height: 240px; margin-top: 14px; padding-left: 52px; }
.bars-grid { position: absolute; inset: 0 0 24px 0; display: flex; flex-direction: column-reverse; justify-content: space-between; }
.bars-grid div { border-top: 1px solid var(--border); position: relative; height: 0; }
.bars-grid div span { position: absolute; left: 0; top: -8px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bars-cols { position: absolute; left: 52px; right: 0; top: 0; bottom: 0; display: flex; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; min-width: 0; }
.bar-pair { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 6px; padding-bottom: 0; }
.bar { width: min(18px, 28%); border-radius: 6px 6px 3px 3px; position: relative; min-height: 2px; transition: height .4s ease; }
.bar.a { background: repeating-linear-gradient(135deg, #d9ddd5 0 2px, #f1f3ef 2px 5px); border: 1px solid #dde1d8; }
.bar.b { background: var(--accent); }
.bar.b.neg { background: #f3b3b5; }
.bar-tip {
  position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--accent); font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; white-space: nowrap;
}
.bar-lbl { height: 24px; display: flex; align-items: flex-end; font-size: 12px; color: var(--muted); }
.bar-col.current .bar-lbl { color: var(--text); font-weight: 700; }

/* Lists in cards */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--border); min-width: 0; }
.list-item:first-child { border-top: 0; padding-top: 2px; }
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .li-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .li-end { text-align: right; flex: none; }
.li-avatar {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none;
  font-weight: 700; font-size: 12px; background: var(--surface-3); color: var(--text-2);
}
.li-avatar.danger { background: var(--danger-soft); color: #b8262b; }
.li-avatar.warn { background: var(--warn-soft); color: #b0610a; }
.li-avatar.ok { background: var(--ok-soft); color: #2b7417; }
.li-avatar.info { background: var(--info-soft); color: var(--info); }

/* Tabs / segmented */
.tabs { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.tabs button {
  border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font-weight: 600; font-size: 13px; color: var(--muted); cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.tabs button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.tabs button .count { background: var(--surface-3); border-radius: 999px; padding: 0 6px; font-size: 11px; }
.tabs button.active .count { background: var(--accent); color: var(--accent-ink); }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; padding: 3px; width: 100%; }
.seg label { flex: 1; position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: flex; align-items: center; justify-content: center; gap: 6px; height: 34px; border-radius: 8px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.seg input:focus-visible + span { outline: 2px solid var(--accent-strong); }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700;
  background: var(--surface-3); color: var(--text-2); white-space: nowrap; line-height: 1.4;
}
.badge.ok { background: var(--ok-soft); color: #2b7417; }
.badge.danger { background: var(--danger-soft); color: #b8262b; }
.badge.warn { background: var(--warn-soft); color: #a8580a; }
.badge.info { background: var(--info-soft); color: #2d58b5; }
.badge.dark { background: var(--text); color: var(--accent); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.dot.fascon { background: var(--fascon); } .dot.citrun { background: var(--citrun); } .dot.gear { background: var(--gear); } .dot.lain { background: var(--faint); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
.card.flush .table-wrap { margin: 0; padding: 0; }
.tbl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tbl th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 12px; background: var(--surface-2);
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.tbl th:first-child { border-top-left-radius: 10px; border-left: 1px solid var(--border); }
.tbl th:last-child { border-top-right-radius: 10px; border-right: 1px solid var(--border); }
.card.flush .tbl th:first-child, .card.flush .tbl th:last-child { border-radius: 0; border-left: 0; border-right: 0; }
.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tbody tr:hover td { background: #fafbf8; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl .right, .tbl th.right { text-align: right; }
.tbl tfoot td { font-weight: 700; border-top: 2px solid var(--border); padding: 11px 12px; }
.tbl .cell-title { font-weight: 600; }
.tbl .cell-sub { font-size: 12px; color: var(--muted); }
.tbl tr.row-muted td { color: var(--muted); }
.empty-sm { padding: 26px 12px; text-align: center; color: var(--muted); font-size: 13px; }
.empty {
  padding: 40px 20px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.empty .empty-ic { width: 54px; height: 54px; border-radius: 16px; background: var(--accent-soft); color: var(--accent-strong); display: grid; place-items: center; }
.empty h3 { font-size: 16px; }
.empty p { color: var(--muted); max-width: 420px; }

/* Toolbar filters */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .grow { flex: 1; min-width: 180px; }
.summary-strip { display: flex; gap: 22px; flex-wrap: wrap; padding: 12px 16px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 14px; }
.summary-strip div { display: flex; flex-direction: column; }
.summary-strip small { color: var(--muted); font-size: 11.5px; font-weight: 600; }
.summary-strip b { font-size: 15px; font-variant-numeric: tabular-nums; }

/* ---------- Forms ---------- */
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.f { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.f > label, .f-label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.f .hint { font-size: 12px; color: var(--muted); }
.req { color: var(--danger); }
.inp, .sel, textarea.inp {
  width: 100%; height: 40px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface);
  padding: 0 12px; font: inherit; color: var(--text); outline: none; transition: border-color .12s, box-shadow .12s;
}
textarea.inp { height: auto; min-height: 76px; padding: 10px 12px; resize: vertical; }
.sel { appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23727c6d' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.inp:focus, .sel:focus { border-color: var(--accent-strong); box-shadow: 0 0 0 3px var(--accent-soft); }
.inp.invalid, .sel.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.inp[readonly] { background: var(--surface-2); color: var(--text-2); }
.inp.sm, .sel.sm { height: 34px; font-size: 13px; border-radius: 9px; }
.inp-group { display: flex; align-items: stretch; }
.inp-group .inp { border-radius: 10px 0 0 10px; }
.inp-group .addon { display: grid; place-items: center; padding: 0 12px; border: 1px solid var(--border-strong); border-left: 0; border-radius: 0 10px 10px 0; background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: 13px; }
.inp-prefix { position: relative; }
.inp-prefix > span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 600; font-size: 13px; pointer-events: none; }
.inp-prefix > .inp { padding-left: 36px; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
.check input { width: 17px; height: 17px; accent-color: var(--accent-strong); }
.form-section { font-size: 13px; font-weight: 700; color: var(--text); margin: 8px 0 -4px; padding-top: 8px; border-top: 1px dashed var(--border-strong); grid-column: 1 / -1; }
.form-section:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.note { padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12.5px; color: var(--text-2); }
.note.warn { background: var(--warn-soft); border-color: #f6d7b0; color: #7a4508; }
.note.danger { background: var(--danger-soft); border-color: #f6c9ca; color: #8f1d21; }
.note.ok { background: var(--ok-soft); border-color: #cbe9b8; color: #285f16; }

/* Combobox */
.combo { position: relative; }
.combo-list {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 70; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 5px; max-height: 280px; overflow-y: auto; display: none;
  min-width: 240px;
}
.combo-list.open { display: block; }
.combo-item { padding: 8px 10px; border-radius: 8px; cursor: pointer; display: flex; align-items: center; gap: 9px; }
.combo-item:hover, .combo-item.active { background: var(--surface-2); }
.combo-item .ci-main { flex: 1; min-width: 0; }
.combo-item .ci-sub { font-size: 12px; color: var(--muted); }
.combo-item .ci-end { font-size: 12px; color: var(--muted); white-space: nowrap; }
.combo-item mark { background: var(--accent-soft); color: inherit; border-radius: 3px; padding: 0 1px; }
.combo-new { color: var(--accent-strong); font-weight: 600; }

/* Order form */
.order-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.order-side { position: sticky; top: 84px; display: flex; flex-direction: column; gap: 16px; }
.items { display: flex; flex-direction: column; gap: 10px; }
.item-row {
  display: grid; grid-template-columns: minmax(0, 2.4fr) 78px 112px minmax(0, 1.2fr) minmax(0, 1.1fr) 36px; gap: 10px; align-items: start;
  padding: 12px; border: 1px solid var(--border); border-radius: 13px; background: var(--surface-2);
}
.item-row.masuk-row { grid-template-columns: minmax(0, 2fr) 80px 100px minmax(0, 1.3fr) minmax(0, 1fr) 36px; }
.item-row .f > label { font-size: 11.5px; color: var(--muted); }
.item-row .sub-val { height: 40px; display: flex; align-items: center; justify-content: flex-end; font-weight: 700; font-variant-numeric: tabular-nums; }
.item-row .rm { margin-top: 22px; }
.item-hint { font-size: 11.5px; color: var(--muted); grid-column: 1 / -1; margin-top: -2px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.item-hint .warn { color: var(--danger); font-weight: 600; }
.item-num { font-size: 11px; font-weight: 700; color: var(--faint); }
.totals { display: flex; flex-direction: column; gap: 8px; }
.totals .tr { display: flex; justify-content: space-between; gap: 10px; font-variant-numeric: tabular-nums; }
.totals .tr.big { font-size: 20px; font-weight: 800; padding-top: 10px; border-top: 1px solid var(--border); letter-spacing: -0.02em; }
.totals .tr span:first-child { color: var(--muted); }
.totals .tr.big span:first-child { color: var(--text); }

/* Product/stock cards */
.prod-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.prod-card { padding: 16px; display: flex; flex-direction: column; gap: 12px; position: relative; overflow: hidden; }
.prod-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--faint); }
.prod-card.fascon::before { background: var(--fascon); } .prod-card.citrun::before { background: var(--citrun); } .prod-card.gear::before { background: var(--gear); }
.prod-card .pc-name { font-weight: 700; font-size: 14.5px; }
.prod-card .pc-cat { font-size: 12px; color: var(--muted); }
.prod-card .pc-stock { font-size: 28px; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1; }
.prod-card .pc-stock small { font-size: 13px; color: var(--muted); font-weight: 600; letter-spacing: 0; }
.prod-card .pc-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); gap: 8px; }
.prod-card .pc-meta b { color: var(--text); font-weight: 700; }
.prod-card .pc-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.prod-card.low { border-color: #f6d7b0; }
.prod-card.out { border-color: #f6c9ca; }

.stock-mini { display: flex; flex-direction: column; gap: 12px; }
.stock-mini .sm-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; }
.stock-mini .sm-name { font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 7px; min-width: 0; }
.stock-mini .sm-name span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stock-mini .sm-val { font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stock-mini .progress { grid-column: 1 / -1; height: 6px; }
.progress.light > span.warn { background: var(--warn); }
.progress.light > span.danger { background: var(--danger); }

/* Onboarding */
.onboard { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 16px; }
.onboard-step { padding: 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; }
.onboard-step .n { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 800; display: grid; place-items: center; font-size: 13px; }
.onboard-step b { font-size: 14px; }
.onboard-step p { font-size: 12.5px; color: var(--muted); }

/* Detail definition list */
.dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 18px; }
.dl div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dl small { color: var(--muted); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.dl b { font-weight: 600; overflow-wrap: anywhere; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; }
.stat small { display: block; color: var(--muted); font-size: 11.5px; font-weight: 600; }
.stat b { font-size: 16px; font-variant-numeric: tabular-nums; }

/* Nota */
.nota { font-size: 13.5px; }
.nota-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; padding-bottom: 14px; border-bottom: 2px solid var(--text); margin-bottom: 14px; }
.nota-head h4 { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.nota-meta { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 18px; margin-bottom: 14px; }
.nota-meta small { display: block; color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.nota .tbl th:first-child, .nota .tbl th:last-child { border-radius: 0; }
.nota-total { margin-left: auto; width: min(320px, 100%); margin-top: 12px; }
.nota-foot { margin-top: 16px; font-size: 12px; color: var(--muted); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(14, 20, 11, .42); z-index: 100; display: flex; align-items: flex-start; justify-content: center;
  padding: 6vh 16px 16px; overflow-y: auto; animation: fade .15s ease;
}
.modal-backdrop.closing { animation: fadeOut .15s ease forwards; }
.modal {
  background: var(--surface); border-radius: 20px; width: 100%; max-width: 560px; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; animation: pop .18s ease; margin-bottom: 6vh;
}
.modal.sm { max-width: 420px; } .modal.lg { max-width: 760px; } .modal.xl { max-width: 980px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 18px 20px 6px; }
.modal-head h3 { font-size: 17px; }
.modal-body { padding: 12px 20px 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.modal-foot .spacer { flex: 1; }
.confirm-msg { color: var(--text-2); line-height: 1.55; }
@keyframes fade { from { opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; } }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }

/* ---------- Toast ---------- */
#toast-root { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast {
  pointer-events: auto; background: var(--text); color: #fff; padding: 11px 14px 11px 16px; border-radius: 13px; box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 14px; font-weight: 500; animation: pop .2s ease; max-width: 100%;
}
.toast::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.toast.danger::before { background: #ff6b6f; }
.toast.warn::before { background: #ffb357; }
.toast.out { opacity: 0; transform: translateY(6px); transition: .2s; }
.toast-act { background: rgba(255,255,255,.14); border: 0; color: var(--accent); font-weight: 700; padding: 5px 10px; border-radius: 8px; cursor: pointer; }

/* ---------- Login ---------- */
body.locked { overflow: hidden; }
body.locked .app { filter: blur(6px); pointer-events: none; user-select: none; }
.login-wrap {
  position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; padding: 16px;
  background: rgba(243, 245, 241, .7);
}
.login-card {
  width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  box-shadow: var(--shadow-lg); padding: 26px;
}
.login-card h2 { font-size: 22px; font-weight: 800; margin-bottom: 4px; }

/* ---------- Bottom nav (mobile) ---------- */
.bottomnav { display: none; }

/* ---------- Print ---------- */
#print-root { display: none; }
@media print {
  @page { margin: 14mm; }
  body.printing > *:not(#print-root) { display: none !important; }
  body.printing #print-root { display: block !important; }
  body { background: #fff; font-size: 12px; }
  #print-root .tbl th { background: #f1f1f1 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #print-root .table-wrap { overflow: visible; margin: 0; padding: 0; }
  #print-root .no-print { display: none !important; }
  .print-head { display: flex; justify-content: space-between; border-bottom: 2px solid #000; padding-bottom: 8px; margin-bottom: 12px; }
}
.print-head h2 { font-size: 18px; }

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .order-layout { grid-template-columns: minmax(0, 1fr) 300px; }
  .item-row { grid-template-columns: minmax(0, 1fr) 72px 104px minmax(0, 1fr) 36px; }
  .item-row .f.sub { display: none; }
  .item-row.masuk-row .f.sub { display: flex; }
}
@media (max-width: 1180px) {
  .span-3, .span-4, .span-5 { grid-column: span 6; }
  .span-7, .span-8, .span-9 { grid-column: span 12; }
  .dash-side { grid-column: span 12 !important; }
}
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .scrim { position: fixed; inset: 0; background: rgba(14,20,11,.35); z-index: 35; opacity: 0; pointer-events: none; transition: opacity .2s; }
  .sidebar.open ~ .scrim { opacity: 1; pointer-events: auto; }
  .main { margin-left: 0; }
  .topbar .menu-btn { display: inline-grid; }
  .only-mobile { display: inline-grid !important; }
  .order-layout { grid-template-columns: 1fr; }
  .order-side { position: static; }
}
@media (max-width: 760px) {
  body { font-size: 14px; }
  .topbar { padding: 10px 14px; gap: 8px; }
  .page-title { font-size: 16px; }
  .search { width: auto; flex: 1; }
  .search input { height: 38px; }
  .search-kbd { display: none; }
  .bell, .avatar { display: none; }
  .view { padding: 4px 14px calc(96px + env(safe-area-inset-bottom)); }
  .page-head { margin: 8px 0 14px; }
  .page-head h2 { font-size: 20px; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }
  .grid { gap: 12px; }
  .span-3, .span-4, .span-5, .span-6 { grid-column: span 12; }
  .card { padding: 14px; border-radius: 14px; }
  .card.flush .card-head { padding: 14px 14px 0; }
  .table-wrap { margin: 0 -14px; padding: 0 14px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 10px; gap: 8px; }
  .kpi-head { font-size: 12px; }
  .kpi-ic { width: 22px; height: 22px; }
  .kpi-body { padding: 10px; min-height: 0; flex-direction: column; align-items: flex-start; }
  .kpi-val { font-size: 19px; }
  .kpi-spark { display: none; }
  .form-grid, .form-grid.cols-3, .form-grid.cols-4 { grid-template-columns: 1fr; }
  .form-grid.keep-2 { grid-template-columns: 1fr 1fr; }
  .item-row, .item-row.masuk-row { grid-template-columns: 1fr 1fr; }
  .item-row .f.produk { grid-column: 1 / -1; }
  .item-row .f.sub { display: flex; }
  .item-row .rm { position: absolute; top: 8px; right: 8px; margin: 0; }
  .item-row { position: relative; padding-top: 30px; }
  .onboard { grid-template-columns: 1fr; }
  .dl { grid-template-columns: 1fr 1fr; }
  .nota-meta { grid-template-columns: 1fr 1fr; }
  .bars { height: 200px; padding-left: 44px; }
  .bars-cols { left: 44px; }
  .bar { width: min(12px, 30%); }
  .bar-tip { font-size: 10px; padding: 2px 6px; }

  /* Tables become cards */
  .tbl.stackable thead { display: none; }
  .tbl.stackable, .tbl.stackable tbody, .tbl.stackable tr, .tbl.stackable td { display: block; width: 100%; }
  .tbl.stackable tr { border: 1px solid var(--border); border-radius: 12px; padding: 6px 12px; margin-bottom: 10px; background: var(--surface); }
  .tbl.stackable tbody tr:hover td { background: transparent; }
  .tbl.stackable td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 7px 0; border-bottom: 1px dashed var(--border); text-align: right; }
  .tbl.stackable td:last-child { border-bottom: 0; }
  .tbl.stackable td > .td-v { min-width: 0; text-align: right; overflow-wrap: anywhere; }
  .tbl.stackable td.td-actions > .td-v { width: 100%; }
  .tbl.stackable td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 600; text-align: left; flex: none; }
  .tbl.stackable td[data-label=""]::before { display: none; }
  .tbl.stackable td.td-actions { justify-content: flex-end; }
  .tbl.stackable td.td-actions::before { display: none; }
  .tbl.stackable tfoot { display: block; }
  .tbl.stackable tfoot tr { display: flex; flex-direction: column; }
  .tbl.stackable tfoot td { display: flex; justify-content: space-between; border: 0; padding: 4px 0; }
  .tbl.stackable tfoot td:empty { display: none; }
  .tbl.stackable tfoot td::before { content: attr(data-label); color: var(--muted); font-size: 12px; }

  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal { border-radius: 20px 20px 0 0; margin: 0; max-height: 94vh; max-width: 100% !important; animation: sheet .22s ease; }
  .modal-body { overflow-y: auto; }
  .modal-foot { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .modal-foot .btn { flex: 1; }
  @keyframes sheet { from { transform: translateY(40px); opacity: .4; } }

  .bottomnav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; background: rgba(255,255,255,.96);
    backdrop-filter: blur(10px); border-top: 1px solid var(--border); padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  }
  .bottomnav a, .bottomnav button {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10.5px; font-weight: 600; color: var(--muted);
    background: none; border: 0; padding: 4px 0; cursor: pointer; position: relative;
  }
  .bottomnav a.active { color: var(--text); }
  .bottomnav a.active .ic { color: var(--accent-strong); }
  .bottomnav .fab { width: 50px; height: 50px; border-radius: 16px; background: var(--text); color: var(--accent); display: grid; place-items: center; margin-top: -22px; box-shadow: 0 8px 20px -6px rgba(20,33,15,.5); }
  .bottomnav .bn-count { position: absolute; top: 0; left: 55%; background: var(--danger); color: #fff; font-size: 10px; border-radius: 9px; padding: 0 5px; min-width: 16px; }
  #toast-root { bottom: calc(86px + env(safe-area-inset-bottom)); }
}
@media (max-width: 380px) {
  .kpi-val { font-size: 17px; }
}
.kpi-hint { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; color: var(--accent-strong); }
@media (max-width: 760px) { .kpi-hint { display: none; } }
/* Setoran per pelanggan */
.dist-card { display: flex; flex-direction: column; gap: 14px; }
.dist-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.dist-name { font-size: 16px; }
.dist-due { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; text-align: right; }
.dist-due small { color: var(--muted); font-size: 12px; }
.dist-due b { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.dist-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.dist-stats div { display: flex; flex-direction: column; gap: 2px; }
.dist-stats small { color: var(--muted); font-size: 12px; }
.dist-stats b { font-size: 15px; font-variant-numeric: tabular-nums; }
.warn-text { color: #b0610a; }
@media (max-width: 760px) {
  .dist-stats { grid-template-columns: 1fr 1fr; }
  .dist-due { align-items: flex-start; text-align: left; }
}
