/* ══════════════════════════════════════════════════════════════════════════
   Scanly — Dashboard design system
   One stylesheet for the whole authenticated area. Written with logical
   properties throughout, so the same rules serve RTL and LTR.
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Tokens ─────────────────────────────────────────────────────────────── */
:root {
    /* Surfaces */
    --bg:          #F5F6F8;
    --surface:     #FFFFFF;
    --surface-2:   #FAFBFC;
    --surface-3:   #F2F4F7;

    /* Lines */
    --line:        #E3E6EB;
    --line-soft:   #EDEFF3;
    --line-strong: #D4D9E0;

    /* Text */
    --text:        #11161D;
    --text-2:      #39414E;
    --muted:       #68707D;
    --faint:       #98A0AC;

    /* Brand accent (Scanly green — same as the public site) */
    --brand:       #1E8A4C;
    --brand-d:     #176E3C;
    --brand-l:     #EDF6F1;
    --brand-b:     #CBE6D7;

    /* Semantic */
    --ok:          #15803D;  --ok-s:    #ECFAF1;  --ok-b:    #C7E9D5;
    --warn:        #B45309;  --warn-s:  #FEF6EC;  --warn-b:  #F6DFBE;
    --danger:      #C62828;  --danger-s:#FDF0F0;  --danger-b:#F3CFCF;
    --info:        #1D4ED8;  --info-s:  #EEF3FE;  --info-b:  #CFDCFA;
    --neutral-s:   #F1F3F6;  --neutral-b:#E1E5EB;

    /* Sidebar */
    --sb-w:        248px;
    --sb-bg:       #10141A;
    --sb-bg-2:     #171C24;
    --sb-line:     rgba(255,255,255,.07);
    --sb-text:     #98A1AE;
    --sb-text-str: #E7EAEF;

    /* Shape */
    --r-xs: 6px;
    --r:    8px;
    --r-lg: 10px;
    --r-xl: 12px;

    /* Elevation — used sparingly, only for things that float */
    --sh-1: 0 1px 2px rgba(17,22,29,.05);
    --sh-2: 0 6px 20px rgba(17,22,29,.10), 0 1px 3px rgba(17,22,29,.06);
    --sh-3: 0 16px 48px rgba(17,22,29,.18);

    --ease: cubic-bezier(.3, .8, .4, 1);
}

/* ── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    -webkit-text-size-adjust: 100%;
    /* The off-canvas sidebar sits outside the page on phones; clipping here stops
       it from widening the document (and sideways-scrolling the whole screen).
       `clip` rather than `hidden` so sticky headers keep working. */
    overflow-x: clip;
}

body.app {
    background: var(--bg);
    color: var(--text);
    font-family: 'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-size: 14px;
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
table { border-collapse: collapse; width: 100%; }
[hidden] { display: none !important; }

::selection { background: var(--brand-b); color: var(--text); }

:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
    border-radius: var(--r-xs);
}

/* Numbers always read left-to-right and line up in columns */
.num, .table td.num, .table th.num {
    font-variant-numeric: tabular-nums;
    font-feature-settings: 'tnum' 1;
    direction: ltr;
    unicode-bidi: isolate;
    text-align: start;
}

/* ══════════════════════════════════════════════════════════════════════════
   SHELL
   ══════════════════════════════════════════════════════════════════════════ */
.app { display: block; }

.shell { min-height: 100vh; }

.main {
    margin-inline-start: var(--sb-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main__inner {
    width: 100%;
    max-width: 1320px;
    margin-inline: auto;
    padding: 24px 28px 64px;
    flex: 1;
}

/* ── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    width: var(--sb-w);
    background: var(--sb-bg);
    display: flex;
    flex-direction: column;
    z-index: 60;
    border-inline-end: 1px solid rgba(255,255,255,.06);
}

.sb-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 16px 14px;
    border-bottom: 1px solid var(--sb-line);
}
.sb-brand__mark {
    width: 32px; height: 32px;
    border-radius: var(--r);
    background: var(--brand);
    color: #fff;
    display: grid; place-items: center;
    font-size: 14px; font-weight: 700;
    flex: none;
    overflow: hidden;
}
.sb-brand__mark img { width: 100%; height: 100%; object-fit: cover; }
.sb-brand__txt { min-width: 0; }
.sb-brand__name {
    font-size: 13.5px; font-weight: 600; color: #fff;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sb-brand__sub {
    font-size: 10.5px; color: rgba(255,255,255,.34);
    letter-spacing: .08em; text-transform: uppercase; margin-top: 1px;
}

.sb-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0 14px;
    /* No visible scrollbar in the nav — it still scrolls, it just doesn't
       cut a light strip down the dark sidebar. */
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.sb-scroll::-webkit-scrollbar { width: 0; height: 0; display: none; }

.sb-group { padding: 0 10px; }
.sb-group + .sb-group { margin-top: 18px; }
.sb-group__label {
    font-size: 10px; font-weight: 600; letter-spacing: .12em;
    text-transform: uppercase; color: rgba(255,255,255,.3);
    padding: 0 8px 7px;
}

.sb-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px;
    border-radius: var(--r);
    color: var(--sb-text);
    font-size: 13.5px; font-weight: 500;
    transition: background .15s var(--ease), color .15s var(--ease);
    position: relative;
}
.sb-item + .sb-item { margin-top: 1px; }
.sb-item svg { width: 17px; height: 17px; flex: none; opacity: .85; }
.sb-item:hover { background: rgba(255,255,255,.055); color: var(--sb-text-str); }
.sb-item.is-active {
    background: rgba(30,138,76,.16);
    color: #fff;
    font-weight: 600;
}
.sb-item.is-active svg { opacity: 1; color: #46BB7C; }
.sb-item.is-active::before {
    content: '';
    position: absolute;
    inset-inline-start: -10px;
    top: 50%; transform: translateY(-50%);
    width: 3px; height: 20px;
    background: #46BB7C;
    border-start-end-radius: 3px; border-end-end-radius: 3px;
}
.sb-item__label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sb-count {
    font-size: 11px; font-weight: 600;
    min-width: 20px; padding: 1px 6px;
    border-radius: 20px; text-align: center;
    font-variant-numeric: tabular-nums;
    background: rgba(255,255,255,.08); color: rgba(255,255,255,.6);
}
.sb-count--alert { background: rgba(198,40,40,.22); color: #F1998E; }

.sb-foot { padding: 10px; border-top: 1px solid var(--sb-line); display: grid; gap: 6px; }
.sb-foot__row { display: flex; gap: 6px; }
.sb-foot__row > * { flex: 1; }
.sb-fbtn {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    width: 100%;
    padding: 8px 10px;
    border-radius: var(--r);
    border: 1px solid rgba(255,255,255,.1);
    background: rgba(255,255,255,.04);
    color: rgba(255,255,255,.72);
    font-size: 12.5px; font-weight: 500;
    cursor: pointer;
    transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
}
.sb-fbtn svg { width: 15px; height: 15px; }
.sb-fbtn:hover { background: rgba(255,255,255,.1); color: #fff; }
.sb-fbtn--danger { color: rgba(241,153,142,.8); border-color: rgba(198,40,40,.22); background: rgba(198,40,40,.08); }
.sb-fbtn--danger:hover { background: rgba(198,40,40,.18); color: #F8B4AB; }

.sb-overlay { display: none; position: fixed; inset: 0; background: rgba(8,11,15,.55); z-index: 55; }
.sb-overlay.is-open { display: block; }

/* ── Mobile top bar ─────────────────────────────────────────────────────── */
.topbar {
    display: none;
    align-items: center;
    gap: 10px;
    height: 54px;
    padding-inline: 14px;
    background: var(--sb-bg);
    position: sticky; top: 0; z-index: 50;
}
.topbar__btn {
    width: 34px; height: 34px;
    display: grid; place-items: center;
    border-radius: var(--r);
    border: 1px solid rgba(255,255,255,.12);
    background: rgba(255,255,255,.04);
    color: #fff; cursor: pointer;
}
.topbar__btn svg { width: 18px; height: 18px; }
.topbar__title { color: #fff; font-size: 14px; font-weight: 600; flex: 1; min-width: 0;
                 white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ══════════════════════════════════════════════════════════════════════════
   PAGE HEADER
   ══════════════════════════════════════════════════════════════════════════ */
.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding-bottom: 16px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--line);
}
.page-head__t { min-width: 0; }
.page-head h1 { font-size: 19px; font-weight: 600; letter-spacing: -.01em; line-height: 1.35; }
.page-head__sub { font-size: 13px; color: var(--muted); margin-top: 3px; }
.page-head__actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb svg { width: 13px; height: 13px; opacity: .6; }
[dir="rtl"] .breadcrumb svg { transform: scaleX(-1); }

/* ══════════════════════════════════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════════════════════════════════ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    height: 36px;
    padding-inline: 14px;
    border-radius: var(--r);
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--text-2);
    font-size: 13.5px; font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s var(--ease), border-color .15s var(--ease),
                color .15s var(--ease), box-shadow .15s var(--ease), opacity .15s;
}
.btn svg { width: 16px; height: 16px; flex: none; }
.btn:hover { background: var(--surface-3); border-color: var(--line-strong); color: var(--text); }
.btn:active { transform: translateY(.5px); }
.btn[disabled], .btn.is-disabled { opacity: .55; pointer-events: none; }

.btn--primary {
    background: var(--brand); border-color: var(--brand); color: #fff;
}
.btn--primary:hover { background: var(--brand-d); border-color: var(--brand-d); color: #fff; }

.btn--danger { background: var(--surface); border-color: var(--danger-b); color: var(--danger); }
.btn--danger:hover { background: var(--danger-s); border-color: var(--danger); color: var(--danger); }

.btn--solid-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--solid-danger:hover { background: #A81F1F; border-color: #A81F1F; color: #fff; }

.btn--ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn--ghost:hover { background: var(--surface-3); color: var(--text); }

.btn--sm { height: 30px; padding-inline: 10px; font-size: 12.5px; border-radius: var(--r-xs); }
.btn--sm svg { width: 14px; height: 14px; }
.btn--lg { height: 42px; padding-inline: 20px; font-size: 14.5px; }
.btn--icon { width: 34px; padding-inline: 0; }
.btn--icon.btn--sm { width: 30px; }
.btn--block { width: 100%; }

/* ══════════════════════════════════════════════════════════════════════════
   CARDS & SECTIONS
   ══════════════════════════════════════════════════════════════════════════ */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
}
.card--flush { overflow: hidden; }

.card__head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; flex-wrap: wrap;
    padding: 13px 16px;
    border-bottom: 1px solid var(--line-soft);
}
.card__title { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card__title svg { width: 16px; height: 16px; color: var(--muted); }
.card__sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.card__body { padding: 16px; }
.card__body--tight { padding: 12px 16px; }
.card__foot {
    padding: 12px 16px;
    border-top: 1px solid var(--line-soft);
    background: var(--surface-2);
    display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
    border-end-start-radius: var(--r-lg); border-end-end-radius: var(--r-lg);
}

.section-title {
    font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
    color: var(--faint); margin-bottom: 10px;
}

/* ══════════════════════════════════════════════════════════════════════════
   KPI TILES
   ══════════════════════════════════════════════════════════════════════════ */
.kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    overflow: hidden;
}
.kpi { padding: 14px 16px; border-inline-start: 1px solid var(--line-soft); }
.kpi:first-child { border-inline-start: 0; }
.kpi__label { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.kpi__label svg { width: 14px; height: 14px; opacity: .8; }
.kpi__value {
    font-size: 24px; font-weight: 600; letter-spacing: -.02em; line-height: 1.25; margin-top: 6px;
    font-variant-numeric: tabular-nums;
}
.kpi__value small { font-size: 13px; font-weight: 500; color: var(--muted); margin-inline-start: 3px; }
.kpi__foot { font-size: 12px; color: var(--faint); margin-top: 4px; display: flex; align-items: center; gap: 5px; }
.kpi__delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi__delta svg { width: 13px; height: 13px; }
.kpi__delta--up   { color: var(--ok); }
.kpi__delta--down { color: var(--danger); }
.kpi__delta--flat { color: var(--faint); }

/* ══════════════════════════════════════════════════════════════════════════
   BADGES, CHIPS, DOTS
   ══════════════════════════════════════════════════════════════════════════ */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 12px; font-weight: 500;
    background: var(--neutral-s);
    border: 1px solid var(--neutral-b);
    color: var(--text-2);
    white-space: nowrap;
}
.badge svg { width: 12px; height: 12px; }
.badge--ok     { background: var(--ok-s);     border-color: var(--ok-b);     color: var(--ok); }
.badge--warn   { background: var(--warn-s);   border-color: var(--warn-b);   color: var(--warn); }
.badge--danger { background: var(--danger-s); border-color: var(--danger-b); color: var(--danger); }
.badge--info   { background: var(--info-s);   border-color: var(--info-b);   color: var(--info); }
.badge--brand  { background: var(--brand-l);  border-color: var(--brand-b);  color: var(--brand-d); }

.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }

.chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 9px;
    border: 1px solid var(--line);
    border-radius: var(--r-xs);
    background: var(--surface-2);
    font-size: 12.5px; color: var(--text-2);
}
.chip strong { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ══════════════════════════════════════════════════════════════════════════
   TABLES
   ══════════════════════════════════════════════════════════════════════════ */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.table { font-size: 13.5px; }
.table th {
    text-align: start;
    font-size: 12px; font-weight: 600; color: var(--muted);
    padding: 9px 16px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.table td {
    padding: 11px 16px;
    border-bottom: 1px solid var(--line-soft);
    vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s var(--ease); }
.table tbody tr:hover { background: var(--surface-2); }
.table .t-main { font-weight: 500; color: var(--text); }
.table .t-sub { font-size: 12.5px; color: var(--muted); }
.table .t-actions { display: flex; align-items: center; gap: 6px; justify-content: flex-end; }
.table td.shrink, .table th.shrink { width: 1%; white-space: nowrap; }

.thumb {
    width: 38px; height: 38px; border-radius: var(--r);
    object-fit: cover; background: var(--surface-3);
    border: 1px solid var(--line-soft); flex: none;
}
.thumb--lg { width: 52px; height: 52px; }
.thumb--ph { display: grid; place-items: center; color: var(--faint); }
.thumb--ph svg { width: 16px; height: 16px; }

.cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cell__txt { min-width: 0; }
.cell__txt .t-main, .cell__txt .t-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ══════════════════════════════════════════════════════════════════════════
   FORMS
   ══════════════════════════════════════════════════════════════════════════ */
.form-grid { display: grid; gap: 16px; }
.form-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-row { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }

.field { display: block; }
.field + .field { margin-top: 15px; }
.label {
    display: flex; align-items: center; gap: 6px;
    font-size: 12.5px; font-weight: 500; color: var(--text-2);
    margin-bottom: 6px;
}
.label .req { color: var(--danger); }
.label__hint { margin-inline-start: auto; font-size: 11.5px; color: var(--faint); font-weight: 400; }

.input, .select, .textarea {
    width: 100%;
    min-height: 38px;
    padding: 8px 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--r);
    background: var(--surface);
    color: var(--text);
    font-size: 13.5px;
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background .15s;
}
.textarea { min-height: 92px; resize: vertical; line-height: 1.7; }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:hover, .select:hover, .textarea:hover { border-color: #BFC6D0; }
.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(30,138,76,.12);
}
.input[readonly], .input[disabled], .select[disabled] { background: var(--surface-3); color: var(--muted); cursor: not-allowed; }
.input.is-invalid, .select.is-invalid, .textarea.is-invalid { border-color: var(--danger); }
.input.is-invalid:focus { box-shadow: 0 0 0 3px rgba(198,40,40,.12); }

.select {
    appearance: none;
    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='%2368707D' 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: left 10px center;
    padding-inline-end: 12px;
    padding-inline-start: 34px;
}
[dir="ltr"] .select { background-position: right 10px center; padding-inline-start: 12px; padding-inline-end: 34px; }

.hint { font-size: 12px; color: var(--muted); margin-top: 5px; line-height: 1.6; }
.err  { font-size: 12px; color: var(--danger); margin-top: 5px; display: flex; align-items: center; gap: 5px; }
.err svg { width: 13px; height: 13px; flex: none; }

/* Input with a unit / prefix */
.input-group { display: flex; }
.input-group .input { border-start-end-radius: 0; border-end-end-radius: 0; }
.input-group__suffix {
    display: grid; place-items: center;
    padding-inline: 12px;
    border: 1px solid var(--line-strong);
    border-inline-start: 0;
    border-start-end-radius: var(--r); border-end-end-radius: var(--r);
    background: var(--surface-3);
    color: var(--muted); font-size: 12.5px; white-space: nowrap;
}

/* Search box */
.search { position: relative; }
.search svg {
    position: absolute; inset-inline-start: 11px; top: 50%; transform: translateY(-50%);
    width: 15px; height: 15px; color: var(--faint); pointer-events: none;
}
.search .input { padding-inline-start: 34px; }

/* Checkbox / radio */
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13.5px; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); cursor: pointer; }

/* Switch */
.switch { position: relative; display: inline-block; width: 40px; height: 23px; flex: none; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 2; }
.switch__track {
    position: absolute; inset: 0;
    background: #CBD2DB; border-radius: 20px;
    transition: background .2s var(--ease);
}
.switch__knob {
    position: absolute; top: 3px; inset-inline-start: 3px;
    width: 17px; height: 17px; border-radius: 50%;
    background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25);
    transition: transform .2s var(--ease);
}
.switch input:checked ~ .switch__track { background: var(--brand); }
.switch input:checked ~ .switch__knob  { transform: translateX(17px); }
[dir="rtl"] .switch input:checked ~ .switch__knob { transform: translateX(-17px); }
.switch input:focus-visible ~ .switch__track { box-shadow: 0 0 0 3px rgba(30,138,76,.2); }

/* A setting row: label + description + control */
.setting {
    display: flex; align-items: center; gap: 14px;
    padding: 13px 16px;
    border-bottom: 1px solid var(--line-soft);
}
.setting:last-child { border-bottom: 0; }
.setting__txt { flex: 1; min-width: 0; }
.setting__title { font-size: 13.5px; font-weight: 500; }
.setting__sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.setting.is-off { opacity: .55; }
.setting--link:hover { background: var(--surface-2); }

/* File upload / dropzone */
.upload {
    position: relative;
    display: block;
    border: 1px dashed var(--line-strong);
    border-radius: var(--r);
    background: var(--surface-2);
    padding: 18px 16px;
    text-align: center;
    cursor: pointer;
    transition: border-color .15s var(--ease), background .15s var(--ease);
}
.upload:hover, .upload.is-drag { border-color: var(--brand); background: var(--brand-l); }
.upload input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.upload__icon { width: 34px; height: 34px; margin: 0 auto 8px; border-radius: var(--r); display: grid; place-items: center;
                background: var(--surface-3); color: var(--muted); }
.upload__icon svg { width: 17px; height: 17px; }
.upload__text { font-size: 13px; font-weight: 500; }
.upload__sub  { font-size: 12px; color: var(--muted); margin-top: 2px; }
.upload__name { font-size: 12.5px; color: var(--ok); margin-top: 8px; }
.upload__preview { margin-top: 12px; }
.upload__preview img { max-height: 148px; border-radius: var(--r); margin-inline: auto; border: 1px solid var(--line); }

/* A media row: current image beside the uploader */
.media-row { display: flex; gap: 14px; align-items: flex-start; }
.media-row__current { flex: none; }
.media-row__current img { width: 96px; height: 96px; object-fit: cover; border-radius: var(--r); border: 1px solid var(--line); }
.media-row__up { flex: 1; min-width: 0; }

/* Form page shell + sticky action bar */
.form-page { max-width: 760px; }
.form-page--wide { max-width: 1000px; }
.form-actions {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    padding: 12px 16px;
    border-top: 1px solid var(--line-soft);
    background: var(--surface-2);
    border-end-start-radius: var(--r-lg); border-end-end-radius: var(--r-lg);
}
.form-actions__spacer { flex: 1; }

/* Size / price repeater rows */
.size-row {
    display: grid;
    grid-template-columns: minmax(80px, 150px) minmax(0, 1fr) auto;
    align-items: center; gap: 10px;
    padding: 9px 0;
    border-bottom: 1px solid var(--line-soft);
}
.size-row:last-child { border-bottom: 0; }
.size-row__name { font-size: 13.5px; font-weight: 500; }
@media (max-width: 560px) {
    .size-row { grid-template-columns: 1fr auto; }
    .size-row__name { grid-column: 1 / -1; }
}

/* ══════════════════════════════════════════════════════════════════════════
   ALERTS & EMPTY STATES
   ══════════════════════════════════════════════════════════════════════════ */
.alert {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 11px 14px;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--surface);
    font-size: 13px; line-height: 1.65;
    margin-bottom: 16px;
}
.alert svg { width: 16px; height: 16px; flex: none; margin-top: 2px; }
.alert__body { flex: 1; min-width: 0; }
.alert__title { font-weight: 600; }
.alert--ok     { background: var(--ok-s);     border-color: var(--ok-b);     color: #14532D; }
.alert--ok svg { color: var(--ok); }
.alert--warn   { background: var(--warn-s);   border-color: var(--warn-b);   color: #7C3B06; }
.alert--warn svg { color: var(--warn); }
.alert--danger { background: var(--danger-s); border-color: var(--danger-b); color: #8E1F1F; }
.alert--danger svg { color: var(--danger); }
.alert--info   { background: var(--info-s);   border-color: var(--info-b);   color: #1E3A8A; }
.alert--info svg { color: var(--info); }

.empty {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center;
    padding: 48px 24px;
}
.empty__icon {
    width: 44px; height: 44px; border-radius: var(--r-lg);
    display: grid; place-items: center;
    background: var(--surface-3); color: var(--muted);
    margin-bottom: 14px;
}
.empty__icon svg { width: 20px; height: 20px; }
.empty__title { font-size: 14.5px; font-weight: 600; }
.empty__sub { font-size: 13px; color: var(--muted); margin-top: 4px; max-width: 380px; }
.empty .btn { margin-top: 16px; }

/* ══════════════════════════════════════════════════════════════════════════
   TABS / FILTERS / PAGINATION
   ══════════════════════════════════════════════════════════════════════════ */
.tabs {
    display: flex; gap: 2px;
    border-bottom: 1px solid var(--line);
    overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 9px 13px;
    font-size: 13.5px; color: var(--muted); font-weight: 500;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    white-space: nowrap;
    transition: color .15s var(--ease), border-color .15s var(--ease);
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--brand-d); border-bottom-color: var(--brand); font-weight: 600; }
.tab__count {
    font-size: 11.5px; font-variant-numeric: tabular-nums;
    background: var(--surface-3); color: var(--muted);
    border-radius: 20px; padding: 0 6px;
}
.tab.is-active .tab__count { background: var(--brand-l); color: var(--brand-d); }

.segmented {
    display: inline-flex; padding: 3px; gap: 2px;
    background: var(--surface-3); border-radius: var(--r);
}
.segmented a, .segmented button {
    padding: 5px 11px; border-radius: var(--r-xs);
    font-size: 12.5px; color: var(--muted); font-weight: 500;
    border: 0; background: none; cursor: pointer;
    transition: background .15s var(--ease), color .15s var(--ease);
}
.segmented a:hover, .segmented button:hover { color: var(--text); }
.segmented .is-active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--sh-1); }

.toolbar {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    margin-bottom: 14px;
}
.toolbar__spacer { flex: 1; }

/* Laravel pagination inside .pagination-wrap */
.pagination-wrap { padding: 12px 16px; border-top: 1px solid var(--line-soft); }
.pagination-wrap nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.pagination-wrap svg { width: 16px; height: 16px; }
.pagination-wrap .hidden { display: none; }
.pagination-wrap span[aria-current="page"] span,
.pagination-wrap a {
    display: inline-grid; place-items: center;
    min-width: 30px; height: 30px; padding-inline: 8px;
    border: 1px solid var(--line); border-radius: var(--r-xs);
    background: var(--surface); color: var(--text-2);
    font-size: 13px; font-variant-numeric: tabular-nums;
    transition: background .15s var(--ease), border-color .15s var(--ease);
}
.pagination-wrap a:hover { background: var(--surface-3); }
.pagination-wrap span[aria-current="page"] span { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.pagination-wrap span[aria-disabled="true"] span { opacity: .45; }
.pagination-wrap nav > div:last-child { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }

/* ══════════════════════════════════════════════════════════════════════════
   CHART PRIMITIVES (pure CSS/SVG — no chart library)
   ══════════════════════════════════════════════════════════════════════════ */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 150px; }
.bars__col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; height: 100%; position: relative; }
.bars__bar { width: 100%; border-radius: 3px 3px 0 0; background: var(--brand); min-height: 2px; transition: opacity .15s; }
.bars__bar--muted { background: var(--brand-b); }
.bars__col:hover .bars__bar { opacity: .82; }
.bars__tip {
    position: absolute; bottom: calc(100% + 6px); inset-inline-start: 50%; transform: translateX(50%);
    background: var(--text); color: #fff; font-size: 11.5px; line-height: 1.5;
    padding: 4px 8px; border-radius: var(--r-xs); white-space: nowrap;
    opacity: 0; pointer-events: none; transition: opacity .15s; z-index: 5;
}
[dir="ltr"] .bars__tip { transform: translateX(-50%); }
.bars__col:hover .bars__tip { opacity: 1; }
.bars-x { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--faint); margin-top: 8px; }

.spark { display: flex; align-items: flex-end; gap: 2px; height: 26px; width: 72px; }
.spark span { flex: 1; background: var(--brand-b); border-radius: 2px; min-height: 2px; }

.meter { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.meter__fill { height: 100%; border-radius: 3px; background: var(--brand); }
.meter__fill--warn { background: var(--warn); }
.meter__fill--danger { background: var(--danger); }

/* Rank list (popular products, menu performance) */
.rank { display: flex; align-items: center; gap: 12px; padding: 9px 16px; border-bottom: 1px solid var(--line-soft); }
.rank:last-child { border-bottom: 0; }
.rank__n {
    width: 22px; height: 22px; border-radius: var(--r-xs); flex: none;
    display: grid; place-items: center;
    background: var(--surface-3); color: var(--muted);
    font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.rank__txt { flex: 1; min-width: 0; }
.rank__name { font-size: 13.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank__sub { font-size: 12px; color: var(--muted); }
.rank__val { font-size: 13.5px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ── Media cards (offers, menus, branches) ─────────────────────────────── */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(258px, 1fr)); gap: 14px; }
.ocard {
    display: flex; flex-direction: column;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
    overflow: hidden;
    transition: border-color .15s var(--ease);
}
.ocard:hover { border-color: var(--line-strong); }
.ocard__media { aspect-ratio: 16 / 9; background: var(--surface-3); display: grid; place-items: center; color: var(--faint); position: relative; }
.ocard__media img { width: 100%; height: 100%; object-fit: cover; }
.ocard__media svg { width: 22px; height: 22px; }
.ocard__flag { position: absolute; top: 8px; inset-inline-start: 8px; }
.ocard__body { padding: 12px 14px; flex: 1; min-width: 0; }
.ocard__title { font-size: 14px; font-weight: 600; }
.ocard__desc { font-size: 12.5px; color: var(--muted); margin-top: 3px; line-height: 1.6; }
.ocard__foot {
    padding: 10px 14px; border-top: 1px solid var(--line-soft);
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap; background: var(--surface-2);
}
.price-now { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.price-was { font-size: 12.5px; color: var(--muted); text-decoration: line-through; font-variant-numeric: tabular-nums; }

/* ══════════════════════════════════════════════════════════════════════════
   OFFER BUILDER
   The multi-select, size picker and pricing switch used when composing an
   offer out of menu items. Class names match the page script.
   ══════════════════════════════════════════════════════════════════════════ */
.custom-select-wrap { position: relative; }
.custom-select-trigger {
    display: flex; align-items: center; gap: 10px;
    min-height: 40px; padding: 6px 12px;
    border: 1px solid var(--line-strong); border-radius: var(--r);
    background: var(--surface); cursor: pointer;
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.custom-select-wrap.open .custom-select-trigger { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(30,138,76,.12); }
.custom-select-trigger__tags { flex: 1; display: flex; flex-wrap: wrap; gap: 5px; min-width: 0; }
.custom-select-trigger__ph { color: var(--faint); font-size: 13px; }
.custom-select-trigger__arrow { color: var(--muted); font-size: 11px; flex: none; transition: transform .15s var(--ease); }
.custom-select-wrap.open .custom-select-trigger__arrow { transform: rotate(180deg); }

.custom-select-dropdown {
    display: none;
    position: absolute; inset-inline: 0; top: calc(100% + 4px);
    background: var(--surface);
    border: 1px solid var(--line); border-radius: var(--r);
    box-shadow: var(--sh-2);
    z-index: 40; overflow: hidden;
}
.custom-select-wrap.open .custom-select-dropdown { display: block; }
.custom-select-search { padding: 8px; border-bottom: 1px solid var(--line-soft); }
.custom-select-search input {
    width: 100%; height: 32px; padding: 0 10px;
    border: 1px solid var(--line-strong); border-radius: var(--r-xs);
    font-size: 13px; background: var(--surface);
}
.custom-select-search input:focus { outline: none; border-color: var(--brand); }
.custom-select-list { max-height: 260px; overflow-y: auto; }

.custom-select-option {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; cursor: pointer;
    border-bottom: 1px solid var(--line-soft);
    transition: background .12s var(--ease);
}
.custom-select-option:last-child { border-bottom: 0; }
.custom-select-option:hover { background: var(--surface-2); }
.custom-select-option.selected, .custom-select-option.free-selected { background: var(--brand-l); }

.option-check {
    width: 16px; height: 16px; flex: none;
    border: 1.5px solid var(--line-strong); border-radius: 4px;
    position: relative; transition: background .12s, border-color .12s;
}
.option-check--radio { border-radius: 50%; }
.custom-select-option.selected .option-check,
.custom-select-option.free-selected .option-check { background: var(--brand); border-color: var(--brand); }
.custom-select-option.selected .option-check::after,
.custom-select-option.free-selected .option-check::after {
    content: ''; position: absolute; inset-inline-start: 4.5px; top: 1px;
    width: 4px; height: 8px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.option-info { flex: 1; min-width: 0; display: grid; }
.option-name { font-size: 13.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.option-sub  { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.option-price { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.no-results { padding: 16px; text-align: center; color: var(--muted); font-size: 13px; }

.tag {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 4px 3px 8px;
    background: var(--brand-l); border: 1px solid var(--brand-b);
    border-radius: 20px; font-size: 12.5px; color: var(--brand-d);
}
.tag--free { background: var(--warn-s); border-color: var(--warn-b); color: var(--warn); padding-inline: 10px 8px; }
.tag__remove { cursor: pointer; opacity: .6; font-size: 14px; line-height: 1; }
.tag__remove:hover { opacity: 1; }
.tag__qty { display: inline-flex; align-items: center; gap: 3px; background: rgba(30,138,76,.12); border-radius: 20px; padding: 1px 4px; }
.tag__qty button {
    width: 17px; height: 17px; border: 0; border-radius: 50%;
    background: rgba(30,138,76,.18); color: var(--brand-d);
    font-size: 12px; font-weight: 700; line-height: 1; cursor: pointer;
    display: grid; place-items: center; padding: 0;
}
.tag__qty button:hover { background: rgba(30,138,76,.3); }
.tag__qty span { min-width: 14px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }

.selected-summary {
    display: none;
    align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    margin-top: 12px; padding: 10px 14px;
    background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r);
    font-size: 13px;
}
.selected-summary.show { display: flex; }
.selected-summary__total strong { font-variant-numeric: tabular-nums; font-size: 14.5px; }

.pricing-switch { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-3); border-radius: var(--r); }
.pricing-switch__btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 12px; border: 0; border-radius: var(--r-xs);
    background: none; color: var(--muted); font-size: 13px; font-weight: 500; cursor: pointer;
    transition: background .15s var(--ease), color .15s var(--ease);
}
.pricing-switch__btn svg { width: 15px; height: 15px; }
.pricing-switch__btn:hover { color: var(--text); }
.pricing-switch__btn.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--sh-1); }

.img-upload-zone {
    position: relative; display: block;
    border: 1px dashed var(--line-strong); border-radius: var(--r);
    background: var(--surface-2); padding: 18px 16px; text-align: center; cursor: pointer;
    transition: border-color .15s var(--ease), background .15s var(--ease);
}
.img-upload-zone:hover, .img-upload-zone.drag-over { border-color: var(--brand); background: var(--brand-l); }
.img-upload-zone input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.img-upload-zone__icon { display: grid; place-items: center; width: 34px; height: 34px; margin: 0 auto 8px;
                         border-radius: var(--r); background: var(--surface-3); color: var(--muted); }
.img-upload-zone__icon svg { width: 17px; height: 17px; }
.img-upload-zone__text { font-size: 13px; font-weight: 500; }
.img-upload-zone__sub  { font-size: 12px; color: var(--muted); margin-top: 2px; }

.img-preview-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.img-preview-item { position: relative; width: 84px; height: 84px; }
.img-preview-item img { width: 100%; height: 100%; object-fit: cover; border-radius: var(--r); border: 1px solid var(--line); }
.img-preview-item__remove {
    position: absolute; top: -6px; inset-inline-end: -6px;
    width: 20px; height: 20px; border-radius: 50%;
    border: 1px solid var(--line); background: var(--surface); color: var(--danger);
    font-size: 13px; line-height: 1; cursor: pointer; display: grid; place-items: center;
    box-shadow: var(--sh-1);
}
.img-upload-count { font-size: 12px; color: var(--muted); margin-top: 6px; }
.img-preview-item--marked img { opacity: .35; filter: grayscale(1); }
.img-preview-item__badge {
    position: absolute; bottom: 4px; inset-inline-start: 4px;
    background: rgba(17,22,29,.68); color: #fff;
    font-size: 10px; padding: 1px 6px; border-radius: 4px;
}
.img-preview-item__overlay {
    position: absolute; inset: 0; display: grid; place-items: center;
    background: rgba(255,255,255,.55); color: var(--danger); border-radius: var(--r);
}
.img-preview-item__overlay svg { width: 18px; height: 18px; }

/* Repeater row (offer contents, and anything else built row by row) */
.repeat-row {
    border: 1px solid var(--line); border-radius: var(--r);
    background: var(--surface-2); padding: 12px; margin-bottom: 10px;
}
.repeat-row__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 9px; }
.repeat-row__num { font-size: 12px; font-weight: 600; color: var(--muted); }

.size-modal-overlay {
    display: none; position: fixed; inset: 0; z-index: 9990;
    background: rgba(12,16,22,.5);
    align-items: center; justify-content: center; padding: 20px;
}
.size-modal-overlay.open { display: flex; }
.size-modal {
    position: relative; width: 100%; max-width: 380px;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--r-xl); box-shadow: var(--sh-3); padding: 20px;
    animation: modalIn .2s var(--ease) both;
}
.size-modal__close {
    position: absolute; top: 12px; inset-inline-end: 12px;
    width: 28px; height: 28px; border-radius: var(--r-xs);
    border: 1px solid var(--line); background: var(--surface); color: var(--muted);
    cursor: pointer; font-size: 15px; line-height: 1;
}
.size-modal__title { font-size: 14.5px; font-weight: 600; }
.size-modal__sub { font-size: 12.5px; color: var(--muted); margin: 2px 0 14px; }
.size-list { display: grid; gap: 6px; margin-bottom: 14px; max-height: 50vh; overflow-y: auto; }
.size-option {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--r);
    cursor: pointer; transition: border-color .12s var(--ease), background .12s var(--ease);
}
.size-option:hover { background: var(--surface-2); }
.size-option.picked { border-color: var(--brand); background: var(--brand-l); }
.size-option__radio { width: 15px; height: 15px; border: 1.5px solid var(--line-strong); border-radius: 50%; flex: none; }
.size-option.picked .size-option__radio { border-color: var(--brand); border-width: 4px; }
.size-option__name { flex: 1; font-size: 13.5px; font-weight: 500; }
.size-option__price { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.size-modal__confirm {
    width: 100%; height: 38px; border-radius: var(--r);
    border: 1px solid var(--brand); background: var(--brand); color: #fff;
    font-size: 13.5px; font-weight: 500; cursor: pointer;
}
.size-modal__confirm:disabled { opacity: .5; cursor: not-allowed; }

/* ══════════════════════════════════════════════════════════════════════════
   MISC
   ══════════════════════════════════════════════════════════════════════════ */
.stack  { display: grid; gap: 16px; }
.stack--sm { gap: 10px; }
.row    { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 16px; }
.cols-main { display: grid; grid-template-columns: minmax(0,1.9fr) minmax(0,1fr); gap: 16px; }
.muted  { color: var(--muted); }
.faint  { color: var(--faint); }
.small  { font-size: 12.5px; }
.strong { font-weight: 600; }
.mt-0 { margin-top: 0 } .mt-8 { margin-top: 8px } .mt-16 { margin-top: 16px } .mt-24 { margin-top: 24px }
.mb-0 { margin-bottom: 0 } .mb-8 { margin-bottom: 8px } .mb-16 { margin-bottom: 16px }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Quick actions strip */
.quick {
    display: grid;
    grid-template-columns: repeat(6, minmax(0,1fr));
    gap: 8px;
}
.quick__item {
    display: flex; align-items: center; gap: 9px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--surface);
    font-size: 13px; font-weight: 500; color: var(--text-2);
    transition: border-color .15s var(--ease), background .15s var(--ease), color .15s var(--ease);
}
.quick__item svg { width: 16px; height: 16px; color: var(--muted); flex: none; }
.quick__item:hover { border-color: var(--brand-b); background: var(--brand-l); color: var(--brand-d); }
.quick__item:hover svg { color: var(--brand); }

/* Branch / menu switcher in the page context bar */
.context {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    padding: 10px 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    margin-bottom: 18px;
}
.context__id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.context__logo {
    width: 36px; height: 36px; border-radius: var(--r); object-fit: cover; flex: none;
    border: 1px solid var(--line); background: var(--surface-3);
}
.context__name { font-size: 14px; font-weight: 600; line-height: 1.3; }
.context__meta { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.context__sep { width: 1px; height: 28px; background: var(--line); }
.context__spacer { flex: 1; }
.context__pick { display: flex; align-items: center; gap: 6px; }
.context__pick .select { min-height: 32px; height: 32px; padding-block: 0; font-size: 13px; }

/* Inline mini-form (filters that submit on change) */
.inline-form { display: inline-flex; align-items: center; gap: 6px; }

/* Copy-to-clipboard field */
.copy-field { display: flex; gap: 6px; }
.copy-field .input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; direction: ltr; text-align: start; }

/* Toast */
.toasts {
    position: fixed; inset-block-end: 20px; inset-inline-end: 20px;
    display: flex; flex-direction: column; gap: 8px; z-index: 9999;
}
.toast {
    display: flex; align-items: flex-start; gap: 9px;
    min-width: 260px; max-width: 380px;
    padding: 11px 14px;
    border-radius: var(--r);
    border: 1px solid var(--line);
    background: var(--surface);
    box-shadow: var(--sh-2);
    font-size: 13px;
    animation: toastIn .22s var(--ease) both;
}
.toast svg { width: 16px; height: 16px; flex: none; margin-top: 1px; }
.toast--ok svg { color: var(--ok); }
.toast--danger svg { color: var(--danger); }
.toast--warn svg { color: var(--warn); }
.toast--info svg { color: var(--info); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Modal (used by the global confirm/alert) */
.modal-overlay {
    position: fixed; inset: 0; z-index: 9998;
    display: flex; align-items: center; justify-content: center; padding: 20px;
    background: rgba(12,16,22,.5);
}
.modal {
    width: 100%; max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-xl);
    box-shadow: var(--sh-3);
    overflow: hidden;
    animation: modalIn .2s var(--ease) both;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.modal__body { padding: 20px; display: flex; gap: 12px; align-items: flex-start; }
.modal__icon { width: 34px; height: 34px; border-radius: var(--r); display: grid; place-items: center; flex: none; }
.modal__icon svg { width: 17px; height: 17px; }
.modal__icon--ok     { background: var(--ok-s);     color: var(--ok); }
.modal__icon--danger { background: var(--danger-s); color: var(--danger); }
.modal__icon--warn   { background: var(--warn-s);   color: var(--warn); }
.modal__icon--info   { background: var(--info-s);   color: var(--info); }
.modal__title { font-size: 14.5px; font-weight: 600; }
.modal__text { font-size: 13.5px; color: var(--text-2); margin-top: 3px; line-height: 1.7; }
.modal__foot { padding: 12px 16px; background: var(--surface-2); border-top: 1px solid var(--line-soft); display: flex; justify-content: flex-end; gap: 8px; }

/* Print — used by the QR page */
@media print {
    .sidebar, .topbar, .page-head__actions, .no-print { display: none !important; }
    .main { margin-inline-start: 0; }
    .main__inner { padding: 0; max-width: none; }
    .card { border: 0; }
    body.app { background: #fff; }
}

/* ══════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 1180px) {
    .quick { grid-template-columns: repeat(3, minmax(0,1fr)); }
    .cols-main { grid-template-columns: minmax(0,1fr); }
}

@media (max-width: 1024px) {
    .kpis { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .kpi:nth-child(3) { border-inline-start: 0; }
    .kpi:nth-child(n+3) { border-top: 1px solid var(--line-soft); }
    .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .grid-3 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform .22s var(--ease);
        box-shadow: var(--sh-3);
    }
    [dir="rtl"] .sidebar { transform: translateX(100%); }
    .sidebar.is-open { transform: none; }
    .main { margin-inline-start: 0; }
    .main__inner { padding: 16px 16px 56px; }
    .topbar { display: flex; }
    .page-head { margin-bottom: 16px; }
}

@media (max-width: 680px) {
    .kpis { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .grid-2, .grid-3, .grid-4, .form-row, .form-grid--2 { grid-template-columns: minmax(0,1fr); }
    .quick { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .page-head { flex-direction: column; align-items: stretch; }
    .page-head__actions .btn { flex: 1; }
    .context { gap: 10px; }
    .context__sep { display: none; }
    .context__pick { width: 100%; }
    .context__pick .select { flex: 1; }
    .toasts { inset-inline: 12px; inset-block-end: 12px; }
    .toast { max-width: none; }

    /* Tables become stacked records on phones */
    .table--stack thead { display: none; }
    .table--stack tbody tr {
        display: block;
        padding: 12px 14px;
        border-bottom: 1px solid var(--line-soft);
    }
    .table--stack tbody tr:last-child { border-bottom: 0; }
    .table--stack td {
        display: flex; align-items: center; justify-content: space-between; gap: 12px;
        padding: 3px 0; border: 0;
    }
    .table--stack td::before {
        content: attr(data-l);
        font-size: 12px; color: var(--muted); font-weight: 500;
        flex: none;
    }
    .table--stack td.t-wide { display: block; }
    .table--stack td.t-wide::before { display: block; margin-bottom: 4px; }
    .table--stack .t-actions { justify-content: flex-start; padding-top: 8px; }
}
