/* ==========================================================================
   BW.ERP design system
   Mobile-first, responsive to desktop. Light and dark themes.
   ========================================================================== */

:root {
  --bg: #f4f6fb;
  --bg-elevated: #ffffff;
  --bg-sunken: #eaeef6;
  --surface: #ffffff;
  --surface-2: #f7f9fd;
  --border: #dde3ee;
  --border-strong: #c5cee0;
  --text: #131a2b;
  --text-muted: #5c6880;
  --text-faint: #8b95aa;

  /* Brand, derived from the BW.ERP mark. The tile blue is a touch light for
     interactive elements on white, so the accent is a deeper relative of it. */
  --brand: #3f6f9f;
  --brand-soft: #e8eff6;
  --brand-text: #2c567d;
  --logo-tile: #5b80a6;
  --logo-accent: #8fbee4;

  --ok: #0d9f6e;
  --ok-soft: #dcf5ec;
  --warn: #c07800;
  --warn-soft: #fdf1d8;
  --danger: #d13438;
  --danger-soft: #fbe3e4;
  --info: #0b7ea3;
  --info-soft: #ddf1f8;
  --purple: #7048e8;
  --purple-soft: #ece5fd;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .04);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, .08), 0 2px 4px rgba(16, 24, 40, .04);
  --shadow-lg: 0 20px 40px rgba(16, 24, 40, .16);

  --radius: 10px;
  --radius-sm: 7px;
  --radius-lg: 16px;

  --sidebar-w: 244px;
  --topbar-h: 56px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="dark"] {
  --bg: #0b1020;
  --bg-elevated: #131a2e;
  --bg-sunken: #070b16;
  --surface: #131a2e;
  --surface-2: #1a2340;
  --border: #263153;
  --border-strong: #364673;
  --text: #e8ecf6;
  --text-muted: #9aa6c2;
  --text-faint: #6f7c9c;

  --brand: #7fa9d0;
  --brand-soft: #1c2a38;
  --brand-text: #a9cce8;
  --logo-tile: #5b80a6;
  --logo-accent: #8fbee4;

  --ok: #34d399;
  --ok-soft: #10362c;
  --warn: #fbbf24;
  --warn-soft: #3a2d0c;
  --danger: #f87171;
  --danger-soft: #3d1a1c;
  --info: #38bdf8;
  --info-soft: #0d2f40;
  --purple: #a78bfa;
  --purple-soft: #2a1f4d;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, .45);
  --shadow-lg: 0 24px 48px rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: var(--sans);
  font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 21px; } h2 { font-size: 17px; } h3 { font-size: 15px; } h4 { font-size: 13px; }
p { margin: 0 0 10px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; border: 3px solid var(--bg); }

/* ------------------------------------------------------------------ boot -- */
.boot {
  position: fixed; inset: 0; display: grid; place-content: center;
  gap: 14px; justify-items: center; background: var(--bg);
}
.boot-mark {
  width: 52px; height: 52px; border-radius: 6px; display: block;
  animation: pulse 1.4s ease-in-out infinite;
}
.wordmark { font-weight: 500; letter-spacing: -.01em; white-space: nowrap; }
.wordmark .accent { color: var(--logo-accent); }
.login-hero .wordmark { color: #fff; }

.boot-text { color: var(--text-muted); letter-spacing: .12em; text-transform: uppercase; font-size: 11px; }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .6; transform: scale(.94); } }

/* ----------------------------------------------------------------- login -- */
.login-page {
  min-height: 100dvh; display: grid; grid-template-columns: 1fr;
  background: var(--bg);
}
.login-hero { display: none; }
.login-panel { display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.login-brand .mark { width: 42px; height: 42px; border-radius: 5px; display: block; flex: none; }
.login-demo { margin-top: 22px; border-top: 1px solid var(--border); padding-top: 16px; }
.login-demo-grid { display: grid; gap: 6px; }
.demo-user {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 8px 10px; border-radius: var(--radius-sm); border: 1px solid transparent;
  background: transparent; cursor: pointer;
}
.demo-user:hover { background: var(--surface-2); border-color: var(--border); }
.demo-user .avatar { width: 26px; height: 26px; font-size: 11px; }
.demo-user small { color: var(--text-faint); display: block; }

@media (min-width: 900px) {
  .login-page { grid-template-columns: 1.05fr .95fr; }
  .login-hero {
    display: flex; flex-direction: column; justify-content: space-between;
    padding: 44px; color: #fff;
    background:
      radial-gradient(900px 500px at 15% 15%, rgba(91, 128, 166, .55), transparent 60%),
      radial-gradient(700px 500px at 85% 80%, rgba(143, 190, 228, .32), transparent 60%),
      linear-gradient(160deg, #10202e, #16293a 60%, #0b1420);
  }
  .login-hero h1 { font-size: 34px; line-height: 1.15; max-width: 12ch; }
  .login-hero .lede { color: rgba(255, 255, 255, .72); max-width: 44ch; margin-top: 14px; font-size: 15px; }
  .hero-points { display: grid; gap: 14px; margin-top: 30px; }
  .hero-point { display: flex; gap: 12px; align-items: flex-start; }
  .hero-point .dot {
    width: 7px; height: 7px; border-radius: 50%; margin-top: 7px; flex: none;
    background: linear-gradient(135deg, #8fbee4, #5b80a6);
  }
  .hero-point strong { display: block; color: #fff; font-weight: 600; }
  .hero-point span { color: rgba(255, 255, 255, .62); font-size: 13px; }
  .hero-foot { color: rgba(255, 255, 255, .4); font-size: 12px; }
}

/* ------------------------------------------------------------------ shell -- */
.shell { min-height: 100dvh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--topbar-h);
  display: flex; align-items: center; gap: 10px; padding: 0 12px;
  background: var(--bg-elevated); border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}
.topbar .brand { display: flex; align-items: center; gap: 9px; font-weight: 650; }
.topbar .brand .mark { width: 28px; height: 28px; border-radius: 4px; flex: none; display: block; }
.topbar .brand span { display: none; }
.topbar .spacer { flex: 1; }

.searchbtn {
  display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 11px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; color: var(--text-faint); cursor: pointer; min-width: 34px;
}
.searchbtn .label, .searchbtn kbd { display: none; }
.searchbtn:hover { border-color: var(--border-strong); }

.iconbtn {
  width: 34px; height: 34px; display: grid; place-content: center; flex: none;
  border-radius: 9px; border: 1px solid transparent; background: transparent;
  color: var(--text-muted); cursor: pointer; position: relative;
}
.iconbtn:hover { background: var(--surface-2); color: var(--text); }
.iconbtn .dot-badge {
  position: absolute; top: 5px; right: 5px; min-width: 15px; height: 15px;
  border-radius: 999px; background: var(--danger); color: #fff;
  font-size: 9px; font-weight: 700; display: grid; place-content: center; padding: 0 3px;
}

.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  display: grid; place-content: center; color: #fff;
  font-size: 12px; font-weight: 650;
}

.body { display: flex; flex: 1; min-height: 0; min-width: 0; }

/* The page itself must never scroll sideways; wide content scrolls inside its
   own container instead. */
html, body { overflow-x: hidden; }
.shell, .main { max-width: 100%; min-width: 0; }

.sidebar {
  width: var(--sidebar-w); flex: none; background: var(--bg-elevated);
  border-right: 1px solid var(--border); overflow-y: auto;
  position: fixed; inset: var(--topbar-h) auto 0 0; z-index: 45;
  transform: translateX(-100%); transition: transform .22s ease;
  padding-bottom: 20px;
}
.sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
.nav-group { padding: 12px 10px 4px; }
.nav-group-title {
  font-size: 10px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--text-faint); padding: 0 10px 6px; font-weight: 650;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: var(--radius-sm); color: var(--text-muted);
  cursor: pointer; font-weight: 500; border: none; background: none;
  width: 100%; text-align: left; font-size: 13.5px;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--brand-soft); color: var(--brand-text); font-weight: 600; }
.nav-item .ico { width: 17px; flex: none; opacity: .85; }
.nav-item .count {
  margin-left: auto; font-size: 11px; background: var(--danger); color: #fff;
  border-radius: 999px; padding: 1px 6px; font-weight: 700;
}

.scrim {
  position: fixed; inset: 0; background: rgba(4, 8, 20, .5);
  z-index: 44; backdrop-filter: blur(2px);
}

.main { flex: 1; min-width: 0; padding: 14px; padding-bottom: 86px; }

@media (min-width: 1024px) {
  .topbar .brand span { display: block; }
  .searchbtn { min-width: 250px; }
  .searchbtn .label { display: block; flex: 1; }
  .searchbtn kbd {
    display: block; font-family: var(--mono); font-size: 10px;
    border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px;
  }
  .sidebar { position: sticky; top: var(--topbar-h); height: calc(100dvh - var(--topbar-h)); transform: none; }
  .menu-toggle { display: none; }
  .main { padding: 20px 24px; padding-bottom: 32px; }
  .bottom-nav { display: none; }
}

/* --------------------------------------------------------- bottom nav (m) -- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 46;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--bg-elevated); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav button {
  border: none; background: none; padding: 8px 2px 9px; cursor: pointer;
  display: grid; justify-items: center; gap: 3px;
  color: var(--text-faint); font-size: 10px; font-weight: 550;
}
.bottom-nav button.active { color: var(--brand); }
.bottom-nav svg { width: 20px; height: 20px; }

/* ------------------------------------------------------------ page header -- */
.page-head {
  display: flex; align-items: flex-start; gap: 12px;
  flex-wrap: wrap; margin-bottom: 16px;
}
.page-head .titles { flex: 1; min-width: 200px; }
.page-head .sub { color: var(--text-muted); font-size: 13px; margin-top: 3px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.tabs {
  display: flex; gap: 2px; overflow-x: auto; margin-bottom: 16px;
  border-bottom: 1px solid var(--border); scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 9px 13px; border: none; background: none; cursor: pointer;
  color: var(--text-muted); font-weight: 550; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px; font-size: 13.5px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }

/* ----------------------------------------------------------------- layout -- */
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: 1fr; }
.grid.cols-3 { grid-template-columns: 1fr; }
.grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.split { grid-template-columns: 1fr; }
@media (min-width: 720px) {
  .grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (min-width: 1100px) {
  .grid.split { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
}
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.stack { display: grid; gap: 12px; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.tiny { font-size: 11.5px; }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); font-size: .92em; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.grow { flex: 1; }
.hide-sm { display: none; }
@media (min-width: 720px) { .hide-sm { display: revert; } }

/* ------------------------------------------------------------------ cards -- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden;
}
.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
}
.card-head h3 { flex: 1; }
.card-body { padding: 14px; }
.card-body.flush { padding: 0; }
.card-foot {
  padding: 10px 14px; border-top: 1px solid var(--border);
  background: var(--surface-2); font-size: 12.5px;
}

.kpi { padding: 13px 14px; }
.kpi .label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-faint); font-weight: 650;
}
.kpi .value { font-size: 22px; font-weight: 680; margin-top: 5px; letter-spacing: -.02em; }
.kpi .value.sm { font-size: 18px; }
.kpi .delta { font-size: 12px; margin-top: 4px; display: flex; align-items: center; gap: 4px; }
.kpi .delta.up { color: var(--ok); }
.kpi .delta.down { color: var(--danger); }

/* ----------------------------------------------------------------- badges -- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 650; white-space: nowrap;
  background: var(--surface-2); color: var(--text-muted);
  border: 1px solid var(--border);
}
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge.brand { background: var(--brand-soft); color: var(--brand-text); border-color: transparent; }
.badge.purple { background: var(--purple-soft); color: var(--purple); border-color: transparent; }
.badge .pip { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* --------------------------------------------------------------- controls -- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); font-weight: 570; cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, opacity .12s;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--brand); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover:not(:disabled) { filter: brightness(1.08); background: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-muted); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn.block { width: 100%; }
.btn.lg { height: 40px; padding: 0 18px; }

.field { display: grid; gap: 5px; }
.field > label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.field .hint { font-size: 11.5px; color: var(--text-faint); }
.input, .select, .textarea {
  width: 100%; height: 36px; padding: 0 11px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); color: var(--text); outline: none;
}
.textarea { height: auto; padding: 9px 11px; min-height: 72px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
.input.right { text-align: right; font-family: var(--mono); }
.input:disabled, .select:disabled { background: var(--surface-2); color: var(--text-faint); }
.select { appearance: none; padding-right: 30px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-faint) 50%),
                    linear-gradient(135deg, var(--text-faint) 50%, transparent 50%);
  background-position: calc(100% - 15px) 15px, calc(100% - 10px) 15px;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
.checkbox { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.checkbox input { width: 16px; height: 16px; accent-color: var(--brand); }

.filters {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px;
}
.filters .input, .filters .select { height: 32px; width: auto; min-width: 130px; }
.filters .search { flex: 1; min-width: 160px; }

/* ----------------------------------------------------------------- tables -- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; padding: 9px 12px; font-size: 11px; font-weight: 650;
  text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint);
  background: var(--surface-2); border-bottom: 1px solid var(--border);
  white-space: nowrap; position: sticky; top: 0; z-index: 1;
}
table.data th.right, table.data td.right { text-align: right; }
table.data td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr.clickable:hover { background: var(--surface-2); }
table.data tfoot td {
  padding: 10px 12px; font-weight: 650; background: var(--surface-2);
  border-top: 2px solid var(--border-strong);
}
table.data td.num, table.data th.num { text-align: right; font-family: var(--mono); font-size: 12.5px; }
table.data .strong { font-weight: 600; }
.indent-1 { padding-left: 26px !important; }

.empty { padding: 34px 16px; text-align: center; color: var(--text-faint); }
.empty .big { font-size: 26px; margin-bottom: 6px; opacity: .5; }

/* --------------------------------------------------------- mobile records -- */
.record-list { display: grid; }
/* Grid and flex children default to min-width:auto, which lets a long title
   push the whole page wider than the viewport. Every level is pinned to 0. */
.record {
  display: grid; gap: 4px; padding: 11px 13px; min-width: 0;
  border-bottom: 1px solid var(--border); cursor: pointer;
}
.record:last-child { border-bottom: none; }
.record:active { background: var(--surface-2); }
.record .r1, .record .r2 { display: flex; align-items: center; gap: 8px; min-width: 0; }
.record .r1 .t { font-weight: 600; flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.record .r1 > .badge, .record .r2 > .badge { flex: none; }
.record .r2 { color: var(--text-muted); font-size: 12.5px; }
.record .r2 > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.record .r2 .amt { margin-left: auto; flex: none; font-family: var(--mono); font-weight: 600; color: var(--text); }

/* ----------------------------------------------------------------- modals -- */
.overlay {
  position: fixed; inset: 0; z-index: 60; background: rgba(6, 10, 22, .55);
  display: flex; align-items: flex-end; justify-content: center;
  backdrop-filter: blur(3px); padding: 0;
}
@media (min-width: 720px) { .overlay { align-items: center; padding: 24px; } }
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%; max-height: 92dvh; display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg); animation: slide-up .2s ease;
}
@media (min-width: 720px) {
  .modal { border-radius: var(--radius-lg); max-width: 620px; max-height: 88dvh; animation: pop .16s ease; }
  .modal.wide { max-width: 960px; }
  .modal.xwide { max-width: 1200px; }
}
@keyframes slide-up { from { transform: translateY(24px); opacity: .6; } }
@keyframes pop { from { transform: scale(.97); opacity: 0; } }
.modal-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.modal-head h2 { flex: 1; }
.modal-body { padding: 16px; overflow-y: auto; flex: 1; }
.modal-foot {
  display: flex; gap: 8px; justify-content: flex-end;
  padding: 12px 16px; border-top: 1px solid var(--border); background: var(--surface-2);
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}

/* --------------------------------------------------------------- palette -- */
.palette-overlay { align-items: flex-start; padding-top: 8vh; }
.palette {
  width: 100%; max-width: 620px; background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); overflow: hidden; margin: 0 12px;
}
.palette input {
  width: 100%; height: 50px; padding: 0 16px; border: none;
  background: transparent; outline: none; font-size: 15px;
  border-bottom: 1px solid var(--border);
}
.palette-results { max-height: 58dvh; overflow-y: auto; }
.palette-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 15px; cursor: pointer;
}
.palette-item:hover, .palette-item.sel { background: var(--brand-soft); }
.palette-item .kind {
  font-size: 10px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-faint); min-width: 78px; font-weight: 650;
}
.palette-item .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------------- toasts -- */
.toasts {
  position: fixed; z-index: 90; left: 12px; right: 12px; bottom: 78px;
  display: grid; gap: 8px; pointer-events: none;
}
@media (min-width: 720px) { .toasts { left: auto; right: 20px; bottom: 20px; width: 380px; } }
.toast {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--brand); border-radius: var(--radius);
  padding: 11px 13px; box-shadow: var(--shadow-md); pointer-events: auto;
  animation: slide-in .2s ease;
}
@keyframes slide-in { from { transform: translateY(8px); opacity: 0; } }
.toast.ok { border-left-color: var(--ok); }
.toast.error { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }
.toast .t { font-weight: 620; margin-bottom: 2px; }
.toast .m { color: var(--text-muted); font-size: 12.5px; white-space: pre-wrap; }

/* --------------------------------------------------------------- pipeline -- */
.pipeline { display: grid; gap: 8px; }
@media (min-width: 900px) { .pipeline { grid-auto-flow: column; grid-auto-columns: 1fr; } }
.pipe-stage {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px; position: relative;
}
.pipe-stage .n { font-size: 11px; color: var(--text-faint); font-weight: 650; text-transform: uppercase; letter-spacing: .05em; }
.pipe-stage .v { font-size: 17px; font-weight: 660; margin-top: 4px; }
.pipe-stage .c { font-size: 11.5px; color: var(--text-muted); }
.pipe-bar { height: 3px; border-radius: 2px; background: var(--brand); margin-top: 8px; opacity: .8; }

/* ---------------------------------------------------------------- charts -- */
.chart { width: 100%; display: block; overflow: visible; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .axis-label { fill: var(--text-faint); font-size: 10px; font-family: var(--sans); }
.chart .bar { fill: var(--brand); }
.chart .bar.alt { fill: var(--purple); }
.chart .line { fill: none; stroke: var(--brand); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.alt { stroke: var(--ok); }
.chart .area { fill: url(#atlasArea); }
.chart .pt { fill: var(--brand); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-muted); }
.legend .k { display: flex; align-items: center; gap: 6px; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; }

.meter { height: 6px; background: var(--bg-sunken); border-radius: 3px; overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--brand); border-radius: 3px; }
.meter.ok > span { background: var(--ok); }
.meter.warn > span { background: var(--warn); }
.meter.danger > span { background: var(--danger); }

/* ------------------------------------------------------------- exceptions -- */
.exception {
  display: flex; gap: 11px; padding: 11px 14px; border-bottom: 1px solid var(--border);
  cursor: pointer; align-items: flex-start;
}
.exception:last-child { border-bottom: none; }
.exception:hover { background: var(--surface-2); }
.exception .sev { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: none; }
.exception .sev.critical { background: var(--danger); }
.exception .sev.warning { background: var(--warn); }
.exception .sev.action { background: var(--brand); }
.exception .sev.info { background: var(--info); }
.exception .t { font-weight: 590; }
.exception .d { color: var(--text-muted); font-size: 12.5px; }

/* ------------------------------------------------------------------ trace -- */
.trace { display: grid; gap: 10px; }
.trace-node {
  display: flex; gap: 11px; align-items: center; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); cursor: pointer;
}
.trace-node:hover { border-color: var(--brand); }
.trace-node .kind {
  font-size: 10px; text-transform: uppercase; letter-spacing: .05em;
  font-weight: 700; padding: 2px 7px; border-radius: 5px;
  background: var(--brand-soft); color: var(--brand-text); white-space: nowrap;
}
.trace-node .lbl { flex: 1; min-width: 0; font-weight: 550; overflow: hidden; text-overflow: ellipsis; }
.trace-arrow { color: var(--text-faint); padding-left: 20px; font-size: 12px; }

/* ------------------------------------------------------------ line editor -- */
.line-editor { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.line-editor table { width: 100%; border-collapse: collapse; }
.line-editor th {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; text-align: left;
  padding: 7px 8px; background: var(--surface-2); color: var(--text-faint);
  border-bottom: 1px solid var(--border); font-weight: 650;
}
.line-editor td { padding: 5px 6px; border-bottom: 1px solid var(--border); }
.line-editor .input, .line-editor .select { height: 32px; font-size: 13px; }
.line-editor tr:last-child td { border-bottom: none; }
.doc-totals { display: grid; gap: 5px; margin-left: auto; max-width: 280px; margin-top: 12px; }
.doc-totals .r { display: flex; justify-content: space-between; gap: 24px; font-size: 13px; }
.doc-totals .r.total {
  font-size: 16px; font-weight: 680; border-top: 1px solid var(--border-strong);
  padding-top: 7px; margin-top: 3px;
}

/* --------------------------------------------------------------- utility -- */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--bg-sunken) 50%, var(--surface-2) 75%);
  background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: var(--radius-sm);
}
@keyframes shimmer { to { background-position: -200% 0; } }
.divider { height: 1px; background: var(--border); margin: 12px 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 13px; align-items: baseline; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; font-weight: 550; text-align: right; }
.offline-bar {
  background: var(--warn-soft); color: var(--warn); text-align: center;
  padding: 5px; font-size: 12px; font-weight: 600;
}
@media print {
  .topbar, .sidebar, .bottom-nav, .page-actions, .filters, .toasts { display: none !important; }
  .main { padding: 0; } .card { box-shadow: none; border: 1px solid #ccc; }
  body { background: #fff; }
}
