/* ==========================================================================
   LogixFlow — design system
   ========================================================================== */
:root {
  --brand: #2a78d6;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --surface-3: #f1f3f6;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --text: #101828;
  --text-2: #475467;
  --muted: #667085;
  --focus: color-mix(in srgb, var(--brand) 35%, transparent);
  --brand-soft: color-mix(in srgb, var(--brand) 10%, var(--surface));
  --brand-ink: color-mix(in srgb, var(--brand) 80%, #000);

  --side-bg: #0b1220;
  --side-bg-2: #111a2e;
  --side-text: #b4bccb;
  --side-muted: #6b768b;
  --side-active: #ffffff;

  --green: #067647; --green-bg: #ecfdf3;
  --amber: #b54708; --amber-bg: #fffaeb;
  --red: #b42318;   --red-bg: #fef3f2;
  --blue: #175cd3;  --blue-bg: #eff8ff;
  --violet: #5925dc; --violet-bg: #f4f3ff;
  --gray: #475467;  --gray-bg: #f2f4f7;

  /* Chart categorical slots (validated reference palette, light) */
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 16px 40px -8px rgba(16, 24, 40, .18), 0 4px 10px -4px rgba(16, 24, 40, .08);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c111d; --surface: #131a2a; --surface-2: #161e30; --surface-3: #1c2538;
    --border: #243049; --border-strong: #33415e;
    --text: #f2f4f7; --text-2: #c2c9d6; --muted: #8b95a8;
    --brand-soft: color-mix(in srgb, var(--brand) 18%, var(--surface));
    --brand-ink: color-mix(in srgb, var(--brand) 55%, #fff);
    --side-bg: #080d18; --side-bg-2: #0f1626;
    --green: #47cd89; --green-bg: rgba(71, 205, 137, .12);
    --amber: #fdb022; --amber-bg: rgba(253, 176, 34, .12);
    --red: #f97066;   --red-bg: rgba(249, 112, 102, .12);
    --blue: #53b1fd;  --blue-bg: rgba(83, 177, 253, .12);
    --violet: #a48afb; --violet-bg: rgba(164, 138, 251, .12);
    --gray: #a4acba;  --gray-bg: rgba(164, 172, 186, .12);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4);
    --shadow-lg: 0 16px 40px -8px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c111d; --surface: #131a2a; --surface-2: #161e30; --surface-3: #1c2538;
  --border: #243049; --border-strong: #33415e;
  --text: #f2f4f7; --text-2: #c2c9d6; --muted: #8b95a8;
  --brand-soft: color-mix(in srgb, var(--brand) 18%, var(--surface));
  --brand-ink: color-mix(in srgb, var(--brand) 55%, #fff);
  --side-bg: #080d18; --side-bg-2: #0f1626;
  --green: #47cd89; --green-bg: rgba(71, 205, 137, .12);
  --amber: #fdb022; --amber-bg: rgba(253, 176, 34, .12);
  --red: #f97066;   --red-bg: rgba(249, 112, 102, .12);
  --blue: #53b1fd;  --blue-bg: rgba(83, 177, 253, .12);
  --violet: #a48afb; --violet-bg: rgba(164, 138, 251, .12);
  --gray: #a4acba;  --gray-bg: rgba(164, 172, 186, .12);
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --shadow: 0 1px 3px rgba(0, 0, 0, .4);
  --shadow-lg: 0 16px 40px -8px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px; line-height: 1.5; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss01";
}
a { color: var(--brand-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }
p { margin: 0 0 8px; }
.icon { flex-shrink: 0; display: inline-block; vertical-align: middle; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num, .tnum { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; min-width: 0; }
.mt { margin-top: 16px; } .mb { margin-bottom: 16px; } .mt-sm { margin-top: 8px; }
.row { display: flex; align-items: center; gap: 8px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack > * + * { margin-top: 16px; }
.hidden { display: none !important; }
.text-green { color: var(--green); } .text-red { color: var(--red); } .text-amber { color: var(--amber); }

/* ---------- Shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 260px; flex-shrink: 0; background: var(--side-bg); color: var(--side-text);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  border-right: 1px solid rgba(255, 255, 255, .04); z-index: 40;
}
.side-logo { display: block; padding: 18px 20px 10px; }
.side-logo img { height: 40px; width: auto; display: block; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content { padding: 24px 28px 48px; max-width: 1440px; width: 100%; margin: 0 auto; }

/* Company switcher */
.switcher { position: relative; margin: 6px 12px 10px; }
.switcher-btn {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px;
  background: var(--side-bg-2); border: 1px solid rgba(255, 255, 255, .06); color: #fff; cursor: pointer; text-align: left;
}
.switcher-btn:hover { border-color: rgba(255, 255, 255, .14); }
.switcher-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.switcher-text strong { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.switcher-text small { font-size: 11.5px; color: var(--side-muted); display: flex; align-items: center; gap: 4px; }
.switcher-caret { color: var(--side-muted); }
.co-mark { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 12px; flex-shrink: 0; }
.co-mark.sm { width: 24px; height: 24px; font-size: 10px; border-radius: 6px; }
.switcher-menu { left: 0; right: 0; top: calc(100% + 6px); min-width: 280px; }

/* Nav */
.nav { padding: 4px 10px; flex: 1; }
.nav-link {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 8px;
  color: var(--side-text); font: inherit; font-weight: 500; background: none; border: 0; cursor: pointer; text-align: left;
}
.nav-link:hover { background: rgba(255, 255, 255, .05); color: #fff; text-decoration: none; }
.nav-link.active { background: color-mix(in srgb, var(--brand) 28%, transparent); color: var(--side-active); }
.nav-link.active-parent { color: #fff; }
.nav-link span { flex: 1; }
.nav-caret { transition: transform .15s; color: var(--side-muted); }
.nav-group.open .nav-caret { transform: rotate(90deg); }
.nav-children { display: none; padding: 2px 0 6px 38px; position: relative; }
.nav-children::before { content: ""; position: absolute; left: 19px; top: 2px; bottom: 8px; width: 1px; background: rgba(255, 255, 255, .08); }
.nav-group.open .nav-children { display: block; }
.nav-sub { display: block; padding: 6px 10px; border-radius: 6px; color: var(--side-muted); font-size: 13px; }
.nav-sub:hover { color: #fff; text-decoration: none; background: rgba(255, 255, 255, .04); }
.nav-sub.active { color: #fff; background: rgba(255, 255, 255, .07); font-weight: 500; }
.side-foot { padding: 10px; border-top: 1px solid rgba(255, 255, 255, .06); }

/* Topbar */
.topbar {
  height: 60px; display: flex; align-items: center; gap: 12px; padding: 0 28px; position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.search { position: relative; flex: 1; min-width: 0; max-width: 520px; display: flex; align-items: center; gap: 8px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 0 10px; height: 38px; color: var(--muted); }
.search:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--focus); }
.search input { flex: 1; border: 0; outline: 0; background: none; font: inherit; color: var(--text); height: 100%; min-width: 0; }
.search kbd { font: 11px/1 Inter, sans-serif; padding: 3px 6px; border-radius: 5px; border: 1px solid var(--border); color: var(--muted); }
.search-results { left: 0; right: 0; top: calc(100% + 6px); max-height: 420px; overflow-y: auto; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.icon-btn { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 9px; border: 1px solid transparent;
  background: none; color: var(--text-2); cursor: pointer; }
.icon-btn:hover { background: var(--surface-3); }
.user-btn { display: flex; align-items: center; gap: 8px; padding: 4px 8px 4px 4px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; }
.theme-moon { display: none; }
:root[data-theme="dark"] .theme-sun { display: none; }
:root[data-theme="dark"] .theme-moon { display: inline; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-sun { display: none; }
  :root:not([data-theme="light"]) .theme-moon { display: inline; }
}
.only-mobile { display: none; }
.scrim { display: none; }

/* Dropdowns */
[data-dropdown] { position: relative; }
.dropdown {
  display: none; position: absolute; z-index: 60; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; min-width: 230px; top: calc(100% + 6px); left: 0; color: var(--text);
}
.dropdown.align-right { left: auto; right: 0; }
[data-dropdown].open > .dropdown, .dropdown.show { display: block; }
.dd-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 8px; border: 0; background: none;
  color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.dd-item:hover, .dd-item.kb { background: var(--surface-3); text-decoration: none; }
.dd-item small { display: block; color: var(--muted); font-size: 11.5px; }
.dd-item.is-current { background: var(--brand-soft); }
.dd-item .icon { color: var(--muted); }
.dd-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 8px 10px 4px; font-weight: 600; }
.dd-sep { height: 1px; background: var(--border); margin: 6px 0; }
.dd-head { padding: 8px 10px 10px; display: flex; flex-direction: column; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.dd-head small { color: var(--muted); }
.dropdown form { margin: 0; }

/* ---------- Page ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-sub { color: var(--muted); margin: 4px 0 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--text); }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin: -4px 0 20px; overflow-x: auto; }
.tab { padding: 10px 14px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--text); border-color: var(--brand); }
.tab .count { background: var(--surface-3); border-radius: 999px; padding: 0 7px; font-size: 11.5px; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-head h2 { font-size: 15px; }
.card-head .sub { color: var(--muted); font-size: 12.5px; }
.card-body { padding: 18px; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.card.pad { padding: 18px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); }
.span-2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }

/* KPI */
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; position: relative; box-shadow: var(--shadow-sm); }
.kpi-icon { position: absolute; right: 14px; top: 14px; width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-ink); }
.kpi-label { color: var(--muted); font-size: 12.5px; font-weight: 500; padding-right: 40px; line-height: 1.35; }
.kpi-value { font-size: 26px; font-weight: 650; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi-sub { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; margin-top: 2px; min-height: 18px; }
.kpi-delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; }
.kpi-delta.up { color: var(--green); }
.kpi-delta.down { color: var(--red); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 9px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-weight: 550; cursor: pointer;
  white-space: nowrap; box-shadow: var(--shadow-sm); transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:focus-visible, .input:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: color-mix(in srgb, var(--brand) 88%, #000); }
.btn-danger { color: var(--red); }
.btn-danger:hover { background: var(--red-bg); }
.btn-ghost { border-color: transparent; background: none; box-shadow: none; }
.btn-sm { height: 32px; padding: 0 10px; font-size: 13px; }
.btn-xs { height: 26px; padding: 0 8px; font-size: 12px; border-radius: 7px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.link-btn { background: none; border: 0; padding: 0; color: var(--brand-ink); font: inherit; cursor: pointer; }
.link-btn.danger { color: var(--red); }
form.inline { display: inline; margin: 0; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 13px; font-weight: 550; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local],
input[type=tel], input[type=url], input:not([type]), input[type=search]:not(.search input), input[type=color], select, textarea, .input {
  width: 100%; height: 38px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); font: inherit; transition: border-color .12s, box-shadow .12s;
}
textarea { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
input[type=color] { padding: 3px; width: 64px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--focus); }
input[type=file] { font: inherit; color: var(--text-2); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.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; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); }
fieldset { border: 0; padding: 0; margin: 0; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; margin: 8px 0 12px; }

/* Toolbar / filters */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.toolbar .input, .toolbar select, .toolbar input:not([type=checkbox]):not([type=radio]) { height: 34px; width: auto; min-width: 140px; }
.toolbar input[type=search] { min-width: 220px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border);
  color: var(--text-2); background: var(--surface); font-weight: 500; font-size: 13px; }
.chip:hover { text-decoration: none; border-color: var(--border-strong); }
.chip.active { background: var(--text); color: var(--surface); border-color: var(--text); }
.chip .count { opacity: .7; font-size: 12px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 14px; background: var(--surface-2);
  border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table tr[data-href] { cursor: pointer; }
.table .num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table td .sub { display: block; color: var(--muted); font-size: 12.5px; }
.table tfoot td { font-weight: 600; background: var(--surface-2); }
.table.compact td, .table.compact th { padding: 8px 12px; }
.cell-main { font-weight: 550; color: var(--text); }
a.cell-main:hover { color: var(--brand-ink); }

.pager { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-top: 1px solid var(--border); font-size: 13px; }
.pager-links { display: flex; align-items: center; gap: 4px; }
.pager-num { color: var(--muted); padding: 0 6px; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 550; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-gray { color: var(--gray); background: var(--gray-bg); }
.badge-blue { color: var(--blue); background: var(--blue-bg); }
.badge-green { color: var(--green); background: var(--green-bg); }
.badge-amber { color: var(--amber); background: var(--amber-bg); }
.badge-red { color: var(--red); background: var(--red-bg); }
.badge-violet { color: var(--violet); background: var(--violet-bg); }
.tag { display: inline-block; padding: 1px 8px; border-radius: 6px; background: var(--surface-3); color: var(--text-2); font-size: 12px; font-weight: 500; }

.avatar { --h: 210; display: inline-grid; place-items: center; border-radius: 50%; font-weight: 600; flex-shrink: 0;
  background: hsl(var(--h) 70% 92%); color: hsl(var(--h) 55% 32%); }
:root[data-theme="dark"] .avatar { background: hsl(var(--h) 40% 25%); color: hsl(var(--h) 70% 85%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .avatar { background: hsl(var(--h) 40% 25%); color: hsl(var(--h) 70% 85%); } }
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
.avatar-md { width: 36px; height: 36px; font-size: 13px; }
.avatar-lg { width: 48px; height: 48px; font-size: 16px; }

/* Flash */
.flash { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; font-weight: 500; border: 1px solid; }
.flash span { flex: 1; }
.flash-success { background: var(--green-bg); color: var(--green); border-color: color-mix(in srgb, var(--green) 25%, transparent); }
.flash-error { background: var(--red-bg); color: var(--red); border-color: color-mix(in srgb, var(--red) 25%, transparent); }
.flash-info { background: var(--blue-bg); color: var(--blue); border-color: color-mix(in srgb, var(--blue) 25%, transparent); }
.flash-warn { background: var(--amber-bg); color: var(--amber); border-color: color-mix(in srgb, var(--amber) 25%, transparent); }
.flash-warn a { color: inherit; text-decoration: underline; font-weight: 600; }
.flash-x { background: none; border: 0; color: inherit; cursor: pointer; opacity: .7; }
.alert { padding: 12px 14px; border-radius: 10px; background: var(--surface-3); color: var(--text-2); display: flex; gap: 10px; align-items: flex-start; }
.alert-warn { background: var(--amber-bg); color: var(--amber); }
.alert-error { background: var(--red-bg); color: var(--red); }

/* Empty state */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-icon { width: 54px; height: 54px; border-radius: 14px; background: var(--surface-3); display: grid; place-items: center; margin: 0 auto 14px; color: var(--text-2); }
.empty h3 { color: var(--text); font-size: 15px; margin-bottom: 4px; }
.empty .btn { margin-top: 14px; }

/* Definition lists */
.dl { display: grid; grid-template-columns: 140px 1fr; gap: 10px 16px; margin: 0; }
.dl dt { color: var(--muted); font-size: 13px; }
.dl dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }

/* Timeline / activity */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.timeline li:last-child { border-bottom: 0; }
.tl-icon { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); flex-shrink: 0; }
.tl-body { flex: 1; min-width: 0; }
.tl-meta { color: var(--muted); font-size: 12.5px; }
.tl-text { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 2px; }

/* Progress */
.progress { height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand); border-radius: 999px; }

/* Kanban */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.kan-col { background: var(--surface-3); border-radius: var(--radius); padding: 10px; min-height: 200px; display: flex; flex-direction: column; gap: 8px; }
.kan-col.drop { outline: 2px dashed var(--brand); outline-offset: -2px; }
.kan-head { display: flex; justify-content: space-between; align-items: center; padding: 2px 4px 6px; font-weight: 600; font-size: 13px; }
.kan-head small { color: var(--muted); font-weight: 500; }
.kan-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; box-shadow: var(--shadow-sm); cursor: grab; }
.kan-card:hover { border-color: var(--border-strong); }
.kan-card .t { font-weight: 550; color: var(--text); display: block; }
.kan-card .m { display: flex; justify-content: space-between; color: var(--muted); font-size: 12.5px; margin-top: 6px; }

/* Charts */
.chart-wrap { position: relative; width: 100%; }
.chart { width: 100%; height: 100%; display: block; overflow: visible; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .baseline { stroke: var(--border-strong); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: inherit; }
.chart .bar { transition: opacity .12s; }
.chart .bar.s1, .sw.s1, .hbar-fill { fill: var(--s1); background: var(--s1); }
.chart .bar.s2, .sw.s2 { fill: var(--s2); background: var(--s2); }
.chart .bar.s3, .sw.s3 { fill: var(--s3); background: var(--s3); }
.chart .bar.s4, .sw.s4 { fill: var(--s4); background: var(--s4); }
.chart .line { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.chart .line.s1 { stroke: var(--s1); } .chart .line.s2 { stroke: var(--s2); } .chart .line.s3 { stroke: var(--s3); } .chart .line.s4 { stroke: var(--s4); }
.chart .area.s1 { fill: var(--s1); opacity: .08; }
.chart .hit { fill: transparent; }
.chart .hit.col:hover { fill: var(--text); opacity: .04; }
.chart:hover .bar { opacity: .75; }
.chart .bar:hover { opacity: 1; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; font-size: 12.5px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar { display: grid; grid-template-columns: minmax(90px, 160px) 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.hbar-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-2); }
.hbar-track { height: 10px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 999px; }
.hbar-val { font-variant-numeric: tabular-nums; font-weight: 550; min-width: 64px; text-align: right; }
.tooltip { position: fixed; z-index: 100; pointer-events: none; background: var(--text); color: var(--surface); padding: 6px 10px; border-radius: 8px;
  font-size: 12.5px; font-weight: 500; box-shadow: var(--shadow-lg); opacity: 0; transition: opacity .08s; max-width: 320px; }
.tooltip.show { opacity: 1; }

/* Line items editor */
.lines th, .lines td { padding: 6px 6px; }
.lines td input, .lines td select { height: 34px; padding: 0 8px; }
.lines .col-desc { min-width: 240px; }
.lines .col-qty { width: 80px; } .lines .col-unit { width: 100px; }
.lines .col-price { width: 120px; } .lines .col-tax { width: 90px; } .lines .col-total { width: 120px; }
.lines .col-ledger { width: 190px; } .lines .col-x { width: 36px; }
.totals { margin-left: auto; width: 320px; max-width: 100%; }
.totals div { display: flex; justify-content: space-between; padding: 6px 0; font-variant-numeric: tabular-nums; }
.totals .grand { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 10px; font-size: 17px; font-weight: 650; }

/* Home */
.hello { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.hello h1 { font-size: 24px; }
.module-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.module-tile { display: flex; gap: 12px; align-items: center; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); }
.module-tile:hover { border-color: var(--brand); text-decoration: none; box-shadow: var(--shadow); }
.module-tile .mi { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-ink); }
.module-tile small { display: block; color: var(--muted); font-size: 12px; }

/* List rows */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 11px 18px; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.list .meta { color: var(--muted); font-size: 12.5px; }

/* Auth pages */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-art { background: radial-gradient(1200px 600px at 10% 10%, color-mix(in srgb, var(--brand) 45%, #0b1220) 0%, #0b1220 60%); color: #cbd5e1; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-art img { height: 56px; width: auto; align-self: flex-start; }
.auth-art h2 { color: #fff; font-size: 30px; font-weight: 650; letter-spacing: -.02em; max-width: 460px; line-height: 1.2; }
.auth-art ul { list-style: none; padding: 0; margin: 24px 0 0; display: grid; gap: 12px; }
.auth-art li { display: flex; align-items: center; gap: 10px; }
.auth-art li .icon { color: #7cb4ff; }
.auth-art .grid-bg { position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px); background-size: 40px 40px; mask-image: linear-gradient(180deg, transparent, #000 40%, transparent); pointer-events: none; }
.auth-form { display: grid; place-items: center; padding: 40px 24px; background: var(--surface); }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 24px; margin-bottom: 6px; }
.auth-card .page-sub { margin-bottom: 24px; }
.auth-card .field { margin-bottom: 14px; }

/* Document (invoice / quote print view) */
.doc { background: #fff; color: #101828; max-width: 860px; margin: 0 auto; padding: 48px; border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); }
.doc table { width: 100%; border-collapse: collapse; }
.doc-head { display: flex; justify-content: space-between; gap: 24px; margin-bottom: 36px; }
.doc-title { font-size: 28px; font-weight: 700; letter-spacing: -.02em; color: var(--brand); }
.doc-meta { text-align: right; font-size: 13px; }
.doc-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 28px; font-size: 13px; }
.doc-parties h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #667085; margin-bottom: 6px; }
.doc-lines th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #667085; border-bottom: 2px solid #101828; padding: 8px 6px; }
.doc-lines td { padding: 10px 6px; border-bottom: 1px solid #eaecf0; font-size: 13px; vertical-align: top; }
.doc-lines .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.doc-totals { width: 300px; margin: 18px 0 0 auto; font-size: 13px; }
.doc-totals div { display: flex; justify-content: space-between; padding: 5px 0; }
.doc-totals .grand { border-top: 2px solid #101828; font-weight: 700; font-size: 16px; padding-top: 10px; margin-top: 4px; }
.doc-foot { margin-top: 36px; padding-top: 18px; border-top: 1px solid #eaecf0; font-size: 12px; color: #475467; white-space: pre-wrap; }
.doc-stamp { display: inline-block; border: 2px solid; border-radius: 8px; padding: 4px 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; font-size: 13px; transform: rotate(-4deg); }

@media print {
  body { background: #fff; }
  .sidebar, .topbar, .no-print, .flash, .page-head, .tabs, .portal-top { display: none !important; }
  .content { padding: 0; max-width: none; }
  .doc { border: 0; box-shadow: none; padding: 0; max-width: none; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  body.side-open .sidebar { transform: none; }
  body.side-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 35; }
  .only-mobile { display: grid; }
  .topbar { padding: 0 16px; }
  .content { padding: 18px 16px 40px; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .form-grid, .form-grid.cols-3, .form-grid.cols-4 { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .search kbd, .hide-sm { display: none; }
  .topbar { gap: 8px; }
  .top-actions { gap: 4px; }
  .search input { width: 100%; text-overflow: ellipsis; }
  /* Filter bars (a form of selects + search box) wrap instead of pushing the page wider than the screen. */
  form.row { flex-wrap: wrap; margin-left: 0 !important; max-width: 100%; }
  form.row > input, form.row > select { min-width: 0; flex: 1 1 140px; }
  .badge { white-space: normal; }
  .dl { grid-template-columns: 1fr; gap: 2px 0; }
  .dl dd { margin-bottom: 8px; }
  .doc { padding: 20px; }
  .doc-parties, .doc-head { grid-template-columns: 1fr; flex-direction: column; }
  .doc-meta { text-align: left; }
  .span-2 { grid-column: auto; }
}
@media (max-width: 560px) {
  .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .page-head { align-items: flex-start; }
}

/* Utility overrides */
.alert-success { background: var(--green-bg); color: var(--green); }
.table td .sub.text-red, .text-red.sub { color: var(--red); }
.table td .sub.text-amber { color: var(--amber); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.card-foot.form-actions { margin-top: 0; }
svg.barcode { display: block; max-width: 100%; height: auto; background: #fff; }
[hidden] { display: none !important; }
