/* Accoy admin dashboard */
:root {
    --red: #db1f27;
    --red-dark: #b5151c;
    --red-soft: #fde8e8;
    --cream: #fef1e2;
    --cream-dark: #f8d9b5;
    --orange: #fb8a2e;
    --ink: #1c1c1e;
    --ink-2: #4a4a4f;
    --muted: #8a8a90;
    --line: #ececef;
    --bg: #f7f7f8;
    --card: #ffffff;
    --green: #1f9d55;
    --green-soft: #dcf5e6;
    --amber: #b7791f;
    --amber-soft: #fdf3d7;
    --blue: #3b5bdb;
    --blue-soft: #e5ebff;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(20, 20, 30, .04), 0 4px 16px rgba(20, 20, 30, .04);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    font-family: 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-size: 14px;
    color: var(--ink);
    background: var(--bg);
    line-height: 1.5;
}
a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.num { font-variant-numeric: tabular-nums; text-align: right; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar {
    background: var(--card);
    border-right: 1px solid var(--line);
    padding: 20px 14px;
    position: sticky; top: 0; height: 100vh;
    display: flex; flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; }
.brand-mark {
    width: 38px; height: 38px; border-radius: 10px; background: var(--red);
    display: grid; place-items: center; color: #fff; font-weight: 700; letter-spacing: .5px;
}
.brand-name { font-weight: 700; letter-spacing: 2px; font-size: 17px; }
.brand-sub { font-size: 10px; letter-spacing: 1.4px; color: var(--muted); text-transform: uppercase; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); padding: 14px 12px 6px; }
.nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border-radius: 10px; color: var(--ink-2); font-weight: 500;
}
.nav a svg { width: 18px; height: 18px; flex: none; }
.nav a:hover { background: var(--bg); text-decoration: none; }
.nav a.active { background: var(--red-soft); color: var(--red); }
.nav .badge { margin-left: auto; }
.sidebar-foot { margin-top: auto; padding: 12px; border-top: 1px solid var(--line); font-size: 13px; }
.sidebar-foot form { margin: 0; }
.link-btn { background: none; border: 0; padding: 0; color: var(--red); font: inherit; cursor: pointer; }

.main { min-width: 0; }
.topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 22px 32px 0;
}
.content { padding: 20px 32px 48px; }
.btn.menu-toggle { display: none; }

/* ---------- cards & grids ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.stack > * + * { margin-top: 16px; }

.stat { padding: 18px 20px; display: flex; flex-direction: column; gap: 4px; }
.stat-top { display: flex; align-items: center; justify-content: space-between; }
.stat-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; }
.stat-icon svg { width: 20px; height: 20px; }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1.15; margin-top: 10px; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--ink-2); }
.stat-sub { font-size: 12px; color: var(--muted); }
.tone-red { background: var(--red-soft); color: var(--red); }
.tone-cream { background: var(--cream); color: #c2410c; }
.tone-amber { background: var(--amber-soft); color: var(--amber); }
.tone-green { background: var(--green-soft); color: var(--green); }
.tone-blue { background: var(--blue-soft); color: var(--blue); }

/* ---------- badges ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap;
    background: var(--bg); color: var(--ink-2);
}
.badge-pending { background: var(--amber-soft); color: var(--amber); }
.badge-partially_dispatched { background: var(--blue-soft); color: var(--blue); }
.badge-dispatched { background: var(--green-soft); color: var(--green); }
.badge-cancelled { background: #eee; color: #777; text-decoration: line-through; }
.badge-open { background: var(--cream); color: #c2410c; }
.badge-converted { background: var(--green-soft); color: var(--green); }
.badge-discarded { background: #eee; color: #777; }
.badge-red { background: var(--red); color: #fff; }
.badge-on { background: var(--green-soft); color: var(--green); }
.badge-off { background: #eee; color: #777; }
.badge-role-admin { background: #1c1c1e; color: #fff; }
.badge-role-sales_executive { background: var(--red-soft); color: var(--red); }
.badge-role-temp_sales { background: var(--cream); color: #c2410c; }
.trend-up { color: var(--green); font-size: 12px; font-weight: 600; }
.trend-down { color: var(--red); font-size: 12px; font-weight: 600; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 11px 16px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th { font-size: 12px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; background: #fcfcfd; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fcfcfd; }
.table .num { text-align: right; }
.table td.actions { text-align: right; white-space: nowrap; }
.table td.actions > * { margin-left: 6px; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

/* ---------- forms ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 38px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent;
    font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; text-decoration: none !important;
    background: var(--red); color: #fff;
}
.btn:hover { background: var(--red-dark); }
.btn svg { width: 16px; height: 16px; }
.btn-light { background: var(--cream); color: var(--ink); }
.btn-light:hover { background: var(--cream-dark); }
.btn-ghost { background: var(--card); color: var(--ink-2); border-color: var(--line); }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { height: 30px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn-danger-ghost { background: transparent; color: var(--red); border-color: #f5c6c8; }
.btn-danger-ghost:hover { background: var(--red-soft); }
.inline { display: inline; margin: 0; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 500; font-size: 13px; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.input, select.input, textarea.input {
    width: 100%; height: 40px; padding: 0 12px;
    border: 1px solid #dcdce0; border-radius: 10px; background: #fff;
    font: inherit; color: var(--ink);
}
textarea.input { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
.input:focus { outline: 2px solid rgba(219, 31, 39, .18); border-color: var(--red); }
.input-sm { height: 32px; font-size: 13px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.form-grid .span-2 { grid-column: span 2; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; padding: 16px 20px; border-top: 1px solid var(--line); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
.check input { width: 17px; height: 17px; accent-color: var(--red); }
.error { color: var(--red); font-size: 12px; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.filters .input { width: auto; min-width: 150px; height: 36px; }
.filters .grow { flex: 1; min-width: 200px; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab {
    padding: 7px 14px; border-radius: 999px; background: var(--card); border: 1px solid var(--line);
    color: var(--ink-2); font-weight: 500; font-size: 13px;
}
.tab:hover { text-decoration: none; background: var(--bg); }
.tab.active { background: var(--red); color: #fff; border-color: var(--red); }
.tab .count { opacity: .7; margin-left: 4px; }

/* ---------- alerts ---------- */
.alert { padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; font-weight: 500; }
.alert-success { background: var(--green-soft); color: #166534; }
.alert-error { background: var(--red-soft); color: var(--red-dark); }
.alert ul { margin: 6px 0 0; padding-left: 18px; font-weight: 400; }

/* ---------- size chips / variants ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { padding: 1px 8px; border-radius: 6px; background: var(--cream); font-size: 12px; font-weight: 500; }
.chip-off { background: #eee; color: #999; text-decoration: line-through; }
.variant-grid { display: grid; gap: 14px; }
.variant-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.variant-row .sleeve { min-width: 60px; font-weight: 600; background: var(--orange); color: #fff; padding: 6px 12px; border-radius: 10px; text-align: center; }
.size-toggle { position: relative; }
.size-toggle input { position: absolute; opacity: 0; }
.size-toggle span {
    display: inline-grid; place-items: center; min-width: 56px; height: 38px; padding: 0 12px;
    border-radius: 10px; background: #bdbdc2; color: #fff; font-weight: 600; cursor: pointer; user-select: none;
}
.size-toggle input:checked + span { background: var(--orange); }
.size-toggle input:focus-visible + span { outline: 2px solid var(--red); outline-offset: 2px; }

.thumb { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: var(--cream); display: grid; place-items: center; color: #c2410c; font-size: 11px; font-weight: 600; }

/* ---------- charts ---------- */
.bar-chart { width: 100%; height: 190px; display: block; }
.bar-chart .bar { fill: var(--red); }
.bar-chart .bar:hover { fill: var(--red-dark); }
.bar-chart .axis { fill: var(--muted); font-size: 10px; font-family: inherit; }
.bar-chart .grid-line { stroke: var(--line); }
.target-row { display: grid; grid-template-columns: 1fr; gap: 6px; }
.meter { height: 10px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.meter > span { display: block; height: 100%; background: #f4c84b; border-radius: 999px; }
.meter > span.done { background: var(--green); }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }

/* ---------- pagination ---------- */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.pager .pages { display: flex; gap: 4px; }
.pager a, .pager span.cur { min-width: 32px; height: 32px; padding: 0 8px; display: inline-grid; place-items: center; border-radius: 8px; border: 1px solid var(--line); color: var(--ink-2); }
.pager a:hover { background: var(--bg); text-decoration: none; }
.pager span.cur { background: var(--red); border-color: var(--red); color: #fff; }
.pager span.dis { opacity: .4; min-width: 32px; height: 32px; display: inline-grid; place-items: center; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-art { background: var(--red); color: #fff; display: grid; place-items: center; text-align: center; padding: 40px; }
.auth-art .logo { font-size: 56px; font-weight: 600; letter-spacing: 6px; }
.auth-art .tag { letter-spacing: 4px; font-size: 13px; margin-top: 6px; }
.auth-form { display: grid; place-items: center; padding: 40px 20px; }
.auth-form .card { width: 100%; max-width: 380px; }

@media (max-width: 1100px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-main { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { position: fixed; z-index: 20; left: 0; width: 250px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
    .shell.nav-open .sidebar { transform: none; }
    .btn.menu-toggle { display: inline-flex; }
    .topbar, .content { padding-left: 16px; padding-right: 16px; }
    .topbar { flex-wrap: wrap; }
    .grid-3, .grid-2, .form-grid { grid-template-columns: 1fr; }
    .form-grid .span-2 { grid-column: auto; }
    .auth { grid-template-columns: 1fr; }
    .auth-art { padding: 36px 16px; }
    .auth-art .logo { font-size: 40px; }
    .kv { grid-template-columns: 110px 1fr; }
}
@media (max-width: 480px) {
    .grid-4 { grid-template-columns: 1fr; }
}

/* ---------- order sections (tabs) ---------- */
.section-tabs { display: flex; gap: 4px; padding: 10px 16px 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.section-tab {
    border: 0; background: transparent; font: inherit; font-weight: 500; color: var(--ink-2);
    padding: 10px 14px; border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap;
}
.section-tab:hover { color: var(--ink); }
.section-tab.active { color: var(--red); border-bottom-color: var(--red); }
.section-tab .count { display: inline-block; margin-left: 6px; padding: 0 7px; border-radius: 999px; background: var(--bg); font-size: 12px; color: var(--ink-2); }
.section-tab.active .count { background: var(--red-soft); color: var(--red); }
.section-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 12px 20px; }
.matrix th, .matrix td { padding: 8px 10px; }
.matrix td.cell { min-width: 64px; }
.matrix .qty { font-weight: 600; }
.matrix .disp { width: 56px; height: 26px; padding: 0 4px; margin-top: 3px; text-align: right; font-size: 12px; }
.matrix .disp.part { border-color: var(--blue); background: var(--blue-soft); }
.matrix .disp.full { border-color: var(--green); background: var(--green-soft); }
.matrix tfoot td { font-weight: 600; background: #fcfcfd; border-top: 1px solid var(--line); }
.matrix tfoot tr.subtotal td { font-weight: 500; color: var(--ink-2); }

/* ---------- brands & seasons ---------- */
.season-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 0; border-top: 1px solid var(--line); }
.season-row:first-of-type { border-top: 0; }
.season-new { margin-top: 4px; }
.months { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; min-width: 260px; }
.month-toggle { position: relative; }
.month-toggle input { position: absolute; opacity: 0; }
.month-toggle span {
    display: inline-grid; place-items: center; min-width: 42px; height: 30px; padding: 0 8px; border-radius: 8px;
    background: var(--bg); color: var(--muted); font-size: 12.5px; font-weight: 500; cursor: pointer; user-select: none;
    border: 1px solid var(--line);
}
.month-toggle input:checked + span { background: var(--red); border-color: var(--red); color: #fff; }
.month-toggle input:focus-visible + span { outline: 2px solid var(--red); outline-offset: 2px; }
.scope-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.scope-bar .input { width: auto; min-width: 150px; height: 36px; }
.scope-note { color: var(--ink-2); font-size: 13px; }
