/* ==========================================================================
   Ayoub Store — base styles
   Colors that change with the chosen system color live in assets/theme.php.
   This file holds the neutral tokens and every component.
   ========================================================================== */

:root {
    --font: "Noto Sans Arabic", "Noto Sans", "Segoe UI", Tahoma, system-ui, sans-serif;
    --dir: 1;

    --radius: 16px;
    --radius-md: 12px;
    --radius-sm: 9px;
    --sb-w: 268px;
    --tb-h: 66px;

    --surface: #FFFFFF;
    --text: #291C0E;
    --text-2: #6B5B4D;
    --text-3: #8A796A;
    --border: rgba(41, 28, 14, .10);
    --border-strong: rgba(41, 28, 14, .18);

    --success: #3E7B58;  --success-soft: #E6F1EA;
    --warning: #95600F;  --warning-soft: #FBF0DC;
    --danger:  #B03A2E;  --danger-soft:  #F9E4E1;  --danger-ink: #FFFFFF;
    --info:    #2F6F7D;  --info-soft:    #E3F0F3;

    --shadow-sm: 0 1px 2px rgba(41, 28, 14, .05);
    --shadow:    0 1px 2px rgba(41, 28, 14, .05), 0 10px 30px -12px rgba(41, 28, 14, .14);
    --shadow-lg: 0 18px 50px -14px rgba(41, 28, 14, .30), 0 2px 6px rgba(41, 28, 14, .06);

    color-scheme: light;
}

html[lang="en"] { --font: "Noto Sans", "Noto Sans Arabic", "Segoe UI", system-ui, sans-serif; }
[dir="rtl"] { --dir: -1; }

[data-theme="dark"] {
    --text: #F2E9DD;
    --text-2: #BEB5A9;
    --text-3: #8F8375;
    --border: rgba(242, 233, 221, .09);
    --border-strong: rgba(242, 233, 221, .17);

    --success: #8FCBA5;  --success-soft: rgba(143, 203, 165, .12);
    --warning: #E9BC72;  --warning-soft: rgba(233, 188, 114, .12);
    --danger:  #F09A8E;  --danger-soft:  rgba(240, 154, 142, .12);  --danger-ink: #2A0F0A;
    --info:    #99CDD8;  --info-soft:    rgba(153, 205, 216, .12);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow:    0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -12px rgba(0, 0, 0, .5);
    --shadow-lg: 0 18px 50px -14px rgba(0, 0, 0, .7), 0 2px 6px rgba(0, 0, 0, .3);

    color-scheme: dark;
}

/* ── Base ─────────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    transition: background-color .25s ease, color .25s ease;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.3; font-weight: 700; }
p { margin: 0; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
::selection { background: var(--focus-soft); }

.ico {
    width: 20px; height: 20px; flex: none;
    fill: none; stroke: currentColor; stroke-width: 1.8;
    stroke-linecap: round; stroke-linejoin: round;
}
[dir="rtl"] .flip-rtl { transform: scaleX(-1); }

/* Changing tabs: a thin bar at the top while the next page loads (the sidebar stays put). */
body.is-navigating { cursor: progress; }
body.is-navigating::before {
    content: ''; position: fixed; top: 0; inset-inline: 0; z-index: 100; height: 3px;
    background: var(--accent);
    transform-origin: left center;
    animation: nav-progress 1.4s ease-out forwards;
}
[dir="rtl"] body.is-navigating::before { transform-origin: right center; }
@keyframes nav-progress { from { transform: scaleX(0); } to { transform: scaleX(.85); } }
.main { transition: opacity .12s ease .2s; }
body.is-navigating .main { opacity: .55; }

.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
/* A number block reads left-to-right but must stay on its column's side in right-to-left pages. */
[dir="rtl"] div.num, [dir="rtl"] td.num { text-align: right; }
[dir="rtl"] .end div.num, [dir="rtl"] td.num.end, [dir="rtl"] th.num.end { text-align: left; }
.muted { color: var(--text-2); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

[data-theme="light"] .show-dark,
[data-theme="dark"] .show-light { display: none; }
[hidden] { display: none !important; }

/* ── App shell ────────────────────────────────────────────────────────── */

.app { min-height: 100vh; }

.sidebar {
    position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 40;
    width: var(--sb-w);
    display: flex; flex-direction: column;
    background: var(--sb-bg);
    color: var(--sb-ink);
    border-inline-end: 1px solid var(--sb-edge);
    transition: background-color .25s ease, color .25s ease;
}
.sb-brand { display: flex; align-items: center; gap: 12px; padding: 20px 18px 14px; }
.sb-logo {
    width: 42px; height: 42px; flex: none;
    display: grid; place-items: center;
    border-radius: 12px;
    background: var(--sb-active);
    color: var(--sb-mark);
}
.sb-logo .ico { width: 22px; height: 22px; }
.sb-brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.sb-brand-text strong { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-brand-text small { font-size: 12px; color: var(--sb-ink-2); }
.sidebar .sb-close { display: none; margin-inline-start: auto; }
.sidebar .icon-btn { color: var(--sb-ink); }
.sidebar .icon-btn:hover { background: var(--sb-hover); color: var(--sb-ink); }

.sb-nav {
    flex: 1; overflow-y: auto;
    padding: 4px 12px 24px;
    scrollbar-width: thin;
    scrollbar-color: var(--sb-active) transparent;
}
.sb-label {
    padding: 18px 12px 6px;
    font-size: 12px; font-weight: 600;
    color: var(--sb-ink-2);
}
html[lang="en"] .sb-label { text-transform: uppercase; letter-spacing: .07em; font-size: 11px; }

.sb-link {
    position: relative;
    display: flex; align-items: center; gap: 12px;
    padding: 9px 12px; margin-bottom: 2px;
    border-radius: 10px;
    color: var(--sb-ink);
    font-size: 14.5px; font-weight: 500;
    transition: background-color .15s ease;
}
.sb-link:hover { background: var(--sb-hover); text-decoration: none; }
.sb-link.is-active { background: var(--sb-active); color: var(--sb-active-ink); font-weight: 700; }
.sb-link.is-active::before {
    content: ""; position: absolute;
    inset-inline-start: -12px; top: 9px; bottom: 9px; width: 4px;
    border-start-end-radius: 4px; border-end-end-radius: 4px;
    background: var(--sb-mark);
}
.sb-link.is-soon { opacity: .5; cursor: default; }
.sb-link.is-soon:hover { background: transparent; }
.sb-badge {
    margin-inline-start: auto; min-width: 22px; height: 22px; padding: 0 7px;
    display: inline-grid; place-items: center; border-radius: 99px;
    background: var(--danger); color: var(--danger-ink); font-size: 12px; font-weight: 800; line-height: 1;
}

.sb-overlay { display: none; }

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

.topbar {
    position: sticky; top: 0; z-index: 30;
    height: var(--tb-h);
    display: flex; align-items: center; gap: 12px;
    padding: 0 28px;
    background: var(--topbar-bg);
    -webkit-backdrop-filter: saturate(1.5) blur(12px);
    backdrop-filter: saturate(1.5) blur(12px);
    border-bottom: 1px solid var(--border);
}
.topbar .tb-menu { display: none; }
.tb-title {
    flex: 1; min-width: 0;
    font-size: 19px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tb-actions { display: flex; align-items: center; gap: 4px; }
.tb-sep { width: 1px; height: 26px; background: var(--border-strong); margin: 0 6px; }

/* min-width: 0 lets wide tables scroll inside their box instead of stretching the page. */
.content { flex: 1; width: 100%; min-width: 0; max-width: 1440px; padding: 28px; }

/* ── Icon buttons & user button ───────────────────────────────────────── */

.icon-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 40px; min-width: 40px; padding: 0 10px;
    border: 1px solid transparent; border-radius: 11px;
    background: transparent;
    color: var(--text-2);
    cursor: pointer;
    transition: background-color .15s, color .15s, border-color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn[aria-expanded="true"] { background: var(--surface); border-color: var(--border); color: var(--text); box-shadow: var(--shadow-sm); }
.icon-btn .lbl { font-size: 13.5px; font-weight: 600; }

.user-btn {
    display: flex; align-items: center; gap: 10px;
    height: 46px; padding: 0 8px; padding-inline-end: 10px;
    border: 1px solid transparent; border-radius: 13px;
    background: transparent;
    cursor: pointer; text-align: start;
    transition: background-color .15s, border-color .15s;
}
.user-btn:hover, .user-btn[aria-expanded="true"] { background: var(--surface-2); }
.user-btn[aria-expanded="true"] { border-color: var(--border); }
.avatar {
    width: 34px; height: 34px; flex: none;
    display: grid; place-items: center;
    border-radius: 50%;
    background: var(--accent);
    color: var(--accent-ink);
    font-weight: 700; font-size: 15px;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.25; max-width: 160px; }
.user-meta strong { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta small { font-size: 12px; color: var(--text-3); }
.user-chev { width: 16px; height: 16px; color: var(--text-3); }

/* ── Dropdowns ────────────────────────────────────────────────────────── */

.dd { position: relative; }
.dd-menu {
    position: absolute; top: calc(100% + 8px); inset-inline-end: 0; z-index: 60;
    min-width: 210px; padding: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    opacity: 0; visibility: hidden; transform: translateY(-4px);
    transition: opacity .14s ease, transform .14s ease, visibility 0s linear .14s;
}
.dd.is-open .dd-menu {
    opacity: 1; visibility: visible; transform: none;
    transition: opacity .14s ease, transform .14s ease;
}
.dd-title { padding: 8px 10px 6px; font-size: 12px; font-weight: 600; color: var(--text-3); }
.dd-item {
    display: flex; align-items: center; gap: 10px;
    width: 100%; padding: 9px 10px;
    border: 0; border-radius: 9px;
    background: none; color: var(--text);
    font-size: 14px; text-align: start;
    cursor: pointer;
}
.dd-item:hover { background: var(--surface-2); text-decoration: none; }
.dd-item .ico { width: 18px; height: 18px; color: var(--text-2); }
.dd-item .check { margin-inline-start: auto; color: var(--accent-text); opacity: 0; }
.dd-item[aria-checked="true"] { font-weight: 700; }
.dd-item[aria-checked="true"] .check { opacity: 1; }
.dd-item.is-danger, .dd-item.is-danger .ico { color: var(--danger); }
.dd-item.is-disabled { opacity: .55; cursor: default; }
.dd-item.is-disabled:hover { background: none; }
.dd-soon { margin-inline-start: auto; font-style: normal; font-size: 11px; color: var(--text-3); }
.dd-sep { height: 1px; margin: 6px 4px; background: var(--border); }
.dd-user { display: flex; flex-direction: column; padding: 8px 10px 6px; line-height: 1.4; }
.dd-user small { color: var(--text-3); font-size: 12.5px; text-align: start; }

.swatches { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; width: 360px; padding: 2px 4px 6px;
            max-height: min(62vh, 460px); overflow-y: auto; }   /* 23 colors: scroll on short screens */
.swatch {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 9px 2px 7px;
    border: 0; border-radius: 11px;
    background: none; color: var(--text-2);
    font-size: 11.5px; line-height: 1.3;
    cursor: pointer;
}
.swatch:hover { background: var(--surface-2); color: var(--text); }
.swatch-dot {
    width: 36px; height: 36px;
    display: grid; place-items: center;
    border-radius: 50%;
    background: var(--sw);
    color: var(--sw-ink);
    box-shadow: inset 0 0 0 1px rgba(41, 28, 14, .14);
    transition: box-shadow .15s ease, transform .15s ease;
}
[data-theme="dark"] .swatch-dot,
[data-theme="dark"] .chip { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .2); }
.swatch:hover .swatch-dot { transform: scale(1.06); }
.swatch-dot .ico { width: 17px; height: 17px; stroke-width: 2.6; opacity: 0; transform: scale(.5); transition: .15s ease; }
.swatch[aria-checked="true"] { color: var(--text); font-weight: 700; }
.swatch[aria-checked="true"] .swatch-dot { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.swatch[aria-checked="true"] .swatch-dot .ico { opacity: 1; transform: none; }

/* ── Buttons ──────────────────────────────────────────────────────────── */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 42px; padding: 0 18px;
    border: 1px solid transparent; border-radius: 11px;
    font-size: 14.5px; font-weight: 600; white-space: nowrap;
    cursor: pointer;
    transition: background-color .15s, border-color .15s, box-shadow .15s, transform .06s;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn .ico { width: 18px; height: 18px; }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--accent-text); }
.btn-ghost:hover { background: var(--accent-soft); }
.btn-danger { background: var(--danger); color: var(--danger-ink); }
.btn-danger:hover { filter: brightness(.94); }
.btn-lg { height: 50px; font-size: 16px; border-radius: 13px; }
.btn-block { width: 100%; }
.btn[disabled], .btn.is-loading { opacity: .65; pointer-events: none; }
.btn.is-loading::after {
    content: ""; width: 16px; height: 16px;
    border: 2px solid currentColor; border-inline-end-color: transparent; border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Forms ────────────────────────────────────────────────────────────── */

.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 18px; }
.label { font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.hint { font-size: 12.5px; color: var(--text-3); }
.input {
    width: 100%; height: 46px; padding: 0 14px;
    border: 1px solid var(--border-strong); border-radius: 12px;
    background: var(--input-bg);
    color: var(--text); font-size: 15px;
    transition: border-color .15s, box-shadow .15s, background-color .25s;
}
.input::placeholder { color: var(--text-3); }
.input:hover { border-color: var(--text-3); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--focus-soft); }
select.input { appearance: none; -webkit-appearance: none; padding-inline-end: 40px; cursor: pointer; }

.input-wrap { position: relative; }
.input-wrap > .ico {
    position: absolute; top: 50%; inset-inline-start: 14px;
    transform: translateY(-50%);
    width: 18px; height: 18px;
    color: var(--text-3); pointer-events: none;
}
.input-wrap > .ico + .input { padding-inline-start: 42px; }
.input-wrap .select-chev { inset-inline-start: auto; inset-inline-end: 14px; }
.input-wrap .reveal {
    position: absolute; top: 50%; inset-inline-end: 5px;
    transform: translateY(-50%);
    height: 36px; min-width: 36px; padding: 0;
}
.input-wrap.has-reveal .input { padding-inline-end: 46px; }
/* Left-to-right inputs (phone, username, password) inside a right-to-left page:
   the icon sits on the right, so the space for it must be on the right too. */
[dir="rtl"] .input-wrap > .ico + .input[dir="ltr"] { padding-left: 14px; padding-right: 42px; }
[dir="rtl"] .input-wrap.has-reveal > .ico + .input[dir="ltr"] { padding-left: 46px; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; }

/* ── Alerts & badges ──────────────────────────────────────────────────── */

.alert {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px 14px; margin-bottom: 18px;
    border-radius: 12px;
    font-size: 14px; font-weight: 500;
}
.alert .ico { width: 19px; height: 19px; margin-top: 1px; }
.alert-danger  { background: var(--danger-soft);  color: var(--danger); }
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-info    { background: var(--info-soft);    color: var(--info); }
.alert-warning { background: var(--warning-soft); color: var(--warning); }
.alert.is-compact { padding: 8px 12px; margin: 8px 0 0; font-size: 13.5px; }
.alert.is-compact .ico { width: 17px; height: 17px; }

.badge {
    display: inline-flex; align-items: center; gap: 6px;
    height: 24px; padding: 0 10px;
    border-radius: 99px;
    background: var(--surface-3); color: var(--text-2);
    font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-accent  { background: var(--accent-soft);  color: var(--accent-text); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger); }
.badge-info    { background: var(--info-soft);    color: var(--info); }

/* ── Cards, stats, tables ─────────────────────────────────────────────── */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: background-color .25s ease;
}
.card + .card { margin-top: 20px; }
.card-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    padding: 16px 22px;
    border-bottom: 1px solid var(--border);
}
.card-head h3 { font-size: 16px; }
.card-body { padding: 22px; }
.section-title { font-size: 13px; font-weight: 700; color: var(--text-3); margin: 0 0 12px; }
.section + .section { margin-top: 28px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.stat {
    display: flex; align-items: center; gap: 14px;
    padding: 18px;
    border: 1px solid var(--border); border-radius: 14px;
    background: var(--surface);
}
.stat-ico {
    width: 48px; height: 48px; flex: none;
    display: grid; place-items: center;
    border-radius: 13px;
    background: var(--accent-soft); color: var(--accent-text);
}
.stat-ico .ico { width: 22px; height: 22px; }
.stat-label { font-size: 13px; color: var(--text-2); }
.stat-value { font-size: 22px; font-weight: 700; line-height: 1.3; }

.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* position: relative keeps hidden labels inside the table's own scroll area. */
.table-wrap { position: relative; overflow-x: auto; border: 1px solid var(--border); border-radius: 13px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
    padding: 11px 16px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    color: var(--text-2); font-size: 12.5px; font-weight: 600;
    text-align: start; white-space: nowrap;
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .end { text-align: end; }

.card-sub { font-size: 13.5px; color: var(--text-2); margin-top: 2px; }
.card > .table-wrap.is-flush { border: 0; border-radius: 0 0 var(--radius) var(--radius); }
.table tbody tr.is-dim td { color: var(--text-3); }
.table tbody tr.is-dim .avatar { opacity: .55; }

.btn-sm { height: 34px; padding: 0 12px; font-size: 13.5px; border-radius: 9px; gap: 6px; }
.btn-sm .ico { width: 16px; height: 16px; }
.badge-sm { height: 20px; padding: 0 8px; font-size: 11px; vertical-align: 2px; }

.avatar-sm { width: 36px; height: 36px; font-size: 14px; }
.person { display: flex; align-items: center; gap: 12px; }
.person-text { display: flex; flex-direction: column; line-height: 1.4; min-width: 0; }
.person-text strong { font-weight: 600; }
.person-text small { color: var(--text-3); font-size: 12.5px; text-align: start; }

.cust-meta { display: flex; flex-wrap: wrap; gap: 2px 12px; }
.cust-meta span { display: inline-flex; align-items: center; gap: 4px; }
.phone-link { color: var(--text); font-weight: 600; }
.phone-link:hover { color: var(--accent-text); }
.affix .input[readonly] { color: var(--text-3); cursor: not-allowed; }

/* ── Switch (on/off checkbox) ─────────────────────────────────────────── */

.switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; font-size: 14.5px; font-weight: 500; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track {
    position: relative; flex: none;
    width: 44px; height: 26px;
    border-radius: 99px;
    background: var(--surface-3);
    box-shadow: inset 0 0 0 1px var(--border-strong);
    transition: background-color .15s;
}
.switch-track::after {
    content: ""; position: absolute; top: 3px; inset-inline-start: 3px;
    width: 20px; height: 20px; border-radius: 50%;
    background: #FFFFFF;
    box-shadow: 0 1px 3px rgba(41, 28, 14, .3);
    transition: transform .18s ease;
}
.switch input:checked + .switch-track { background: var(--accent); box-shadow: none; }
.switch input:checked + .switch-track::after { transform: translateX(calc(18px * var(--dir))); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--focus); outline-offset: 2px; }
.switch input:disabled + .switch-track { opacity: .5; }
.switch:has(input:disabled) { cursor: default; }

.self-note { display: flex; align-items: center; gap: 6px; margin-top: 12px; }
.self-note .ico { width: 16px; height: 16px; }

/* ── Page header, empty state, small helpers ──────────────────────────── */

.page-head {
    display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
    margin-bottom: 20px;
}
.page-head h2 { font-size: 20px; }
.page-head p { color: var(--text-2); font-size: 14px; margin-top: 2px; }

.empty {
    display: flex; flex-direction: column; align-items: center; text-align: center;
    padding: 52px 20px;
    background: var(--surface);
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--radius);
}
.empty.is-flat { border: 0; background: none; padding: 40px 20px 44px; }
.empty-ico {
    width: 60px; height: 60px;
    display: grid; place-items: center;
    border-radius: 18px;
    background: var(--accent-soft); color: var(--accent-text);
    margin-bottom: 14px;
}
.empty-ico .ico { width: 28px; height: 28px; }
.empty h3 { font-size: 17px; margin-bottom: 4px; }
.empty p { color: var(--text-2); font-size: 14px; }
.empty .btn { margin-top: 18px; }

.optional { font-weight: 400; color: var(--text-3); font-size: 12.5px; }
.hint.is-error { color: var(--danger); }
.ico-xs { width: 14px !important; height: 14px !important; opacity: .7; }
.inline-form { display: inline; margin: 0; }
.input-row { display: flex; gap: 10px; align-items: flex-start; }
.input-row > .input, .input-row > .grow { flex: 1; min-width: 0; }
.input-row > .btn { height: 46px; flex: none; }
.textarea { height: auto; min-height: 92px; padding: 11px 14px; line-height: 1.6; resize: vertical; }

.icon-btn-sm { height: 34px; min-width: 34px; padding: 0 8px; border-radius: 9px; }
.icon-btn-sm .ico { width: 17px; height: 17px; }
.icon-btn.is-danger:hover { background: var(--danger-soft); color: var(--danger); }

/* ── Storages (cards) ─────────────────────────────────────────────────── */

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.place {
    display: flex; flex-direction: column; gap: 12px;
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.place-head { display: flex; align-items: center; gap: 12px; }
.place-title { flex: 1; min-width: 0; line-height: 1.35; }
.place-title h3 { font-size: 16px; overflow-wrap: anywhere; }
.place-count { font-size: 12.5px; color: var(--text-3); font-weight: 600; }
.place-count:hover { color: var(--accent-text); }
.tile-count {
    min-width: 26px; height: 22px; padding: 0 7px;
    display: grid; place-items: center;
    border-radius: 99px;
    background: var(--surface); border: 1px solid var(--border);
    color: var(--text-3); font-size: 12px; font-weight: 700;
}
.tile-count:hover { color: var(--accent-text); border-color: var(--accent); text-decoration: none; }
.place-ico {
    width: 44px; height: 44px; flex: none;
    display: grid; place-items: center;
    border-radius: 13px;
    background: var(--accent-soft); color: var(--accent-text);
}
.place-ico .ico { width: 22px; height: 22px; }
.place-actions { display: flex; gap: 2px; margin-inline-end: -6px; }
.place-row { display: flex; gap: 8px; align-items: flex-start; color: var(--text-2); font-size: 14px; }
.place-row .ico { width: 17px; height: 17px; margin-top: 3px; color: var(--text-3); }
.place-note {
    padding: 10px 12px;
    background: var(--surface-2);
    border-radius: 10px;
    color: var(--text-2); font-size: 13.5px;
    white-space: pre-line; overflow-wrap: anywhere;
}
.place-foot { margin-top: auto; padding-top: 2px; display: flex; flex-wrap: wrap; gap: 8px; }

/* ── Categories (tiles) ───────────────────────────────────────────────── */

.quick-add .alert { margin-bottom: 12px; }
.card-body.has-divider { border-top: 1px solid var(--border); }
.filter-box { max-width: 340px; margin-bottom: 16px; }
.tile-list {
    list-style: none; margin: 0; padding: 0;
    display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px;
}
.tile {
    display: flex; align-items: center; gap: 10px;
    min-height: 52px; padding-block: 8px; padding-inline: 12px 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 12px;
}
.tile-ico { color: var(--accent-text); display: grid; }
.tile-ico .ico { width: 18px; height: 18px; }
.tile-name { flex: 1; min-width: 0; font-weight: 600; font-size: 14.5px; overflow-wrap: anywhere; }
.tile-actions { display: flex; gap: 2px; opacity: .55; transition: opacity .15s; }
.tile:hover .tile-actions, .tile:focus-within .tile-actions { opacity: 1; }
.no-match { padding: 8px 2px; }

/* ── Items: toolbar, table cells, pager ───────────────────────────────── */

.toolbar {
    display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
    margin-bottom: 16px;
}
.toolbar .input-wrap { min-width: 170px; }
.toolbar .toolbar-search { flex: 1; min-width: 220px; }
.toolbar .btn { height: 46px; }

.chip-toggle { position: relative; cursor: pointer; }
.chip-toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip-toggle span {
    display: inline-flex; align-items: center; gap: 8px;
    height: 46px; padding: 0 14px;
    border: 1px solid var(--border-strong); border-radius: 12px;
    background: var(--input-bg); color: var(--text-2);
    font-size: 14px; font-weight: 600; white-space: nowrap;
    transition: background-color .15s, border-color .15s, color .15s;
}
.chip-toggle .ico { width: 17px; height: 17px; }
.chip-toggle b { font-size: 12px; padding: 1px 7px; border-radius: 99px; background: var(--warning-soft); color: var(--warning); }
.chip-toggle input:checked + span { background: var(--warning-soft); border-color: transparent; color: var(--warning); }
.chip-toggle input:checked + span b { background: var(--warning); color: var(--surface); }
.chip-toggle input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

.cell-main { font-weight: 600; }
.cell-sub { font-size: 12.5px; color: var(--text-3); margin-top: 1px; }
.nowrap { white-space: nowrap; }
.items-table td { vertical-align: top; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 16px; font-size: 13.5px; }
.pager-links { display: flex; align-items: center; gap: 8px; }
.pager-now { padding: 0 6px; color: var(--text-2); font-weight: 600; }

/* ── Bigger forms: sections, grids, unit switch, affixed inputs ───────── */

.modal-lg { width: min(780px, calc(100vw - 24px)); }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }
.span-2 { grid-column: span 2; }

.form-section { border: 0; margin: 6px 0 0; padding: 18px 0 0; border-top: 1px solid var(--border); min-width: 0; }
.form-section-title {
    display: flex; align-items: center; gap: 8px;
    padding: 0; margin-bottom: 14px;
    font-size: 14.5px; font-weight: 700; color: var(--text);
}
.form-section-title .ico { width: 18px; height: 18px; color: var(--accent-text); }

.segmented {
    display: inline-flex; padding: 4px; gap: 4px;
    background: var(--surface-3); border-radius: 12px;
}
.segmented label { position: relative; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented span {
    display: block; padding: 7px 22px; border-radius: 9px;
    font-size: 14px; font-weight: 600; color: var(--text-2);
    transition: background-color .15s, color .15s, box-shadow .15s;
}
.segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 1px; }

.affix {
    display: flex; align-items: stretch;
    border: 1px solid var(--border-strong); border-radius: 12px;
    background: var(--input-bg);
    transition: border-color .15s, box-shadow .15s;
}
.affix:hover { border-color: var(--text-3); }
.affix:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--focus-soft); }
.affix .input { border: 0; box-shadow: none; background: transparent; min-width: 0; flex: 1; height: 44px; }
.affix .input:focus { box-shadow: none; }
.affix-pre, .affix-post {
    display: flex; align-items: center;
    padding: 0 12px;
    color: var(--text-3); font-size: 13.5px; font-weight: 600; white-space: nowrap;
}
.affix-pre { border-right: 1px solid var(--border); padding-right: 10px; }
.affix-post { border-left: 1px solid var(--border); background: var(--surface-2); border-radius: 0 11px 11px 0; }
.affix-narrow { max-width: 240px; }

.qty-row { display: flex; gap: 12px; flex-wrap: wrap; }
.qty-row > .field { flex: 1; min-width: 120px; margin-bottom: 10px; }
.qty-total {
    display: inline-flex; gap: 6px; align-items: center;
    padding: 7px 12px; border-radius: 10px;
    background: var(--accent-soft); color: var(--accent-text);
    font-size: 14px;
}
.qty-total strong { font-variant-numeric: tabular-nums; }

.price-preview {
    display: flex; flex-wrap: wrap; gap: 8px;
    margin-top: 4px;
}
.price-preview span {
    padding: 6px 11px; border-radius: 9px;
    background: var(--surface-2); border: 1px solid var(--border);
    font-size: 13.5px; font-weight: 600; color: var(--text-2);
    font-variant-numeric: tabular-nums;
}
.price-preview .is-profit { background: var(--success-soft); border-color: transparent; color: var(--success); }
.price-preview .is-loss { background: var(--danger-soft); color: var(--danger); }

/* ── Excel import ─────────────────────────────────────────────────────── */

.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 16px; align-items: start; }
.steps .card + .card { margin-top: 0; }
.step h3 { font-size: 16px; margin-bottom: 8px; }
.step p { margin-bottom: 16px; }
.rules { margin: 0; padding-inline-start: 18px; color: var(--text-2); font-size: 14px; display: grid; gap: 8px; }

.dropzone {
    position: relative;
    display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
    padding: 26px 16px;
    border: 1.5px dashed var(--border-strong); border-radius: 14px;
    background: var(--surface-2);
    cursor: pointer;
    transition: border-color .15s, background-color .15s;
}
.dropzone:hover, .dropzone:focus-within { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.has-file { border-style: solid; border-color: var(--accent); }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone .ico { width: 30px; height: 30px; color: var(--accent-text); }
.dropzone strong { font-size: 14.5px; overflow-wrap: anywhere; }
.dropzone small { color: var(--text-3); font-size: 12.5px; }

.import-summary { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.badge-lg { height: 32px; padding: 0 14px; font-size: 13.5px; }
.table tbody tr.is-error-row td { background: var(--danger-soft); }
.import-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 18px; align-items: center; }
.import-actions .alert { margin: 0; }

/* ── Sell screen ──────────────────────────────────────────────────────── */

.link-btn { border: 0; background: none; padding: 0; color: var(--accent-text); font-weight: 600; font-size: 13px; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }

.sell { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.sell-main { display: grid; gap: 16px; min-width: 0; }
/* Pinned while scrolling a long cart; scrolls on its own if taller than the screen,
   so the "complete sale" button can always be reached. */
.sell-side {
    display: grid; gap: 16px;
    position: sticky; top: calc(var(--tb-h) + 16px);
    max-height: calc(100vh - var(--tb-h) - 32px);
    overflow-y: auto; overscroll-behavior: contain;
    scrollbar-width: thin;
    padding: 2px; margin: -2px;   /* room for card shadows inside the scroll area */
}
.sell .card + .card { margin-top: 0; }
.sell-block { padding: 18px; }
.sell-block-head { margin-bottom: 14px; }
.segmented span { display: inline-flex; align-items: center; gap: 7px; }
.segmented .ico { width: 17px; height: 17px; }
.segmented-full { display: flex; }
.segmented-full label { flex: 1; }
.segmented-full span { justify-content: center; width: 100%; }

.picker { position: relative; }
.input-lg .input { height: 54px; font-size: 16.5px; border-radius: 14px; }
.input-lg > .ico { width: 21px; height: 21px; }
.picker-list {
    position: absolute; inset-inline: 0; top: calc(100% + 6px); z-index: 20;
    max-height: 340px; overflow-y: auto;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
}
.picker-item {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 10px 12px; border-radius: 10px;
    cursor: pointer;
}
.picker-item.is-hi, .picker-item:hover { background: var(--accent-soft); }
.pi-main { display: flex; flex-direction: column; min-width: 0; line-height: 1.4; }
.pi-main strong { font-weight: 600; overflow-wrap: anywhere; }
.pi-main small, .pi-side small { color: var(--text-3); font-size: 12.5px; }
.pi-side { display: flex; flex-direction: column; align-items: flex-end; flex: none; line-height: 1.4; font-weight: 700; }
.pi-side small.is-out { color: var(--danger); font-weight: 600; }
.picker-empty { padding: 12px; color: var(--text-3); font-size: 14px; }

.chosen {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px;
    background: var(--accent-soft);
    border-radius: 13px;
}
.chosen-text { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.4; }
.chosen-text small { color: var(--text-2); font-size: 12.5px; }

.cart-head, .cart-line {
    display: grid;
    grid-template-columns: minmax(150px, 1fr) 118px 138px 132px 92px 34px;
    gap: 10px; align-items: center;
}
.cart-head {
    margin-top: 16px; padding: 0 10px 8px;
    border-bottom: 1px solid var(--border);
    color: var(--text-3); font-size: 12px; font-weight: 600;
}
.cart { display: grid; gap: 6px; margin-top: 8px; }
.cart-line {
    padding: 10px;
    border: 1px solid transparent; border-radius: 12px;
    transition: background-color .15s, border-color .15s;
}
.cart-line:hover { background: var(--surface-2); }
.cart-line.is-active { background: var(--surface-2); border-color: var(--border-strong); }
.cart-line.has-error { border-color: var(--danger); background: var(--danger-soft); }
.cl-name { display: flex; flex-direction: column; min-width: 0; line-height: 1.4; }
.cl-name strong { font-weight: 600; overflow-wrap: anywhere; }
.cl-name small { color: var(--text-3); font-size: 12px; }
.cl-unit-text { color: var(--text-2); font-size: 14px; }
.cl-total { text-align: end; font-weight: 700; }
.cl-warn, .cl-note { display: block; margin-top: 4px; font-size: 11.5px; line-height: 1.3; color: var(--text-3); }
.cl-warn, .cl-note.is-loss { color: var(--danger); font-weight: 600; }

.input-sm { height: 38px; padding: 0 10px; font-size: 14px; border-radius: 10px; }
select.input-sm { padding-inline-end: 10px; }
.affix-sm .input { height: 36px; font-size: 14px; }
.affix-sm .affix-pre { padding: 0 8px; }
.affix-sm { border-radius: 10px; }
.stepper { display: flex; align-items: stretch; }
.stepper .input { text-align: center; border-radius: 0; min-width: 0; flex: 1; padding: 0 4px; }
.stepper button {
    width: 34px; flex: none;
    border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
    font-size: 17px; font-weight: 700; cursor: pointer;
}
.stepper button:first-child { border-radius: 10px 0 0 10px; border-right: 0; }
.stepper button:last-child { border-radius: 0 10px 10px 0; border-left: 0; }
.stepper button:hover { background: var(--surface-3); }

.info-card { padding: 16px 18px; }
.info-empty { display: flex; gap: 10px; align-items: center; color: var(--text-3); font-size: 14px; }
.info-head { display: flex; flex-direction: column; line-height: 1.4; margin-bottom: 12px; }
.info-head strong { font-size: 16px; }
.info-head small { color: var(--text-3); font-size: 12.5px; }
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin: 0; }
.info-grid dt { color: var(--text-3); font-size: 12px; font-weight: 600; }
.info-grid dd { margin: 2px 0 0; font-weight: 700; font-size: 14.5px; }
.info-grid dd small { display: block; font-weight: 500; font-size: 12px; color: var(--text-3); }
.info-grid dd .link-btn { font-size: 12px; }
.is-gain { color: var(--success); }
.is-loss { color: var(--danger); }
.info-last { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.info-last h4 { font-size: 12px; color: var(--text-3); font-weight: 600; margin: 0 0 4px; }
.info-last p { font-size: 14.5px; }
.info-last small { color: var(--text-2); font-size: 12.5px; }

.totals { padding: 18px; }
.t-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 6px 0; font-size: 14.5px; }
.t-muted { color: var(--text-3); font-size: 13px; }
.t-total {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
    margin-top: 8px; padding-top: 12px; border-top: 1px dashed var(--border-strong);
    font-weight: 700;
}
.t-total > div { display: flex; flex-direction: column; align-items: flex-end; }
.t-total strong { font-size: 26px; line-height: 1.2; }
.t-total small { color: var(--text-2); font-size: 13.5px; font-weight: 600; }
.t-debt strong { color: var(--warning); }
.discount-box { display: flex; gap: 6px; max-width: 170px; }
.discount-box .input { height: 38px; text-align: center; }
.mini-toggle { display: flex; padding: 3px; gap: 2px; background: var(--surface-3); border-radius: 10px; }
.mini-toggle button {
    width: 32px; border: 0; border-radius: 8px; background: none;
    color: var(--text-2); font-weight: 700; cursor: pointer;
}
.mini-toggle button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.loan-box { margin-top: 14px; padding: 12px; border-radius: 12px; background: var(--warning-soft); }
.loan-box .field { margin-bottom: 10px; }
.sell-error { margin: 14px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--danger-soft); color: var(--danger); font-size: 14px; font-weight: 600; }
.sell-submit { margin-top: 16px; }
.rate-line { display: flex; align-items: center; gap: 8px; margin-top: 12px; color: var(--text-3); font-size: 13px; }

@media (max-width: 1180px) {
    .sell { grid-template-columns: minmax(0, 1fr); }
    .sell-side { position: static; max-height: none; overflow: visible; }
}
@media (max-width: 760px) {
    .cart-head { display: none; }
    .cart-line {
        grid-template-columns: 1fr 1fr 34px;
        grid-template-areas: "name name remove" "unit qty qty" "price price total";
        border-color: var(--border);
    }
    .cl-name { grid-area: name; }
    .cl-unit { grid-area: unit; }
    .cl-qty { grid-area: qty; }
    .cl-price { grid-area: price; }
    .cl-total { grid-area: total; align-self: center; }
    .cl-remove { grid-area: remove; }
}

/* ── Invoice ──────────────────────────────────────────────────────────── */

.invoice-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.seg-links { display: inline-flex; padding: 4px; gap: 4px; background: var(--surface-3); border-radius: 12px; }
.seg-links a {
    padding: 7px 16px; border-radius: 9px;
    font-size: 14px; font-weight: 600; color: var(--text-2); text-decoration: none;
}
.seg-links a:hover { color: var(--text); }
.seg-links a.is-on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.rc-stage { overflow-x: auto; padding-bottom: 8px; }

/*
 * The printed invoice: an A4 page like the old system's receipt. It is paper, so it
 * stays white with dark ink in every theme. Sizes are in em so the preview can shrink it.
 */
.receipt {
    width: 210mm; min-height: 297mm; max-width: 100%;
    margin: 0 auto; padding: 2.2em 2.6em;
    display: flex; flex-direction: column;
    background: #fff; color: #1a1a1a;
    font-size: 13px; line-height: 1.5;
    border: 1px solid #ddd; box-shadow: 0 6px 24px rgba(0, 0, 0, .12);
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.receipt > * { flex-shrink: 0; }
.receipt [hidden] { display: none !important; }
.receipt .ico { width: 1.15em; height: 1.15em; flex: none; }
.receipt .num { font-variant-numeric: tabular-nums; }

.rc-head { text-align: center; padding-bottom: 1.2em; margin-bottom: 1.2em; border-bottom: 2px solid #333; }
.rc-logo { display: block; max-width: 17em; max-height: 8.5em; margin: 0 auto .5em; object-fit: contain; }
.rc-name { font-size: 1.75em; font-weight: 800; color: #1a1a1a; }
.rc-slogan { color: #666; font-size: .95em; margin-top: .15em; }
.rc-place { display: inline-flex; align-items: center; gap: .35em; margin-top: .45em; color: #444; font-weight: 600; }

.rc-bar {
    display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .3em 1.2em;
    padding: .75em 1.15em; margin-bottom: 1.1em;
    background: #f5f5f5; border: 1px solid #ddd; border-radius: 4px;
    font-weight: 600;
}
.rc-bar b { font-weight: 800; }
.rc-no b { font-size: 1.2em; }

.rc-cust { width: 100%; border-collapse: collapse; margin-bottom: 1.2em; }
.rc-cust th, .rc-cust td { padding: .5em .8em; border-bottom: 1px dashed #ddd; text-align: start; font-weight: 600; }
.rc-cust th { width: 28%; color: #666; }

.rc-loan {
    display: flex; align-items: center; justify-content: center; gap: .5em; flex-wrap: wrap;
    padding: .8em 1.2em; margin-bottom: 1.2em;
    background: #fff8e1; border: 2px solid #ff9800; border-radius: 6px;
    color: #e65100; font-weight: 700; font-size: 1.05em; text-align: center;
}

.rc-items { width: 100%; border-collapse: collapse; border: 1px solid #ccc; margin-bottom: 1.4em; }
.rc-items th {
    padding: .75em .9em; text-align: start; font-weight: 800;
    background: #f5f5f5; border-bottom: 2px solid #ccc;
}
.rc-items td { padding: .6em .9em; text-align: start; vertical-align: top; border-bottom: 1px dashed #e6e6e6; }
.rc-items tr:last-child td { border-bottom: 0; }
.rc-items .rc-n { width: 2.6em; color: #999; font-size: .85em; }
.rc-items small { color: #777; font-size: .85em; }
.rc-items tr, .rc-totals, .rc-loan, .rc-foot { break-inside: avoid; }
.rc-empty td { height: 2.3em; }

.rc-totals {
    align-self: flex-start; min-width: 22em; max-width: 100%;
    border: 1px solid #ddd; border-radius: 6px; overflow: hidden; margin-bottom: 1.4em;
}
.rc-row { display: flex; justify-content: space-between; gap: 1.5em; padding: .6em 1.2em; border-bottom: 1px solid #eee; }
.rc-row:last-child { border-bottom: 0; }
.rc-row > span:first-child { color: #666; }
.rc-row > span:last-child { font-weight: 700; }
.rc-disc { color: #e65100; }
.rc-disc > span:first-child { color: inherit; }
.rc-grand { background: #f0f7f0; color: #2e7d32; font-size: 1.2em; font-weight: 800; }
.rc-grand > span:first-child { color: inherit; }
.rc-iqd { background: #e8f4fd; color: #1565c0; font-size: 1.08em; font-weight: 700; }
.rc-iqd > span:first-child { color: inherit; }
.rc-rate { background: #fafafa; font-size: .92em; }
.rc-rate > span:last-child { color: #1565c0; }
.rc-pay { background: #f9f9f9; }

.rc-foot { margin-top: auto; padding-top: .8em; border-top: 2px solid #333; text-align: center; font-weight: 600; }
.rc-foot-text { white-space: pre-line; }
.rc-phones { display: inline-flex; align-items: center; gap: .4em; margin-top: .2em; }

/* Many invoices printed together: one page each. */
.rc-many { display: grid; gap: 24px; }

/* ── Receipts list ────────────────────────────────────────────────────── */

.rc-stats { margin-bottom: 16px; }
.stat-sub { font-size: 12.5px; color: var(--text-3); }
.stat-ico.is-gain { background: var(--success-soft); color: var(--success); }
.stat-ico.is-warn { background: var(--warning-soft); color: var(--warning); }
.stat-value.is-loss { color: var(--danger); }

.date-field { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-2); }
.date-field .input { width: auto; min-width: 150px; }

.check { width: 17px; height: 17px; margin: 0; cursor: pointer; accent-color: var(--accent); vertical-align: middle; }
.table .check-col { width: 44px; padding-inline-end: 0; }
.table tbody tr.is-picked td { background: var(--accent-soft); }
.rid { font-weight: 700; color: var(--text); white-space: nowrap; }
.rid:hover { color: var(--accent-text); }
.is-warn-text { color: var(--warning); font-weight: 600; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 13px; font-weight: 700; background: var(--surface-3); color: var(--text-2); }
.pill.is-gain { background: var(--success-soft); color: var(--success); }
.pill.is-loss { background: var(--danger-soft); color: var(--danger); }
.receipts-table td .icon-btn, .receipts-table td .inline-form { vertical-align: middle; }

.pick-bar {
    position: fixed; bottom: 20px; left: 50%; z-index: 30;
    transform: translateX(-50%);
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; padding-inline-start: 18px;
    background: var(--surface); border: 1px solid var(--border-strong); border-radius: 16px;
    box-shadow: var(--shadow-lg); white-space: nowrap;
}
.pick-bar[hidden] { display: none; }
.pick-count { font-weight: 700; }

.edit-banner { align-items: center; }
.edit-banner > span { flex: 1; }
.edit-banner .btn { color: inherit; }

/* ── Loans ────────────────────────────────────────────────────────────── */

.stat-ico.is-danger { background: var(--danger-soft); color: var(--danger); }
.btn-ghost.is-danger { color: var(--danger); }
.btn-ghost.is-danger:hover { background: var(--danger-soft); }
.is-debt { color: var(--danger); font-weight: 700; }
a.person { color: inherit; text-decoration: none; }
a.person:hover strong { color: var(--accent-text); }
.person-text small .num { font-weight: 500; }
.loans-table td .btn, .loans-table td .icon-btn { vertical-align: middle; }
.is-wa { color: #1a8f4c; }
[data-theme="dark"] .is-wa { color: #5fd08e; }
.wa-banner { align-items: center; }
.wa-banner > span { flex: 1; }

.num-input { height: 50px; font-size: 19px; font-weight: 700; }
.cur-switch { flex: none; align-self: stretch; align-items: center; }
.cur-switch span { padding: 9px 16px; }
.pay-who { display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin-bottom: 18px; background: var(--surface-2); border-radius: 13px; }
.pay-who > div { display: flex; flex-direction: column; line-height: 1.45; min-width: 0; }
.pay-who small { color: var(--text-2); }
.pay-who b { color: var(--danger); }
.pay-hint { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 6px; }
.pay-hint .hint { margin: 0; }
.hint.is-error { color: var(--danger); font-weight: 600; }

.st-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; padding: 20px 22px; margin-bottom: 14px; }
.st-person { display: flex; align-items: center; gap: 14px; min-width: 0; }
.st-person h2 { font-size: 21px; overflow-wrap: anywhere; }
.avatar-lg { width: 56px; height: 56px; font-size: 22px; }
.st-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 4px; color: var(--text-2); font-size: 14px; }
.st-meta > * { display: inline-flex; align-items: center; gap: 6px; }
.st-meta .ico { width: 15px; height: 15px; color: var(--text-3); }
.st-balance { display: flex; flex-direction: column; align-items: flex-end; padding: 12px 18px; border-radius: 14px; line-height: 1.3; }
.st-balance span { font-size: 13px; font-weight: 600; }
.st-balance strong { font-size: 28px; }
.st-balance small { font-size: 13px; opacity: .85; }
.st-balance.is-owing { background: var(--danger-soft); color: var(--danger); }
.st-balance.is-clear { background: var(--success-soft); color: var(--success); }
.st-balance.is-credit { background: var(--info-soft); color: var(--info); }
.st-actions { margin-bottom: 16px; }
.st-table .ico-xs { vertical-align: -2px; }
.st-note { color: var(--text-2); }
.st-wa { margin-top: 16px; }
.stat-value.is-gain { color: var(--success); }

.wa-list { list-style: none; margin: 0; padding: 6px 0; }
.wa-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 10px 22px; border-bottom: 1px solid var(--border); font-size: 14px; }
.wa-list li:last-child { border-bottom: 0; }
.wa-list li > div { display: flex; flex-direction: column; min-width: 0; }
.wa-error { color: var(--danger); overflow-wrap: anywhere; }

.wa-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
.wa-main, .wa-side { display: grid; gap: 16px; min-width: 0; }
.wa-counts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.wa-counts > div { display: flex; flex-direction: column; align-items: center; padding: 12px 8px; background: var(--surface-2); border-radius: 12px; text-align: center; }
.wa-counts strong { font-size: 22px; }
.wa-counts span { font-size: 12.5px; color: var(--text-2); }
.wa-send { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.wa-when { margin-top: 18px; }
.wa-preview { display: flex; padding: 14px; margin-bottom: 18px; background: #e7ded3; border-radius: 14px; }
[data-theme="dark"] .wa-preview { background: #0b141a; }
.wa-bubble {
    max-width: 90%; padding: 9px 12px; border-radius: 10px 10px 10px 2px;
    background: #dcf8c6; color: #111; font-size: 14.5px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere;
    box-shadow: 0 1px 1px rgba(0, 0, 0, .12);
}
[dir="rtl"] .wa-bubble { border-radius: 10px 10px 2px 10px; }
[data-theme="dark"] .wa-bubble { background: #005c4b; color: #e9edef; }
.wa-service-hint { margin: -4px 0 14px; }
.wa-cron p { margin-bottom: 10px; font-size: 14px; }
.wa-cron .label { margin-top: 10px; }
.input.code { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
code { font-family: ui-monospace, Consolas, monospace; font-size: .92em; padding: 1px 5px; background: var(--surface-3); border-radius: 6px; }

.print-only { display: none; }

@media (max-width: 1100px) {
    .wa-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ── Cash box ─────────────────────────────────────────────────────────── */

.ico.rot-start { transform: rotate(90deg); }
.ico.rot-end { transform: rotate(-90deg); }
[dir="rtl"] .ico.rot-start { transform: rotate(-90deg); }
[dir="rtl"] .ico.rot-end { transform: rotate(90deg); }
.day-bar { align-items: center; }
.day-bar > .input { width: auto; min-width: 170px; }
.day-bar .icon-btn { height: 46px; min-width: 46px; border: 1px solid var(--border-strong); border-radius: 12px; background: var(--surface); }
.cash-people { margin-bottom: 16px; }
.cash-people tfoot th { background: var(--surface-2); border-top: 1px solid var(--border); color: var(--text); font-size: 14px; }
.cash-reason { color: var(--text-2); font-size: 13.5px; }
.cash-kind { margin-bottom: 18px; }

/* ── Returns ──────────────────────────────────────────────────────────── */

.ret-invoice { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; padding: 14px 18px; margin-bottom: 16px; }
.ret-invoice-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.ret-invoice-main > div { display: flex; flex-direction: column; line-height: 1.5; min-width: 0; }
.ret-invoice-main small { color: var(--text-2); }
.ret-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.ret-side { position: sticky; top: calc(var(--tb-h) + 16px); }
.ret-side .segmented { margin: 14px 0 6px; }
.ret-total { padding: 12px 0; border-top: 0; }
.ret-owes { margin: 4px 0 0; }
.ret-qty { display: flex; align-items: center; gap: 10px; }
.ret-qty .stepper { width: 128px; }
.ret-table tr.is-picked td { background: var(--accent-soft); }
.ret-table tr.has-error td { background: var(--danger-soft); }
.inv-returns { max-width: 210mm; margin: 0 auto 16px; }
.inv-returns .card-head h3 { display: flex; align-items: center; gap: 8px; }

/* The return receipt: same paper, with a clear "return" title. */
.rc-doc-title {
    display: flex; align-items: center; justify-content: center; gap: .5em;
    padding: .55em 1em; margin-bottom: 1em;
    background: #fdecea; border: 2px solid #c62828; border-radius: 6px;
    color: #b71c1c; font-size: 1.25em; font-weight: 800; letter-spacing: .02em;
}
.rc-doc-title .ico { width: 1.1em; height: 1.1em; }

.ret-table td:first-child { min-width: 150px; }

@media (max-width: 1280px) {
    .ret-layout { grid-template-columns: minmax(0, 1fr); }
    .ret-side { position: static; max-width: 520px; }
}

/* ── Buying ───────────────────────────────────────────────────────────── */

.buy-links { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin: -4px 0 12px; }
.block-title { display: flex; align-items: center; gap: 8px; font-size: 15px; margin-bottom: 12px; }
.block-title .ico { width: 18px; height: 18px; color: var(--accent-text); }
.picker-item.is-new { color: var(--accent-text); }
.picker-item.is-new .ico { width: 18px; height: 18px; flex: none; }
.sup-new { padding: 12px 12px 10px; border-radius: 13px; background: var(--accent-soft); }
.sup-new .field { margin-bottom: 8px; }
.sup-new-hint { margin: 0; }
.buy-meta { display: grid; grid-template-columns: minmax(0, 1fr) 170px minmax(0, 1.4fr); gap: 12px; margin-top: 14px; }
.buy-meta .field { margin-bottom: 0; }
.buy-way {
    display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 12px; align-items: end;
    margin-top: 12px; padding: 12px; border-radius: 12px; background: var(--info-soft);
}
.buy-way .field { margin: 0; }
.buy-way .hint { margin: 0 0 12px; }
.buy-search-row { display: flex; gap: 10px; align-items: flex-start; }
.buy-search-row .picker { flex: 1; min-width: 0; }
.buy-search-row .btn-lg { height: 54px; flex: none; }
.cl-note.is-up { color: var(--danger); font-weight: 600; }
.cl-note.is-down { color: var(--success); font-weight: 600; }
.cl-name small.cl-sellmark { color: var(--accent-text); font-weight: 600; }
.info-sell { display: grid; gap: 4px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.info-sell .label { margin-bottom: 2px; }
.info-sell .affix { max-width: 170px; }
.info-sell .hint.is-gain { color: var(--success); font-weight: 600; }
.info-sell .hint.is-loss { color: var(--danger); font-weight: 600; }
.box-switch { margin-top: 14px; font-size: 14px; }
.box-switch[hidden] { display: none; }
.buy-note { margin: 14px 0 0; }
.buy-owe {
    display: flex; align-items: center; gap: 10px;
    max-width: 210mm; margin: 0 auto 14px; padding: 10px 14px;
    border-radius: 12px; background: var(--warning-soft); color: var(--warning); font-weight: 600; font-size: 14px;
}
.buy-owe .ico { width: 18px; height: 18px; flex: none; }
.buy-table td .inline-form { vertical-align: middle; }

/* The purchase paper: the same A4 page as the invoice, with its own title and room to sign. */
.receipt.is-purchase .rc-doc-title { background: #e8f0fb; border-color: #1f4e8c; color: #173d6e; }
.rc-sign { display: grid; grid-template-columns: 1fr 1fr; gap: 4em; margin: 1.6em 2em 1.2em; break-inside: avoid; }
.rc-sign div { padding-top: .4em; border-top: 1px solid #555; text-align: center; font-size: .92em; color: #444; }

@media (max-width: 900px) {
    .buy-meta { grid-template-columns: 1fr 1fr; }
    .buy-meta .field:last-child { grid-column: 1 / -1; }
    .buy-way { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
    .buy-search-row { flex-direction: column; align-items: stretch; }
    .buy-meta { grid-template-columns: minmax(0, 1fr); }
}

/* ── Low stock ────────────────────────────────────────────────────────── */

.empty-ico.is-good { background: var(--success-soft); color: var(--success); }
.is-warn-text { color: var(--warning); }
.low-table td .badge { margin-top: 4px; }
.list-more { padding: 12px 18px; margin: 0; border-top: 1px solid var(--border); }

/* ── Price history ────────────────────────────────────────────────────── */

.ph-item { padding: 18px 20px; margin-bottom: 16px; }
.ph-item-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.ph-item-head h3 { font-size: 18px; }
.ph-prices { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.ph-prices > div { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; background: var(--surface-2); border-radius: 12px; }
.ph-prices span { color: var(--text-3); font-size: 12px; font-weight: 600; }
.ph-prices strong { font-size: 17px; }
.ph-costs { margin-bottom: 16px; }
.ph-costs .card-head h3, .ph-table + * .card-head h3 { display: flex; align-items: center; gap: 8px; }
.pc { display: inline-flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.pc s { color: var(--text-3); font-size: .92em; }
.pc-arrow { color: var(--text-3); }
[dir="rtl"] .pc-arrow { transform: scaleX(-1); display: inline-block; }
.pc-pct { font-weight: 700; font-size: 11.5px; }
.pc-pct.is-up { color: var(--danger); }
.pc-pct.is-down { color: var(--success); }

/* ── Stock count ──────────────────────────────────────────────────────── */

.sc-storages { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin-bottom: 18px; }
.sc-storage {
    display: flex; flex-direction: column; gap: 3px; padding: 18px;
    color: var(--text); text-decoration: none; transition: border-color .15s, transform .1s;
}
.sc-storage:hover { border-color: var(--accent); }
.sc-storage:active { transform: scale(.98); }
.sc-storage strong { font-size: 16.5px; margin-top: 6px; }
.sc-storage small { color: var(--text-2); font-size: 13px; }
.sc-storage small.muted { color: var(--text-3); font-size: 12px; }
.sc-storage-ico { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; background: var(--accent-soft); color: var(--accent-text); }
.sc-storage-ico .ico { width: 22px; height: 22px; }
.sc-history { margin-top: 4px; }
.sc-history .card-head h3 { display: flex; align-items: center; gap: 8px; }

.sc-bar {
    position: sticky; top: var(--tb-h); z-index: 5;
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    padding: 12px 0; margin: -8px 0 12px;
    background: var(--bg);
}
.sc-back { border: 1px solid var(--border-strong); border-radius: 12px; height: 44px; min-width: 44px; background: var(--surface); }
.sc-bar-text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.35; }
.sc-bar-text strong { font-size: 18px; }
.sc-bar-text small { color: var(--text-2); font-size: 13px; }
.sc-find { flex: 0 1 320px; min-width: 200px; }
.sc-list { display: grid; gap: 8px; }
.sc-row {
    display: grid; grid-template-columns: minmax(0, 1fr) auto 120px; gap: 14px; align-items: center;
    padding: 12px 16px; border: 1px solid var(--border); transition: border-color .15s, background-color .15s;
}
.sc-row.is-dirty { border-color: var(--warning); background: var(--warning-soft); }
.sc-row.has-error { border-color: var(--danger); background: var(--danger-soft); }
.sc-name { display: flex; flex-direction: column; min-width: 0; line-height: 1.4; }
.sc-name strong { font-weight: 600; font-size: 15px; overflow-wrap: anywhere; }
.sc-name small { color: var(--text-3); font-size: 12px; }
.sc-name .sc-sys { color: var(--text-2); font-size: 12.5px; }
.sc-count { display: flex; align-items: flex-end; gap: 8px; }
.sc-part { display: flex; flex-direction: column; gap: 3px; margin: 0; }
.sc-part > span { color: var(--text-3); font-size: 11.5px; font-weight: 600; text-align: center; white-space: nowrap; }
.sc-part > .input { width: 64px; height: 42px; text-align: center; font-weight: 700; font-size: 16px; padding: 0 4px; }
.sc-units .stepper { width: 132px; }
.sc-units .stepper .input { height: 42px; font-weight: 700; font-size: 16px; }
.sc-diff { display: flex; flex-direction: column; align-items: flex-end; text-align: end; font-size: 15px; line-height: 1.3; }
.sc-diff small { font-size: 12px; font-weight: 600; }
.sc-save {
    position: sticky; bottom: 12px; z-index: 6;
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    margin-top: 14px; padding: 12px 14px;
    background: var(--surface); border: 1px solid var(--border-strong); border-radius: 16px; box-shadow: var(--shadow-lg);
}
.sc-save[hidden] { display: none; }
.sc-save-text { display: flex; flex-direction: column; flex: 1; min-width: 150px; line-height: 1.35; }
.sc-save-text strong { color: var(--warning); }
.sc-save-text small { color: var(--text-2); font-size: 13px; }
.sc-note { flex: 1 1 200px; height: 42px; }

@media (max-width: 900px) {
    .ph-prices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .sc-row { grid-template-columns: minmax(0, 1fr) auto; }
    .sc-count { grid-column: 1; }
    .sc-diff { grid-row: 1; grid-column: 2; }
}
@media (max-width: 560px) {
    .sc-find { flex: 1 1 100%; }
    .sc-row { grid-template-columns: minmax(0, 1fr); gap: 10px; }
    .sc-diff { grid-row: auto; grid-column: 1; align-items: flex-start; text-align: start; }
    .sc-count { flex-wrap: wrap; }
    .sc-save .btn { flex: 1; }
}

/* ── Employees ────────────────────────────────────────────────────────── */

.table tbody tr.is-faded td, .is-faded { opacity: .6; }
.pay-kinds { margin-bottom: 6px; }
.pay-kinds span { padding-inline: 8px; font-size: 13.5px; }
[data-kind-hint] { margin: 0 0 14px; min-height: 1.2em; }

/* ── Reports ──────────────────────────────────────────────────────────── */

.rp-period { align-items: center; }
.rp-period .seg-links { flex-wrap: wrap; }
.rp-title { font-size: 17px; margin: 4px 0 14px; }
.rp-net { border-color: var(--accent); }
.rp-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin: 16px 0; }
.rp-grid > .card { margin: 0; min-width: 0; }
.rp-pl .card-head h3, .rp-grid .card-head h3, .rp-chart-card .card-head h3 { display: flex; align-items: center; gap: 8px; }
.rp-lines { margin: 0; padding: 6px 0; }
.rp-lines > div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 22px; font-size: 14.5px; }
.rp-lines dt { color: var(--text-2); }
.rp-lines dd { margin: 0; font-weight: 700; }
.rp-lines .is-sub { padding-block: 2px 8px; font-size: 13px; }
.rp-lines .is-sub dt, .rp-lines .is-sub dd { color: var(--text-3); font-weight: 500; }
.rp-lines .is-total { border-top: 1px solid var(--border); }
.rp-lines .is-total dt { color: var(--text); font-weight: 700; }
.rp-lines .is-grand { border-top: 2px solid var(--border-strong); font-size: 17px; }
.rp-lines .is-grand dt { color: var(--text); font-weight: 800; }
.rp-note { padding: 0 22px 14px; margin: 0; }
.rp-now-head { border-top: 1px solid var(--border); }
.rp-chart-card { margin-top: 16px; }
.rp-legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--text-2); }
.rp-legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 6px; vertical-align: -1px; }
.rp-legend .is-sales::before { background: var(--accent-soft); border: 1px solid var(--accent); }
.rp-legend .is-profit::before { background: var(--success); }
.rp-chart { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 3px; align-items: end; height: 220px; padding: 16px 22px 10px; direction: ltr; }
.rp-bar { display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; min-width: 0; }
.rp-bar-track { position: relative; flex: 1; width: 100%; max-width: 34px; }
.rp-bar-track span { position: absolute; bottom: 0; left: 0; right: 0; border-radius: 4px 4px 0 0; }
.rp-bar-sales { background: var(--accent-soft); border: 1px solid var(--accent); border-bottom: 0; }
.rp-bar-profit { background: var(--success); left: 25% !important; right: 25% !important; }
.rp-bar:hover .rp-bar-sales { background: var(--accent); }
.rp-bar small { height: 1.3em; font-size: 10.5px; color: var(--text-3); white-space: nowrap; }
.rp-share { list-style: none; margin: 0; padding: 12px 22px 16px; display: grid; gap: 12px; }
.rp-share-top { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; margin-bottom: 5px; }
.rp-share-bar { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.rp-share-bar span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

/* ── Activity log ─────────────────────────────────────────────────────── */

.al-users { margin-bottom: 16px; }
.al-users .card-head h3 { display: flex; align-items: center; gap: 8px; }
.al-people-list { list-style: none; margin: 0; padding: 10px 16px 14px; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.al-people-list li { padding: 8px 10px; border-radius: 12px; background: var(--surface-2); }
.al-people-list .person { color: var(--text); text-decoration: none; }
.al-list { list-style: none; margin: 0; padding: 0 0 6px; }
.al-day { padding: 10px 22px 6px; font-size: 12.5px; font-weight: 700; color: var(--text-3); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.al-row { display: flex; align-items: center; gap: 12px; padding: 10px 22px; border-bottom: 1px solid var(--border); }
.al-row:last-child { border-bottom: 0; }
.al-ico { width: 34px; height: 34px; flex: none; display: grid; place-items: center; border-radius: 10px; background: var(--surface-3); color: var(--text-2); }
.al-ico .ico { width: 17px; height: 17px; }
.al-sales .al-ico { background: var(--accent-soft); color: var(--accent-text); }
.al-money .al-ico { background: var(--success-soft); color: var(--success); }
.al-stock .al-ico { background: var(--warning-soft); color: var(--warning); }
.al-row.al-people .al-ico { background: var(--info-soft); color: var(--info); }
.al-row.is-bad .al-ico { background: var(--danger-soft); color: var(--danger); }
.al-row.is-bad .cell-main { color: var(--danger); }
.al-text { flex: 1; min-width: 0; }
.al-text .cell-main { overflow-wrap: anywhere; }
.al-time { color: var(--text-3); font-size: 13px; white-space: nowrap; }

/* ── Backup ───────────────────────────────────────────────────────────── */

.bk-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.bk-grid > .card { margin: 0; }
.bk-grid .card-head h3 { display: flex; align-items: center; gap: 8px; }
.confirm-ico[hidden] { display: none; }

/* ── Old receipts ─────────────────────────────────────────────────────── */

.legacy-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.legacy-main > .card + .card { margin-top: 16px; }
.legacy-main > .card, .legacy-side { margin: 0; }
.legacy-side { position: sticky; top: calc(var(--tb-h) + 16px); }
.legacy-lines td { vertical-align: middle; }
.legacy-lines .lg-n { width: 36px; color: var(--text-3); text-align: center; }
.legacy-lines .lg-qty { width: 96px; }
.legacy-lines .lg-price { width: 150px; }
.legacy-lines td:nth-child(2) { min-width: 180px; }
.legacy-lines td .input { width: 100%; }
.lg-add-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding-top: 12px; padding-bottom: 14px; }
.lg-add-row .hint { margin: 0; }
.lg-totals { margin: 6px 0 16px; padding: 12px 14px; border-radius: 13px; background: var(--surface-2); }
.lg-totals div { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; font-size: 14px; color: var(--text-2); }
.lg-totals dd { margin: 0; }
.lg-totals .is-total { padding-top: 8px; margin-top: 4px; border-top: 1px solid var(--border); font-size: 18px; font-weight: 800; color: var(--text); }
.lg-totals .is-left { color: var(--danger); font-weight: 700; }
.lg-totals div[hidden] { display: none; }
.lg-save { width: 100%; }
.legacy-names { max-width: 280px; }
.legacy-names .cell-sub { display: block; margin-top: 3px; overflow-wrap: anywhere; }
.legacy-meta { max-width: 210mm; margin: 10px auto 0; font-size: 13px; text-align: center; }
/* The old receipt paper: the same A4 page, with its own title. */
.receipt.is-legacy .rc-doc-title { background: #f1ecf8; border-color: #5b3a8c; color: #4a2c78; }

@media (max-width: 1100px) {
    .legacy-layout { grid-template-columns: minmax(0, 1fr); }
    .legacy-side { position: static; }
}
@media (max-width: 640px) {
    /* Each item row: the name on top, then quantity · price · amount · remove. */
    .legacy-lines thead { display: none; }
    .legacy-lines, .legacy-lines tbody { display: block; }
    .legacy-lines tr { display: grid; grid-template-columns: 22px 76px minmax(0, 1fr) auto auto; gap: 8px; align-items: center;
                       padding: 10px 12px; border-bottom: 1px solid var(--border); }
    .legacy-lines td { display: block; padding: 0; border: 0; }
    .legacy-lines td.lg-n { grid-row: 1 / 3; width: auto; }
    .legacy-lines td:nth-child(2) { grid-column: 2 / -1; min-width: 0; }
    .table.legacy-lines tbody tr:hover td { background: none; }
}

/* ── User permissions ─────────────────────────────────────────────────── */

.perm-who h2 { font-size: 20px; margin: 0; }
.perm-who small { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; }
.perm-presets { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 12px 16px; margin: 0 0 6px; }
.perm-presets-label { font-weight: 600; color: var(--text-2); }
.perm-group { margin: 22px 2px 10px; font-size: 13px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; color: var(--text-3); }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; align-items: start; }
.perm-grid > .card { margin: 0; overflow: hidden; }
.perm-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; cursor: pointer; }
.perm-ico {
    display: grid; place-items: center; flex: none; width: 38px; height: 38px; border-radius: 11px;
    background: var(--accent-soft); color: var(--accent-text);
}
.perm-name { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.perm-name small { color: var(--text-3); font-size: 12.5px; }
.perm-head .switch { flex: none; }
.perm-list { display: flex; flex-direction: column; padding: 4px 8px 10px; border-top: 1px solid var(--border); }
.perm-item { display: flex; align-items: flex-start; gap: 10px; padding: 8px; border-radius: 10px; cursor: pointer; font-size: 14px; line-height: 1.4; }
.perm-item:hover { background: var(--surface-2); }
.perm-item .check { margin-top: 1px; flex: none; }
.perm-card.is-off .perm-ico { background: var(--surface-3); color: var(--text-3); }
.perm-card.is-off .perm-name strong { color: var(--text-2); }
.perm-card.is-off .perm-item { opacity: .45; cursor: default; }
.perm-card.is-off .perm-item:hover { background: none; }
.perm-save {
    position: sticky; bottom: 12px; z-index: 5;
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
    margin-top: 20px; padding: 10px 12px; padding-inline-start: 18px;
    background: var(--surface); border: 1px solid var(--border-strong); border-radius: 16px; box-shadow: var(--shadow-lg);
}
.perm-save-count { font-weight: 700; }
@media (max-width: 640px) {
    .perm-save { padding: 8px 10px; gap: 6px; bottom: 8px; }
    .perm-save-count { font-size: 13.5px; padding-inline: 4px; }
    .perm-save .btn-row { width: 100%; flex-wrap: nowrap; gap: 8px; }
    .perm-save .btn-row .btn { flex: 1; padding-inline: 10px; }
}

@media (max-width: 1000px) {
    .rp-grid, .bk-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
    .rp-chart { height: 170px; padding-inline: 12px; gap: 2px; }
    .rp-lines > div, .al-row { padding-inline: 16px; }
    .al-time { font-size: 12px; }
}

/* ── Receipt settings ─────────────────────────────────────────────────── */

.rs-layout { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 20px; align-items: start; }
.rs-form { display: grid; gap: 16px; min-width: 0; }
.rs-side { position: sticky; top: calc(var(--tb-h) + 16px); min-width: 0; }
.rs-paper { padding: 16px; background: var(--surface-3); border-radius: 0 0 16px 16px; }
.receipt.is-mini { width: 100%; min-height: auto; aspect-ratio: 210 / 297; font-size: 7.6px; padding: 1.8em 2em; box-shadow: 0 2px 10px rgba(0, 0, 0, .1); }
.rs-logo {
    display: grid; place-items: center; padding: 14px; margin-bottom: 14px;
    background: #fff; border: 1px solid var(--border); border-radius: 14px;
}
.rs-logo img { max-width: 100%; max-height: 110px; object-fit: contain; }
.rs-logo.is-removed { opacity: .35; }
.rs-remove { margin-top: 14px; }
.rs-switches { display: grid; gap: 14px; }
.rs-switch-text { display: inline-flex; align-items: center; gap: 8px; }
.rs-switch-text .ico { width: 18px; height: 18px; color: var(--text-3); }

@media (max-width: 1100px) {
    .rs-layout { grid-template-columns: minmax(0, 1fr); }
    .rs-side { position: static; max-width: 460px; }
}

@media (max-width: 640px) {
    .receipt:not(.is-mini) { font-size: 11px; padding: 1.4em 1.2em; min-height: 0; }
    .rc-totals { min-width: 0; width: 100%; }
}

@media print {
    @page { margin: 12mm; }
    body { background: #fff !important; }
    .sidebar, .sb-overlay, .topbar, .no-print, .invoice-actions, .alert { display: none !important; }
    .main { margin: 0 !important; }
    .content { padding: 0 !important; max-width: none; }
    .print-only { display: block !important; }
    .print-head { display: flex !important; justify-content: space-between; padding-bottom: 10px; margin-bottom: 14px; border-bottom: 2px solid #333; }
    .card { box-shadow: none !important; }
    .st-head, .st-balance { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .table-wrap { overflow: visible !important; }
    .rc-stage { overflow: visible; padding: 0; }
    .rc-many { display: block; }
    .rc-many .receipt { break-after: page; }
    .rc-many .receipt:last-child { break-after: auto; }
    .receipt { width: auto; max-width: none; min-height: 296mm; margin: 0; border: 0; box-shadow: none; padding: 7mm 9mm; font-size: 11.5px; line-height: 1.4; }
    .rc-logo { max-height: 7.5em; }
    .rc-head { padding-bottom: 1em; margin-bottom: 1em; }
    .rc-cust th, .rc-cust td { padding: .35em .8em; }
    .rc-items td { padding: .5em .9em; }
    .rc-empty td { height: 2.1em; }
    .rc-row { padding: .45em 1.2em; }
}

/* ── Confirm dialog ───────────────────────────────────────────────────── */

.modal-sm { width: min(420px, calc(100vw - 24px)); }
.confirm-body { display: flex; gap: 14px; align-items: flex-start; }
.confirm-body h3 { font-size: 17px; margin-bottom: 4px; }
.confirm-body p { color: var(--text-2); overflow-wrap: anywhere; }
.confirm-ico {
    width: 44px; height: 44px; flex: none;
    display: grid; place-items: center;
    border-radius: 50%;
    background: var(--danger-soft); color: var(--danger);
}

/* ── Modal dialog ─────────────────────────────────────────────────────── */

.modal {
    width: min(540px, calc(100vw - 24px));
    max-height: calc(100vh - 24px);
    padding: 0; border: 0;
    border-radius: 20px;
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-lg);
}
.modal::backdrop { background: rgba(20, 13, 6, .5); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.modal[open] { animation: modal-in .18s ease; }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-form { display: flex; flex-direction: column; max-height: calc(100vh - 24px); }
.modal-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding-block: 16px; padding-inline: 22px 14px;
    border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 17px; }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-foot {
    display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px;   /* many buttons on a narrow screen go onto a second line */
    padding: 14px 22px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    border-radius: 0 0 20px 20px;
}

/* ── Dashboard ────────────────────────────────────────────────────────── */

.hero {
    position: relative; overflow: hidden;
    display: flex; align-items: center; justify-content: space-between; gap: 28px; flex-wrap: wrap;
    padding: 28px 30px; margin-bottom: 20px;
    border-radius: 20px;
    background: var(--sb-bg); color: var(--sb-ink);
    transition: background-color .25s ease, color .25s ease;
}
.hero::after {
    content: ""; position: absolute; inset-inline-end: -60px; top: -80px;
    width: 260px; height: 260px; border-radius: 50%;
    background: var(--sb-hover); pointer-events: none;
}
.hero-text { position: relative; z-index: 1; max-width: 560px; }
.hero-date { font-size: 13px; font-weight: 600; color: var(--sb-ink-2); }
.hero h2 { font-size: 26px; margin: 4px 0 8px; }
.hero p { color: var(--sb-ink-2); }
.hero p b { color: var(--sb-ink); }
.dash-actions { position: relative; z-index: 1; display: flex; flex-wrap: wrap; gap: 10px; max-width: 560px; }
/* On the colored header the buttons take the sidebar's own colors, so they stand out with every system color. */
.dash-actions .btn-secondary { background: var(--sb-hover); color: var(--sb-ink); border-color: transparent; box-shadow: none; }
.dash-actions .btn-secondary:hover { background: var(--sb-active); color: var(--sb-active-ink); }
.dash-actions .btn-primary { background: var(--sb-ink); color: var(--sb-bg); border-color: transparent; }
.dash-actions .btn-primary:hover { filter: brightness(.95); }
.dash-title { margin: 4px 2px 12px; font-size: 15px; color: var(--text-2); }
.dash-stats { margin-bottom: 16px; }
.dash-stats .stat-value a { color: inherit; }
.dash-trend { display: inline-flex; align-items: center; gap: 3px; margin-inline-start: 6px; padding: 1px 7px; border-radius: 99px; font-weight: 700; font-size: 12px; }
.dash-trend.is-up { background: var(--success-soft); color: var(--success); }
.dash-trend.is-down { background: var(--danger-soft); color: var(--danger); }
.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; align-items: start; }
.dash-grid > .card { margin: 0; }
.dash-grid .card-head h3, .dash-recent .card-head h3 { display: flex; align-items: center; gap: 8px; }
.dash-periods th[scope="row"] { font-weight: 700; white-space: nowrap; }
.dash-now { list-style: none; margin: 0; padding: 6px 12px 10px; }
.dash-now li { display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-bottom: 1px solid var(--border); }
.dash-now li:last-child { border-bottom: 0; }
.dash-now li > div { flex: 1; min-width: 0; display: flex; flex-direction: column; font-weight: 600; }
.dash-now li > div a { color: inherit; }
.dash-now li > div a:hover { color: var(--accent-text); }
.dash-now small { font-weight: 400; font-size: 12.5px; color: var(--text-3); }
.dash-now b { font-size: 16px; white-space: nowrap; }
.dash-now-ico { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-text); }
.dash-now-ico .ico { width: 18px; height: 18px; }
.dash-now-ico.is-danger { background: var(--danger-soft); color: var(--danger); }
.dash-now-ico.is-warn { background: var(--warning-soft); color: var(--warning); }
.rp-bar.is-today .rp-bar-sales { background: var(--accent); }
.rp-bar.is-today small { color: var(--text); font-weight: 700; }
.dash-top { list-style: none; margin: 0; padding: 6px 12px 10px; }
.dash-top li { display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-bottom: 1px solid var(--border); }
.dash-top li:last-child { border-bottom: 0; }
.dash-rank { display: grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: 50%; font-weight: 800; font-size: 13px;
             background: var(--surface-3); color: var(--text-2); }
.dash-rank.is-1 { background: #f6d365; color: #5a4300; }
.dash-rank.is-2 { background: #d9dde3; color: #3b4450; }
.dash-rank.is-3 { background: #e7b58a; color: #5a3212; }
.dash-top-name { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.dash-top-name strong { overflow-wrap: anywhere; }
.dash-top-name small, .dash-top-money small { font-size: 12.5px; color: var(--text-3); }
.dash-top-money { display: flex; flex-direction: column; align-items: flex-end; }
.dash-top-money small.is-gain { color: var(--success); }
.dash-recent { margin-bottom: 16px; }
.dash-attention { align-items: center; margin-bottom: 16px; font-weight: 600; text-decoration: none; }
.dash-attention:hover { text-decoration: none; filter: brightness(.97); }
.dash-attention span { flex: 1; }
.dash-attention b { white-space: nowrap; }

/* ── Dollar rate ──────────────────────────────────────────────────────── */

.rate-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; margin-bottom: 16px; }
.rate-grid > .card { margin: 0; }
.rate-grid .card-head h3, .rate-auto .card-head h3 { display: flex; align-items: center; gap: 8px; }
.rate-now .card-body { display: flex; flex-direction: column; gap: 4px; }
.rate-label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.rate-big { font-size: 30px; font-weight: 800; line-height: 1.25; }
.rate-when { font-size: 13px; color: var(--text-3); }
.rate-manual { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.rate-manual .input-row { flex-wrap: wrap; }
.rate-manual .affix { flex: 1 1 200px; min-width: 0; }   /* on a phone the button drops below instead of squeezing the box */
.rate-source { margin: 0 0 12px; }
.rate-source a .ico { width: 14px; height: 14px; vertical-align: -2px; }
.rate-result { margin-bottom: 14px; padding: 12px 14px; border-radius: 13px; background: var(--surface-2); }
.rate-result .rp-lines { margin: 0 0 8px; padding: 0; }
.rate-result-text { margin: 0 0 10px; font-weight: 600; }
.rate-result.is-error .rate-result-text, .rate-result.is-stale .rate-result-text { color: var(--danger); }
.rate-result.is-needs_review .rate-result-text { color: var(--warning); }
.rate-auto { margin: 0 0 16px; }
.rate-auto-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 18px; margin: 16px 0 6px; }
.rate-last { display: flex; align-items: flex-start; gap: 8px; margin: 4px 0 14px; padding: 10px 12px; border-radius: 12px;
             background: var(--info-soft); color: var(--info); font-size: 14px; }
.rate-last .ico { width: 17px; height: 17px; flex: none; margin-top: 2px; }
.rate-last.is-applied, .rate-last.is-unchanged { background: var(--success-soft); color: var(--success); }
.rate-last.is-error, .rate-last.is-stale, .rate-last.is-needs_review { background: var(--warning-soft); color: var(--warning); }

@media (max-width: 900px) {
    .rate-grid, .rate-auto-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ── Nightly WhatsApp report ──────────────────────────────────────────── */
.nr-preview { margin: 16px 0 12px; }
.nr-preview .wa-bubble { max-width: 100%; }
.nr-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.nr-hint { margin: 12px 0 0; }
.nr-first { margin-top: 16px; }
.nr-phones { min-height: 64px; font-family: inherit; }
.nr-hour-hint { margin: -4px 0 14px; }
.nr-parts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 6px; margin: 4px -8px 12px; }
.nr-parts .perm-item:has(input:disabled) { cursor: default; opacity: .7; }
.nr-skip { margin-bottom: 18px; }

/* ── Move stock between storages ──────────────────────────────────────── */

.tf-card { margin: 0 0 16px; }
.tf-card .card-head h3, .tf-slip .card-head h3 { display: flex; align-items: center; gap: 8px; }
.tf-pick { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 12px; align-items: end; padding: 16px 22px 4px; }
.tf-pick .field { margin: 0; }
.tf-swap { margin-bottom: 4px; }
.tf-hint { margin: 10px 22px 18px; }
.tf-search { padding: 12px 22px; }
.tf-search .input-wrap { max-width: 360px; }
.tf-table td { vertical-align: middle; }
.tf-table tr.is-picked td { background: var(--accent-soft); }
.tf-qty-col { width: 190px; }
.tf-qty { display: flex; align-items: center; gap: 6px; }
.tf-qty .input { width: 100px; }
.input.is-invalid { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.tf-no-match { margin: 12px 22px; }
.tf-foot { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; padding: 16px 22px 20px; border-top: 1px solid var(--border); }
.tf-foot .field { flex: 1 1 240px; margin: 0; }
.tf-count { font-weight: 700; color: var(--accent-text); }
.tf-arrow .ico { width: 14px; height: 14px; vertical-align: -2px; color: var(--text-3); }
/* The slip */
.tf-slip { margin: 0 0 16px; }
.tf-route { display: flex; align-items: center; gap: 16px; padding: 20px 22px 8px; }
.tf-route > div { display: flex; flex-direction: column; flex: 1; min-width: 0; padding: 12px 14px; border-radius: 13px; background: var(--surface-2); }
.tf-route small { color: var(--text-3); font-size: 12.5px; }
.tf-route strong { font-size: 18px; overflow-wrap: anywhere; }
.tf-route-arrow .ico { width: 22px; height: 22px; color: var(--accent-text); }
.tf-facts { display: flex; flex-wrap: wrap; gap: 10px 28px; margin: 0; padding: 10px 22px 16px; }
.tf-facts div { display: flex; flex-direction: column; }
.tf-facts dt { font-size: 12.5px; color: var(--text-3); }
.tf-facts dd { margin: 0; font-weight: 600; }
.tf-sign { margin-top: 2.2em; }

@media (max-width: 640px) {
    .tf-pick { grid-template-columns: minmax(0, 1fr); padding: 14px 16px 4px; }
    .tf-swap { justify-self: center; transform: rotate(90deg); }
    .tf-search, .tf-foot { padding-inline: 16px; }
    .tf-foot .btn { width: 100%; }
    .tf-route { flex-direction: column; align-items: stretch; gap: 8px; }
    .tf-route-arrow { align-self: center; }
    .tf-route .tf-route-arrow .ico.rot-end { transform: none; }   /* the chevron's own direction: down, from → to */
}
@media print {
    .tf-slip { box-shadow: none; border: 0; }
}

/* ── Invoice on WhatsApp ──────────────────────────────────────────────── */

.inv-wa-last { display: flex; align-items: center; gap: 8px; max-width: 210mm; margin: 0 auto 12px; font-size: 13.5px; color: var(--text-2); }
.inv-wa-last .ico { width: 16px; height: 16px; color: #1a8f4c; }
.wa-text { min-height: 190px; line-height: 1.6; font-size: 14px; }
/* The customer's page (i.php): just the paper, with a small bar to pick the language and print. */
.pi-body { padding: 16px; }
.pi-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 14px; max-width: 210mm; margin: 0 auto 14px; }
.pi-bar strong { font-size: 17px; }
.pi-stage { max-width: 210mm; margin: 0 auto; }
.pi-missing { max-width: 460px; margin: 12vh auto 0; }
@media (max-width: 640px) {
    .pi-body { padding: 10px; }
    .pi-bar .btn { width: 100%; justify-content: center; }
}

/* ── Profile ──────────────────────────────────────────────────────────── */

.pf-facts { display: flex; flex-wrap: wrap; gap: 10px 28px; margin: 0; }
.pf-facts div { display: flex; flex-direction: column; }
.pf-facts dt { font-size: 12.5px; color: var(--text-3); }
.pf-facts dd { margin: 0; font-weight: 700; }
.pf-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; margin-bottom: 16px; }
.pf-grid > .card { margin: 0; }
.pf-grid .card-head h3, .pf-look .card-head h3 { display: flex; align-items: center; gap: 8px; }
.pf-look { margin: 0 0 16px; }
.pf-look-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin-bottom: 16px; }
.pf-look-row > .label { min-width: 120px; margin: 0; }
.pf-look-row.is-colors { align-items: flex-start; }
.pf-opt {
    display: inline-flex; align-items: center; gap: 7px; padding: 7px 18px; border: 0; border-radius: 9px;
    background: none; color: var(--text-2); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
    transition: background-color .15s, color .15s, box-shadow .15s;
}
.pf-opt .ico { width: 16px; height: 16px; }
.pf-opt[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.pf-opt:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.pf-swatches { flex: 1 1 260px; min-width: 0; width: auto; max-width: 560px; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); padding: 0;
               max-height: none; overflow: visible; }
.pf-look-hint { margin: 0; }
.pf-all { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-weight: 700; color: var(--success); }
.pf-perm-group { margin-bottom: 12px; }
.pf-perm-label { display: block; margin-bottom: 6px; font-size: 12.5px; font-weight: 700; color: var(--text-3); }
.pf-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pf-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; background: var(--accent-soft); color: var(--accent-text); font-size: 13px; font-weight: 600; }
.pf-chip .ico { width: 14px; height: 14px; }
.pf-activity { list-style: none; margin: 0; padding: 4px 0 8px; }
.pf-activity li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 20px; border-top: 1px solid var(--border); font-size: 14px; }
.pf-activity li span { min-width: 0; overflow-wrap: anywhere; }
.pf-activity small { flex: none; color: var(--text-3); }

@media (max-width: 1000px) {
    .pf-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ── Daily sales ──────────────────────────────────────────────────────── */

.daily-close { margin: 0 0 16px; border-inline-start: 4px solid var(--warning); }
.daily-close.is-closed { border-inline-start-color: var(--success); }
.daily-close .card-head h3 { display: flex; align-items: center; gap: 8px; }
.daily-close .rp-lines { max-width: 460px; margin: 0; padding: 0; }
.daily-closed-at { margin: 0 0 10px; font-weight: 600; color: var(--success); }
.daily-close-text { margin: 0 0 14px; font-weight: 600; }
.daily-close-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 12px; align-items: end; max-width: 820px; }
.daily-close-form .field { margin: 0; }
.daily-reopen { margin-top: 12px; }
.daily-close .alert { margin-top: 12px; max-width: 460px; }
.daily-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.daily-grid > .card { margin: 0; }
.daily-grid .card-head h3 { display: flex; align-items: center; gap: 8px; }

@media (max-width: 1100px) {
    .daily-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 700px) {
    .daily-close-form { grid-template-columns: minmax(0, 1fr); }
}
@media print {
    .daily-grid { grid-template-columns: minmax(0, 1fr); }
    .daily-close, .daily-grid > .card { break-inside: avoid; }
}

/* ── Notifications ────────────────────────────────────────────────────── */

.nt-group { margin: 0 0 16px; border-inline-start: 4px solid var(--info); }
.nt-group.is-danger { border-inline-start-color: var(--danger); }
.nt-group.is-warning { border-inline-start-color: var(--warning); }
.nt-group .card-head h3 { display: flex; align-items: center; gap: 10px; }
.nt-ico { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--info-soft); color: var(--info); }
.nt-ico .ico { width: 18px; height: 18px; }
.nt-group.is-danger .nt-ico { background: var(--danger-soft); color: var(--danger); }
.nt-group.is-warning .nt-ico { background: var(--warning-soft); color: var(--warning); }
.nt-count { font-size: 12.5px; }
.nt-list { list-style: none; margin: 0; padding: 0 0 6px; }
.nt-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 11px 20px; border-top: 1px solid var(--border); }
.nt-main { flex: 1 1 220px; min-width: 0; display: flex; flex-direction: column; }
.nt-main strong { overflow-wrap: anywhere; }
.nt-main strong a { color: inherit; }
.nt-main strong a:hover { color: var(--accent-text); }
.nt-main small { font-size: 12.5px; color: var(--text-3); }
.nt-amount { white-space: nowrap; font-size: 15px; }
.nt-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.nt-more { margin: 0; padding: 10px 20px 14px; border-top: 1px solid var(--border); font-size: 13.5px; }

@media (max-width: 640px) {
    .nt-list li { padding: 11px 14px; }
    .nt-actions { width: 100%; }
}

@media (max-width: 1000px) {
    .dash-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
    .dash-actions .btn { flex: 1 1 calc(50% - 5px); justify-content: center; }
    .dash-actions .btn-primary { flex-basis: 100%; }
}

/* ── Login / setup pages ──────────────────────────────────────────────── */

.auth { min-height: 100vh; display: flex; flex-direction: column; padding: 16px 20px 40px; }
.auth-tools { display: flex; justify-content: flex-end; gap: 4px; }
.auth-card {
    width: 100%; max-width: 420px; margin: auto;
    padding: 36px 34px 34px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: var(--shadow);
}
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; font-size: 15px; }
.auth-logo {
    width: 40px; height: 40px; flex: none;
    display: grid; place-items: center;
    border-radius: 12px;
    background: var(--accent); color: var(--accent-ink);
}
.auth-logo .ico { width: 21px; height: 21px; }
.auth-card h1 { font-size: 26px; margin-bottom: 6px; }
.auth-card .sub { color: var(--text-2); margin-bottom: 26px; }

/* ── Responsive ───────────────────────────────────────────────────────── */

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(calc(-100% * var(--dir)));
        transition: transform .25s ease, background-color .25s ease;
        box-shadow: none;
    }
    body.sb-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
    .sb-overlay {
        display: block; position: fixed; inset: 0; z-index: 35;
        background: rgba(20, 13, 6, .45);
        opacity: 0; visibility: hidden;
        transition: opacity .25s ease, visibility 0s linear .25s;
    }
    body.sb-open .sb-overlay { opacity: 1; visibility: visible; transition: opacity .25s ease; }
    body.sb-open { overflow: hidden; }
    .sidebar .sb-close { display: inline-flex; }
    .main { margin-inline-start: 0; }
    .topbar .tb-menu { display: inline-flex; margin-inline-start: -6px; }
}

@media (max-width: 640px) {
    .topbar { padding: 0 12px; gap: 6px; }
    .tb-title { font-size: 17px; }
    .tb-sep, .user-meta, .user-chev, .lang-lbl { display: none; }
    .user-btn { padding: 0 4px; }
    .content { padding: 16px; }
    .card-body { padding: 16px; }
    .card-head { padding: 14px 16px; }
    .hero { padding: 22px 20px; }
    .hero h2 { font-size: 22px; }
    .dd-menu { position: fixed; top: calc(var(--tb-h) - 4px); inset-inline: 12px; min-width: 0; }
    .swatches { width: auto; }
    .modal-body { padding: 18px; }
    .modal-foot { padding: 12px 18px; }
    .modal-foot .btn { flex: 1; }
    .modal .input-row { flex-direction: column; align-items: stretch; }
    .form-grid-2, .form-grid-3 { grid-template-columns: minmax(0, 1fr); }
    .span-2 { grid-column: auto; }
    .affix-narrow { max-width: none; }
    .toolbar .input-wrap, .toolbar .toolbar-search { min-width: 0; flex: 1 1 100%; }
    .toolbar .date-field { flex: 1 1 100%; }
    .toolbar .date-field .input { flex: 1; min-width: 0; }
    .pick-bar { left: 12px; right: 12px; transform: none; justify-content: space-between; }
    .rc-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .rc-stats .stat { padding: 12px; gap: 10px; align-items: flex-start; }
    .rc-stats .stat-ico { width: 34px; height: 34px; border-radius: 10px; }
    .rc-stats .stat-ico .ico { width: 18px; height: 18px; }
    .rc-stats .stat-value { font-size: 17px; }
    .page-head form, .page-head form .btn { width: 100%; }
    .toolbar .chip-toggle { flex: 1; }
    .toolbar .chip-toggle span { justify-content: center; }
    .page-head .btn { width: 100%; }
    .tile-actions { opacity: 1; }
    .auth { padding: 12px 16px 24px; }
    .auth-card { padding: 28px 22px 24px; border-radius: 18px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; }
}
