/* Makarim order desk — colors come from the square Kufic logo (night → sky). */
:root {
    --night: #171a33;
    --night-2: #222650;
    --night-line: rgba(255, 255, 255, .09);
    --ink: #1b1e36;
    --muted: #5e6380;
    --faint: #8a8fa8;
    --line: #e3e5ef;
    --line-strong: #cfd2e0;
    --paper: #f3f4f8;
    --surface: #ffffff;
    --indigo: #2c4d9e;
    --indigo-600: #233f86;
    --indigo-tint: #e8edf9;
    --sky: #4c7df0;
    --gold: #c9a23a;
    --gold-ink: #7a5c14;
    --gold-tint: #faf3e1;
    --green: #23794b;
    --green-tint: #e6f4ec;
    --amber: #8a6410;
    --amber-tint: #fbf1da;
    --rose: #b4324f;
    --rose-tint: #fbe7ec;

    --font-display: 'Anek Bangla', 'Hind Siliguri', system-ui, sans-serif;
    --font-body: 'Hind Siliguri', system-ui, sans-serif;

    --radius-lg: 14px;
    --radius: 9px;
    --radius-sm: 6px;
    --sidebar: 248px;
    --shadow: 0 1px 2px rgba(23, 26, 51, .06), 0 4px 16px -6px rgba(23, 26, 51, .08);
    --btn: #2c4d9e;
    --btn-hover: #233f86;
    --gold-hover: #b8922c;
    --gold-line: #efe0b4;
    --teal: #1f5f8f;
    --teal-tint: #e3f0fb;
    --subtle: #fafbfd;
    --row-hover: #f8f9fc;
    --hover-strong: #eceef5;
    --inverse: #171a33;
    --inverse-ink: #ffffff;
    --focus-ring: rgba(76, 125, 240, .18);
    --logo-bg: transparent;
    --logo-pad: 0px;
    --chart-grid: #eceef5;
    --chart-tick: #5e6380;
    --series-profit: #2c4d9e;
    --series-cost: #c3c9dc;
    color-scheme: light;
}


/* Dark theme: chosen in the header toggle, or taken from the device setting when none is saved. */
:root[data-theme="dark"] {
    --ink: #e8eaf6;
    --muted: #a6abc9;
    --faint: #7b80a3;
    --line: #272b47;
    --line-strong: #383d61;
    --paper: #0e1020;
    --surface: #161930;
    --subtle: #1a1d36;
    --row-hover: #1c1f3a;
    --hover-strong: #242844;
    --indigo: #93adff;
    --indigo-600: #b2c5ff;
    --indigo-tint: rgba(120, 150, 255, .15);
    --btn: #4064d4;
    --btn-hover: #4d71e0;
    --sky: #7398ff;
    --gold: #d6b04c;
    --gold-hover: #e2bf62;
    --gold-ink: #e8c873;
    --gold-tint: rgba(214, 176, 76, .14);
    --gold-line: rgba(214, 176, 76, .35);
    --green: #6bd69a;
    --green-tint: rgba(107, 214, 154, .13);
    --amber: #ecbd5c;
    --amber-tint: rgba(236, 189, 92, .14);
    --rose: #f4869f;
    --rose-tint: rgba(244, 134, 159, .14);
    --teal: #7cc4f2;
    --teal-tint: rgba(124, 196, 242, .14);
    --inverse: #e8eaf6;
    --inverse-ink: #10122a;
    --focus-ring: rgba(115, 152, 255, .3);
    --logo-bg: #ffffff;
    --logo-pad: 3px;
    --chart-grid: #262a45;
    --chart-tick: #a6abc9;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --series-profit: #6585e6;
    --series-cost: #3b4168;
    color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --ink: #e8eaf6;
        --muted: #a6abc9;
        --faint: #7b80a3;
        --line: #272b47;
        --line-strong: #383d61;
        --paper: #0e1020;
        --surface: #161930;
        --subtle: #1a1d36;
        --row-hover: #1c1f3a;
        --hover-strong: #242844;
        --indigo: #93adff;
        --indigo-600: #b2c5ff;
        --indigo-tint: rgba(120, 150, 255, .15);
        --btn: #4064d4;
        --btn-hover: #4d71e0;
        --sky: #7398ff;
        --gold: #d6b04c;
        --gold-hover: #e2bf62;
        --gold-ink: #e8c873;
        --gold-tint: rgba(214, 176, 76, .14);
        --gold-line: rgba(214, 176, 76, .35);
        --green: #6bd69a;
        --green-tint: rgba(107, 214, 154, .13);
        --amber: #ecbd5c;
        --amber-tint: rgba(236, 189, 92, .14);
        --rose: #f4869f;
        --rose-tint: rgba(244, 134, 159, .14);
        --teal: #7cc4f2;
        --teal-tint: rgba(124, 196, 242, .14);
        --inverse: #e8eaf6;
        --inverse-ink: #10122a;
        --focus-ring: rgba(115, 152, 255, .3);
        --logo-bg: #ffffff;
        --logo-pad: 3px;
        --chart-grid: #262a45;
        --chart-tick: #a6abc9;
        --shadow: 0 1px 2px rgba(0, 0, 0, .3);
        --series-profit: #6585e6;
    --series-cost: #3b4168;
    color-scheme: dark;
    }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font: 400 15px/1.55 var(--font-body);
    -webkit-font-smoothing: antialiased;
}
a { color: var(--indigo); text-decoration: none; }
a:hover { color: var(--indigo-600); text-decoration: underline; text-underline-offset: 3px; }
img { max-width: 100%; }
h1, h2, h3 { font-family: var(--font-display); color: var(--ink); margin: 0; line-height: 1.15; }
h1 { font-size: 30px; font-weight: 600; font-stretch: 92%; letter-spacing: -.01em; }
h2 { font-size: 19px; font-weight: 600; font-stretch: 95%; }
h3 { font-size: 16px; font-weight: 600; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--sky); outline-offset: 2px; border-radius: 4px; }
.num { font-family: var(--font-display); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
    position: sticky; top: 0; height: 100vh;
    display: flex; flex-direction: column;
    background: var(--surface);
    border-right: 1px solid var(--line);
    padding: 20px 14px 16px;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 10px 24px; color: var(--ink); }
.brand:hover { color: var(--ink); text-decoration: none; }
.brand img { width: 38px; height: 38px; background: var(--logo-bg); border-radius: 9px; padding: var(--logo-pad); }
.brand strong { display: block; font: 600 19px/1.1 var(--font-display); font-stretch: 90%; }
.brand span { display: block; font-size: 13px; color: var(--muted); }

.nav { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.nav a {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: var(--muted); font-weight: 500;
}
.nav a i { width: 18px; text-align: center; color: var(--faint); }
.nav a:hover { background: var(--paper); color: var(--ink); text-decoration: none; }
.nav a:hover i { color: var(--ink); }
.nav a[aria-current="page"] { background: var(--indigo-tint); color: var(--indigo); }
.nav a[aria-current="page"] i { color: var(--indigo); }
.nav .count {
    margin-left: auto; font: 600 12px/1 var(--font-display);
    background: var(--gold-tint); color: var(--gold-ink); padding: 4px 8px; border-radius: 20px;
}
.nav-label { margin: 22px 12px 8px; font-size: 13px; color: var(--faint); }

.sidebar-foot { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 14px 10px 0; border-top: 1px solid var(--line); }
.sidebar-foot img { width: 36px; height: 36px; border-radius: 50%; }
.sidebar-foot div { line-height: 1.25; min-width: 0; }
.sidebar-foot strong { display: block; color: var(--ink); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot a { color: var(--muted); font-size: 13px; }

.main { min-width: 0; padding: 0 36px 48px; }
.appbar { display: flex; align-items: center; gap: 16px; padding: 16px 0; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.appbar .search { width: min(420px, 100%); }
.appbar .search input { background: var(--surface); }
.appbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.appbar-date { color: var(--muted); font-size: 14px; }
.topbar { display: none; }
.scrim { display: none; }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head p { color: var(--muted); margin-top: 6px; }
.crumb { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.crumb a { color: var(--muted); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 40px; padding: 0 16px;
    border: 1px solid transparent; border-radius: var(--radius);
    font: 500 15px/1 var(--font-body); cursor: pointer; white-space: nowrap;
    transition: background-color .15s, border-color .15s, color .15s;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--btn); color: #fff; }
.btn-primary:hover { background: var(--btn-hover); color: #fff; }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-ghost:hover { border-color: var(--indigo); color: var(--indigo); }
.btn-gold { background: var(--gold); color: var(--night); }
.btn-gold:hover { background: var(--gold-hover); color: var(--night); }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: 14px; }
.btn-lg { min-height: 48px; padding: 0 22px; font-size: 16px; }
.btn-block { width: 100%; }
.icon-btn {
    display: inline-grid; place-items: center; width: 34px; height: 34px;
    border-radius: var(--radius-sm); color: var(--muted); background: transparent; border: 0; cursor: pointer;
}
.icon-btn:hover { background: var(--paper); color: var(--indigo); text-decoration: none; }
.icon-btn.print { color: var(--gold-ink); }
.icon-btn.print:hover { background: var(--gold-tint); color: var(--gold-ink); }
.icon-btn.danger:hover { background: var(--rose-tint); color: var(--rose); }

/* ---------- Panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.panel-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 12px; padding: 18px 22px 0; }
.panel-head p { color: var(--muted); font-size: 14px; }
.panel-body { padding: 18px 22px 22px; }

/* ---------- Flash ---------- */
.flash {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px; margin-bottom: 20px; border-radius: var(--radius);
    background: var(--green-tint); color: var(--green); font-weight: 500;
}
.flash.error { background: var(--rose-tint); color: var(--rose); align-items: flex-start; }
.flash ul { margin: 0; padding-left: 18px; font-weight: 400; }

/* ---------- Status pill ---------- */
.status { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px; border-radius: 20px; font-size: 13px; font-weight: 500; white-space: nowrap; }
.status i { font-size: 11px; }
.status-Complete { background: var(--green-tint); color: var(--green); }
.status-Accept { background: var(--indigo-tint); color: var(--indigo); }
.status-Pending { background: var(--amber-tint); color: var(--amber); }
.status-Hold { background: var(--rose-tint); color: var(--rose); }
.printed { font-size: 13px; color: var(--muted); white-space: nowrap; }
.not-printed { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; color: var(--gold-ink); white-space: nowrap; }
.not-printed::before { content: ''; width: 7px; height: 7px; background: var(--gold); transform: rotate(45deg); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.table th {
    text-align: left; font-weight: 500; font-size: 13px; color: var(--muted);
    padding: 12px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--subtle);
}
.table td { padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--row-hover); }
.table .right { text-align: right; }
.table .tight { width: 1%; white-space: nowrap; }
.who strong { display: block; font-weight: 500; }
.who span { color: var(--muted); font-size: 13.5px; }
.inv { font-size: 13px; color: var(--faint); margin-left: 8px; }
.thumb { width: 44px; height: 56px; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); background: var(--paper); }

/* ---------- Toolbar: tabs + search ---------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs a { display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 20px; color: var(--muted); font-size: 14px; font-weight: 500; }
.tabs a:hover { background: var(--paper); color: var(--ink); text-decoration: none; }
.tabs a[aria-current="true"] { background: var(--inverse); color: var(--inverse-ink); }
.tabs a span { font: 500 12px/1 var(--font-display); opacity: .75; }
.tabs a.tab-print[aria-current="true"] { background: var(--gold); color: var(--night); }
.search { position: relative; min-width: 260px; }
.search i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); font-size: 13px; }
.search input { padding-left: 34px; }
.table-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 18px; border-top: 1px solid var(--line); font-size: 14px; color: var(--muted); }
.pager { display: flex; gap: 4px; }
.pager a, .pager span { display: inline-grid; place-items: center; min-width: 34px; height: 34px; padding: 0 8px; border-radius: var(--radius-sm); color: var(--ink); font: 500 14px/1 var(--font-display); }
.pager a:hover { background: var(--paper); text-decoration: none; }
.pager .current { background: var(--inverse); color: var(--inverse-ink); }
.pager .disabled { color: var(--line-strong); }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink); font: 600 17px/1.3 var(--font-display); margin-bottom: 4px; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.form-narrow { max-width: 720px; }
.section { padding: 22px; }
.section + .section { border-top: 1px solid var(--line); }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.section-title p { color: var(--muted); font-size: 14px; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.fields-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.field { display: grid; gap: 6px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field > label, .label { font-size: 14px; font-weight: 500; color: var(--ink); }
.hint { font-size: 13px; color: var(--muted); }
.input, .form-control, select.form-control, textarea.form-control {
    width: 100%; min-height: 42px; padding: 9px 12px;
    background: var(--surface); color: var(--ink);
    border: 1px solid var(--line-strong); border-radius: var(--radius);
    font: 400 15px/1.4 var(--font-body);
    transition: border-color .15s, box-shadow .15s;
}
textarea.form-control { min-height: 84px; resize: vertical; }
.form-control:focus, .input:focus { outline: none; border-color: var(--sky); box-shadow: 0 0 0 3px var(--focus-ring); }
.form-control[readonly], .form-control:disabled { background: var(--subtle); color: var(--muted); }
.form-control.is-invalid { border-color: var(--rose); }
.input-row { display: flex; gap: 8px; }
.input-row .form-control { flex: 1; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--indigo); }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.file-drop { display: flex; align-items: center; gap: 14px; padding: 14px; border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--subtle); }
.file-drop input { font: inherit; font-size: 14px; }

/* Order items (cloned rows from the add form) */
.product-item + .product-item { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line); }
.item-head { margin-bottom: 12px; }

/* Order summary (sticky column) */
.summary { position: sticky; top: 24px; }
.summary .panel-body { display: grid; gap: 14px; }
.summary-line { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 15px; }
.summary-line .form-control { width: 120px; text-align: right; }
.summary-total { border-top: 1px solid var(--line); padding-top: 14px; }
.summary-total label { font: 600 17px/1.2 var(--font-display); }
.summary-total .form-control { width: 140px; font: 600 20px/1 var(--font-display); color: var(--ink); }

/* ---------- Select2 ---------- */
.select2-container { width: 100% !important; font-size: 15px; }
.select2-container--default .select2-selection--single { height: 42px; border: 1px solid var(--line-strong); border-radius: var(--radius); }
.select2-container--default .select2-selection--single .select2-selection__rendered { line-height: 40px; padding-left: 12px; color: var(--ink); }
.select2-container--default .select2-selection--single .select2-selection__arrow { height: 40px; right: 6px; }
.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--single { border-color: var(--sky); }
.select2-dropdown { border-color: var(--line-strong); border-radius: var(--radius); overflow: hidden; }
.select2-container--default .select2-results__option--highlighted[aria-selected] { background: var(--indigo); }

/* ---------- Dashboard ---------- */
.avatar {
    flex: none; display: inline-grid; place-items: center;
    width: 36px; height: 36px; border-radius: 50%;
    font: 600 14px/1 var(--font-display);
}
.av-0 { background: var(--indigo-tint); color: var(--indigo); }
.av-1 { background: var(--teal-tint); color: var(--teal); }
.av-2 { background: var(--green-tint); color: var(--green); }
.av-3 { background: var(--gold-tint); color: var(--gold-ink); }
.av-4 { background: var(--rose-tint); color: var(--rose); }
.person { display: flex; align-items: center; gap: 12px; min-width: 0; }
.person .who { min-width: 0; }
.person .who strong, .person .who span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.hero {
    position: relative; overflow: hidden;
    display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap;
    padding: 28px 30px; margin-bottom: 20px;
    border-radius: 18px; color: #fff;
    background-color: var(--night);
    background-image:
        radial-gradient(90% 140% at 100% 0%, rgba(76, 125, 240, .55), transparent 60%),
        linear-gradient(45deg, rgba(255, 255, 255, .07) 1px, transparent 1px),
        linear-gradient(-45deg, rgba(255, 255, 255, .07) 1px, transparent 1px);
    background-size: auto, 30px 30px, 30px 30px;
}
.hero::after {
    /* the logo's diamond, oversized and cropped at the right edge */
    content: ''; position: absolute; right: -70px; top: 50%; width: 260px; height: 260px;
    border: 26px solid rgba(255, 255, 255, .08); transform: translateY(-50%) rotate(45deg);
    pointer-events: none;
}
.hero { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06); }
.hero > * { position: relative; z-index: 1; }
.hero h1 { color: #fff; font-size: 32px; }
.hero p { color: #b9c2ec; margin-top: 6px; }
.hero .actions { gap: 10px; }
.btn-light { background: #fff; color: var(--night); }
.btn-light:hover { background: #eef1fb; color: var(--night); }
.btn-glass { background: rgba(255, 255, 255, .12); color: #fff; border-color: rgba(255, 255, 255, .22); }
.btn-glass:hover { background: rgba(255, 255, 255, .2); color: #fff; }
.btn-glass .count { background: var(--gold); color: var(--night); font: 600 12px/1 var(--font-display); padding: 4px 7px; border-radius: 20px; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi { display: grid; gap: 14px; padding: 18px 20px; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.kpi-label { color: var(--muted); font-size: 14px; font-weight: 500; }
.kpi-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; font-size: 15px; }
.kpi-value { font: 600 32px/1 var(--font-display); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 20px; font-size: 12.5px; font-weight: 600; background: var(--paper); color: var(--muted); }
.pill.up { background: var(--green-tint); color: var(--green); }
.pill.down { background: var(--rose-tint); color: var(--rose); }
.kpi.attention { background: linear-gradient(180deg, var(--gold-tint), var(--surface) 70%); border-color: var(--gold-line); }

.dash-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 20px; margin-bottom: 20px; }
.seg { display: inline-flex; padding: 3px; background: var(--paper); border-radius: var(--radius); }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 7px; font: 500 13.5px/1 var(--font-body); color: var(--muted); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.chart-box { position: relative; height: 320px; }
.chart-note { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 13px; color: var(--muted); }
.chart-note .ring { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--indigo); background: var(--surface); }

.methods { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.methods li { display: grid; gap: 7px; font-size: 14px; }
.methods .row { display: flex; justify-content: space-between; gap: 10px; }
.methods .row span:last-child { color: var(--muted); font-family: var(--font-display); }
.methods .track { height: 8px; background: var(--paper); border-radius: 4px; overflow: hidden; }
.methods .track span { display: block; height: 100%; background: linear-gradient(90deg, var(--indigo), var(--sky)); border-radius: 4px; }
.owed { display: grid; gap: 10px; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.owed a { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: var(--radius); background: var(--paper); color: var(--ink); }
.owed a:hover { text-decoration: none; background: var(--hover-strong); }
.owed .num { font-size: 15px; }

.queue-list { list-style: none; margin: 0; padding: 0; }
.queue-list li { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.queue-list li:first-child { border-top: 0; }
.queue-list .person { flex: 1; }
.queue-empty { display: grid; justify-items: center; gap: 8px; padding: 30px 10px; text-align: center; color: var(--muted); }
.queue-empty i { font-size: 26px; color: var(--green); }

.all-time { display: flex; gap: 10px 28px; flex-wrap: wrap; color: var(--muted); font-size: 14px; margin-top: 4px; }
.all-time strong { color: var(--ink); font: 600 15px/1 var(--font-display); margin-right: 4px; }

/* ---------- Reports ---------- */
.report-filters { padding: 14px 18px; margin-bottom: 20px; display: grid; gap: 12px; }
.filter-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 12px; border-top: 1px solid var(--line); }
.date-range { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.date-range .form-control { width: auto; min-height: 36px; padding: 6px 10px; font-size: 14px; }
.seg a { padding: 7px 12px; border-radius: 7px; font-size: 13.5px; font-weight: 500; color: var(--muted); }
.seg a:hover { color: var(--ink); text-decoration: none; }
.seg a.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.kpis-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.kpis-5 .kpi-value { font-size: 28px; }
.report-section { margin-bottom: 20px; overflow: hidden; }
.report-grid { align-items: stretch; }
.legend { display: flex; gap: 18px; margin-bottom: 10px; font-size: 13.5px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.key { width: 12px; height: 12px; border-radius: 3px; }
.key-profit { background: var(--series-profit); }
.key-cost { background: var(--series-cost); }
.table tfoot td { padding: 13px 14px; font-weight: 600; border-top: 1px solid var(--line-strong); background: var(--subtle); }
.table .strong { font-weight: 600; }
.table .neg { color: var(--rose); }
.share { display: flex; align-items: center; gap: 10px; }
.share .track { flex: 1; height: 8px; background: var(--paper); border-radius: 4px; overflow: hidden; }
.share .track span { display: block; height: 100%; background: var(--series-profit); border-radius: 4px; }
.share .num { width: 38px; text-align: right; color: var(--muted); font-size: 13.5px; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.mini-title { font-size: 14px; color: var(--muted); font-weight: 500; font-family: var(--font-body); margin-bottom: 12px; }
.status-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.status-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 14px; }
.aging { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.aging li { display: grid; grid-template-columns: 96px minmax(0, 1fr) 84px 70px; align-items: center; gap: 12px; font-size: 14px; }
.aging .track { height: 10px; background: var(--paper); border-radius: 5px; overflow: hidden; }
.aging .track span { display: block; height: 100%; background: var(--amber); border-radius: 5px; }
.aging .num { text-align: right; }
.aging .muted { font-size: 13px; text-align: right; }
.recon { margin: 0; display: grid; }
.recon div { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; padding: 9px 0; border-top: 1px solid var(--line); }
.recon div:first-child { border-top: 0; }
.recon dt { font-size: 14.5px; }
.recon dt .hint { display: block; }
.recon dd { margin: 0; font-size: 15px; white-space: nowrap; }
.recon .minus { color: var(--rose); }
.recon .plus { color: var(--green); }
.recon .total dt, .recon .total dd { font-weight: 600; }
.recon .total { border-top: 1px solid var(--line-strong); }
.recon-note { display: flex; gap: 8px; margin-top: 14px; padding: 10px 12px; border-radius: var(--radius); background: var(--amber-tint); color: var(--amber); font-size: 13.5px; }
.recon-note i { margin-top: 3px; }
details.method { padding: 0; }
details.method summary { padding: 16px 22px; cursor: pointer; font-weight: 500; color: var(--ink); }
details.method ul { margin: 0; padding: 0 22px 18px 40px; color: var(--muted); font-size: 14px; display: grid; gap: 6px; }
details.method strong { color: var(--ink); font-weight: 500; }

/* ---------- Login ---------- */
.login {
    position: relative; min-height: 100vh; overflow: hidden;
    display: grid; place-items: center; gap: 20px; align-content: center;
    padding: 48px 16px;
    background: var(--paper);
}
.login::before {
    /* faint Kufic lattice that fades out around the card */
    content: ''; position: absolute; inset: 0; pointer-events: none;
    background-image:
        linear-gradient(45deg, var(--line) 1px, transparent 1px),
        linear-gradient(-45deg, var(--line) 1px, transparent 1px);
    background-size: 36px 36px;
    -webkit-mask-image: radial-gradient(60% 55% at 50% 45%, #000 0%, transparent 75%);
    mask-image: radial-gradient(60% 55% at 50% 45%, #000 0%, transparent 75%);
    opacity: .8;
}
.login::after {
    content: ''; position: absolute; left: 50%; top: -220px; width: 760px; height: 480px; pointer-events: none;
    transform: translateX(-50%);
    background: radial-gradient(closest-side, var(--indigo-tint), transparent);
}
.login > * { position: relative; z-index: 1; }
.login > .theme-toggle { position: absolute; top: 20px; right: 20px; }
.login-card {
    width: 100%; max-width: 420px;
    padding: 36px 36px 32px;
    background: var(--surface); border: 1px solid var(--line); border-radius: 20px;
    box-shadow: 0 1px 2px rgba(23, 26, 51, .05), 0 24px 48px -24px rgba(23, 26, 51, .18);
}
.login-brand { display: flex; align-items: center; gap: 14px; padding-bottom: 24px; margin-bottom: 26px; border-bottom: 1px solid var(--line); }
.login-brand img { width: 52px; height: 52px; background: var(--logo-bg); border-radius: 12px; padding: var(--logo-pad); }
.login-brand strong { display: block; font: 600 22px/1.1 var(--font-display); font-stretch: 90%; color: var(--ink); }
.login-brand span { display: block; margin-top: 2px; font-size: 14px; color: var(--muted); }
.login-card form { display: grid; gap: 18px; }
.login-card h1 { font-size: 24px; }
.login-card .intro { color: var(--muted); margin-top: 4px; }
.input-icon { position: relative; }
.input-icon > i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--faint); font-size: 14px; pointer-events: none; }
.input-icon .form-control { padding-left: 40px; min-height: 46px; }
.input-icon .reveal { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); }
.input-icon .form-control.has-reveal { padding-right: 46px; }
.login-card .btn-lg { margin-top: 4px; }
.login-foot { font-size: 13px; color: var(--faint); text-align: center; }

/* ---------- Theme toggle ---------- */
.theme-toggle { color: var(--muted); border: 1px solid var(--line-strong); background: var(--surface); }
.theme-toggle:hover { color: var(--indigo); border-color: var(--indigo); background: var(--surface); }
.select2-dropdown { background: var(--surface); color: var(--ink); }
.select2-container--default .select2-selection--single { background: var(--surface); }
.select2-container--default .select2-results__option[aria-selected=true] { background: var(--hover-strong); }
.select2-container--default .select2-search--dropdown .select2-search__field { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
    .dash-grid, .form-grid { grid-template-columns: minmax(0, 1fr); }
    .kpis, .kpis-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .summary { position: static; }
}
@media (max-width: 900px) {
    .shell { grid-template-columns: minmax(0, 1fr); }
    .sidebar {
        position: fixed; inset: 0 auto 0 0; width: min(280px, 84vw); z-index: 30;
        transform: translateX(-100%); transition: transform .2s ease;
    }
    body.nav-open .sidebar { transform: none; }
    body.nav-open .scrim { position: fixed; inset: 0; background: rgba(8, 9, 20, .55); z-index: 20; }
    .topbar {
        position: sticky; top: 0; z-index: 10;
        display: flex; align-items: center; gap: 10px;
        padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
    }
    .topbar .brand { padding: 0; margin-right: auto; }
    .topbar .brand img { width: 30px; height: 30px; }
    .appbar { display: none; }
    body.nav-open .scrim { display: block; }
    .hero { padding: 22px 20px; }
    .hero h1 { font-size: 24px; }
    .kpi { padding: 14px 16px; }
    .kpi-value { font-size: 26px; }
    .chart-box { height: 220px; }
    .two-col { grid-template-columns: minmax(0, 1fr); }
    .aging li { grid-template-columns: 84px minmax(0, 1fr) 76px; }
    .aging li .muted { display: none; }
    .main { padding: 20px 16px 40px; }
    .sidebar { box-shadow: 0 0 40px rgba(23, 26, 51, .2); }
    h1, .greeting h1 { font-size: 26px; }
    .fields, .fields-4 { grid-template-columns: minmax(0, 1fr); }
    .search { min-width: 0; width: 100%; }
    .login { align-content: start; padding-top: 72px; }
    .login-card { padding: 26px 22px 24px; }
    .hide-sm { display: none; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; }
}
