/* ==========================================================================
   Casa Visatoare — Admin design system
   Single stylesheet, no build step, no external dependencies.
   Sections: 1. tokens  2. base  3. shell  4. components  5. utils  6. print
   ========================================================================== */

/* 1. Design tokens ======================================================== */

:root {
    /* Brand */
    --brand-50:  #eeedf5;
    --brand-100: #ddd9ea;
    --brand-300: #9d9bc4;
    --brand-500: #56547d;
    --brand-600: #454367;
    --brand-700: #363450;
    --accent-400:#d08b9c;
    --accent-500:#c07285;
    --accent-600:#a95d70;

    /* Neutrals — light theme */
    --bg:          #f4f4f8;
    --surface:     #ffffff;
    --surface-2:   #fafafc;
    --surface-3:   #f1f1f6;
    --border:      #e4e4ed;
    --border-strong:#d2d2de;
    --text:        #1d1c28;
    --text-muted:  #6d6b84;
    --text-faint:  #9392a8;

    /* Semantic */
    --success-bg:#dff3e6; --success-fg:#14663c; --success:#1a7f4b;
    --warning-bg:#fdefcd; --warning-fg:#7d5a06; --warning:#b07f0a;
    --danger-bg: #fbe0e0; --danger-fg: #9d2b2b; --danger:#c53c3c;
    --info-bg:   #dcedf6; --info-fg:   #145a75; --info:#1877a0;
    --primary-bg:var(--brand-50); --primary-fg:var(--brand-600);

    /* Sidebar keeps its own scale so it stays dark in both themes */
    --rail-bg:      #2c2a41;
    --rail-bg-2:    #25233a;
    --rail-text:    #cfcde0;
    --rail-text-dim:#8c89a8;
    --rail-hover:   rgba(255,255,255,.07);
    --rail-active:  rgba(255,255,255,.12);

    /* Elevation */
    --shadow-sm: 0 1px 2px rgba(24,23,40,.06);
    --shadow:    0 1px 3px rgba(24,23,40,.08), 0 1px 2px rgba(24,23,40,.04);
    --shadow-md: 0 4px 12px rgba(24,23,40,.10), 0 1px 3px rgba(24,23,40,.06);
    --shadow-lg: 0 16px 48px rgba(24,23,40,.18);

    /* Geometry */
    --r-sm: 6px; --r: 9px; --r-lg: 14px; --r-full: 999px;
    --rail-w: 244px;
    --topbar-h: 60px;

    /* Type */
    --font: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

    color-scheme: light;
}

:root[data-theme="dark"] {
    --bg:          #121118;
    --surface:     #1b1a24;
    --surface-2:   #20202c;
    --surface-3:   #272635;
    --border:      #2e2d3d;
    --border-strong:#3c3b4e;
    --text:        #e9e8f2;
    --text-muted:  #a3a1ba;
    --text-faint:  #7d7b95;

    --brand-50:  #262441;
    --brand-100: #2f2d4f;
    --brand-500: #8987c0;
    --brand-600: #9d9bd0;
    --brand-700: #b3b1de;

    --success-bg:#123324; --success-fg:#6ddba0;
    --warning-bg:#332708; --warning-fg:#e8bc5c;
    --danger-bg: #3a1717; --danger-fg: #f09393;
    --info-bg:   #0d2c3a; --info-fg:   #7ac6e6;
    --primary-bg:#262441; --primary-fg:#a9a7dd;

    --rail-bg:   #17161f;
    --rail-bg-2: #131219;

    --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
    --shadow:    0 1px 3px rgba(0,0,0,.45);
    --shadow-md: 0 4px 12px rgba(0,0,0,.5);
    --shadow-lg: 0 16px 48px rgba(0,0,0,.6);

    color-scheme: dark;
}

/* 2. Base ================================================================= */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

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

a { color: var(--brand-600); text-decoration: none; }
a:hover { color: var(--accent-500); }

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.011em; color: var(--text); }
h1 { font-size: 20px; }
h2 { font-size: 15px; }
h3 { font-size: 14px; }
p  { margin: 0 0 10px; }
p:last-child { margin-bottom: 0; }

hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }

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

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

.icon { width: 18px; height: 18px; flex: 0 0 auto; stroke-width: 1.7; }
.icon--sm { width: 15px; height: 15px; }

/* 3. Application shell ==================================================== */

.app { display: flex; min-height: 100vh; }

/* --- Sidebar rail --- */
.rail {
    width: var(--rail-w);
    flex: 0 0 var(--rail-w);
    background: var(--rail-bg);
    color: var(--rail-text);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 40;
}

.rail__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    height: var(--topbar-h);
    padding: 0 18px;
    flex: 0 0 var(--topbar-h);
    border-bottom: 1px solid rgba(255,255,255,.07);
    color: #fff;
}
.rail__mark {
    width: 30px; height: 30px;
    border-radius: 8px;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--accent-500), #7c5a8f);
    color: #fff; font-weight: 700; font-size: 13px;
    flex: 0 0 auto;
}
.rail__name { font-size: 14px; font-weight: 650; line-height: 1.15; letter-spacing: -.01em; }
.rail__name small { display: block; font-size: 11px; font-weight: 500; color: var(--rail-text-dim); letter-spacing: .02em; }

.rail__nav { flex: 1; overflow-y: auto; padding: 14px 10px; }
.rail__section {
    padding: 14px 10px 6px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: var(--rail-text-dim);
}
.rail__section:first-child { padding-top: 2px; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    margin-bottom: 2px;
    border-radius: var(--r-sm);
    color: var(--rail-text);
    font-weight: 500;
    position: relative;
    transition: background .12s ease, color .12s ease;
}
.nav-link:hover { background: var(--rail-hover); color: #fff; }
.nav-link.is-active { background: var(--rail-active); color: #fff; font-weight: 600; }
.nav-link.is-active::before {
    content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px;
    width: 3px; border-radius: 0 3px 3px 0; background: var(--accent-500);
}
.nav-link__count {
    margin-left: auto;
    min-width: 20px;
    padding: 1px 6px;
    border-radius: var(--r-full);
    background: var(--accent-500);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.nav-link__ext { margin-left: auto; opacity: .5; }

.rail__footer {
    padding: 12px;
    border-top: 1px solid rgba(255,255,255,.07);
    background: var(--rail-bg-2);
}
.rail__user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.rail__user-meta { min-width: 0; }
.rail__user-name { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail__user-role { font-size: 11px; color: var(--rail-text-dim); }
/* Doua butoane pe rand acum (contul meu, delogare): `margin-left:auto` il
   impinge pe primul spre dreapta, al doilea vine lipit langa el. */
.rail__logout + .rail__logout { margin-left: 6px; }
.rail__logout {
    display: grid; place-items: center;
    width: 30px; height: 30px; margin-left: auto; flex: 0 0 auto;
    border-radius: var(--r-sm);
    color: var(--rail-text);
    background: rgba(255,255,255,.06);
}
.rail__logout:hover { background: var(--danger); color: #fff; }

/* --- Main column --- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    height: var(--topbar-h);
    flex: 0 0 var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 30;
}
.topbar__spacer { flex: 1; }

.breadcrumb { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-muted); min-width: 0; }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--brand-600); }
.breadcrumb .sep { color: var(--text-faint); }
.breadcrumb .current { color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.content { flex: 1; padding: 24px; }
.content > *:last-child { margin-bottom: 0; }

.page-head {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.page-head__text { min-width: 0; flex: 1; }
.page-head h1 { font-size: 22px; }
.page-head__sub { color: var(--text-muted); font-size: 13px; margin-top: 3px; }
.page-head__actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Mobile rail toggle */
.rail-toggle { display: none; }
.rail-scrim { display: none; }

/* 4. Components =========================================================== */

/* --- Card --- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 18px;
    overflow: hidden;
}
.card__head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}
.card__head h2 { flex: 1; min-width: 0; }
.card__head-actions { display: flex; gap: 8px; align-items: center; }
.card__body { padding: 18px; }
.card__body--flush { padding: 0; }
.card__foot {
    padding: 12px 18px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}

/* --- Stats --- */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(212px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}
.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
    padding: 16px 18px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
}
.stat__icon {
    width: 38px; height: 38px; flex: 0 0 auto;
    border-radius: 10px;
    display: grid; place-items: center;
    background: var(--primary-bg);
    color: var(--primary-fg);
}
.stat__icon--accent  { background: #f8e7ec; color: var(--accent-600); }
.stat__icon--success { background: var(--success-bg); color: var(--success-fg); }
.stat__icon--warning { background: var(--warning-bg); color: var(--warning-fg); }
.stat__body { min-width: 0; }
.stat__label {
    font-size: 11.5px; font-weight: 650; letter-spacing: .05em;
    text-transform: uppercase; color: var(--text-muted);
}
.stat__value {
    font-size: 24px; font-weight: 680; letter-spacing: -.02em;
    color: var(--text); font-variant-numeric: tabular-nums;
    margin-top: 2px; line-height: 1.2;
}
.stat__meta { font-size: 12px; color: var(--text-faint); margin-top: 2px; }

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 14px;
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    font: inherit;
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    white-space: nowrap;
    transition: background .12s ease, border-color .12s ease, color .12s ease;
    background: var(--brand-500);
    color: #fff;
}
.btn:hover { background: var(--brand-600); color: #fff; }
.btn:active { transform: translateY(.5px); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.btn--accent { background: var(--accent-500); }
.btn--accent:hover { background: var(--accent-600); }

.btn--ghost {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border-strong);
    box-shadow: var(--shadow-sm);
}
.btn--ghost:hover { background: var(--surface-3); color: var(--text); border-color: var(--border-strong); }

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

.btn--danger { background: var(--danger); }
.btn--danger:hover { background: #a83232; }

.btn--danger-ghost { background: var(--surface); color: var(--danger); border-color: var(--border-strong); }
.btn--danger-ghost:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

.btn--sm { padding: 5px 10px; font-size: 12.5px; gap: 5px; }
.btn--block { width: 100%; }

.icon-btn {
    display: inline-grid; place-items: center;
    width: 32px; height: 32px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    transition: background .12s ease, color .12s ease;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn--bare { border-color: transparent; background: transparent; }

.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }

/* --- Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2.5px 9px;
    border-radius: var(--r-full);
    font-size: 11.5px;
    font-weight: 650;
    letter-spacing: .01em;
    white-space: nowrap;
    background: var(--surface-3);
    color: var(--text-muted);
}
.badge::before {
    content: ""; width: 5px; height: 5px; border-radius: 50%;
    background: currentColor; opacity: .85; flex: 0 0 auto;
}
.badge--plain::before { display: none; }
.badge--warning { background: var(--warning-bg); color: var(--warning-fg); }
.badge--info    { background: var(--info-bg);    color: var(--info-fg); }
.badge--primary { background: var(--primary-bg); color: var(--primary-fg); }
.badge--success { background: var(--success-bg); color: var(--success-fg); }
.badge--danger  { background: var(--danger-bg);  color: var(--danger-fg); }

/* --- Tables --- */
.table-wrap { width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td {
    text-align: left;
    padding: 11px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table thead th {
    position: sticky; top: 0; z-index: 1;
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .1s ease; }
.table tbody tr:hover { background: var(--surface-2); }
.table tfoot td, .table tfoot th {
    background: var(--surface-2);
    font-weight: 650;
    border-top: 1px solid var(--border);
    border-bottom: 0;
}
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions > * { vertical-align: middle; }
.table__primary { font-weight: 620; color: var(--text); }
.table__sub { display: block; font-size: 12px; color: var(--text-faint); margin-top: 1px; }
.table--fixed-head { max-height: 520px; overflow-y: auto; }

/* Sortable column headers */
.th-sort { display: inline-flex; align-items: center; gap: 4px; color: inherit; }
.th-sort:hover { color: var(--brand-600); }
.th-sort .caret { opacity: .35; }
.th-sort.is-sorted { color: var(--brand-600); }
.th-sort.is-sorted .caret { opacity: 1; }

/* --- Media cell --- */
.thumb {
    width: 42px; height: 42px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface-3);
    display: block;
}
.thumb--empty { display: grid; place-items: center; color: var(--text-faint); }

.avatar {
    width: 32px; height: 32px; flex: 0 0 auto;
    border-radius: 50%;
    display: grid; place-items: center;
    background: var(--brand-100);
    color: var(--brand-600);
    font-size: 12px; font-weight: 700;
    letter-spacing: .02em;
}
.avatar--lg { width: 46px; height: 46px; font-size: 16px; }
.avatar--rail { background: rgba(255,255,255,.12); color: #fff; }

.media { display: flex; align-items: center; gap: 10px; min-width: 0; }
.media__body { min-width: 0; }

/* --- Filter bar --- */
.filters {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}
.filters__spacer { flex: 1; }
.filters__count { font-size: 12.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.search { position: relative; display: flex; align-items: center; min-width: 210px; }
.search .icon { position: absolute; left: 10px; color: var(--text-faint); pointer-events: none; }

/* Segmented tabs (status filter) */
.segmented {
    display: inline-flex;
    padding: 3px;
    gap: 2px;
    background: var(--surface-3);
    border-radius: var(--r);
    flex-wrap: wrap;
}
.segmented a {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 11px;
    border-radius: var(--r-sm);
    font-size: 12.5px; font-weight: 600;
    color: var(--text-muted);
}
.segmented a:hover { color: var(--text); background: var(--surface); }
.segmented a.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented .n {
    font-size: 11px; font-weight: 700;
    padding: 0 5px; border-radius: var(--r-full);
    background: var(--surface-3); color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}
.segmented a.is-active .n { background: var(--brand-50); color: var(--brand-600); }

/* --- Forms --- */
.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.field > label:not(.switch), .label {
    display: block;
    margin-bottom: 6px;
    font-size: 12.5px;
    font-weight: 650;
    color: var(--text);
}
.field .required { color: var(--danger); margin-left: 2px; }

input[type=text], input[type=email], input[type=number], input[type=password],
input[type=search], input[type=tel], input[type=url], input[type=date],
textarea, select {
    width: 100%;
    padding: 8px 11px;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 13.5px;
    transition: border-color .12s ease, box-shadow .12s ease;
}
input:hover:not([disabled]), textarea:hover, select:hover { border-color: var(--brand-300); }
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--brand-500);
    box-shadow: 0 0 0 3px var(--brand-50);
}
/* `--text-muted`, nu `--text-faint`: textul de sugestie e adesea singura
   explicație a unui câmp dintr-o bară de filtre, iar la contrastul de „faint"
   se citea greu pe amândouă temele. */
input::placeholder, textarea::placeholder { color: var(--text-muted); opacity: 1; }

/*  Loc pentru iconița din `.search`, care stă absolut la `left: 10px`.

    Regula asta trebuie să vină **după** blocul de mai sus, nu lângă `.search`:
    `.search input` avea exact aceeași specificitate ca `input[type=search]`, iar
    `padding: 8px 11px` — prescurtat, deci rescrie și `padding-left` — venea mai
    jos și câștiga. Textul pornea de la 11px, adică pe sub iconiță. Calificarea
    pe tip ar fi fost de ajuns ca specificitate, dar locul de aici o face
    independentă de ordinea în care cineva mai adaugă ceva. E a treia oară când
    fișierul ăsta pierde o proprietate așa — vezi și `.field > label:not(.switch)`. */
.search input[type="search"], .search input[type="text"] { padding-left: 32px; }
textarea { resize: vertical; min-height: 84px; line-height: 1.55; }
select {
    appearance: none;
    padding-right: 30px;
    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='%236d6b84' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 9px center;
}
:root[data-theme="dark"] select {
    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='%23a3a1ba' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}
input[type=file] {
    width: 100%;
    padding: 8px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--r-sm);
    background: var(--surface-2);
    font-size: 13px;
    color: var(--text-muted);
}
input[type=file]::file-selector-button {
    margin-right: 10px; padding: 5px 11px;
    border: 0; border-radius: var(--r-sm);
    background: var(--brand-500); color: #fff;
    font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
}

.field--inline { display: flex; align-items: flex-start; gap: 10px; }
.field--inline > label { margin-bottom: 0; }

.help { font-size: 12px; color: var(--text-faint); margin-top: 5px; }
.field-errors { list-style: none; margin: 6px 0 0; padding: 0; font-size: 12.5px; color: var(--danger-fg); }
.field-errors li { display: flex; align-items: flex-start; gap: 5px; }
.has-error input, .has-error textarea, .has-error select { border-color: var(--danger); }

/* Toggle switch (checkbox) */
.switch {
    display: inline-flex; align-items: flex-start; gap: 10px;
    margin-bottom: 0; cursor: pointer;
    font-weight: 600; font-size: 13.5px; line-height: 1.5; color: var(--text);
}
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__track {
    width: 36px; height: 20px; flex: 0 0 auto; margin-top: 1px;
    border-radius: var(--r-full);
    background: var(--border-strong);
    position: relative;
    transition: background .15s ease;
}
.switch__track::after {
    content: ""; position: absolute; top: 2px; left: 2px;
    width: 16px; height: 16px; border-radius: 50%;
    background: #fff; box-shadow: var(--shadow-sm);
    transition: transform .15s ease;
}
.switch input:checked + .switch__track { background: var(--success); }
.switch input:checked + .switch__track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--brand-500); outline-offset: 2px; }
.switch__text small { display: block; font-weight: 500; font-size: 12px; color: var(--text-faint); }

/* --- Key/value list --- */
.kv { display: grid; grid-template-columns: minmax(88px, auto) 1fr; gap: 9px 16px; font-size: 13.5px; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }

/* --- Flash / alerts --- */
.flash {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 11px 14px;
    border-radius: var(--r);
    margin-bottom: 14px;
    font-size: 13.5px;
    font-weight: 500;
    border: 1px solid transparent;
}
.flash__close { margin-left: auto; }
.flash--success { background: var(--success-bg); color: var(--success-fg); border-color: color-mix(in srgb, var(--success) 25%, transparent); }
.flash--info    { background: var(--info-bg);    color: var(--info-fg);    border-color: color-mix(in srgb, var(--info) 25%, transparent); }
.flash--warning { background: var(--warning-bg); color: var(--warning-fg); border-color: color-mix(in srgb, var(--warning) 25%, transparent); }
.flash--error,
.flash--danger  { background: var(--danger-bg);  color: var(--danger-fg);  border-color: color-mix(in srgb, var(--danger) 25%, transparent); }

/* --- Empty state --- */
.empty { padding: 44px 20px; text-align: center; color: var(--text-muted); }
.empty__icon {
    width: 44px; height: 44px; margin: 0 auto 12px;
    border-radius: 12px;
    display: grid; place-items: center;
    background: var(--surface-3);
    color: var(--text-faint);
}
.empty h3 { margin-bottom: 4px; }
.empty p { font-size: 13px; margin-bottom: 14px; }

/* --- Pagination --- */
.pagination { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pagination__info { font-size: 12.5px; color: var(--text-muted); margin-right: auto; font-variant-numeric: tabular-nums; }
.pagination a, .pagination span.page {
    min-width: 30px; height: 30px;
    padding: 0 8px;
    display: inline-grid; place-items: center;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--surface);
    font-size: 13px; font-weight: 600;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}
.pagination a:hover { background: var(--surface-3); color: var(--text); }
.pagination .is-current { background: var(--brand-500); border-color: var(--brand-500); color: #fff; }
.pagination .is-disabled { opacity: .4; pointer-events: none; }
.pagination .gap { border: 0; background: transparent; }

/* --- Status timeline (order) --- */
.steps { display: flex; flex-direction: column; gap: 0; }
.step { display: flex; gap: 12px; }
.step__marker { display: flex; flex-direction: column; align-items: center; flex: 0 0 auto; }
.step__dot {
    width: 20px; height: 20px; border-radius: 50%;
    display: grid; place-items: center;
    border: 2px solid var(--border-strong);
    background: var(--surface);
    color: var(--surface);
    flex: 0 0 auto;
}
.step__line { width: 2px; flex: 1; background: var(--border); min-height: 14px; }
.step__label { font-size: 13px; padding-bottom: 14px; color: var(--text-faint); font-weight: 500; }
.step:last-child .step__label { padding-bottom: 0; }
.step.is-done .step__dot { background: var(--success); border-color: var(--success); color: #fff; }
.step.is-done .step__line { background: var(--success); }
.step.is-done .step__label { color: var(--text); font-weight: 600; }
.step.is-current .step__dot { border-color: var(--brand-500); background: var(--brand-500); color: #fff; }
.step.is-current .step__label { color: var(--text); font-weight: 700; }
.step.is-cancelled .step__dot { background: var(--danger); border-color: var(--danger); color: #fff; }
.step.is-cancelled .step__label { color: var(--danger-fg); font-weight: 700; }

/* --- Image manager (product form) --- */
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 10px; }
.img-tile { position: relative; aspect-ratio: 1; border-radius: var(--r); overflow: hidden; border: 1px solid var(--border); background: var(--surface-3); }
.img-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-tile__del {
    position: absolute; top: 5px; right: 5px;
    width: 22px; height: 22px;
    display: grid; place-items: center;
    border: 0; border-radius: 50%;
    background: rgba(20,18,30,.72);
    color: #fff; cursor: pointer;
    opacity: 0; transition: opacity .12s ease;
}
.img-tile:hover .img-tile__del, .img-tile__del:focus-visible { opacity: 1; }
.img-tile__del:hover { background: var(--danger); }
.img-tile__badge {
    position: absolute; left: 5px; bottom: 5px;
    padding: 1px 7px; border-radius: var(--r-full);
    background: rgba(20,18,30,.72); color: #fff;
    font-size: 10px; font-weight: 700; letter-spacing: .03em;
}

/* --- Media manager (product gallery tab) ---
   One row per file: thumbnail, what it is, what to do with it, and a
   <details> panel for the text. The row is a grid so the edit panel can span
   the full width without a second wrapper. */
.stat__unit { font-size: 13px; font-weight: 600; color: var(--text-faint); margin-left: 2px; }

.audit { border-left: 3px solid var(--warning); }
.audit__list { list-style: none; margin: 0; padding: 0; }
.audit__item {
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr) auto;
    gap: 10px;
    align-items: start;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
}
.audit__item:last-child { border-bottom: 0; }
.audit__marker { color: var(--warning); padding-top: 1px; }
.audit__item--blocking .audit__marker { color: var(--danger); }
.audit__item--advice .audit__marker { color: var(--info); }
.audit__text { min-width: 0; font-size: 13.5px; }
.audit__text strong { display: block; font-weight: 620; }
.audit__detail { display: block; margin-top: 2px; color: var(--text-muted); font-size: 12.5px; }
.audit__level { padding-top: 1px; }

.media-list { list-style: none; margin: 0; padding: 0; }
.media-row {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr) auto;
    grid-template-areas: "thumb body actions" "edit edit edit";
    gap: 4px 14px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    transition: background .1s ease;
}
.media-row:last-child { border-bottom: 0; }
.media-row:hover { background: var(--surface-2); }
.media-row.is-main { background: linear-gradient(90deg, var(--brand-50), transparent 42%); }
.media-row.is-broken { background: linear-gradient(90deg, var(--danger-bg), transparent 42%); }
.media-row.is-muted { opacity: .62; }

.media-row__thumb {
    grid-area: thumb;
    position: relative;
    width: 92px; aspect-ratio: 1;
    border-radius: var(--r);
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--surface-3);
}
.media-row__thumb a { display: block; width: 100%; height: 100%; }
.media-row__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-row__thumb--video { background: #1c1a28; display: grid; place-items: center; }
.media-row__thumb--video img { position: absolute; inset: 0; opacity: .55; }
.media-row__play { position: relative; color: #fff; opacity: .9; }
.media-row__zoom {
    position: absolute; inset: 0;
    display: grid; place-items: center;
    background: rgba(20,18,30,.45); color: #fff;
    opacity: 0; transition: opacity .12s ease;
}
.media-row__thumb a:hover .media-row__zoom,
.media-row__thumb a:focus-visible .media-row__zoom { opacity: 1; }
.media-row__broken { display: grid; place-items: center; width: 100%; height: 100%; color: var(--danger); }
.media-row__pos {
    position: absolute; left: 5px; top: 5px;
    min-width: 19px; height: 19px; padding: 0 5px;
    display: grid; place-items: center;
    border-radius: var(--r-full);
    background: rgba(20,18,30,.72); color: #fff;
    font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums;
}

.media-row__body { grid-area: body; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.media-row__alt { font-size: 14px; font-weight: 620; line-height: 1.35; }
.media-row__facts {
    display: flex; align-items: center; flex-wrap: wrap; gap: 5px;
    font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums;
}
.media-row__facts .mono { max-width: 220px; }
.media-row__facts .dot { color: var(--text-faint); }
.media-row__badges { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.media-row__note { font-size: 12.5px; color: var(--text-muted); }

.media-row__actions { grid-area: actions; display: flex; gap: 5px; align-items: flex-start; flex-wrap: wrap; justify-content: flex-end; }
.media-row__actions .btn--sm { padding: 5px 7px; }

.media-row__edit { grid-area: edit; margin-top: 8px; }
.media-row__edit > summary {
    display: inline-flex; align-items: center; gap: 6px;
    cursor: pointer; list-style: none;
    font-size: 12.5px; font-weight: 600; color: var(--text-muted);
    padding: 4px 9px; border-radius: var(--r-sm);
    border: 1px solid var(--border);
    background: var(--surface);
}
.media-row__edit > summary::-webkit-details-marker { display: none; }
.media-row__edit > summary:hover { color: var(--text); border-color: var(--border-strong); }
.media-row__edit[open] > summary { background: var(--surface-3); color: var(--text); }
.media-row__form {
    margin-top: 12px; padding: 16px;
    border: 1px solid var(--border); border-radius: var(--r);
    background: var(--surface-2);
}

.pill {
    display: inline-block;
    padding: 1px 7px; border-radius: var(--r-full);
    font-size: 10.5px; font-weight: 700; letter-spacing: .02em;
    background: var(--surface-3); color: var(--text-muted);
}
.pill--warning { background: var(--warning-bg); color: var(--warning-fg); }

/* Drop target for bulk upload. The real <input type=file> stays inside the
   label, so clicking works and JS is only there for the drag gesture. */
.dropzone {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 22px 14px; margin-bottom: 12px;
    border: 1.5px dashed var(--border-strong); border-radius: var(--r-lg);
    background: var(--surface-2);
    cursor: pointer; text-align: center;
    transition: border-color .12s ease, background .12s ease;
}
.dropzone:hover, .dropzone.is-dragover { border-color: var(--accent-500); background: var(--surface-3); }
.dropzone .icon { color: var(--text-faint); width: 26px; height: 26px; }
.dropzone.is-dragover .icon { color: var(--accent-500); }
.dropzone__title { font-size: 13.5px; font-weight: 620; }
.dropzone__hint { font-size: 12px; color: var(--text-muted); }
.dropzone input[type="file"] { margin-top: 8px; max-width: 100%; }

.legend { list-style: none; margin: 0; padding: 0; }
.legend__item {
    display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
    padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: 12.5px;
}
.legend__item:last-child { border-bottom: 0; }
.legend__key { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--text-faint); }
.legend__val { color: var(--text-muted); text-align: right; }
.legend__item--live .legend__key { color: var(--success); }
.legend__item--live .legend__val { color: var(--text); }

.media-dialog {
    border: 0; padding: 0; border-radius: var(--r-lg);
    background: var(--surface); color: var(--text);
    max-width: min(94vw, 1000px); max-height: 92vh;
    box-shadow: var(--shadow-lg);
}
.media-dialog::backdrop { background: rgba(18,17,24,.72); }
.media-dialog__head {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px; border-bottom: 1px solid var(--border);
    font-size: 13.5px; font-weight: 600;
}
.media-dialog__head .truncate { flex: 1; min-width: 0; }
.media-dialog img { display: block; max-width: 100%; max-height: calc(92vh - 52px); margin: 0 auto; }

@media (max-width: 720px) {
    .media-row {
        grid-template-columns: 72px minmax(0, 1fr);
        grid-template-areas: "thumb body" "actions actions" "edit edit";
    }
    .media-row__thumb { width: 72px; }
    .media-row__actions { justify-content: flex-start; margin-top: 8px; }
    .audit__item { grid-template-columns: 22px minmax(0, 1fr); }
    .audit__level { grid-column: 2; }
}

/* --- Image editor ---
   The stage is the picture at whatever size the column allows; the crop box is
   positioned in the same coordinate space, so a window resize only needs the
   box repainted, not the maths redone. */
.editor-stage {
    position: relative;
    display: inline-block;
    max-width: 100%;
    line-height: 0;
    border-radius: var(--r);
    overflow: hidden;
    background: var(--surface-3);
    touch-action: none;              /* pointer drags must not scroll the page */
    cursor: crosshair;
    user-select: none;
}
.editor-stage img { display: block; max-width: 100%; height: auto; }

.crop-box {
    position: absolute;
    box-sizing: border-box;
    border: 1px solid #fff;
    cursor: move;
    /* The dimmed surround is one huge shadow rather than four overlay divs —
       it can never disagree with the box it surrounds. */
    box-shadow: 0 0 0 9999px rgba(18, 17, 24, .55);
}
.crop-box::before,
.crop-box::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: .45;
}
/* Rule of thirds, drawn with two gradients instead of four more elements. */
.crop-box::before {
    background:
        linear-gradient(to right, transparent calc(33.333% - .5px), #fff calc(33.333% - .5px), #fff calc(33.333% + .5px), transparent calc(33.333% + .5px)),
        linear-gradient(to right, transparent calc(66.666% - .5px), #fff calc(66.666% - .5px), #fff calc(66.666% + .5px), transparent calc(66.666% + .5px));
}
.crop-box::after {
    background:
        linear-gradient(to bottom, transparent calc(33.333% - .5px), #fff calc(33.333% - .5px), #fff calc(33.333% + .5px), transparent calc(33.333% + .5px)),
        linear-gradient(to bottom, transparent calc(66.666% - .5px), #fff calc(66.666% - .5px), #fff calc(66.666% + .5px), transparent calc(66.666% + .5px));
}

.crop-handle {
    position: absolute;
    width: 13px; height: 13px;
    background: #fff;
    border: 1px solid var(--brand-700);
    border-radius: 2px;
    z-index: 1;
}
.crop-handle--nw { left: -7px;  top: -7px;    cursor: nwse-resize; }
.crop-handle--n  { left: 50%;   top: -7px;    margin-left: -7px; cursor: ns-resize; }
.crop-handle--ne { right: -7px; top: -7px;    cursor: nesw-resize; }
.crop-handle--e  { right: -7px; top: 50%;     margin-top: -7px;  cursor: ew-resize; }
.crop-handle--se { right: -7px; bottom: -7px; cursor: nwse-resize; }
.crop-handle--s  { left: 50%;   bottom: -7px; margin-left: -7px; cursor: ns-resize; }
.crop-handle--sw { left: -7px;  bottom: -7px; cursor: nesw-resize; }
.crop-handle--w  { left: -7px;  top: 50%;     margin-top: -7px;  cursor: ew-resize; }

.editor-ratios { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 14px 0 4px; }
.editor-ratios .btn.is-active { background: var(--brand-500); color: #fff; border-color: var(--brand-500); }

.editor-original {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; flex-wrap: wrap;
}

/* --- Auth screen --- */
.auth {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(1000px 520px at 12% -10%, rgba(192,114,133,.28), transparent 62%),
        radial-gradient(900px 520px at 100% 108%, rgba(86,84,125,.42), transparent 60%),
        #211f31;
}
.auth__card {
    width: 100%; max-width: 392px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    padding: 30px;
}
.auth__brand { display: flex; align-items: center; gap: 11px; margin-bottom: 22px; }
.auth__brand .rail__mark { width: 36px; height: 36px; border-radius: 10px; font-size: 15px; }
.auth__brand-name { font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.auth__brand-name small { display: block; font-size: 11.5px; font-weight: 500; color: var(--text-muted); }
.auth h1 { font-size: 19px; margin-bottom: 3px; }
.auth__sub { color: var(--text-muted); font-size: 13px; margin-bottom: 22px; }
.auth__foot { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-faint); text-align: center; }

/* 5. Utilities ============================================================ */

.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: 12.5px; }
.mono { font-family: var(--font-mono); font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tnum { font-variant-numeric: tabular-nums; }
.strong { font-weight: 650; }
.right { text-align: right; }
.center { text-align: center; }

.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row--tight { gap: 6px; }
.spacer { flex: 1; }

.cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 18px; align-items: start; }
.split--reverse { grid-template-columns: minmax(280px, 1fr) minmax(0, 2fr); }

.mb-0 { margin-bottom: 0; }
.mt-16 { margin-top: 16px; }
.inline-form { display: inline; }

/* 6. Responsive =========================================================== */

@media (max-width: 1080px) {
    .split, .split--reverse { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
    .rail {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        transform: translateX(-100%);
        transition: transform .2s ease;
        box-shadow: var(--shadow-lg);
    }
    body.rail-open .rail { transform: translateX(0); }
    body.rail-open .rail-scrim {
        display: block;
        position: fixed; inset: 0;
        background: rgba(15,14,22,.5);
        z-index: 35;
    }
    .rail-toggle { display: inline-grid; }
    .content { padding: 16px; }
    .topbar { padding: 0 16px; }
    .cols-2 { grid-template-columns: 1fr; }
    .page-head h1 { font-size: 19px; }
    .table th, .table td { padding: 10px 12px; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}

/* 7. Print ================================================================ */

@media print {
    .rail, .topbar, .page-head__actions, .card__foot, .flash, .no-print { display: none !important; }
    body { background: #fff; }
    .content { padding: 0; }
    .card { border-color: #ccc; box-shadow: none; break-inside: avoid; }
    .split { grid-template-columns: 1fr 1fr; }
}

/* 8. Late additions ======================================================= */

.visually-hidden {
    position: absolute;
    width: 1px; height: 1px;
    margin: -1px; padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* Icons that sit inline with text rather than in a flex row. */
.kv dt .icon,
.auth__foot .icon,
.filters__count .icon,
.label .icon,
.small .icon { vertical-align: -3px; margin-right: 3px; }

.auth__foot .icon { opacity: .7; }
.card__head h2 .icon { vertical-align: -3px; }

/* The pagination bar is the card's only footer content — let it fill. */
.card__foot .pagination { width: 100%; }

/* 9. Order lines (new-order form) ========================================= */

.lines { display: flex; flex-direction: column; gap: 10px; }

.line {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 108px 116px 32px;
    gap: 12px;
    align-items: start;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--r);
    background: var(--surface-2);
}
.line .field { margin-bottom: 0; }
.line--over { border-color: var(--danger); background: var(--danger-bg); }

.line__total { display: flex; flex-direction: column; gap: 6px; }
.line__total .label { margin-bottom: 0; }
.line__total > span:last-child { font-weight: 650; padding: 8px 0; }

.line__remove { align-self: end; margin-bottom: 4px; }
.line__remove:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

@media (max-width: 720px) {
    .line { grid-template-columns: minmax(0, 1fr) 96px; }
    .line__total { grid-column: 1 / -1; flex-direction: row; align-items: center; gap: 10px; }
    .line__remove { grid-column: 2; justify-self: end; }
}

/* 10. Exchange rates ====================================================== */

.rate-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}
.rate-grid .card { margin-bottom: 0; }
.rate-card .card__body { display: flex; flex-direction: column; gap: 10px; }

.rate-card__code {
    display: grid; place-items: center;
    width: 40px; height: 40px; flex: 0 0 auto;
    border-radius: 10px;
    background: var(--primary-bg);
    color: var(--primary-fg);
    font-size: 12px; font-weight: 700; letter-spacing: .02em;
}
.rate-card__name { font-weight: 620; font-size: 13.5px; }

.trend {
    display: inline-flex; align-items: center; gap: 3px;
    font-size: 12.5px; font-weight: 650;
    font-variant-numeric: tabular-nums;
    padding: 2px 8px; border-radius: var(--r-full);
}
.trend--up { background: var(--success-bg); color: var(--success-fg); }
.trend--down { background: var(--danger-bg); color: var(--danger-fg); }

/* Sparkline inside a rate card */
.spark { width: 100%; height: 56px; display: block; overflow: visible; }
.spark__line { fill: none; stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.spark__area { stroke: none; opacity: .13; }
.spark--up .spark__line, .spark--up .spark__area { stroke: var(--success); fill: var(--success); }
.spark--down .spark__line, .spark--down .spark__area { stroke: var(--danger); fill: var(--danger); }

/* Full chart */
.chart svg { width: 100%; height: 190px; display: block; overflow: visible; }
.chart__line {
    fill: none;
    stroke: var(--brand-500);
    stroke-width: 2;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
}
.chart__area { fill: var(--brand-500); stroke: none; opacity: .1; }
.chart__dot { fill: var(--accent-500); stroke: var(--surface); stroke-width: 2; vector-effect: non-scaling-stroke; }
.chart__axis {
    display: flex; margin-top: 6px;
    font-size: 11.5px; color: var(--text-faint);
    font-variant-numeric: tabular-nums;
}

pre.code {
    margin: 8px 0 0;
    padding: 10px 12px;
    border-radius: var(--r-sm);
    background: var(--surface-3);
    border: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: 11.5px;
    line-height: 1.5;
    color: var(--text);
    overflow-x: auto;
    white-space: pre;
}

/* Currency checkboxes in the settings form: a compact grid, not a tall column. */
#exchange_rate_settings_currencies { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
#exchange_rate_settings_currencies .field { margin-bottom: 0; }
#exchange_rate_settings_currencies .switch__text { font-size: 12.5px; }
@media (max-width: 520px) { #exchange_rate_settings_currencies { grid-template-columns: 1fr; } }

/* 11. Subscription rows (customer tab) ==================================== */

.subs-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--r);
    background: var(--surface-2);
}
.subs-row__icon {
    width: 32px; height: 32px; flex: 0 0 auto;
    display: grid; place-items: center;
    border-radius: 8px;
    background: var(--surface-3);
    color: var(--text-faint);
}
.subs-row__body { min-width: 0; }
.subs-row__body p { margin: 0; }

/* 12. Star ratings ======================================================== */

.stars { display: inline-flex; gap: 1px; vertical-align: -3px; }
.stars .icon { color: var(--border-strong); fill: none; }
.stars .icon.is-on { color: var(--warning); fill: currentColor; }

.review__body {
    margin-top: 6px;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.55;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 13. Review moderation =================================================== */

/* A review nobody has looked at yet earns a stripe, not just a badge. */
.table tbody tr.row--pending td:first-child { box-shadow: inset 3px 0 0 var(--warning); }
.table tbody tr.row--pending { background: color-mix(in srgb, var(--warning-bg) 45%, transparent); }
.table tbody tr.row--pending:hover { background: color-mix(in srgb, var(--warning-bg) 70%, transparent); }

/* 14. Demand counter (favourites) ========================================= */

.demand {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 9px;
    border-radius: var(--r-full);
    background: var(--surface-3);
    color: var(--text-muted);
    font-weight: 650;
    font-variant-numeric: tabular-nums;
}
.demand .icon { color: var(--text-faint); }
.demand--stranded { background: var(--warning-bg); color: var(--warning-fg); }
.demand--stranded .icon { color: currentColor; }

/* 15. Cart contents ======================================================= */

.cart-lines { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.cart-lines li { display: flex; gap: 6px; align-items: baseline; padding: 1px 0; }
.cart-lines li + li { border-top: 1px dashed var(--border); padding-top: 3px; margin-top: 2px; }
.cart-lines__qty {
    flex: 0 0 auto;
    min-width: 26px;
    color: var(--text-muted);
    font-weight: 650;
    font-variant-numeric: tabular-nums;
}

/* 16. Favourite sources =================================================== */

.sources { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }

.source-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 1px 7px;
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.6;
    white-space: nowrap;
}
.source-chip b {
    font-variant-numeric: tabular-nums;
    color: var(--text);
    font-weight: 700;
}
/* A save from before the column existed — dimmed, never dressed up as a source. */
.source-chip--unknown { border-style: dashed; color: var(--text-faint); }
.source-chip--unknown b { color: var(--text-faint); }

/* Cart lines carry a source chip, so the name and it stack. */
.cart-lines li { align-items: flex-start; }
.cart-lines__body { min-width: 0; }
.cart-lines .sources { margin-top: 2px; }

/* 17. Modal =============================================================== */

.modal {
    /* Pinned near the top rather than centred: the dialog grows downwards with
       the number of cart lines, and a centred one would slide up and down the
       screen from row to row. `margin-block-end: auto` is what keeps it there —
       the UA sheet's `inset-block: 0` would otherwise centre it. */
    margin-inline: auto;
    margin-block: 48px auto;
    width: min(760px, calc(100vw - 32px));
    max-height: calc(100vh - 96px);
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.modal::backdrop { background: rgba(15, 14, 22, .55); }

/* Header, scrolling body: a column, so the body's height falls out of the
   dialog's own max-height instead of a hand-tuned number that stops matching
   the moment the header wraps to two lines. */
.modal[open] { display: flex; flex-direction: column; }

.modal__head {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}
.modal__head > div { flex: 1; min-width: 0; }
.modal__head h2 { font-size: 15px; line-height: 1.3; }
.modal__head .icon-btn { flex: 0 0 auto; margin-top: -2px; }

/* The subtitle mixes text and a badge; a flex row keeps their baselines from
   fighting and lets it wrap cleanly on a narrow screen. */
.modal__head .table__sub {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 3px;
}

.modal__body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 18px;
}
.modal__body > * + * { margin-top: 16px; }
.modal__body .table-wrap {
    border: 1px solid var(--border);
    border-radius: var(--r);
}
.modal__body .table th:first-child,
.modal__body .table td:first-child { padding-left: 14px; }
.modal__body .table th:last-child,
.modal__body .table td:last-child { padding-right: 14px; }

/* Opened by ?cos= without JavaScript: not a modal, so it sits in the flow
   instead of floating in a corner. */
.modal[open]:not(:modal) {
    margin: 0 0 18px;
    width: 100%;
    max-height: none;
    box-shadow: var(--shadow-sm);
}

@media (max-width: 560px) {
    .modal {
        width: calc(100vw - 16px);
        margin-block: 16px auto;
        max-height: calc(100vh - 32px);
    }
    .modal__head, .modal__body { padding: 14px; }
}

/* 18. Stock ledger ======================================================== */

.delta {
    display: inline-block;
    min-width: 46px;
    padding: 2px 9px;
    border-radius: var(--r-sm);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    text-align: right;
}
.delta--in { background: var(--success-bg); color: var(--success-fg); }
.delta--out { background: var(--danger-bg); color: var(--danger-fg); }

/* 19. Delivery estimate =================================================== */

.estimate {
    display: grid;
    gap: 3px;
    padding: 12px 14px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
    border-radius: var(--r);
    background: var(--surface-2);
}
.estimate__label {
    font-size: 11px;
    font-weight: 650;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.estimate__range { font-size: 17px; font-weight: 680; letter-spacing: -.01em; }
.estimate__dates { font-size: 13px; color: var(--text); }
.estimate__dates .icon { vertical-align: -3px; color: var(--text-faint); margin-right: 3px; }
.estimate__parts { font-size: 12px; color: var(--text-faint); font-variant-numeric: tabular-nums; }

/* Inline variant, for a cart or order panel. */
.estimate--inline { margin-bottom: 0; background: transparent; border-style: dashed; }

/* 20. Facturare: taburi, panouri, ferestre, explicații ==================== */

/* --- Bara de taburi ------------------------------------------------------ */
/* Link-uri adevărate către adrese adevărate; `async-ui.js` doar le prinde
   clicul. Pe ecran îngust bara derulează orizontal în loc să se rupă pe două
   rânduri — un tab tăiat la jumătate se vede că mai continuă, unul rupt pe alt
   rând arată ca alt lucru. */
.tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 18px;
    padding-bottom: 1px;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tabs__link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    flex: 0 0 auto;
    padding: 9px 14px;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    border-radius: var(--r-sm) var(--r-sm) 0 0;
    color: var(--text-muted);
    font-size: 13.5px;
    font-weight: 600;
    white-space: nowrap;
    transition: color .12s ease, background .12s ease, border-color .12s ease;
}
.tabs__link:hover { color: var(--text); background: var(--surface-2); }
.tabs__link .icon { color: var(--text-faint); }
.tabs__link.is-active {
    color: var(--brand-600);
    border-bottom-color: var(--accent-500);
    background: var(--surface);
}
.tabs__link.is-active .icon { color: var(--accent-500); }

.tabs__n {
    min-width: 18px;
    padding: 1px 6px;
    border-radius: var(--r-full);
    background: var(--surface-3);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    text-align: center;
}
.tabs__n--warning { background: var(--warning-bg); color: var(--warning-fg); }

/* --- Panoul de sub taburi ------------------------------------------------ */
/* Schimbat prin fetch, deci trebuie să spună că lucrează. Fără înălțime fixă:
   un panou care sare la 400px și înapoi e mai deranjant decât unul care se
   estompează o clipă. */
.panel { position: relative; }
.panel.is-loading { opacity: .45; pointer-events: none; transition: opacity .12s ease; }
.panel.is-loading::after {
    content: "";
    position: absolute;
    inset-inline: 0;
    top: -19px;
    height: 2px;
    border-radius: var(--r-full);
    background: linear-gradient(90deg, transparent, var(--accent-500), transparent);
    animation: panel-sweep 1s linear infinite;
}
@keyframes panel-sweep {
    from { transform: translateX(-40%) scaleX(.4); }
    to   { transform: translateX(40%) scaleX(.4); }
}

.panel__head {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.panel__text { flex: 1; min-width: 260px; }
.panel__text h2 { font-size: 16px; letter-spacing: -.01em; }
.panel__text p { margin-top: 4px; color: var(--text-muted); font-size: 13px; max-width: 76ch; }
.panel__actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* --- Explicații (tooltip) ------------------------------------------------ */
/* Un `<button>`, nu un `<span>`: altfel explicația ar exista doar pentru cine
   folosește mouse-ul — nu s-ar putea ajunge la ea nici cu tastatura, nici pe
   un ecran tactil. Se deschide la hover, la focus și la atingere. */
.tip { position: relative; display: inline-flex; vertical-align: -3px; }
/* O etichetă de indicator care poartă o explicație stă pe un rând cu ea. */
.stat__label { display: inline-flex; align-items: center; gap: 5px; }
.tip__btn {
    display: inline-flex;
    padding: 1px;
    border: 0;
    border-radius: var(--r-full);
    background: transparent;
    color: var(--text-faint);
    cursor: help;
    line-height: 0;
}
.tip__btn:hover, .tip__btn:focus-visible { color: var(--accent-500); }
.tip__btn:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 1px; }

.tip__bubble {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(-3px);
    z-index: 60;
    width: max-content;
    max-width: min(340px, calc(100vw - 40px));
    padding: 10px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--r);
    background: var(--surface);
    box-shadow: var(--shadow-md);
    color: var(--text);
    font-size: 12.5px;
    font-weight: 450;
    line-height: 1.55;
    text-align: left;
    white-space: normal;
    /* Explicit, fiindcă semnul de întrebare stă adesea într-un antet de tabel
       sau într-o etichetă de indicator, scrise cu majuscule și spațiate — o
       bulă care le-ar moșteni ar fi un paragraf de citit cu majuscule. */
    text-transform: none;
    letter-spacing: normal;
    color: var(--text);
    visibility: hidden;
    opacity: 0;
    transition: opacity .12s ease, transform .12s ease, visibility 0s linear .12s;
}
.tip__bubble p { margin: 0; }
.tip__bubble p + p, .tip__bubble br + * { margin-top: 6px; }
.tip__bubble .mono { font-size: 11.5px; }

.tip:hover .tip__bubble,
.tip:focus-within .tip__bubble {
    visibility: visible;
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    transition-delay: 0s;
}

/* Lângă marginea din dreapta, o bulă centrată ar ieși din ecran. */
.tip--end .tip__bubble { left: auto; right: 0; transform: translateY(-3px); }
.tip--end:hover .tip__bubble,
.tip--end:focus-within .tip__bubble { transform: translateY(0); }

/* Un rând de formular cu explicație alături: eticheta rămâne unde e, semnul
   de întrebare se aliniază cu ea, nu cu mijlocul câmpului. */
.switch-row, .field-with-tip {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 16px;
}
.switch-row > .field, .field-with-tip > *:first-child { flex: 1; min-width: 0; margin-bottom: 0; }
.field-with-tip > .tip, .switch-row > .tip { margin-top: 2px; }

/* --- Faptele scurte de pe ecranul unui document ------------------------- */
.facts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 1px;
    margin-bottom: 18px;
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: var(--border);
    overflow: hidden;
}
.fact { display: grid; gap: 3px; padding: 13px 16px; background: var(--surface); }
.fact__label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 650;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.fact__value { font-size: 17px; font-weight: 680; letter-spacing: -.01em; }
.fact__meta { font-size: 12px; color: var(--text-faint); }

/* --- Bara de acțiuni ----------------------------------------------------- */
.actionbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 12px 14px;
    margin-bottom: 18px;
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: var(--surface-2);
}
.actionbar__note {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1 1 260px;
    min-width: 0;
    font-size: 12.5px;
    color: var(--text-muted);
}
.actionbar__note .icon { flex: 0 0 auto; color: var(--text-faint); }

/* --- Casetă de explicație în corpul unei ferestre ----------------------- */
.notice {
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-left: 3px solid var(--border-strong);
    border-radius: var(--r);
    background: var(--surface-2);
    font-size: 13px;
}
.notice strong { display: block; margin-bottom: 4px; }
.notice p { color: var(--text-muted); }
.notice p + p, .notice .bullets { margin-top: 7px; }
.notice--warning { border-left-color: var(--warning); background: var(--warning-bg); }
.notice--warning p, .notice--warning strong { color: var(--warning-fg); }
.notice--danger { border-left-color: var(--danger); background: var(--danger-bg); }
.notice--danger p, .notice--danger strong { color: var(--danger-fg); }

/* --- Liste explicative --------------------------------------------------- */
.bullets { margin: 0; padding-left: 18px; font-size: 13px; color: var(--text-muted); }
.bullets li + li { margin-top: 7px; }
.bullets strong { color: var(--text); }

/* --- Ferestre ------------------------------------------------------------ */
/* `.modal` (secțiunea 17) e învelișul; astea sunt bucățile de care are nevoie
   o fereastră cu formular: un corp care derulează și un subsol care nu. */
.modal__form { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.modal__form > .modal__body { flex: 1 1 auto; }

.modal__foot {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
    padding: 14px 18px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
}
.modal--form { width: min(620px, calc(100vw - 32px)); }
.modal.is-busy { opacity: .6; pointer-events: none; }

/* Explicațiile din corpul unei ferestre se deschid în sus când sunt jos de
   tot: corpul derulează, deci o bulă în jos ar fi tăiată de marginea lui. */
.modal__foot .tip__bubble,
.modal__body > *:last-child .tip__bubble {
    top: auto;
    bottom: calc(100% + 8px);
}

/* Aceleași bucăți, când ruta e deschisă ca pagină (fără JavaScript). */
.modal-page { max-width: 720px; }
.modal-page .modal__head { display: none; }
.modal-page .modal__body { padding: 18px; }
.modal-page .modal__foot { border-radius: 0 0 var(--r-lg) var(--r-lg); }

/* --- Amănunte ------------------------------------------------------------ */
.logo-preview {
    padding: 14px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: var(--r);
    background: #fff;
    text-align: center;
}
.logo-preview img { max-height: 70px; max-width: 100%; }

/* Documentul se randează cu stilurile lui, scrise pentru mPDF — pe fundal alb
   în ambele teme, fiindcă asta e hârtia. */
.document-frame { background: #fff; color: #111; }

.journal__summary { color: var(--text); font-weight: 550; }
.journal__summary:hover { color: var(--brand-600); text-decoration: underline; }

.ellipsis {
    display: block;
    max-width: 46ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ellipsis-all { overflow-wrap: anywhere; }

pre.code--wrap { white-space: pre-wrap; word-break: break-word; max-height: 320px; overflow: auto; }

/* O listă de definiții în care descrierea stă sub termen, nu lângă el. */
.kv--stacked { grid-template-columns: 1fr; gap: 2px 0; }
.kv--stacked dd { margin-bottom: 10px; color: var(--text-muted); font-size: 12.5px; }
.kv--stacked dd:last-child { margin-bottom: 0; }

@media (max-width: 720px) {
    .actionbar { padding: 10px; }
    .actionbar .btn { flex: 1 1 auto; justify-content: center; }
    .tip__bubble { max-width: calc(100vw - 32px); }
}

/* 21. Bara de filtre pe un rând și selectorul de interval ================== */

/* Rândul de filtre. Fiecare control își cere lățimea de care are nevoie și
   nimic nu se întinde: un `<select>` cu „Toate seriile" nu are de ce să fie
   la fel de lat cu unul care ține un nume de lună. Se rupe pe rânduri abia
   când chiar nu mai încape. */
.filters--row { padding: 10px 14px; }
.filters__form {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    width: 100%;
}
.filters__form > select { width: auto; min-width: 0; flex: 0 0 auto; }
/* Câmpul de căutare e singurul care crește, și nu coboară sub lățimea la care
   textul lui de sugestie s-ar tăia: un text de sugestie retezat la jumătate nu
   mai explică nimic, doar ocupă loc. */
.filters__form .search { flex: 1 1 270px; min-width: 250px; }
.filters__form .search input { width: 100%; }
.filters__form > .tip { margin-left: auto; }

/* --- Selectorul de interval --------------------------------------------- */

/* Înainte ca `date-range.js` să apuce să ruleze — și pentru totdeauna, dacă nu
   rulează — astea sunt două câmpuri de text obișnuite, una lângă alta. */
.daterange { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.daterange input { width: 148px; }

/* După ce a rulat: câmpurile se mută în fereastră, iar aici rămâne butonul. */
.dr { position: relative; }
.dr > input { display: none; }

.dr__trigger {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--text-muted);
    font: inherit;
    font-size: 13.5px;
    white-space: nowrap;
    cursor: pointer;
    transition: border-color .12s ease, color .12s ease;
}
.dr__trigger:hover { border-color: var(--brand-300); }
.dr__trigger .icon { color: var(--text-faint); }
.dr__trigger.is-set { color: var(--text); font-weight: 600; }
.dr__trigger.is-set .icon { color: var(--accent-500); }
.dr__trigger[aria-expanded="true"] {
    border-color: var(--brand-500);
    box-shadow: 0 0 0 3px var(--brand-50);
}

/*  Poziție fixă, și nu absolută în interiorul cardului.

    `.card` are `overflow: hidden`, ca să taie colțurile pătrate ale tabelului
    la marginea lui rotunjită — iar dintr-un `overflow: hidden` nu scapă niciun
    z-index, oricât de mare. Fereastra se mută în `<body>` cât e deschisă și e
    ancorată de buton din `date-range.js`, care îi pune `top` și `left` și o
    întoarce în sus dacă nu încape dedesubt. */
.dr__pop {
    position: fixed;
    z-index: 90;
    top: 0;
    left: 0;
    display: flex;
    max-width: calc(100vw - 16px);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-lg);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

/* Intervalele gata făcute. Coloană, fiindcă sunt zece și un rând de zece
   butoane ar fi mai lat decât cele două luni de lângă el. */
.dr__presets {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 10px;
    border-right: 1px solid var(--border);
    background: var(--surface-2);
}
.dr__preset {
    padding: 6px 12px;
    border: 0;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--text-muted);
    font: inherit;
    font-size: 12.5px;
    font-weight: 550;
    text-align: left;
    white-space: nowrap;
    cursor: pointer;
}
.dr__preset:hover { background: var(--surface-3); color: var(--text); }
.dr__preset.is-active { background: var(--brand-50); color: var(--brand-600); font-weight: 650; }

.dr__main { display: flex; flex-direction: column; }
.dr__cals { display: flex; gap: 18px; padding: 14px 16px; }
.dr__cal { width: 224px; }
.dr__cal-head {
    display: grid;
    grid-template-columns: 28px 1fr 28px;
    align-items: center;
    margin-bottom: 8px;
}
.dr__cal-title { text-align: center; font-size: 13px; font-weight: 650; }

.dr__grid { width: 100%; border-collapse: collapse; table-layout: fixed; }
.dr__grid th {
    padding: 4px 0;
    font-size: 10.5px;
    font-weight: 650;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--text-faint);
    text-align: center;
}
.dr__grid td { padding: 1px 0; text-align: center; }

.dr__day {
    width: 100%;
    padding: 6px 0;
    border: 0;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 12.5px;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
}
.dr__day:hover { background: var(--surface-3); }
.dr__day:focus-visible { outline: 2px solid var(--brand-500); outline-offset: -2px; }
.dr__day.is-outside { color: var(--text-faint); }
/* Ziua de azi rămâne recognoscibilă și când e în interval, de aceea e un
   contur, nu un fundal. */
.dr__day.is-today { box-shadow: inset 0 0 0 1px var(--border-strong); font-weight: 650; }
.dr__day.is-inside { background: var(--brand-50); border-radius: 0; color: var(--brand-600); }
.dr__day.is-edge {
    background: var(--accent-500);
    color: #fff;
    font-weight: 650;
    box-shadow: none;
}

.dr__fields {
    display: flex;
    gap: 10px;
    padding: 0 16px 12px;
}
.dr__field { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.dr__field > span {
    font-size: 11px;
    font-weight: 650;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.dr__field input { width: 100%; }

.dr__foot {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 11px 16px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
}
.dr__hint { flex: 1; font-size: 12px; color: var(--text-faint); }

/* Pe ecran îngust cele două luni nu încap una lângă alta, iar fereastra n-are
   de ce să iasă din pagină: se așază pe verticală și se ancorează la dreapta. */
@media (max-width: 760px) {
    .dr__pop { flex-direction: column; max-height: calc(100vh - 24px); overflow-y: auto; }
    .dr__presets {
        flex-direction: row;
        flex-wrap: wrap;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }
    .dr__cals { flex-direction: column; }
    .dr__cal { width: 100%; }
}
