/* ==========================================================================
   DD Foods — Factory Management System
   Modern ERP design system
   ========================================================================== */

:root {
    --bg: #f4f6fa;
    --panel: #ffffff;
    --panel-soft: #f8fafc;
    --ink: #0d1a2b;
    --ink-soft: #334155;
    --muted: #64748b;
    --muted-2: #94a3b8;
    --line: #e5eaf1;
    --line-strong: #d3dbe7;

    --brand: #0d9488;
    --brand-dark: #0b7c72;
    --brand-soft: #e6f6f4;
    --accent: #0ea5e9;
    --accent-soft: #e6f4fd;
    --warn: #d97706;
    --warn-soft: #fef3c7;
    --danger: #dc2626;
    --danger-soft: #fee2e2;
    --success: #15803d;
    --success-soft: #dcfce7;

    --sidebar: #0b1526;
    --sidebar-2: #0f2033;
    --sidebar-text: #b8c6d9;
    --sidebar-active: #14b8a6;

    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 8px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
    --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 10px 30px -18px rgba(15, 23, 42, .35);
    --shadow-lg: 0 24px 60px -30px rgba(15, 23, 42, .45);
    --sidebar-w: 264px;
    --font: "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92em; background: var(--panel-soft); padding: 1px 5px; border-radius: 5px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.icon { width: 18px; height: 18px; flex: 0 0 auto; display: inline-block; vertical-align: -3px; }

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

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    z-index: 40;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 18px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 38px; height: 38px;
    border-radius: 11px;
    background: linear-gradient(135deg, #14b8a6, #0ea5e9);
    color: #04212b;
    font-weight: 800;
    font-size: 15px;
    letter-spacing: -.02em;
    flex: 0 0 auto;
}
.brand-mark--lg { width: 52px; height: 52px; border-radius: 14px; font-size: 18px; }

.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { color: #fff; font-size: 15px; letter-spacing: -.01em; }
.brand-text small { color: #7f93ab; font-size: 11.5px; letter-spacing: .02em; text-transform: uppercase; }

.sidebar__close { display: none; margin-left: auto; color: #9fb2c8; }

.sidebar__nav { flex: 1; overflow-y: auto; padding: 14px 10px 20px; }
.sidebar__nav::-webkit-scrollbar { width: 6px; }
.sidebar__nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 6px; }

.nav-group { margin-bottom: 16px; }
.nav-group__label {
    margin: 0 0 6px;
    padding: 0 10px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: #64778f;
}
.nav-group ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 11px;
    border-radius: 9px;
    color: var(--sidebar-text);
    font-size: 13.5px;
    font-weight: 500;
    transition: background .15s ease, color .15s ease;
    position: relative;
}
.nav-link .icon { width: 17px; height: 17px; opacity: .8; }
.nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-link.is-active { background: rgba(20, 184, 166, .14); color: #fff; font-weight: 600; }
.nav-link.is-active .icon { color: var(--sidebar-active); opacity: 1; }
.nav-link.is-active::before {
    content: "";
    position: absolute;
    left: -10px; top: 50%;
    transform: translateY(-50%);
    width: 3px; height: 18px;
    border-radius: 0 3px 3px 0;
    background: var(--sidebar-active);
}

.sidebar__foot { padding: 12px; border-top: 1px solid rgba(255, 255, 255, .07); }
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar {
    display: grid; place-items: center;
    width: 34px; height: 34px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .1);
    color: #fff; font-weight: 700; font-size: 13px;
    flex: 0 0 auto;
}
.user-chip__meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.user-chip__meta strong { color: #fff; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip__meta small { color: #74879f; font-size: 11px; }
.user-chip .icon-btn { color: #9fb2c8; }

.app__scrim { display: none; }

.app__main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }

/* ------------------------------------------------------------------ topbar */
.topbar {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; gap: 16px;
    padding: 12px 26px;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}
.topbar__burger { display: none; }
.topbar__title { min-width: 0; }
.topbar__title h1 { font-size: 16.5px; font-weight: 650; }
.topbar__title p { font-size: 12.5px; color: var(--muted); margin-top: 1px; }

.topbar__search {
    position: relative;
    margin-left: auto;
    width: min(380px, 34vw);
}
.topbar__search input {
    width: 100%;
    padding: 9px 12px 9px 36px;
    border: 1px solid var(--line);
    background: var(--panel-soft);
    border-radius: 10px;
    font: inherit;
    font-size: 13px;
    color: var(--ink);
    transition: border-color .15s, background .15s, box-shadow .15s;
}
.topbar__search input:focus {
    outline: none;
    border-color: var(--brand);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(13, 148, 136, .12);
}
.topbar__search-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted-2); }
.topbar__search-icon .icon { width: 16px; height: 16px; }

.topbar__actions { display: flex; align-items: center; gap: 8px; }

.content { padding: 22px 26px 40px; flex: 1; width: 100%; max-width: 1600px; }

.mobile-nav { display: none; }

/* ----------------------------------------------------------------- buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 15px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: var(--brand);
    color: #fff;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, border-color .15s, transform .06s, box-shadow .15s;
    white-space: nowrap;
    box-shadow: 0 1px 1px rgba(13, 148, 136, .18);
}
.btn:hover { background: var(--brand-dark); }
.btn:active { transform: translateY(1px); }
.btn .icon { width: 16px; height: 16px; }
.btn--ghost { background: #fff; border-color: var(--line-strong); color: var(--ink-soft); box-shadow: none; }
.btn--ghost:hover { background: var(--panel-soft); border-color: var(--muted-2); }
.btn--sm { padding: 7px 11px; font-size: 12.5px; border-radius: 9px; }
.btn--lg { padding: 12px 20px; font-size: 14px; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 34px; height: 34px;
    border-radius: 9px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { background: var(--panel-soft); color: var(--ink); border-color: var(--line); }
.icon-btn .icon { width: 17px; height: 17px; }

.link { color: var(--brand-dark); font-weight: 600; font-size: 12.5px; }
.link:hover { text-decoration: underline; }

.inline-form { display: inline; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 10px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.block { display: block; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.strong { font-weight: 700; }

/* --------------------------------------------------------------- page head */
.page-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 16px; flex-wrap: wrap;
    margin-bottom: 18px;
}
.page-head h2 { font-size: 21px; letter-spacing: -.015em; }
.page-head p { color: var(--muted); font-size: 13px; margin-top: 3px; }
.page-head__actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* -------------------------------------------------------------------- hero */
.hero {
    display: flex; align-items: center; justify-content: space-between;
    gap: 24px;
    padding: 24px 26px;
    border-radius: var(--radius);
    background:
        radial-gradient(900px 300px at 88% -10%, rgba(20, 184, 166, .35), transparent 60%),
        linear-gradient(120deg, #0b1526, #123049 65%, #0d3d47);
    color: #e6eef7;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    position: relative;
    margin-bottom: 16px;
}
.hero::after {
    content: "";
    position: absolute; right: -60px; bottom: -90px;
    width: 260px; height: 260px; border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, .09);
}
.hero__eyebrow { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: #7dd3c7; font-weight: 700; }
.hero__text h2 { font-size: 24px; margin: 6px 0 6px; color: #fff; }
.hero__text p { color: #a9bed2; font-size: 13px; max-width: 62ch; }
.hero__stats { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 14px; font-size: 12.5px; color: #93a9bf; }
.hero__stats strong { color: #fff; font-variant-numeric: tabular-nums; }
.hero__figure {
    text-align: right; padding-left: 24px; border-left: 1px solid rgba(255, 255, 255, .12);
    flex: 0 0 auto;
}
.hero__figure-label { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: #7dd3c7; font-weight: 700; }
.hero__figure strong { display: block; font-size: 38px; line-height: 1.1; color: #fff; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.hero__figure-meta { font-size: 12px; color: #8fa6bd; }

/* -------------------------------------------------------------------- KPIs */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 12px;
    margin: 16px 0;
}
.kpi {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-areas: "icon label" "icon value" "icon meta";
    column-gap: 12px;
    align-items: center;
    padding: 16px 16px 14px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: box-shadow .18s, transform .18s, border-color .18s;
    min-height: 92px;
}
a.kpi:hover { box-shadow: var(--shadow); transform: translateY(-1px); border-color: var(--line-strong); }
.kpi__icon {
    grid-area: icon;
    display: grid; place-items: center;
    width: 38px; height: 38px;
    border-radius: 11px;
    background: var(--brand-soft);
    color: var(--brand-dark);
}
.kpi__icon .icon { width: 19px; height: 19px; }
.kpi__label { grid-area: label; font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .01em; }
.kpi__value { grid-area: value; font-size: 23px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.25; }
.kpi__meta { grid-area: meta; font-size: 11.5px; color: var(--muted-2); }
.kpi--in .kpi__icon { background: var(--brand-soft); color: var(--brand-dark); }
.kpi--out .kpi__icon { background: var(--warn-soft); color: var(--warn); }
.kpi--warn .kpi__icon { background: var(--warn-soft); color: var(--warn); }
.kpi--ink .kpi__icon { background: #eef2f7; color: var(--ink-soft); }

/* ------------------------------------------------------------------- cards */
.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.card + .card { margin-top: 16px; }
.card__head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, #fff, #fcfdfe);
}
.card__head h3 { font-size: 14px; font-weight: 650; }
.card__actions { display: flex; align-items: center; gap: 8px; }
.card__body { padding: 18px; }
.card__body > *:first-child { margin-top: 0; }
.card__body > *:last-child { margin-bottom: 0; }

.grid { display: grid; gap: 16px; margin-bottom: 16px; }
.grid--2 { grid-template-columns: 1.35fr 1fr; }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--sidebar { grid-template-columns: 1.6fr 1fr; align-items: start; }
.grid > .card + .card, .grid .stack > .card + .card { margin-top: 0; }

.chart-box { position: relative; width: 100%; }

/* --------------------------------------------------------- range / filters */
.range-bar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; flex-wrap: wrap;
    padding: 10px 12px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
}
.range-chips { display: flex; gap: 4px; flex-wrap: wrap; }
.chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 11px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 550;
    color: var(--ink-soft);
    border: 1px solid transparent;
    transition: background .15s, color .15s, border-color .15s;
}
.chip:hover { background: var(--panel-soft); border-color: var(--line); }
.chip.is-active { background: var(--brand-soft); color: var(--brand-dark); border-color: rgba(13, 148, 136, .25); font-weight: 650; }
.chip--sm { padding: 4px 9px; font-size: 12px; border-color: var(--line); }
.chip--add { border-style: dashed; color: var(--brand-dark); }

.range-custom { display: flex; align-items: center; gap: 8px; }
.range-custom input[type="date"] {
    font: inherit; font-size: 12.5px;
    padding: 6px 9px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
}
.range-custom__sep { color: var(--muted-2); }
.range-note { margin: 10px 2px 14px; font-size: 12.5px; color: var(--muted); }
.range-note strong { color: var(--ink-soft); }

.filter-bar {
    display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap;
    padding: 14px 16px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 14px;
}
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field--grow { flex: 1 1 220px; }
.field--action { flex-direction: row; align-items: center; gap: 8px; }
.field label, .mobile-label {
    font-size: 11.5px; font-weight: 650; color: var(--ink-soft);
    letter-spacing: .01em;
}
.req { color: var(--danger); }
.hint { font-size: 11.5px; color: var(--muted-2); margin-top: 6px; }

input[type="text"], input[type="search"], input[type="date"], input[type="number"],
input[type="password"], input[type="email"], select, textarea {
    width: 100%;
    padding: 9px 11px;
    font: inherit;
    font-size: 13.5px;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--line-strong);
    border-radius: 9px;
    transition: border-color .15s, box-shadow .15s;
    min-height: 38px;
}
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 17px, calc(100% - 11px) 17px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, .12);
}
.input--readonly { background: var(--panel-soft); color: var(--muted); }

.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.form-grid .field--full { grid-column: 1 / -1; }

/* -------------------------------------------------------------- stat strip */
.stat-strip {
    display: flex; flex-wrap: wrap; gap: 0;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}
.stat-strip > div {
    flex: 1 1 180px;
    padding: 12px 18px;
    border-right: 1px solid var(--line);
    display: flex; flex-direction: column; gap: 2px;
}
.stat-strip > div:last-child { border-right: 0; }
.stat-strip span { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.stat-strip strong { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }

/* ------------------------------------------------------------------ tables */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th {
    font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
    color: var(--muted); font-weight: 700;
    background: var(--panel-soft);
    position: sticky; top: 0; z-index: 1;
    white-space: nowrap;
}
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: #fbfdff; }
.table tbody tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table--compact th, .table--compact td { padding: 9px 10px; }
.table .actions-col { width: 1%; white-space: nowrap; }
.row-actions { display: flex; gap: 2px; justify-content: flex-end; align-items: center; }

/* ------------------------------------------------------------------ badges */
.badge {
    display: inline-flex; align-items: center;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11px; font-weight: 650;
    letter-spacing: .01em;
    white-space: nowrap;
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-warning { background: var(--warn-soft); color: var(--warn); }
.badge-neutral { background: #eef2f7; color: var(--ink-soft); }

.pill {
    display: inline-block; padding: 2px 8px; border-radius: 6px;
    font-size: 10.5px; font-weight: 800; letter-spacing: .06em;
}
.pill--in { background: var(--brand-soft); color: var(--brand-dark); }
.pill--out { background: var(--warn-soft); color: var(--warn); }
.tag { font-size: 11px; padding: 1px 6px; border-radius: 5px; font-weight: 600; }
.tag--muted { background: #eef2f7; color: var(--muted); }

/* ------------------------------------------------------------------- lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
    font-size: 13px;
}
.list li:last-child { border-bottom: 0; }
.list li > div { display: flex; flex-direction: column; min-width: 0; }
.list li .muted { font-size: 11.5px; }
.list__meta { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--muted); }

.check-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.check-list li { display: flex; gap: 9px; align-items: flex-start; font-size: 13px; color: var(--ink-soft); }
.check-list .icon { width: 16px; height: 16px; margin-top: 2px; }
.check-list .is-ok .icon { color: var(--success); }
.check-list .is-warn .icon { color: var(--warn); }

.detail-list { display: grid; gap: 12px; margin: 0; }
.detail-list > div { display: grid; grid-template-columns: 120px 1fr; gap: 12px; }
.detail-list dt { font-size: 12px; color: var(--muted); font-weight: 600; }
.detail-list dd { margin: 0; font-size: 13.5px; }

/* ------------------------------------------------------------------- empty */
.empty { text-align: center; padding: 34px 20px; }
.empty__icon {
    display: inline-grid; place-items: center;
    width: 48px; height: 48px; border-radius: 14px;
    background: var(--panel-soft); color: var(--muted-2);
    margin-bottom: 12px;
}
.empty__icon .icon { width: 22px; height: 22px; }
.empty h4 { font-size: 14.5px; margin-bottom: 4px; }
.empty p { color: var(--muted); font-size: 13px; max-width: 46ch; margin: 0 auto; }
.empty__action { margin-top: 14px; }

/* ------------------------------------------------------------------ toasts */
.toast {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 14px;
    border-radius: 11px;
    margin-bottom: 14px;
    font-size: 13px;
    border: 1px solid transparent;
}
.toast .icon { width: 17px; height: 17px; flex: 0 0 auto; }
.toast--success { background: var(--success-soft); color: #14532d; border-color: #bbf7d0; }
.toast--error { background: var(--danger-soft); color: #7f1d1d; border-color: #fecaca; }
.toast--warning { background: var(--warn-soft); color: #78350f; border-color: #fde68a; }
.toast--info { background: var(--accent-soft); color: #0c4a6e; border-color: #bae6fd; }
.toast a { text-decoration: underline; font-weight: 650; }

.callout {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 14px 16px;
    border-radius: 12px;
    background: var(--panel-soft);
    border: 1px solid var(--line);
    margin-bottom: 14px;
    font-size: 13px;
}
.callout .icon { color: var(--brand-dark); flex: 0 0 auto; margin-top: 1px; }
.callout p { color: var(--muted); margin-top: 3px; }
.callout > .link { margin-left: auto; align-self: center; }
.callout--warn { background: #fffbeb; border-color: #fde68a; }
.callout--warn .icon { color: var(--warn); }
.callout--info { background: #f0f9ff; border-color: #bae6fd; }
.callout--info .icon { color: #0284c7; }

/* ------------------------------------------------------------------- tabs */
.type-tabs, .report-tabs {
    display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 14px;
    scrollbar-width: thin;
}
.type-tab, .report-tab {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 9px 14px;
    border-radius: 10px;
    background: var(--panel);
    border: 1px solid var(--line);
    font-size: 13px; font-weight: 550;
    color: var(--ink-soft);
    white-space: nowrap;
    transition: border-color .15s, background .15s, color .15s;
}
.type-tab:hover, .report-tab:hover { border-color: var(--line-strong); background: #fff; }
.type-tab.is-active, .report-tab.is-active { background: var(--ink); border-color: var(--ink); color: #fff; }
.type-tab small { font-size: 10.5px; opacity: .7; font-weight: 600; }
.type-tab__dot { width: 7px; height: 7px; border-radius: 50%; }
.type-tab__dot--in { background: var(--brand); }
.type-tab__dot--out { background: var(--warn); }
.report-tab .icon { width: 16px; height: 16px; }

/* ------------------------------------------------------------------- pager */
.pager { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: center; margin-top: 16px; }
.pager__btn {
    min-width: 34px; padding: 6px 10px;
    border-radius: 8px; border: 1px solid var(--line);
    background: #fff; font-size: 12.5px; font-weight: 600;
    color: var(--ink-soft); text-align: center;
}
.pager__btn:hover { border-color: var(--line-strong); background: var(--panel-soft); }
.pager__btn.is-active { background: var(--ink); border-color: var(--ink); color: #fff; }
.pager__btn.is-disabled { opacity: .45; pointer-events: none; }
.pager__gap { color: var(--muted-2); padding: 0 2px; }
.pager__meta { text-align: center; font-size: 12px; color: var(--muted); margin-top: 8px; }

/* --------------------------------------------------------------- challan form */
.challan-form .card + .card { margin-top: 16px; }
.items { display: flex; flex-direction: column; gap: 10px; }
.item-row {
    display: grid;
    grid-template-columns: 2.2fr 1.4fr .8fr .8fr 1fr 1fr auto;
    gap: 10px;
    align-items: end;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: var(--panel-soft);
}
.item-row--head {
    padding: 0 12px;
    border: 0; background: transparent;
    font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700;
}
.item-row--head span:first-child { padding-left: 2px; }
.item-row .mobile-label { display: none; }
.item-row .multiplier {
    display: grid; place-items: center;
    min-height: 38px;
    border-radius: 9px;
    background: #fff; border: 1px dashed var(--line-strong);
    font-size: 13px; font-weight: 650; color: var(--ink-soft);
    font-variant-numeric: tabular-nums;
}
.item-row .line-total { display: grid; place-items: center; min-height: 38px; font-weight: 650; font-size: 13.5px; }
.item-row .remove-row { margin-bottom: 2px; }

.save-bar {
    position: sticky; bottom: 0; z-index: 20;
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    margin-top: 16px;
    padding: 14px 18px;
    background: rgba(255, 255, 255, .96);
    backdrop-filter: blur(8px);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow);
}
.save-bar__total { display: flex; flex-direction: column; }
.save-bar__total span { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.save-bar__total strong { font-size: 22px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.save-bar__actions { display: flex; gap: 8px; }

/* ------------------------------------------------------------------ search */
.search-hero {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 14px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 16px;
}
.search-hero__icon { color: var(--muted-2); }
.search-hero input { border: 0; box-shadow: none; font-size: 15px; background: transparent; }
.search-hero input:focus { box-shadow: none; }

.split { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; align-items: start; }
.setup-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }

/* ==========================================================================
   Print sheet (challan document)
   ========================================================================== */
.print-page { background: #eef2f7; }
.print-toolbar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 20px;
    background: #fff;
    border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 10;
    flex-wrap: wrap;
}
.print-toolbar__right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.sheet {
    width: min(210mm, 100%);
    margin: 22px auto 60px;
    background: #fff;
    padding: 16mm 14mm;
    border-radius: 6px;
    box-shadow: 0 20px 50px -30px rgba(15, 23, 42, .5);
    color: #0d1a2b;
}
.sheet__head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; border-bottom: 2px solid #0b1526; padding-bottom: 14px; }
.sheet__brand { display: flex; gap: 12px; align-items: center; }
.sheet__brand h1 { font-size: 19px; letter-spacing: -.01em; }
.sheet__brand p { font-size: 11.5px; color: #64748b; margin-top: 2px; }
.sheet__doc { text-align: right; }
.sheet__doc h2 { font-size: 15px; letter-spacing: .08em; color: #0b1526; }
.sheet__doc p { font-size: 11px; color: #64748b; margin: 2px 0 6px; }
.sheet__status .badge { font-size: 10px; }

.sheet__meta {
    display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid #e2e8f0;
}
.sheet__meta .label { display: block; font-size: 9.5px; text-transform: uppercase; letter-spacing: .1em; color: #94a3b8; font-weight: 700; margin-bottom: 3px; }
.sheet__meta strong { font-size: 13px; display: block; }
.sheet__meta small { font-size: 11px; color: #64748b; }

.sheet__items { width: 100%; border-collapse: collapse; margin-top: 16px; font-size: 12px; }
.sheet__items th {
    text-align: left; font-size: 9.5px; text-transform: uppercase; letter-spacing: .08em;
    color: #475569; border-bottom: 1.5px solid #0b1526; padding: 7px 6px; font-weight: 700;
}
.sheet__items td { padding: 7px 6px; border-bottom: 1px solid #eef2f7; }
.sheet__items .num { text-align: right; font-variant-numeric: tabular-nums; }
.sheet__items .col-sno { width: 28px; color: #94a3b8; }
.sheet__items tfoot td { border-top: 1.5px solid #0b1526; border-bottom: 0; font-weight: 700; padding-top: 9px; }
.sheet__items .empty-row { text-align: center; color: #94a3b8; padding: 18px; }
.sheet__items .strong { font-weight: 800; }

.sheet__totals { display: flex; justify-content: space-between; gap: 24px; margin-top: 16px; align-items: flex-start; }
.sheet__words { max-width: 58%; }
.sheet__words .label { font-size: 9.5px; text-transform: uppercase; letter-spacing: .1em; color: #94a3b8; font-weight: 700; }
.sheet__words p { font-size: 12px; margin: 2px 0 10px; color: #1e293b; }
.sheet__sum { min-width: 210px; }
.sheet__sum > div { display: flex; justify-content: space-between; gap: 18px; padding: 5px 0; font-size: 12px; border-bottom: 1px solid #eef2f7; }
.sheet__sum > div span { color: #64748b; }
.sheet__sum > div strong { font-variant-numeric: tabular-nums; }
.sheet__sum-total { border-bottom: 0 !important; border-top: 1.5px solid #0b1526; margin-top: 4px; padding-top: 8px !important; }
.sheet__sum-total strong { font-size: 15px; }

.sheet__legs { margin-top: 16px; padding-top: 12px; border-top: 1px solid #e2e8f0; }
.sheet__legs .label { font-size: 9.5px; text-transform: uppercase; letter-spacing: .1em; color: #94a3b8; font-weight: 700; }
.leg-chips { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.sheet__legs .chip { border: 1px solid #e2e8f0; }

.sheet__foot { display: flex; gap: 40px; margin-top: 40px; padding-top: 16px; border-top: 1px solid #e2e8f0; position: relative; }
.sign { display: flex; flex-direction: column; gap: 22px; min-width: 130px; }
.sign span { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: #94a3b8; font-weight: 700; }
.sign strong { font-size: 12px; border-top: 1px solid #94a3b8; padding-top: 5px; }
.sheet__note { position: absolute; right: 0; bottom: 0; font-size: 9.5px; color: #94a3b8; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1280px) {
    .grid--2 { grid-template-columns: 1fr; }
    .grid--sidebar { grid-template-columns: 1fr; }
}

@media (max-width: 1024px) {
    :root { --sidebar-w: 240px; }
    .content { padding: 18px 18px 36px; }
    .topbar { padding: 10px 18px; }
    .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .hero { flex-direction: column; align-items: flex-start; }
    .hero__figure { text-align: left; padding-left: 0; border-left: 0; border-top: 1px solid rgba(255,255,255,.12); padding-top: 12px; width: 100%; }
}

@media (max-width: 860px) {
    .sidebar {
        transform: translateX(-102%);
        transition: transform .22s ease;
        width: 280px;
        box-shadow: 0 0 60px rgba(2, 8, 23, .5);
    }
    body.sidebar-open .sidebar { transform: translateX(0); }
    .sidebar__close { display: inline-grid; }
    .app__scrim {
        display: block;
        position: fixed; inset: 0;
        background: rgba(8, 15, 28, .5);
        opacity: 0; pointer-events: none;
        transition: opacity .2s;
        z-index: 35;
    }
    body.sidebar-open .app__scrim { opacity: 1; pointer-events: auto; }
    .app__main { margin-left: 0; }
    .topbar__burger { display: inline-grid; }
    .topbar__search { width: auto; flex: 1; margin-left: 0; }
    .topbar__title { display: none; }
    .content { padding: 14px 14px 92px; }
    .grid--2, .grid--3 { grid-template-columns: 1fr; }
    .split { grid-template-columns: 1fr; }

    .mobile-nav {
        display: flex;
        position: fixed; left: 0; right: 0; bottom: 0;
        z-index: 25;
        background: rgba(255, 255, 255, .97);
        backdrop-filter: blur(12px);
        border-top: 1px solid var(--line);
        padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    }
    .mobile-nav a {
        flex: 1;
        display: flex; flex-direction: column; align-items: center; gap: 3px;
        padding: 6px 4px;
        border-radius: 9px;
        font-size: 10.5px; font-weight: 600;
        color: var(--muted);
    }
    .mobile-nav a.is-active { color: var(--brand-dark); background: var(--brand-soft); }
    .mobile-nav .icon { width: 19px; height: 19px; }

    .save-bar {
        position: fixed; left: 0; right: 0; bottom: 0;
        border-radius: 0;
        margin: 0;
        padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
        border-left: 0; border-right: 0; border-bottom: 0;
        z-index: 26;
    }
    .content:has(.save-bar) { padding-bottom: 108px; }
    .save-bar__total strong { font-size: 18px; }
    .save-bar__actions .btn--ghost { display: none; }

    .sheet { padding: 8mm 6mm; margin: 12px auto 40px; border-radius: 0; }
    .sheet__head { flex-direction: column; }
    .sheet__doc { text-align: left; }
    .sheet__meta { grid-template-columns: 1fr 1fr; }
    .sheet__totals { flex-direction: column; }
    .sheet__words { max-width: 100%; }
    .sheet__sum { width: 100%; }
    .sheet__foot { gap: 18px; flex-wrap: wrap; }
    .sheet__note { position: static; width: 100%; margin-top: 10px; }
}

@media (max-width: 640px) {
    body { font-size: 13.5px; }
    .topbar { gap: 8px; padding: 9px 12px; }
    .topbar__actions .btn span { display: none; }
    .hero { padding: 18px; }
    .hero__text h2 { font-size: 20px; }
    .hero__figure strong { font-size: 30px; }
    .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .kpi { padding: 12px; min-height: 84px; grid-template-columns: auto 1fr; column-gap: 9px; }
    .kpi__icon { width: 32px; height: 32px; border-radius: 9px; }
    .kpi__icon .icon { width: 16px; height: 16px; }
    .kpi__value { font-size: 18px; }
    .kpi__meta { font-size: 10.5px; }

    .page-head h2 { font-size: 18px; }
    .card__body { padding: 13px; }
    .card__head { padding: 12px 13px; }

    .range-bar { padding: 8px; }
    .range-chips { flex-wrap: nowrap; overflow-x: auto; width: 100%; padding-bottom: 3px; }
    .range-custom { width: 100%; }
    .range-custom input[type="date"] { flex: 1; min-width: 0; }
    .range-custom .btn { flex: 0 0 auto; }

    .filter-bar { gap: 8px; padding: 12px; }
    .field--grow, .field { flex: 1 1 100%; }
    .field--action { flex-direction: row; }
    .form-grid { grid-template-columns: 1fr; }

    .stat-strip > div { flex: 1 1 50%; padding: 10px 13px; border-bottom: 1px solid var(--line); }
    .stat-strip strong { font-size: 15px; }

    /* Tables become stacked cards */
    .table--cards { display: block; }
    .table--cards thead { display: none; }
    .table--cards tbody, .table--cards tr, .table--cards td { display: block; width: 100%; }
    .table--cards tr {
        border: 1px solid var(--line);
        border-radius: 12px;
        padding: 6px 12px;
        margin-bottom: 8px;
        background: #fff;
    }
    .table--cards td {
        display: flex; align-items: center; justify-content: space-between; gap: 14px;
        padding: 6px 0;
        border-bottom: 1px dashed var(--line);
        text-align: right;
    }
    .table--cards td:last-child { border-bottom: 0; }
    .table--cards td::before {
        content: attr(data-label);
        font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
        color: var(--muted); font-weight: 700;
        text-align: left;
        flex: 0 0 auto;
    }
    .table--cards td.num { text-align: right; }
    .table--cards .row-actions { justify-content: flex-end; }
    .table--cards td:not([data-label])::before { content: ""; }

    /* Challan form rows stack */
    .item-row--head { display: none; }
    .item-row {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        padding: 12px;
        position: relative;
    }
    .item-row .field:first-child { grid-column: 1 / -1; }
    .item-row .mobile-label { display: block; font-size: 10.5px; color: var(--muted); margin-bottom: 3px; }
    .item-row .remove-row { position: absolute; top: 6px; right: 6px; }
    .item-row .field { gap: 2px; }
    .item-row .multiplier, .item-row .line-total { min-height: 34px; }
    .save-bar { gap: 10px; }
    .save-bar__actions .btn--lg { padding: 11px 16px; }

    .type-tabs, .report-tabs { gap: 5px; }
    .type-tab, .report-tab { padding: 8px 11px; font-size: 12.5px; }

    .detail-list > div { grid-template-columns: 100px 1fr; }
    .toast { font-size: 12.5px; }
    .print-toolbar { padding: 9px 12px; }
}

@media (max-width: 400px) {
    .kpi-grid { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Print
   ========================================================================== */
@media print {
    body { background: #fff; font-size: 11.5px; }
    .sidebar, .topbar, .mobile-nav, .app__scrim, .print-toolbar,
    .range-bar, .range-note, .filter-bar, .page-head__actions,
    .report-tabs, .type-tabs, .pager, .pager__meta, .toast,
    .row-actions, .actions-col, .chart-box, .save-bar, .btn, .icon-btn,
    .leg-chips, .hint, .search-hero { display: none !important; }
    .app__main { margin: 0; }
    .content { padding: 0; max-width: none; }
    .card { border: 0; box-shadow: none; }
    .card__head { border-bottom: 1px solid #cbd5e1; background: #fff; }
    .card__body { padding: 0; }
    .table { font-size: 10.5px; }
    .table th { background: #fff; position: static; }
    .table th, .table td { padding: 4px 6px; border-bottom: 1px solid #e2e8f0; }
    .table--cards tr, .table--cards td { display: revert; }
    .table--cards td::before { content: none; }
    .hero, .stat-strip { box-shadow: none; }
    .hero { background: #f1f5f9 !important; color: #0f172a !important; }
    .hero__text h2, .hero__stats strong, .hero__figure strong { color: #0f172a !important; }
    .hero__eyebrow, .hero__figure-label { color: #0f766e !important; }
    .hero__text p, .hero__stats, .hero__figure-meta { color: #475569 !important; }
    .print-page { background: #fff; }
    .sheet { box-shadow: none; margin: 0; padding: 0; width: 100%; border-radius: 0; }
    @page { size: A4; margin: 12mm; }
    a { color: inherit !important; text-decoration: none !important; }
}

/* -------------------------------------------------- duplicate-entry warning */
.dup-warn {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 12px;
    margin: 0 0 16px;
    padding: 14px 16px;
    border: 1px solid rgba(217, 119, 6, .35);
    background: var(--warn-soft);
    border-radius: var(--radius-sm);
    font-size: 13px;
    line-height: 1.55;
    color: var(--ink-soft);
}
.dup-warn > .icon { width: 18px; height: 18px; flex: 0 0 auto; margin-top: 1px; color: var(--warn); }
.dup-warn strong { color: var(--ink); }
.dup-warn label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    font-weight: 650;
    white-space: nowrap;
    color: var(--ink);
    cursor: pointer;
}
.dup-warn input { width: 18px; height: 18px; accent-color: var(--warn); margin: 0; }
@media (max-width: 640px) {
    .dup-warn label { margin-left: 0; }
}
