/* ==========================================================================
   Econ ERP — UI/UX Prototype
   Design tokens adapted from the Apex UI system (slate + indigo).
   ========================================================================== */

:root {
    --canvas: #f8fafc;
    --surface: #ffffff;
    --surface-muted: #f8fafc;
    --surface-sunken: #f1f5f9;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --divider: #f1f5f9;

    --text: #0f172a;
    --text-body: #334155;
    --text-muted: #64748b;
    --text-subtle: #94a3b8;

    --brand: #0a85c2;
    --brand-hover: #086c9e;
    --brand-soft: #e8f5fc;
    --brand-soft-border: #b3dcf0;
    --ink: #0f172a;
    --ink-hover: #1e293b;

    --positive: #059669; --positive-strong: #047857; --positive-soft: #ecfdf5; --positive-border: #a7f3d0;
    --negative: #e11d48; --negative-strong: #be123c; --negative-soft: #fff1f2; --negative-border: #fecdd3;
    --pending:  #d97706; --pending-strong:  #b45309; --pending-soft:  #fffbeb; --pending-border:  #fde68a;
    --info:     #0284c7; --info-strong:     #0369a1; --info-soft:     #f0f9ff; --info-border:     #bae6fd;
    --violet:   #7c3aed; --violet-soft: #f5f3ff; --violet-border: #ddd6fe;
    --neutral-soft: #f1f5f9; --neutral-border: #e2e8f0;

    --nav-bg: #0c2233;
    --nav-bg-deep: #08192a;
    --nav-border: #16324a;
    --nav-text: #c9d8e4;
    --nav-text-muted: #86a1b6;
    --nav-hover: rgba(22, 52, 78, .7);
    --nav-active: #143450;

    --font: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-display: 'Montserrat', 'DM Sans', sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    --r-xs: 4px; --r-sm: 6px; --r: 8px; --r-lg: 12px; --r-xl: 16px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
    --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
    --shadow-lg: 0 12px 32px -8px rgba(15, 23, 42, .18), 0 4px 8px -4px rgba(15, 23, 42, .08);
    --shadow-xl: 0 24px 64px -12px rgba(15, 23, 42, .3);
    --focus-ring: 0 0 0 3px rgba(10, 133, 194, .18);

    --sidebar-w: 256px;
    --sidebar-w-collapsed: 72px;
    --header-h: 64px;
    --ease: cubic-bezier(.4, 0, .2, 1);
    --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
}

[data-theme="dark"] {
    --canvas: #0b1120;
    --surface: #111827;
    --surface-muted: #0f172a;
    --surface-sunken: #1e293b;
    --border: #1f2a3c;
    --border-strong: #334155;
    --divider: #1a2435;
    --text: #f1f5f9;
    --text-body: #cbd5e1;
    --text-muted: #94a3b8;
    --text-subtle: #64748b;
    --brand-soft: rgba(10, 133, 194, .16);
    --brand-soft-border: rgba(79, 179, 227, .35);
    --ink: #e2e8f0;
    --ink-hover: #f8fafc;
    --positive-soft: rgba(16, 185, 129, .12); --positive-border: rgba(16, 185, 129, .3); --positive-strong: #34d399;
    --negative-soft: rgba(244, 63, 94, .12);  --negative-border: rgba(244, 63, 94, .3);  --negative-strong: #fb7185;
    --pending-soft: rgba(245, 158, 11, .12);  --pending-border: rgba(245, 158, 11, .3);  --pending-strong: #fbbf24;
    --info-soft: rgba(14, 165, 233, .12);     --info-border: rgba(14, 165, 233, .3);     --info-strong: #38bdf8;
    --violet-soft: rgba(139, 92, 246, .14);   --violet-border: rgba(139, 92, 246, .3);
    --neutral-soft: #1e293b; --neutral-border: #334155;
    --nav-bg: #071827;
    --nav-bg-deep: #051220;
    --shadow-lg: 0 12px 32px -8px rgba(0, 0, 0, .5);
    --shadow-xl: 0 24px 64px -12px rgba(0, 0, 0, .6);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-body);
    background: var(--canvas);
    -webkit-font-smoothing: antialiased;
    transition: background .25s var(--ease), color .25s var(--ease);
}
h1, h2, h3, h4, h5 { font-family: var(--font-display); color: var(--text); margin: 0; letter-spacing: -.01em; }
a { color: var(--brand); text-decoration: none; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
svg.lucide { width: 18px; height: 18px; stroke-width: 1.9; flex-shrink: 0; }
.mono { font-family: var(--font-mono); font-size: 12.5px; }
.muted { color: var(--text-muted); }
.subtle { color: var(--text-subtle); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
    position: fixed; inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--nav-bg);
    border-right: 1px solid var(--nav-border);
    display: flex; flex-direction: column;
    z-index: 40;
    transition: width .28s var(--ease), transform .28s var(--ease);
}
.sidebar__brand {
    height: var(--header-h);
    display: flex; align-items: center; gap: 12px;
    padding: 0 18px;
    border-bottom: 1px solid var(--nav-border);
    flex-shrink: 0;
}
.brand-logo {
    width: 36px; height: 36px; border-radius: 10px;
    background: linear-gradient(135deg, #1a9ad6, #086c9e);
    display: grid; place-items: center;
    color: #fff; font-family: var(--font-display); font-weight: 800; font-size: 15px;
    box-shadow: 0 6px 16px -4px rgba(26, 154, 214, .6);
    flex-shrink: 0;
}
.brand-text { line-height: 1.15; white-space: nowrap; overflow: hidden; }
.brand-text strong { display: block; color: #fff; font-family: var(--font-display); font-size: 15px; }
.brand-text span { color: var(--nav-text-muted); font-size: 11.5px; }

.company-switch {
    margin: 14px 12px 6px;
    padding: 10px 12px;
    background: var(--nav-active);
    border: 1px solid #334155;
    border-radius: var(--r);
    display: flex; align-items: center; gap: 10px;
    color: #fff; width: calc(100% - 24px); text-align: left;
    transition: border-color .2s, background .2s;
    position: relative;
}
.company-switch:hover { border-color: #475569; }
.company-switch .cs-avatar {
    width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
    display: grid; place-items: center; font-weight: 700; font-size: 12px;
    background: rgba(16, 185, 129, .18); color: #34d399;
}
.company-switch .cs-text { overflow: hidden; flex: 1; min-width: 0; }
.company-switch .cs-text b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.company-switch .cs-text small { color: var(--nav-text-muted); font-size: 11px; }
.company-switch .lucide { color: var(--nav-text-muted); width: 16px; height: 16px; }

.nav { flex: 1; overflow-y: auto; padding: 8px 12px 16px; }
.nav::-webkit-scrollbar-thumb { background: #1e293b; }
.nav__label {
    font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
    color: #64748b; padding: 16px 10px 6px; white-space: nowrap;
}
.nav__item {
    display: flex; align-items: center; gap: 12px;
    padding: 9px 10px; margin: 1px 0;
    border-radius: var(--r);
    color: var(--nav-text);
    font-weight: 500; font-size: 13.5px;
    white-space: nowrap;
    position: relative;
    transition: background .18s, color .18s;
    border: 0; background: none; width: 100%; text-align: left;
}
.nav__item:hover { background: var(--nav-hover); color: #fff; }
.nav__item.is-active { background: var(--nav-active); color: #fff; }
.nav__item.is-active::before {
    content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px;
    background: #4fb3e3; border-radius: 0 3px 3px 0;
}
.nav__item .lucide { color: var(--nav-text-muted); transition: color .18s; }
.nav__item:hover .lucide, .nav__item.is-active .lucide { color: #8fd0f0; }
.nav__item .nav__text { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.nav__item .chev { width: 15px; height: 15px; transition: transform .25s var(--ease); }
.nav__group.is-open > .nav__item .chev { transform: rotate(90deg); }
.nav__badge {
    font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 999px;
    background: rgba(244, 63, 94, .18); color: #fb7185;
}
.nav__badge.is-info { background: rgba(26, 154, 214, .22); color: #8fd0f0; }
.nav__sub {
    display: grid; grid-template-rows: 0fr;
    transition: grid-template-rows .28s var(--ease);
}
.nav__group.is-open .nav__sub { grid-template-rows: 1fr; }
.nav__sub > div { overflow: hidden; }
.nav__sub a {
    display: flex; align-items: center; gap: 10px;
    padding: 7px 10px 7px 40px; margin: 1px 0;
    color: var(--nav-text-muted); font-size: 13px; border-radius: var(--r);
    white-space: nowrap; position: relative;
    transition: color .18s, background .18s;
}
.nav__sub a::before {
    content: ""; position: absolute; left: 20px; top: 50%; width: 5px; height: 5px;
    border-radius: 50%; background: #475569; transform: translateY(-50%);
    transition: background .18s, box-shadow .18s;
}
.nav__sub a:hover { color: #fff; }
.nav__sub a.is-active { color: #fff; background: rgba(26, 154, 214, .12); }
.nav__sub a.is-active::before { background: #4fb3e3; box-shadow: 0 0 0 3px rgba(79, 179, 227, .25); }

.sidebar__foot {
    border-top: 1px solid var(--nav-border); padding: 12px;
    flex-shrink: 0;
}
.ai-card {
    border-radius: var(--r-lg);
    padding: 12px;
    background: linear-gradient(135deg, rgba(26, 154, 214, .22), rgba(16, 185, 129, .12));
    border: 1px solid rgba(79, 179, 227, .25);
    color: #e2e8f0; display: flex; gap: 10px; align-items: center;
    width: 100%; text-align: left;
}
.ai-card .lucide { color: #8fd0f0; }
.ai-card b { display: block; font-size: 13px; color: #fff; }
.ai-card small { color: var(--nav-text-muted); font-size: 11.5px; }
.ai-card > div { white-space: nowrap; overflow: hidden; }

/* collapsed sidebar */
.is-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
.is-collapsed .brand-text,
.is-collapsed .nav__label,
.is-collapsed .nav__text,
.is-collapsed .nav__badge,
.is-collapsed .nav__item .chev,
.is-collapsed .cs-text,
.is-collapsed .company-switch > .lucide,
.is-collapsed .ai-card > div,
.is-collapsed .nav__sub { display: none; }
.is-collapsed .company-switch { justify-content: center; padding: 10px 0; }
.is-collapsed .nav__item { justify-content: center; }
.is-collapsed .ai-card { justify-content: center; }
.is-collapsed .main { margin-left: var(--sidebar-w-collapsed); }

.main {
    flex: 1; min-width: 0;
    margin-left: var(--sidebar-w);
    transition: margin-left .28s var(--ease);
    display: flex; flex-direction: column;
}

/* ---------- Header ---------- */
.topbar {
    position: sticky; top: 0; z-index: 30;
    height: var(--header-h);
    background: color-mix(in srgb, var(--surface) 85%, transparent);
    backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 12px;
    padding: 0 24px;
}
.icon-btn {
    width: 38px; height: 38px; border-radius: var(--r);
    display: inline-grid; place-items: center;
    border: 1px solid transparent; background: transparent; color: var(--text-muted);
    position: relative;
    transition: background .18s, color .18s, border-color .18s, transform .12s;
}
.icon-btn:hover { background: var(--surface-sunken); color: var(--text); }
.icon-btn:active { transform: scale(.94); }
.icon-btn .dot {
    position: absolute; top: 8px; right: 9px; width: 8px; height: 8px; border-radius: 50%;
    background: var(--negative); border: 2px solid var(--surface);
}
.icon-btn .dot::after {
    content: ""; position: absolute; inset: -2px; border-radius: 50%;
    border: 2px solid var(--negative); animation: ping 1.8s cubic-bezier(0, 0, .2, 1) infinite;
}
@keyframes ping { 75%, 100% { transform: scale(2.2); opacity: 0; } }

.search {
    flex: 1; max-width: 460px;
    display: flex; align-items: center; gap: 8px;
    height: 38px; padding: 0 12px;
    background: var(--surface-sunken);
    border: 1px solid transparent;
    border-radius: var(--r);
    color: var(--text-muted);
    transition: border-color .18s, background .18s, box-shadow .18s;
}
.search:focus-within { background: var(--surface); border-color: var(--brand); box-shadow: var(--focus-ring); }
.search input { border: 0; outline: 0; background: transparent; flex: 1; min-width: 0; color: var(--text); }
.search kbd {
    font-family: var(--font-mono); font-size: 11px; padding: 2px 6px; border-radius: 4px;
    background: var(--surface); border: 1px solid var(--border); color: var(--text-muted);
}
.topbar__spacer { flex: 1; }
.plant-pill {
    display: inline-flex; align-items: center; gap: 8px;
    height: 38px; padding: 0 12px; border-radius: var(--r);
    border: 1px solid var(--border); background: var(--surface);
    color: var(--text-body); font-weight: 500; font-size: 13px;
}
.plant-pill .live { width: 8px; height: 8px; border-radius: 50%; background: var(--positive); box-shadow: 0 0 0 3px var(--positive-soft); }
.user-chip {
    display: flex; align-items: center; gap: 10px;
    padding: 4px 8px 4px 4px; border-radius: 999px;
    border: 1px solid var(--border); background: var(--surface);
    transition: border-color .18s;
}
.user-chip:hover { border-color: var(--border-strong); }
.avatar {
    width: 32px; height: 32px; border-radius: 50%;
    display: grid; place-items: center;
    font-size: 12px; font-weight: 700; color: #fff;
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    flex-shrink: 0;
}
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.avatar.xs { width: 24px; height: 24px; font-size: 10px; }
.user-chip .u-text { line-height: 1.15; text-align: left; }
.user-chip .u-text b { display: block; font-size: 13px; color: var(--text); }
.user-chip .u-text small { color: var(--text-muted); font-size: 11.5px; }

/* ---------- Page ---------- */
.page { padding: 24px; max-width: 1600px; width: 100%; margin: 0 auto; }
.page-head {
    display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
    margin-bottom: 20px; flex-wrap: wrap;
}
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-muted); margin-bottom: 6px; }
.breadcrumb .lucide { width: 14px; height: 14px; }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--brand); }
.page-title { font-size: 24px; font-weight: 700; }
.page-sub { color: var(--text-muted); margin-top: 4px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 38px; padding: 0 14px;
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-body);
    font-weight: 600; font-size: 13.5px;
    white-space: nowrap;
    position: relative; overflow: hidden;
    transition: background .18s, border-color .18s, color .18s, box-shadow .18s, transform .12s;
}
.btn:hover { border-color: var(--border-strong); background: var(--surface-muted); color: var(--text); }
.btn:active { transform: translateY(1px) scale(.98); }
.btn:focus-visible { outline: 0; box-shadow: var(--focus-ring); }
.btn .lucide { width: 16px; height: 16px; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(10, 133, 194, .3), inset 0 1px 0 rgba(255,255,255,.12); }
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); color: #fff; }
.btn-ink { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.btn-ink:hover { background: var(--ink-hover); border-color: var(--ink-hover); color: var(--surface); }
.btn-success { background: var(--positive); border-color: var(--positive); color: #fff; }
.btn-success:hover { background: var(--positive-strong); border-color: var(--positive-strong); color: #fff; }
.btn-danger { background: var(--negative); border-color: var(--negative); color: #fff; }
.btn-danger:hover { background: var(--negative-strong); border-color: var(--negative-strong); color: #fff; }
.btn-soft { background: var(--brand-soft); border-color: var(--brand-soft-border); color: var(--brand); }
.btn-soft:hover { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-hover); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-sunken); border-color: transparent; }
.btn-sm { height: 32px; padding: 0 10px; font-size: 12.5px; }
.btn-xs { height: 28px; padding: 0 8px; font-size: 12px; gap: 6px; }
.btn-icon { width: 38px; padding: 0; }
.btn-sm.btn-icon { width: 32px; }
.btn-xs.btn-icon { width: 28px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
    content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
    border: 2px solid currentColor; border-color: #fff #fff transparent transparent;
    animation: spin .7s linear infinite;
}
.btn:not(.btn-primary):not(.btn-ink):not(.btn-success):not(.btn-danger).is-loading::after { border-color: var(--brand) var(--brand) transparent transparent; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ripple */
.ripple {
    position: absolute; border-radius: 50%; pointer-events: none;
    background: currentColor; opacity: .25;
    transform: scale(0); animation: ripple .6s var(--ease) forwards;
}
@keyframes ripple { to { transform: scale(4); opacity: 0; } }

.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--r-sm) 0 0 var(--r-sm); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--r-sm) var(--r-sm) 0; }

/* ---------- Cards ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
}
.card-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 16px 18px; border-bottom: 1px solid var(--divider);
}
.card-head h3 { font-size: 15px; font-weight: 700; }
.card-head p { margin: 2px 0 0; font-size: 12.5px; color: var(--text-muted); }
.card-body { padding: 18px; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--divider); }

/* ---------- Grid ---------- */
.grid { display: grid; gap: 16px; }
.grid-kpi { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.grid-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid-1-1 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }

/* ---------- KPI ---------- */
.kpi {
    padding: 16px; position: relative; overflow: hidden;
    transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .25s;
}
.kpi:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--border-strong); }
.kpi__top { display: flex; align-items: center; justify-content: space-between; }
.kpi__icon {
    width: 38px; height: 38px; border-radius: 10px;
    display: grid; place-items: center;
}
.kpi__icon .lucide { width: 19px; height: 19px; }
.kpi__label { font-size: 12.5px; color: var(--text-muted); font-weight: 500; margin-top: 14px; }
.kpi__value { font-family: var(--font-display); font-size: 24px; font-weight: 800; color: var(--text); margin-top: 2px; letter-spacing: -.02em; }
.kpi__value small { font-size: 13px; font-weight: 600; color: var(--text-muted); margin-left: 2px; }
.kpi__meta { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12px; color: var(--text-muted); }
.trend { display: inline-flex; align-items: center; gap: 2px; font-weight: 700; font-size: 12px; }
.trend .lucide { width: 14px; height: 14px; }
.trend.up { color: var(--positive); }
.trend.down { color: var(--negative); }
.kpi canvas.spark { display: block; margin-top: 10px; width: 100% !important; height: 30px !important; opacity: .9; }

.tone-brand { background: var(--brand-soft); color: var(--brand); }
.tone-positive { background: var(--positive-soft); color: var(--positive); }
.tone-negative { background: var(--negative-soft); color: var(--negative); }
.tone-pending { background: var(--pending-soft); color: var(--pending); }
.tone-info { background: var(--info-soft); color: var(--info); }
.tone-violet { background: var(--violet-soft); color: var(--violet); }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 2px 8px; border-radius: 999px;
    font-size: 11.5px; font-weight: 600; white-space: nowrap;
    border: 1px solid transparent; line-height: 1.6;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.no-dot::before { display: none; }
.badge-positive { background: var(--positive-soft); color: var(--positive-strong); border-color: var(--positive-border); }
.badge-negative { background: var(--negative-soft); color: var(--negative-strong); border-color: var(--negative-border); }
.badge-pending { background: var(--pending-soft); color: var(--pending-strong); border-color: var(--pending-border); }
.badge-info { background: var(--info-soft); color: var(--info-strong); border-color: var(--info-border); }
.badge-brand { background: var(--brand-soft); color: var(--brand); border-color: var(--brand-soft-border); }
.badge-violet { background: var(--violet-soft); color: var(--violet); border-color: var(--violet-border); }
.badge-neutral { background: var(--neutral-soft); color: var(--text-muted); border-color: var(--neutral-border); }
.badge-pulse::before { animation: pulseDot 1.6s ease-in-out infinite; }
@keyframes pulseDot { 50% { opacity: .3; } }

.chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 4px 3px 10px; border-radius: 999px;
    background: var(--brand-soft); color: var(--brand);
    border: 1px solid var(--brand-soft-border);
    font-size: 12px; font-weight: 600;
    animation: popIn .25s var(--ease-spring);
}
.chip button { border: 0; background: transparent; color: inherit; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; padding: 0; }
.chip button:hover { background: rgba(10, 133, 194, .15); }
.chip .lucide { width: 12px; height: 12px; }

/* ---------- Progress ---------- */
.progress { height: 6px; background: var(--surface-sunken); border-radius: 999px; overflow: hidden; }
.progress > span {
    display: block; height: 100%; border-radius: inherit; background: var(--brand);
    width: 0; transition: width 1s var(--ease);
}
.progress.positive > span { background: var(--positive); }
.progress.pending > span { background: var(--pending); }
.progress.negative > span { background: var(--negative); }
.progress.info > span { background: var(--info); }

/* ---------- Segmented tabs ---------- */
.segmented {
    display: inline-flex; padding: 3px; gap: 2px;
    background: var(--surface-sunken); border-radius: var(--r);
    position: relative;
}
.segmented button {
    border: 0; background: transparent; padding: 6px 12px; border-radius: var(--r-sm);
    font-size: 12.5px; font-weight: 600; color: var(--text-muted);
    position: relative; z-index: 1; transition: color .2s;
}
.segmented button.is-active { color: var(--text); }
.segmented .seg-indicator {
    position: absolute; top: 3px; bottom: 3px; left: 3px;
    background: var(--surface); border-radius: var(--r-sm); box-shadow: var(--shadow);
    transition: transform .3s var(--ease), width .3s var(--ease);
}

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); padding: 0 18px; overflow-x: auto; }
.tabs button {
    border: 0; background: transparent; padding: 12px 10px; font-weight: 600; font-size: 13px;
    color: var(--text-muted); position: relative; white-space: nowrap; display: inline-flex; gap: 8px; align-items: center;
    transition: color .2s;
}
.tabs button:hover { color: var(--text); }
.tabs button.is-active { color: var(--brand); }
.tabs button::after {
    content: ""; position: absolute; left: 6px; right: 6px; bottom: -1px; height: 2px;
    background: var(--brand); border-radius: 2px 2px 0 0; transform: scaleX(0);
    transition: transform .25s var(--ease);
}
.tabs button.is-active::after { transform: scaleX(1); }
.tabs .count {
    font-size: 11px; padding: 0 7px; border-radius: 999px; background: var(--surface-sunken); color: var(--text-muted);
    line-height: 18px;
}
.tabs button.is-active .count { background: var(--brand-soft); color: var(--brand); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-size: 12.5px; font-weight: 600; color: var(--text-body); }
.field > label .req { color: var(--negative); margin-left: 2px; }
.field .hint { font-size: 11.5px; color: var(--text-subtle); }
.field .error-text { font-size: 11.5px; color: var(--negative); display: none; }
.field.has-error .error-text { display: block; animation: shake .35s; }
.input, .select, .textarea {
    width: 100%; height: 38px; padding: 0 12px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    color: var(--text);
    outline: 0;
    transition: border-color .18s, box-shadow .18s, background .18s;
}
.textarea { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--text-subtle); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-subtle); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); box-shadow: var(--focus-ring); }
.input[readonly] { background: var(--surface-sunken); color: var(--text-muted); }
.field.has-error .input, .field.has-error .select { border-color: var(--negative); box-shadow: 0 0 0 3px rgba(225, 29, 72, .12); }
.select {
    appearance: none; padding-right: 34px; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 10px center;
}
.input-group { position: relative; display: flex; align-items: center; }
.input-group > .lucide { position: absolute; left: 11px; color: var(--text-subtle); width: 16px; height: 16px; pointer-events: none; }
.input-group > .input { padding-left: 34px; }
.input-group .addon {
    position: absolute; right: 1px; top: 1px; bottom: 1px;
    display: grid; place-items: center; padding: 0 10px;
    background: var(--surface-sunken); border-left: 1px solid var(--border);
    border-radius: 0 var(--r-sm) var(--r-sm) 0;
    font-size: 12px; font-weight: 600; color: var(--text-muted);
}
.input-group .addon + .input, .input-group .input.has-addon { padding-right: 64px; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 18px; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-3 { grid-column: 1 / -1; }
.form-section { padding: 20px 0; border-bottom: 1px dashed var(--border); }
.form-section:first-child { padding-top: 0; }
.form-section:last-child { border-bottom: 0; }
.form-section__title { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.form-section__title .num {
    width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center;
    background: var(--brand-soft); color: var(--brand); font-weight: 700; font-size: 12px;
}
.form-section__title h4 { font-size: 14px; }
.form-section__title p { margin: 0; font-size: 12px; color: var(--text-muted); }

/* checkbox / radio / switch */
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-size: 13px; }
.check input { position: absolute; opacity: 0; pointer-events: none; }
.check .box {
    width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--border-strong);
    background: var(--surface); display: grid; place-items: center; flex-shrink: 0;
    transition: background .15s, border-color .15s, transform .15s;
}
.check .box::after {
    content: ""; width: 9px; height: 5px; border-left: 2px solid #fff; border-bottom: 2px solid #fff;
    transform: rotate(-45deg) scale(0); margin-top: -2px; transition: transform .2s var(--ease-spring);
}
.check input:checked + .box { background: var(--brand); border-color: var(--brand); }
.check input:checked + .box::after { transform: rotate(-45deg) scale(1); }
.check input:indeterminate + .box { background: var(--brand); border-color: var(--brand); }
.check input:indeterminate + .box::after { border-left: 0; width: 8px; height: 0; transform: none; margin: 0; }
.check:active .box { transform: scale(.9); }
.check input:focus-visible + .box { box-shadow: var(--focus-ring); }
.radio .box { border-radius: 50%; }
.radio .box::after { width: 8px; height: 8px; border: 0; border-radius: 50%; background: #fff; transform: scale(0); margin: 0; }
.radio input:checked + .box::after { transform: scale(1); }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13px; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track {
    width: 38px; height: 22px; border-radius: 999px; background: var(--border-strong);
    position: relative; transition: background .2s; flex-shrink: 0;
}
.switch .track::after {
    content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
    background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .25s var(--ease-spring);
}
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(16px); }

.radio-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.radio-card { position: relative; cursor: pointer; }
.radio-card input { position: absolute; opacity: 0; }
.radio-card .rc-body {
    border: 1.5px solid var(--border); border-radius: var(--r); padding: 10px 12px;
    display: flex; align-items: center; gap: 10px; transition: border-color .18s, background .18s, box-shadow .18s;
}
.radio-card .rc-body b { display: block; font-size: 13px; color: var(--text); }
.radio-card .rc-body small { color: var(--text-muted); font-size: 11.5px; }
.radio-card input:checked + .rc-body { border-color: var(--brand); background: var(--brand-soft); box-shadow: var(--focus-ring); }
.radio-card .rc-icon { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; }

/* file drop */
.dropzone {
    border: 1.5px dashed var(--border-strong); border-radius: var(--r);
    padding: 22px; text-align: center; color: var(--text-muted);
    transition: border-color .2s, background .2s; cursor: pointer;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.dropzone .lucide { width: 28px; height: 28px; margin-bottom: 6px; }
.dropzone b { color: var(--text); }

/* range */
.range { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 999px; background: var(--surface-sunken); outline: none; }
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--surface); border: 3px solid var(--brand); cursor: pointer; box-shadow: var(--shadow); transition: transform .15s; }
.range::-webkit-slider-thumb:hover { transform: scale(1.15); }

/* ---------- Dropdown ---------- */
.dropdown { position: relative; }
.dropdown-menu {
    position: absolute; top: calc(100% + 6px); right: 0; min-width: 210px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
    box-shadow: var(--shadow-lg); padding: 6px; z-index: 60;
    opacity: 0; visibility: hidden; transform: translateY(-6px) scale(.98); transform-origin: top right;
    transition: opacity .18s var(--ease), transform .18s var(--ease), visibility .18s;
}
.dropdown-menu.left { right: auto; left: 0; transform-origin: top left; }
.dropdown.is-open > .dropdown-menu { opacity: 1; visibility: visible; transform: none; }
.dropdown-menu a, .dropdown-menu button.dd-item {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 8px 10px; border-radius: var(--r-sm); border: 0; background: transparent;
    color: var(--text-body); font-size: 13px; text-align: left;
    transition: background .15s, color .15s;
}
.dropdown-menu a:hover, .dropdown-menu button.dd-item:hover { background: var(--surface-sunken); color: var(--text); }
.dropdown-menu .lucide { width: 16px; height: 16px; color: var(--text-muted); }
.dropdown-menu .danger, .dropdown-menu .danger .lucide { color: var(--negative); }
.dropdown-menu .danger:hover { background: var(--negative-soft) !important; }
.dropdown-menu hr { border: 0; border-top: 1px solid var(--divider); margin: 6px 0; }
.dd-head { padding: 8px 10px 6px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-subtle); }

/* notification panel */
.notif-menu { width: 360px; padding: 0; }
.notif-menu .nm-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--divider); }
.notif-menu .nm-head b { color: var(--text); font-family: var(--font-display); }
.notif-list { max-height: 360px; overflow-y: auto; }
.notif {
    display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--divider);
    transition: background .15s; position: relative;
}
.notif:hover { background: var(--surface-muted); }
.notif.unread::after { content: ""; position: absolute; right: 16px; top: 18px; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }
.notif .n-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.notif .n-icon .lucide { width: 16px; height: 16px; }
.notif p { margin: 0; font-size: 13px; color: var(--text-body); padding-right: 14px; }
.notif p b { color: var(--text); }
.notif small { color: var(--text-subtle); font-size: 11.5px; }

/* ---------- Table ---------- */
.toolbar {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 14px 18px;
}
.toolbar .search { max-width: 320px; background: var(--surface); border-color: var(--border-strong); }
.toolbar .grow { flex: 1; }
.table-wrap { overflow-x: auto; position: relative; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.table th {
    position: sticky; top: 0; z-index: 1;
    background: var(--surface-muted); color: var(--text-muted);
    font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
    text-align: left; padding: 11px 14px; white-space: nowrap;
    border-top: 1px solid var(--divider); border-bottom: 1px solid var(--border);
    user-select: none;
}
.table th.sortable { cursor: pointer; transition: color .15s; }
.table th.sortable:hover { color: var(--text); }
.table th .sort-ico { display: inline-flex; vertical-align: middle; margin-left: 4px; opacity: .35; transition: opacity .15s, transform .2s; }
.table th .sort-ico .lucide { width: 13px; height: 13px; }
.table th.is-sorted { color: var(--brand); }
.table th.is-sorted .sort-ico { opacity: 1; }
.table th.is-sorted.desc .sort-ico { transform: rotate(180deg); }
.table td {
    padding: 12px 14px; border-bottom: 1px solid var(--divider); color: var(--text-body);
    vertical-align: middle; white-space: nowrap;
    transition: background .15s;
}
.table tbody tr { transition: background .15s; }
.table tbody tr:hover td { background: var(--surface-muted); }
.table tbody tr.is-selected td { background: var(--brand-soft); }
.table tbody tr.row-enter { animation: rowIn .4s var(--ease) both; }
.table tbody tr.row-flash td { animation: rowFlash 1.6s var(--ease); }
.table tbody tr.row-leave { animation: rowOut .35s var(--ease) forwards; }
@keyframes rowIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes rowFlash { 0%, 40% { background: var(--positive-soft); } 100% { background: transparent; } }
@keyframes rowOut { to { opacity: 0; transform: translateX(24px); } }
.table td.w-check, .table th.w-check { width: 44px; padding-right: 0; }
.cell-main { display: flex; align-items: center; gap: 10px; }
.cell-main b { color: var(--text); font-weight: 600; display: block; }
.cell-main small { color: var(--text-muted); font-size: 12px; }
.link-strong { color: var(--brand); font-weight: 700; font-family: var(--font-mono); font-size: 12.5px; }
.link-strong:hover { text-decoration: underline; }
.qty-bar { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.qty-bar .progress { flex: 1; }
.qty-bar > span { font-size: 12px; color: var(--text-muted); font-weight: 600; min-width: 34px; text-align: right; }
.row-actions { display: flex; gap: 2px; justify-content: flex-end; opacity: .65; transition: opacity .15s; }
.table tbody tr:hover .row-actions { opacity: 1; }
.row-actions .btn { color: var(--text-muted); }
.row-actions .btn:hover { color: var(--brand); }
.row-actions .btn.del:hover { color: var(--negative); background: var(--negative-soft); }

/* bulk bar */
.bulk-bar {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 18px; background: var(--brand-soft); border-top: 1px solid var(--brand-soft-border);
    color: var(--brand); font-weight: 600; font-size: 13px;
    animation: slideDown .25s var(--ease);
}
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } }

/* empty */
.empty { text-align: center; padding: 56px 20px; }
.empty .e-icon {
    width: 64px; height: 64px; border-radius: 18px; margin: 0 auto 14px;
    display: grid; place-items: center; background: var(--surface-sunken); color: var(--text-subtle);
    animation: float 3s ease-in-out infinite;
}
.empty .e-icon .lucide { width: 28px; height: 28px; }
.empty h4 { font-size: 15px; margin-bottom: 4px; }
.empty p { color: var(--text-muted); margin: 0 0 14px; }
@keyframes float { 50% { transform: translateY(-6px); } }

/* skeleton */
.skel {
    display: block; height: 12px; border-radius: 6px;
    background: linear-gradient(90deg, var(--surface-sunken) 0%, var(--border) 50%, var(--surface-sunken) 100%);
    background-size: 200% 100%; animation: shimmer 1.2s linear infinite;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* pagination */
.pager {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    padding: 12px 18px; border-top: 1px solid var(--divider); font-size: 13px; color: var(--text-muted);
}
.pager .pages { display: flex; gap: 4px; align-items: center; }
.pager .pages button {
    min-width: 32px; height: 32px; padding: 0 8px; border-radius: var(--r-sm);
    border: 1px solid var(--border); background: var(--surface); color: var(--text-body); font-weight: 600; font-size: 12.5px;
    display: inline-grid; place-items: center;
    transition: background .15s, border-color .15s, color .15s, transform .12s;
}
.pager .pages button:hover:not([disabled]) { border-color: var(--brand); color: var(--brand); }
.pager .pages button:active { transform: scale(.94); }
.pager .pages button.is-active { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 2px 6px -1px rgba(10, 133, 194,.45); }
.pager .pages button[disabled] { opacity: .45; cursor: not-allowed; }
.pager .pages .lucide { width: 15px; height: 15px; }
.pager .per-page { display: flex; align-items: center; gap: 8px; }
.pager .per-page .select { height: 32px; width: auto; font-size: 12.5px; }

/* ---------- Filter panel ---------- */
.filter-panel {
    display: grid; grid-template-rows: 0fr; transition: grid-template-rows .3s var(--ease);
    border-top: 1px solid transparent;
}
.filter-panel.is-open { grid-template-rows: 1fr; border-top-color: var(--divider); }
.filter-panel > div { overflow: hidden; }
.filter-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; padding: 16px 18px; background: var(--surface-muted); }
.filter-actions { display: flex; gap: 8px; align-items: flex-end; }
.active-filters { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; padding: 0 18px 12px; }
.active-filters:empty { display: none; }

/* ---------- Status summary tiles (list page) ---------- */
.status-tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.s-tile {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
    padding: 14px 16px; display: flex; align-items: center; gap: 12px; cursor: pointer; text-align: left;
    transition: border-color .2s, box-shadow .2s, transform .2s;
}
.s-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.s-tile.is-active { border-color: var(--brand); box-shadow: var(--focus-ring); }
.s-tile .st-icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; }
.s-tile b { font-family: var(--font-display); font-size: 20px; color: var(--text); display: block; line-height: 1.1; }
.s-tile small { color: var(--text-muted); font-size: 12px; }

/* ---------- Modal / Drawer ---------- */
.overlay {
    position: fixed; inset: 0; background: rgba(15, 23, 42, .5); backdrop-filter: blur(3px);
    z-index: 80; opacity: 0; visibility: hidden; transition: opacity .25s var(--ease), visibility .25s;
}
.overlay.is-open { opacity: 1; visibility: visible; }

.drawer {
    position: fixed; top: 0; right: 0; bottom: 0; width: min(920px, 100vw);
    background: var(--surface); z-index: 90; box-shadow: var(--shadow-xl);
    display: flex; flex-direction: column;
    transform: translateX(100%); transition: transform .38s var(--ease);
}
.drawer.sm { width: min(520px, 100vw); }
.drawer.is-open { transform: none; }
.drawer__head { display: flex; align-items: center; gap: 14px; padding: 18px 24px; border-bottom: 1px solid var(--border); }
.drawer__head .dh-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; }
.drawer__head h3 { font-size: 17px; }
.drawer__head p { margin: 2px 0 0; color: var(--text-muted); font-size: 12.5px; }
.drawer__body { flex: 1; overflow-y: auto; padding: 22px 24px; }
.drawer__foot { display: flex; align-items: center; gap: 8px; padding: 14px 24px; border-top: 1px solid var(--border); background: var(--surface-muted); }
.drawer__foot .grow { flex: 1; }

.modal {
    position: fixed; inset: 0; z-index: 95; display: grid; place-items: center; padding: 16px;
    pointer-events: none;
}
.modal__box {
    width: min(440px, 100%); background: var(--surface); border-radius: var(--r-xl);
    box-shadow: var(--shadow-xl); padding: 24px; text-align: center;
    opacity: 0; transform: translateY(16px) scale(.96);
    transition: opacity .25s var(--ease), transform .3s var(--ease-spring);
    pointer-events: none;
}
.modal.is-open .modal__box { opacity: 1; transform: none; pointer-events: auto; }
.modal__icon { width: 56px; height: 56px; border-radius: 50%; margin: 0 auto 14px; display: grid; place-items: center; }
.modal__icon .lucide { width: 26px; height: 26px; }
.modal__box h3 { font-size: 18px; margin-bottom: 6px; }
.modal__box p { color: var(--text-muted); margin: 0 0 20px; }
.modal__actions { display: flex; gap: 10px; justify-content: center; }
.modal__actions .btn { flex: 1; }

/* ---------- Toast ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 120; display: flex; flex-direction: column; gap: 10px; }
.toast {
    display: flex; gap: 12px; align-items: flex-start;
    width: 360px; max-width: calc(100vw - 40px);
    padding: 14px 14px 16px; border-radius: var(--r-lg);
    background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
    position: relative; overflow: hidden;
    animation: toastIn .4s var(--ease-spring);
}
.toast.leaving { animation: toastOut .3s var(--ease) forwards; }
.toast .t-icon { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; }
.toast .t-icon .lucide { width: 16px; height: 16px; }
.toast b { display: block; color: var(--text); font-size: 13.5px; }
.toast p { margin: 2px 0 0; color: var(--text-muted); font-size: 12.5px; }
.toast .t-close { margin-left: auto; border: 0; background: transparent; color: var(--text-subtle); padding: 2px; }
.toast .t-bar { position: absolute; left: 0; bottom: 0; height: 3px; background: currentColor; animation: toastBar linear forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(40px) scale(.95); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(40px); } }
@keyframes toastBar { from { width: 100%; } to { width: 0; } }

/* tooltip */
[data-tip] { position: relative; }
[data-tip]::after {
    content: attr(data-tip); position: absolute; bottom: calc(100% + 8px); left: 50%;
    transform: translateX(-50%) translateY(4px);
    background: #0f172a; color: #fff; font-size: 11.5px; font-weight: 500; padding: 5px 8px; border-radius: 6px;
    white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .15s, transform .15s; z-index: 70;
}
[data-tip]:hover::after { opacity: 1; transform: translateX(-50%); }

/* ---------- Dashboard specifics ---------- */
.welcome {
    border-radius: var(--r-xl); padding: 22px 24px; margin-bottom: 16px;
    background: radial-gradient(1200px 300px at 0% 0%, rgba(26, 154, 214, .35), transparent 60%),
                radial-gradient(800px 300px at 100% 100%, rgba(16, 185, 129, .25), transparent 60%),
                linear-gradient(135deg, #0f172a, #0c3550);
    color: #e2e8f0; display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
    position: relative; overflow: hidden;
}
.welcome::after {
    content: ""; position: absolute; right: -60px; top: -60px; width: 240px; height: 240px; border-radius: 50%;
    border: 40px solid rgba(255, 255, 255, .04);
}
.welcome h2 { color: #fff; font-size: 22px; }
.welcome p { margin: 4px 0 0; color: #8fd0f0; }
.welcome .w-stats { display: flex; gap: 28px; margin-left: auto; position: relative; z-index: 1; flex-wrap: wrap; }
.welcome .w-stats div b { display: block; font-family: var(--font-display); font-size: 22px; color: #fff; }
.welcome .w-stats div small { color: #94a3b8; font-size: 12px; }
.welcome .btn { position: relative; z-index: 1; }

.chart-box { position: relative; height: 290px; }
.chart-box.sm { height: 220px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

.tank-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.tank {
    border: 1px solid var(--border); border-radius: var(--r); padding: 10px; position: relative; overflow: hidden;
    background: var(--surface); cursor: pointer; transition: transform .2s var(--ease), box-shadow .2s;
}
.tank:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.tank .t-fill {
    position: absolute; left: 0; right: 0; bottom: 0; height: 0;
    transition: height 1.2s var(--ease); opacity: .16;
}
.tank .t-fill::before {
    content: ""; position: absolute; left: -50%; top: -6px; width: 200%; height: 12px;
    background: radial-gradient(ellipse at center, currentColor 40%, transparent 41%) 0 0 / 24px 12px repeat-x;
    animation: wave 3s linear infinite;
}
@keyframes wave { to { transform: translateX(24px); } }
.tank > * { position: relative; }
.tank .t-no { font-weight: 700; color: var(--text); font-size: 13px; display: flex; justify-content: space-between; align-items: center; }
.tank .t-day { font-family: var(--font-display); font-size: 18px; font-weight: 800; color: var(--text); margin-top: 8px; }
.tank .t-day small { font-size: 11px; color: var(--text-muted); font-weight: 600; }
.tank .t-meta { font-size: 11px; color: var(--text-muted); }
.tank.curing { color: var(--info); }
.tank.ready { color: var(--positive); }
.tank.overdue { color: var(--negative); }
.tank.free { color: var(--text-subtle); }
.tank.maint { color: var(--pending); }
.tank .t-fill { background: currentColor; }
.tank.ready { border-color: var(--positive-border); }
.tank.overdue { border-color: var(--negative-border); animation: glow 2s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 0 4px var(--negative-soft); } }

.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--divider); transition: background .15s; }
.list-row:last-child { border-bottom: 0; }
.list-row:hover { background: var(--surface-muted); }
.list-row .lr-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.list-row .lr-icon .lucide { width: 17px; height: 17px; }
.list-row .lr-main { flex: 1; min-width: 0; }
.list-row .lr-main b { display: block; color: var(--text); font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row .lr-main small { color: var(--text-muted); font-size: 12px; }
.list-row .lr-actions { display: flex; gap: 6px; }
.list-row.leaving { animation: rowOut .35s var(--ease) forwards; }

.stage-track { display: flex; align-items: flex-start; gap: 0; overflow-x: auto; padding: 4px 0 6px; }
.stage { flex: 1; min-width: 54px; text-align: center; position: relative; }
.stage::before {
    content: ""; position: absolute; top: 16px; left: -50%; right: 50%; height: 3px; background: var(--surface-sunken); z-index: 0;
}
.stage:first-child::before { display: none; }
.stage.done::before, .stage.active::before { background: var(--positive); }
.stage .s-dot {
    width: 34px; height: 34px; border-radius: 50%; margin: 0 auto 8px; position: relative; z-index: 1;
    display: grid; place-items: center; background: var(--surface); border: 2px solid var(--border-strong); color: var(--text-subtle);
}
.stage .s-dot .lucide { width: 15px; height: 15px; }
.stage.done .s-dot { background: var(--positive); border-color: var(--positive); color: #fff; }
.stage.active .s-dot { border-color: var(--brand); color: var(--brand); box-shadow: 0 0 0 5px var(--brand-soft); animation: pulseRing 2s infinite; }
.stage.hold .s-dot { border-color: var(--pending); color: var(--pending); background: var(--pending-soft); }
@keyframes pulseRing { 50% { box-shadow: 0 0 0 9px transparent; } }
.stage b { display: block; font-size: 11.5px; color: var(--text); font-weight: 600; }
.stage small { font-size: 11px; color: var(--text-muted); }

.quick-actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 10px; }
.qa {
    border: 1px solid var(--border); border-radius: var(--r); padding: 14px 8px; text-align: center; background: var(--surface);
    color: var(--text-body); font-size: 12px; font-weight: 600; transition: transform .2s var(--ease), border-color .2s, box-shadow .2s;
}
.qa:hover { transform: translateY(-3px); border-color: var(--brand-soft-border); box-shadow: var(--shadow-lg); color: var(--brand); }
.qa .qa-icon { width: 38px; height: 38px; border-radius: 10px; margin: 0 auto 8px; display: grid; place-items: center; transition: transform .3s var(--ease-spring); }
.qa:hover .qa-icon { transform: scale(1.12) rotate(-6deg); }

/* view drawer details */
.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.detail-grid dt { font-size: 11.5px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.detail-grid dd { margin: 4px 0 0; color: var(--text); font-weight: 600; }
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ""; position: absolute; left: 9px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding-bottom: 18px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before {
    content: ""; position: absolute; left: -22px; top: 4px; width: 12px; height: 12px; border-radius: 50%;
    background: var(--surface); border: 2px solid var(--brand);
}
.tl-item.ok::before { border-color: var(--positive); background: var(--positive); }
.tl-item.wait::before { border-color: var(--pending); }
.tl-item b { color: var(--text); font-size: 13px; }
.tl-item p { margin: 2px 0 0; color: var(--text-muted); font-size: 12.5px; }

.mat-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.mat-table th { text-align: left; font-size: 11.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; padding: 9px 10px; background: var(--surface-muted); border-bottom: 1px solid var(--border); }
.mat-table td { padding: 9px 10px; border-bottom: 1px solid var(--divider); }
.mat-table tr.short td { background: var(--negative-soft); }
.alert {
    display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r);
    border: 1px solid; font-size: 13px; animation: popIn .3s var(--ease);
}
.alert .lucide { width: 18px; height: 18px; margin-top: 1px; }
.alert b { display: block; }
.alert-warn { background: var(--pending-soft); border-color: var(--pending-border); color: var(--pending-strong); }
.alert-info { background: var(--info-soft); border-color: var(--info-border); color: var(--info-strong); }
.alert-ok { background: var(--positive-soft); border-color: var(--positive-border); color: var(--positive-strong); }

/* entrance animations */
.reveal { opacity: 0; transform: translateY(14px); animation: reveal .55s var(--ease) forwards; }
@keyframes reveal { to { opacity: 1; transform: none; } }
@keyframes popIn { from { opacity: 0; transform: scale(.9); } }

/* stepper */
.stepper { display: flex; gap: 8px; margin-bottom: 20px; }
.step-pill {
    flex: 1; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--r);
    background: var(--surface-muted); border: 1px solid var(--border); cursor: pointer; transition: all .2s;
    text-align: left;
}
.step-pill .sp-num { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--surface); border: 1.5px solid var(--border-strong); color: var(--text-muted); flex-shrink: 0; transition: all .2s; }
.step-pill b { font-size: 12.5px; color: var(--text); display: block; }
.step-pill small { font-size: 11px; color: var(--text-muted); }
.step-pill.is-active { border-color: var(--brand); background: var(--brand-soft); }
.step-pill.is-active .sp-num { background: var(--brand); border-color: var(--brand); color: #fff; }
.step-pill.is-done .sp-num { background: var(--positive); border-color: var(--positive); color: #fff; }
.step-panel { display: none; }
.step-panel.is-active { display: block; animation: stepIn .35s var(--ease); }
@keyframes stepIn { from { opacity: 0; transform: translateX(16px); } }

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth__art {
    position: relative; overflow: hidden; padding: 48px; color: #e2e8f0;
    background: radial-gradient(900px 500px at 10% 10%, rgba(26, 154, 214, .45), transparent 60%),
                radial-gradient(700px 500px at 90% 90%, rgba(16, 185, 129, .3), transparent 60%),
                linear-gradient(160deg, #0b1222, #0c3550);
    display: flex; flex-direction: column;
}
.auth__art .grid-bg {
    position: absolute; inset: 0; opacity: .12;
    background-image: linear-gradient(#94a3b8 1px, transparent 1px), linear-gradient(90deg, #94a3b8 1px, transparent 1px);
    background-size: 44px 44px; mask-image: radial-gradient(circle at 30% 40%, #000, transparent 70%);
}
.auth__art > * { position: relative; }
.auth__art h1 { color: #fff; font-size: 40px; line-height: 1.15; margin-top: auto; max-width: 520px; }
.auth__art h1 span { background: linear-gradient(90deg, #8fd0f0, #6ee7b7); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth__art p { color: #94a3b8; max-width: 480px; font-size: 15px; }
.auth__feat { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 28px; max-width: 520px; }
.auth__feat div {
    display: flex; gap: 10px; align-items: center; padding: 12px; border-radius: var(--r);
    background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .08); font-size: 13px;
    backdrop-filter: blur(6px);
}
.auth__feat .lucide { color: #8fd0f0; }
.float-card {
    position: absolute; background: rgba(15, 23, 42, .7); border: 1px solid rgba(255,255,255,.1);
    border-radius: 14px; padding: 12px 14px; backdrop-filter: blur(10px); box-shadow: 0 20px 40px -12px rgba(0,0,0,.5);
    animation: float 5s ease-in-out infinite; font-size: 12px;
}
.float-card b { color: #fff; font-size: 18px; font-family: var(--font-display); display: block; }
.auth__form { display: grid; place-items: center; padding: 40px 24px; background: var(--surface); }
.auth__box { width: min(400px, 100%); }
.auth__box h2 { font-size: 26px; }
.auth__box .sub { color: var(--text-muted); margin: 6px 0 26px; }
.auth__box .field { margin-bottom: 16px; }
.co-select { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.divider-text { display: flex; align-items: center; gap: 12px; color: var(--text-subtle); font-size: 12px; margin: 20px 0; }
.divider-text::before, .divider-text::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.otp { display: flex; gap: 10px; justify-content: space-between; }
.otp input { width: 52px; height: 56px; text-align: center; font-size: 22px; font-weight: 700; font-family: var(--font-display); padding: 0; }

/* ---------- Responsive ---------- */
.mobile-only { display: none; }
@media (max-width: 1400px) {
    .grid-kpi { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .filter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
    .grid-2-1, .grid-1-1, .grid-3 { grid-template-columns: 1fr; }
    .status-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .tank-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .auth { grid-template-columns: 1fr; }
    .auth__art { display: none; }
}
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); width: var(--sidebar-w) !important; }
    .sidebar-open .sidebar { transform: none; }
    .main, .is-collapsed .main { margin-left: 0; }
    .mobile-only { display: inline-grid; }
    .desktop-only { display: none !important; }
    .is-collapsed .brand-text, .is-collapsed .nav__label, .is-collapsed .nav__text, .is-collapsed .cs-text { display: block; }
    .sidebar-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 35; opacity: 0; visibility: hidden; transition: opacity .25s; }
    .sidebar-open .sidebar-backdrop { opacity: 1; visibility: visible; }
}
@media (max-width: 640px) {
    .page { padding: 16px; }
    .topbar { padding: 0 16px; }
    .grid-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .status-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .filter-grid { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .span-2 { grid-column: auto; }
    .tank-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .detail-grid { grid-template-columns: repeat(2, 1fr); }
    .quick-actions { grid-template-columns: repeat(2, 1fr); }
    .radio-cards { grid-template-columns: 1fr; }
    .stepper { flex-direction: column; }
    .user-chip .u-text { display: none; }
    .welcome .w-stats { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* sticky actions column on wide data grids */
#grid th, #grid td { padding-left: 12px; padding-right: 12px; }
#grid th:last-child, #grid td:last-child { position: sticky; right: 0; z-index: 2; }
#grid td:last-child { background: var(--surface); box-shadow: -10px 0 12px -10px rgba(15, 23, 42, .18); }
#grid th:last-child { box-shadow: -10px 0 12px -10px rgba(15, 23, 42, .18); }
#grid tbody tr.is-selected td:last-child { background: var(--brand-soft); }
#grid td:last-child:has(.dropdown.is-open) { z-index: 6; }

/* off-canvas drawers: no shadow bleeding in from the edge while closed */
.drawer { box-shadow: none; visibility: hidden; transition: transform .38s var(--ease), visibility .38s; }
.drawer.is-open { box-shadow: var(--shadow-xl); visibility: visible; }
.search { min-width: 0; }
@media (max-width: 640px) {
    .topbar { gap: 4px; }
    .topbar .search { display: none; }
    .page-actions { width: 100%; }
}
@media (max-height: 760px) { .float-card { display: none; } }

/* ---------- Econ Antri branding ---------- */
.sidebar__brand { background: #fff; border-bottom-color: #e2e8f0; justify-content: center; padding: 0 14px; }
.sidebar__brand .brand-img { height: 46px; width: auto; max-width: 100%; object-fit: contain; display: block; }
.sidebar__brand .brand-text strong { color: #0c2233; }
.sidebar__brand .brand-text span { color: #64748b; }
.brand-mark { display: none; font-size: 13px; }
.is-collapsed .sidebar__brand .brand-img { display: none; }
.is-collapsed .sidebar__brand .brand-mark { display: grid; }
@media (max-width: 900px) {
    .is-collapsed .sidebar__brand .brand-img { display: block; }
    .is-collapsed .sidebar__brand .brand-mark { display: none; }
}
/* thin sky-blue accent echoing the econantri.com header bar */
.topbar::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: linear-gradient(90deg, #0099dd, #2080b0 60%, #0c3550); }
.auth__logo { height: 54px; width: auto; display: block; margin-bottom: 28px; }
