/* =====================================================================
   Retail Management — Core UI
   White-label themeable, mobile-first, light/dark.
   ===================================================================== */

*, *::before, *::after { box-sizing: border-box; }

:root {
    --primary: #4f46e5;
    --secondary: #0ea5e9;
    --accent: #f59e0b;
    --sidebar-bg: #0f172a;
    --radius: 14px;
    --topbar-h: 64px;
    --control-h: 42px;
    --font: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;

    --radius-sm: calc(var(--radius) * 0.55);
    --radius-lg: calc(var(--radius) * 1.4);
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .08);
    --shadow: 0 4px 6px -1px rgba(15, 23, 42, .08), 0 2px 4px -2px rgba(15, 23, 42, .06);
    --shadow-lg: 0 20px 25px -5px rgba(15, 23, 42, .12), 0 8px 10px -6px rgba(15, 23, 42, .08);
}

/* ---- Colour modes ---- */
[data-theme="light"] {
    color-scheme: light;
    --bg: #f1f5f9;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --border: #e2e8f0;
    --text: #0f172a;
    --text-muted: #64748b;
    --text-soft: #94a3b8;
}
[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0b1120;
    --surface: #131c31;
    --surface-2: #0f172a;
    --border: #243049;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --text-soft: #64748b;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
    --shadow: 0 4px 6px -1px rgba(0,0,0,.5);
    --shadow-lg: 0 20px 25px -5px rgba(0,0,0,.55);
}

html, body { height: 100%; }
[hidden] { display: none !important; }
body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
/* Buttons inherit text colour so themed (dark) text never falls back to UA black. */
button { color: inherit; }
h1, h2, h3, h4 { margin: 0 0 .5rem; font-weight: 700; line-height: 1.25; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
small { color: var(--text-muted); }

/* ---- Utility ---- */
.muted { color: var(--text-muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-success { color: #16a34a; }
.text-danger { color: #dc2626; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; }
.w-100 { width: 100%; }
.hidden { display: none !important; }
.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-1 { gap: .5rem; } .gap-2 { gap: 1rem; }
.flex-wrap { flex-wrap: wrap; }

/* =====================================================================
   App shell
   ===================================================================== */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 60;
    transition: transform .25s ease, width .25s ease, box-shadow .25s ease;
}
.sidebar__brand {
    display: flex; align-items: center; gap: .65rem; flex: none;
    height: var(--topbar-h); padding: 0 1.25rem;
    color: #fff; font-weight: 700; font-size: 1.05rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar__brand img { width: 34px; height: 34px; border-radius: 9px; object-fit: cover; background: #fff; }
.sidebar__brand .logo-fallback {
    width: 34px; height: 34px; border-radius: 9px; flex: none;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: grid; place-items: center; color: #fff; font-weight: 800; font-size: .85rem;
}
.sidebar__name { flex: 1; min-width: 0; max-width: 170px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 1; transition: max-width .25s ease, opacity .2s ease; }
.sidebar__collapse { flex: none; display: grid; place-items: center; width: 30px; height: 30px; border: none; border-radius: 8px; background: rgba(255,255,255,.06); color: #cbd5e1; cursor: pointer; transition: background .15s, color .15s, transform .25s ease; }
.sidebar__collapse:hover { background: rgba(255,255,255,.16); color: #fff; }
.sidebar__collapse svg { width: 18px; height: 18px; }
.sidebar__nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: .75rem; }
.sidebar__tools { display: none; }
.nav-text { max-width: 170px; overflow: hidden; white-space: nowrap; opacity: 1; transition: max-width .25s ease, opacity .2s ease; }
.nav-section { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: #64748b; padding: 1rem .75rem .4rem; }
.nav-link {
    display: flex; align-items: center; gap: .75rem;
    padding: .62rem .75rem; margin-bottom: 2px; position: relative;
    border-radius: 10px; color: #cbd5e1; font-weight: 500; white-space: nowrap;
    transition: background .15s, color .15s, padding .25s ease;
}
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav-link.active { background: linear-gradient(135deg, var(--primary), var(--secondary)); color: #fff; box-shadow: var(--shadow); }
.nav-link.nav-dragging { opacity: .45; background: rgba(255,255,255,.08); }
.sidebar__nav.nav-drop-hint .nav-link { cursor: grab; }
.nav-link svg { width: 19px; height: 19px; flex-shrink: 0; }
.nav-badge { margin-left: auto; background: var(--accent); color: #1f2937; font-size: .7rem; font-weight: 700; padding: .05rem .4rem; border-radius: 999px; }
.nav-badge--warn { background: #f59e0b; color: #1f2937; }
.nav-ext { margin-left: auto; flex: none; display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 6px; color: inherit; opacity: .5; transition: opacity .15s, background .15s, color .15s; cursor: pointer; }
.nav-ext svg { width: 14px; height: 14px; }
.nav-link:hover .nav-ext { opacity: .85; }
.nav-ext:hover { opacity: 1; background: rgba(255,255,255,.14); color: #fff; }

.main { flex: 1; margin-left: 260px; display: flex; flex-direction: column; min-width: 0; transition: margin-left .25s ease; }

.topbar {
    position: sticky; top: 0; z-index: 40;
    display: flex; align-items: center; gap: 1rem;
    height: var(--topbar-h); padding: 0 1.25rem;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}
.topbar__title { font-weight: 700; font-size: 1.05rem; }
.topbar__spacer { flex: 1; }
.hamburger { display: none; background: none; border: none; color: var(--text); cursor: pointer; padding: .35rem; }
.hamburger svg { width: 24px; height: 24px; }
.nav-collapse-btn { display: inline-flex; align-items: center; justify-content: center; background: none; border: none; color: var(--text-muted); cursor: pointer; padding: .35rem; border-radius: 8px; transition: background .15s, color .15s; }
.nav-collapse-btn:hover { background: var(--surface-2); color: var(--text); }
.nav-collapse-btn svg { width: 22px; height: 22px; }

.store-switch select {
    background-color: var(--surface-2); border: 1px solid var(--border); color: var(--text);
    border-radius: 10px; padding: .45rem 2.2rem .45rem .7rem; font-weight: 600; font-size: .85rem; cursor: pointer;
}
.store-switch--single { background-color: var(--surface-2); border: 1px solid var(--border); color: var(--text); border-radius: 10px; padding: .45rem .7rem; font-weight: 600; font-size: .85rem; }

/* Multi-branch selector */
.store-multi { position: relative; }
.store-scope { margin: 0; }
.store-multi__summary { list-style: none; display: inline-flex; align-items: center; gap: .45rem; background-color: var(--surface-2); border: 1px solid var(--border); color: var(--text); border-radius: 10px; padding: .45rem .7rem; font-weight: 600; font-size: .85rem; cursor: pointer; white-space: nowrap; }
.store-multi__summary::-webkit-details-marker { display: none; }
.store-multi__summary:hover { border-color: var(--primary); }
.store-multi__chev { transition: transform .18s; color: var(--text-muted); }
.store-multi[open] .store-multi__chev { transform: rotate(180deg); }
.store-multi__panel { position: absolute; right: 0; top: calc(100% + .4rem); z-index: 60; min-width: 230px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg, 0 12px 32px rgba(15,23,42,.18)); padding: .5rem; }
.store-multi__all { display: flex; align-items: center; gap: .55rem; padding: .5rem .6rem; border-radius: 9px; cursor: pointer; font-weight: 700; }
.store-multi__all:hover { background: var(--surface-2); }
.store-multi__list { max-height: 240px; overflow-y: auto; margin: .25rem 0 .5rem; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: .35rem 0; }
.store-multi__opt { display: flex; align-items: center; gap: .55rem; padding: .45rem .6rem; border-radius: 9px; cursor: pointer; font-size: .88rem; }
.store-multi__opt:hover { background: var(--surface-2); }
.store-multi__opt input, .store-multi__all input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }

.avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .8rem;
    overflow: hidden; flex: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.avatar-xl { width: 72px; height: 72px; font-size: 1.5rem; }
.avatar-sm { width: 30px; height: 30px; font-size: .72rem; }

.content { padding: 1.5rem; max-width: 1320px; width: 100%; margin: 0 auto; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--text-muted); font-size: .9rem; }

/* =====================================================================
   Cards & panels
   ===================================================================== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card__head { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.card__head h2, .card__head h3 { margin: 0; font-size: 1rem; }
.card__body { padding: 1.25rem; }
.card__body.tight { padding: .5rem; }

.kv { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .4rem 0; border-bottom: 1px dashed var(--border); }
.kv:last-child { border-bottom: none; }
.kv span { color: var(--text-muted); }
.kv-total { font-size: 1.15rem; border-bottom: none; border-top: 2px solid var(--border); margin-top: .35rem; padding-top: .65rem; }
.kv-total strong { color: var(--primary); }

.grid { display: grid; gap: 1.25rem; }
.grid-2, .grid-3, .grid-4, .grid-auto { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }

/* Stat cards */
.stat {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.15rem 1.25rem;
    box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.stat__icon {
    width: 44px; height: 44px; border-radius: 12px;
    display: grid; place-items: center; margin-bottom: .85rem;
    background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary);
}
.stat__icon svg { width: 22px; height: 22px; }
.stat__label { color: var(--text-muted); font-size: .82rem; font-weight: 500; }
.stat__value { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; margin-top: .15rem; }
.stat__delta { font-size: .78rem; font-weight: 600; margin-top: .25rem; }
.stat.accent .stat__icon { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.stat.green .stat__icon { background: rgba(22,163,74,.14); color: #16a34a; }
.stat.red .stat__icon { background: rgba(220,38,38,.14); color: #dc2626; }

/* =====================================================================
   Buttons
   ===================================================================== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    padding: .6rem 1rem; border-radius: 11px; border: 1px solid transparent;
    font-family: inherit; font-size: .9rem; font-weight: 600; cursor: pointer;
    transition: transform .08s, box-shadow .15s, background .15s, opacity .15s;
    white-space: nowrap; text-decoration: none; line-height: 1;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 70%, var(--secondary))); color: #fff; box-shadow: var(--shadow); }
.btn-primary:hover { filter: brightness(1.05); color: #fff; }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-accent { background: var(--accent); color: #1f2937; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-success { background: #16a34a; color: #fff; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: .4rem .7rem; font-size: .8rem; border-radius: 9px; }
.btn-lg { padding: .85rem 1.4rem; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-icon { padding: .5rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* =====================================================================
   Forms
   ===================================================================== */
.form-group { margin-bottom: 1.1rem; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.form-row-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: .4rem; }
.form-control, input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=search], input[type=tel], select, textarea {
    width: 100%; padding: .65rem .8rem; font-family: inherit; font-size: .92rem;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-radius: 11px; transition: border .15s, box-shadow .15s;
}
.form-control:focus, input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent);
}
textarea { min-height: 110px; resize: vertical; }

/* Themed selects: custom chevron + consistent appearance (native list follows color-scheme) */
select:not([multiple]) {
    appearance: none; -webkit-appearance: none; -moz-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
    background-repeat: no-repeat;
    background-position: right .75rem center;
    padding-right: 2.4rem;
    cursor: pointer;
}
select:not([multiple])::-ms-expand { display: none; }
select option { background: var(--surface); color: var(--text); }
select optgroup { background: var(--surface); color: var(--text-muted); font-style: normal; font-weight: 700; }

/* Themed custom dropdown (JS-enhanced replacement for native option popups) */
.rm-select__native { display: none !important; }
.rm-select { position: relative; display: inline-flex; vertical-align: middle; }
.rm-select--block { display: block; width: 100%; }
.rm-select__btn {
    display: inline-flex; align-items: center; justify-content: space-between; gap: .6rem;
    width: 100%; min-height: var(--control-h, 42px); height: var(--control-h, 42px);
    background: var(--surface); border: 1px solid var(--border); color: var(--text);
    border-radius: 11px; padding: 0 .75rem; font: inherit; font-size: .9rem; line-height: 1.2; cursor: pointer; text-align: left;
}
.rm-select:not(.rm-select--block) .rm-select__btn { width: auto; }
.rm-select__btn:hover { border-color: var(--primary); }
.rm-select.is-open .rm-select__btn { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent); }
.rm-select__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rm-select__chev { flex: none; color: var(--text-muted); transition: transform .18s; }
.rm-select.is-open .rm-select__chev { transform: rotate(180deg); }
.rm-select__panel {
    position: absolute; top: calc(100% + .35rem); left: 0; z-index: 70; min-width: 100%;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-lg, 0 12px 32px rgba(15,23,42,.18)); padding: 0; max-height: 320px; overflow: hidden;
    display: flex; flex-direction: column;
}
.rm-select--block .rm-select__panel { right: 0; }
.rm-select:not(.rm-select--block) .rm-select__panel { width: max-content; max-width: 340px; }
.rm-select__search { padding: .4rem; border-bottom: 1px solid var(--border); flex: none; }
.rm-select__searchinput { width: 100%; height: 36px; padding: .35rem .6rem; font-size: .85rem; }
.rm-select__opts { overflow-y: auto; padding: .3rem; }
.rm-select__opt { display: block; width: 100%; text-align: left; border: 0; background: none; color: var(--text); font: inherit; font-size: .9rem; padding: .5rem .6rem; border-radius: 9px; cursor: pointer; white-space: nowrap; }
.rm-select__opt:hover:not(.is-disabled) { background: var(--surface-2); }
.rm-select__opt.is-selected { background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary); font-weight: 600; }
.rm-select__opt.is-disabled { opacity: .5; cursor: default; }

/* Themed time picker (JS-enhanced replacement for the native time spinner) */
.rm-time__native { position: absolute !important; width: 1px; height: 1px; opacity: 0; pointer-events: none; margin: 0; }
.rm-time { position: relative; display: block; width: 100%; }
.rm-time__btn {
    display: inline-flex; align-items: center; gap: .5rem; width: 100%;
    min-height: var(--control-h, 42px); height: var(--control-h, 42px);
    background: var(--surface); border: 1px solid var(--border); color: var(--text);
    border-radius: 11px; padding: 0 .75rem; font: inherit; font-size: .9rem; cursor: pointer; text-align: left;
}
.rm-time__btn:hover { border-color: var(--primary); }
.rm-time.is-open .rm-time__btn { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent); }
.rm-time.is-disabled { opacity: .55; }
.rm-time.is-disabled .rm-time__btn { cursor: not-allowed; }
.rm-time__ic { flex: none; color: var(--text-muted); }
.rm-time__val { flex: 1; font-variant-numeric: tabular-nums; letter-spacing: .03em; }
.rm-time__val.is-empty { color: var(--text-muted); }
.rm-time__chev { flex: none; color: var(--text-muted); transition: transform .18s; }
.rm-time.is-open .rm-time__chev { transform: rotate(180deg); }
.rm-time__panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg, 0 12px 32px rgba(15,23,42,.18)); padding: .5rem; }
.rm-time__cols { display: flex; gap: .4rem; }
.rm-time__colwrap { display: flex; flex-direction: column; min-width: 62px; }
.rm-time__collabel { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 700; text-align: center; padding: .15rem 0 .35rem; }
.rm-time__col { max-height: 188px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; scroll-behavior: smooth; padding-right: 2px; }
.rm-time__opt { border: 0; background: none; color: var(--text); font: inherit; font-size: .9rem; font-variant-numeric: tabular-nums; padding: .42rem .6rem; border-radius: 8px; cursor: pointer; text-align: center; }
.rm-time__opt:hover { background: var(--surface-2); }
.rm-time__opt.is-selected { background: var(--primary); color: #fff; font-weight: 700; }
.form-hint { font-size: .78rem; color: var(--text-muted); margin-top: .35rem; }
.form-error { font-size: .78rem; color: #dc2626; margin-top: .35rem; }
.input-error { border-color: #dc2626 !important; }
.input-group { display: flex; }
.input-group .addon { display: grid; place-items: center; padding: 0 .8rem; background: var(--surface-2); border: 1px solid var(--border); border-right: 0; border-radius: 11px 0 0 11px; color: var(--text-muted); font-weight: 600; }
.input-group input { border-radius: 0 11px 11px 0; }

.checkbox { display: flex; align-items: center; gap: .6rem; cursor: pointer; font-weight: 500; }
.checkbox input { width: auto; }

/* Switch */
.switch { position: relative; display: inline-flex; align-items: center; gap: .6rem; cursor: pointer; }
.switch input { display: none; }
.switch .track { width: 42px; height: 24px; border-radius: 999px; background: var(--border); position: relative; transition: background .2s; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: var(--shadow-sm); }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(18px); }

/* Color input */
input[type=color] { width: 100%; height: 44px; padding: 4px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); cursor: pointer; }

/* File upload (styled "Choose file" + previews) */
.file-upload { display: block; }
.file-upload__input { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.file-upload__drop {
    display: flex; align-items: center; gap: .9rem; width: 100%; margin: 0; cursor: pointer;
    padding: .85rem 1rem; background: var(--surface-2);
    border: 1.5px dashed var(--border); border-radius: var(--radius);
    transition: border-color .15s, background .15s, box-shadow .15s;
}
.file-upload__drop:hover { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 5%, var(--surface-2)); }
.file-upload__input:focus-visible + .file-upload__drop { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent); }
.file-upload.is-drag .file-upload__drop { border-color: var(--primary); border-style: solid; background: color-mix(in srgb, var(--primary) 9%, var(--surface-2)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 16%, transparent); }
.file-upload__icon { flex: none; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 11px; background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary); }
.file-upload__icon svg { width: 22px; height: 22px; }
.file-upload__text { min-width: 0; font-size: .86rem; font-weight: 500; color: var(--text); line-height: 1.35; overflow: hidden; }
.file-upload__text strong { display: block; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-upload__text strong b { color: var(--primary); font-weight: 700; }
.file-upload__text span { display: block; font-size: .76rem; color: var(--text-muted); font-weight: 500; margin-top: .12rem; }
.file-upload__cta { flex: none; margin-left: auto; padding: .45rem .85rem; font-size: .82rem; font-weight: 600; border-radius: var(--radius-sm); background: var(--surface); color: var(--text); border: 1px solid var(--border); white-space: nowrap; }
.file-upload__drop:hover .file-upload__cta { border-color: var(--primary); color: var(--primary); }

.file-upload__previews { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: .55rem; margin-top: .8rem; }
.file-upload__previews:empty { display: none; }
.file-preview { position: relative; aspect-ratio: 1; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface-2); animation: toastIn .2s ease; }
.file-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.file-preview__doc { width: 100%; height: 100%; display: grid; place-items: center; font-size: .8rem; font-weight: 800; letter-spacing: .03em; color: var(--text-muted); }
.file-preview__name { position: absolute; left: 0; right: 0; bottom: 0; padding: .55rem .4rem .3rem; font-size: .66rem; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.72)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-preview__rm { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 7px; background: rgba(15,23,42,.6); color: #fff; font-size: .8rem; line-height: 1; cursor: pointer; transition: background .15s; }
.file-preview__rm:hover { background: #dc2626; }

/* =====================================================================
   Tables
   ===================================================================== */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); padding: .75rem 1rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: .8rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table .thumb { width: 40px; height: 40px; border-radius: 9px; object-fit: cover; background: var(--surface-2); }
.table-actions { display: flex; gap: .35rem; justify-content: flex-end; }
/* When applied to a table cell, keep it a normal cell so row heights/borders stay aligned. */
td.table-actions { display: table-cell; text-align: right; white-space: nowrap; vertical-align: middle; }
td.table-actions > * { display: inline-flex; vertical-align: middle; }
td.table-actions > * + * { margin-left: .35rem; }
/* Header alignment must match the column's values (overrides .table th text-align:left). */
.table th.text-right { text-align: right; }
.table th.text-center { text-align: center; }

/* =====================================================================
   Badges & pills
   ===================================================================== */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .55rem; border-radius: 999px; font-size: .73rem; font-weight: 700; }
.badge-success { background: rgba(22,163,74,.14); color: #16a34a; }
.badge-danger  { background: rgba(220,38,38,.14); color: #dc2626; }
.badge-warning { background: rgba(245,158,11,.16); color: #b45309; }
.badge-info    { background: rgba(14,165,233,.14); color: #0284c7; }
.badge-primary { background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary); }
.badge-muted   { background: var(--surface-2); color: var(--text-muted); }

.chip { display: inline-flex; align-items: center; gap: .35rem; padding: .35rem .7rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: .82rem; font-weight: 600; cursor: pointer; }
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.check-card { display: flex; align-items: center; gap: .6rem; padding: .7rem .9rem; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; transition: border-color .15s, background .15s; }
.check-card:hover { border-color: var(--primary); }
.check-card input { width: 18px; height: 18px; accent-color: var(--primary); }
.check-card small { display: block; }

/* Refund vs Return chooser */
.rf-type { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.rf-type__opt { display: flex; flex-direction: column; gap: .15rem; padding: .7rem .85rem; border: 2px solid var(--border); border-radius: var(--radius); cursor: pointer; transition: border-color .15s, background .15s; }
.rf-type__opt:hover { border-color: var(--primary); }
.rf-type__opt.is-active { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 10%, transparent); }
.rf-type__opt input { position: absolute; opacity: 0; pointer-events: none; }
.rf-type__t { font-weight: 700; }
.rf-type__d { font-size: .78rem; color: var(--text-muted); }
.rf-stock { background: var(--surface-2); border-radius: var(--radius); padding: .75rem .85rem; }
.rf-stock__q { font-weight: 600; margin-bottom: .4rem; }

/* Tabs */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.5rem; overflow-x: auto; }
.tabs button { background: none; border: none; padding: .8rem 1.1rem; font-size: .95rem; font-weight: 600; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-pane { display: none; }
.tab-pane.active { display: block; animation: toastIn .2s ease; }

/* Colour pickers */
.color-field { display: flex; align-items: center; gap: .7rem; }
.color-field input[type=color] { width: 46px; height: 46px; border: 1px solid var(--border); border-radius: 10px; background: none; cursor: pointer; padding: 2px; }
.brand-preview { display: flex; align-items: center; gap: 1rem; padding: 1rem; border: 1px dashed var(--border); border-radius: var(--radius); margin-bottom: 1rem; }
.brand-preview img { max-height: 56px; max-width: 160px; object-fit: contain; }
.code-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .82rem; white-space: pre-wrap; word-break: break-all; }

/* =====================================================================
   Flash / alerts / toasts
   ===================================================================== */
.alert { padding: .85rem 1.1rem; border-radius: 12px; margin-bottom: 1rem; font-weight: 500; display: flex; align-items: center; gap: .6rem; border: 1px solid transparent; }
.alert-success { background: rgba(22,163,74,.1); color: #15803d; border-color: rgba(22,163,74,.25); }
.alert-error { background: rgba(220,38,38,.1); color: #b91c1c; border-color: rgba(220,38,38,.25); }
.alert-info { background: rgba(14,165,233,.1); color: #0369a1; border-color: rgba(14,165,233,.25); }
.alert-warning { background: rgba(245,158,11,.12); color: #b45309; border-color: rgba(245,158,11,.3); }

.toast-stack { position: fixed; bottom: 1.25rem; right: 1.25rem; z-index: 200; display: flex; flex-direction: column; gap: .6rem; }
.toast { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--primary); box-shadow: var(--shadow-lg); border-radius: 12px; padding: .8rem 1rem; min-width: 240px; animation: toastIn .25s ease; }
.toast.success { border-left-color: #16a34a; }
.toast.error { border-left-color: #dc2626; }
@keyframes toastIn { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

/* =====================================================================
   Empty states
   ===================================================================== */
.empty { text-align: center; padding: 3rem 1.5rem; color: var(--text-muted); }
.empty svg { width: 56px; height: 56px; margin-bottom: 1rem; color: var(--text-soft); }
.empty h3 { color: var(--text); }

/* =====================================================================
   Modal
   ===================================================================== */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.55); backdrop-filter: blur(2px); z-index: 100; display: none; align-items: center; justify-content: center; padding: 1rem; }
.modal-backdrop.open { display: flex; }
.modal { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 540px; max-height: 90vh; overflow: auto; animation: toastIn .2s ease; }
.modal__head { padding: 1.1rem 1.35rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal__head h3 { margin: 0; }
.modal__body { padding: 1.35rem; }
.modal__foot { padding: 1rem 1.35rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: .6rem; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 1.5rem; line-height: 1; }

/* Themed confirm / alert dialog (RM.confirm / RM.alert) */
.rm-confirm { z-index: 1200; }
.rm-confirm__box { max-width: 420px; padding: 1.6rem 1.5rem 1.3rem; text-align: center; }
.rm-confirm__icon { width: 54px; height: 54px; margin: 0 auto .9rem; border-radius: 50%; display: grid; place-items: center; font-size: 1.6rem; background: color-mix(in srgb, var(--primary) 14%, transparent); }
.rm-confirm__icon.is-danger { background: color-mix(in srgb, #dc2626 16%, transparent); }
.rm-confirm__title { margin: 0 0 .4rem; font-size: 1.2rem; }
.rm-confirm__msg { margin: 0 0 1.3rem; color: var(--text-muted); line-height: 1.55; }
.rm-confirm__foot { display: flex; gap: .6rem; justify-content: center; }
.rm-confirm__foot .btn { min-width: 110px; }
.rm-confirm--alert .rm-confirm__foot { justify-content: center; }

/* =====================================================================
   Auth / setup pages
   ===================================================================== */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background:
    radial-gradient(1200px 600px at 100% 0%, color-mix(in srgb, var(--primary) 22%, transparent), transparent),
    radial-gradient(1000px 500px at 0% 100%, color-mix(in srgb, var(--secondary) 20%, transparent), transparent), var(--bg); }
.auth-card { width: 100%; max-width: 430px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 2rem; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: .75rem; margin-bottom: 1.5rem; text-align: center; }
.auth-brand .logo-fallback { width: 56px; height: 56px; border-radius: 16px; background: linear-gradient(135deg, var(--primary), var(--secondary)); display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 1.3rem; }
.auth-brand img { width: 56px; height: 56px; border-radius: 16px; object-fit: cover; }

/* =====================================================================
   Responsive
   ===================================================================== */
@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .hamburger { display: inline-flex; }
    .nav-collapse-btn { display: none; }
    .content { padding: 1rem; }
    /* Force responsive utility grids to a single column even when an inline
       grid-template-columns (e.g. "2fr 1fr") is set on the element. */
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr !important; }
    .form-row, .form-row-3 { grid-template-columns: 1fr !important; }
    .sidebar-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 55; display: none; }
    .sidebar-backdrop.open { display: block; }
    .hide-mobile { display: none !important; }
    /* Tighter topbar + relocate wide controls into the drawer. */
    .topbar { gap: .55rem; padding: 0 .85rem; }
    .sidebar__tools { display: flex; flex-direction: column; gap: .7rem; padding: .85rem .75rem; border-bottom: 1px solid var(--border); margin-bottom: .25rem; }
    .sidebar__tools .global-search,
    .sidebar__tools .global-search input[type=search],
    .sidebar__tools .store-switch,
    .sidebar__tools .store-multi { width: 100%; max-width: none; }
    .sidebar__tools .store-multi__summary { width: 100%; justify-content: flex-start; }
    .sidebar__tools .store-multi__panel { left: 0; right: auto; min-width: 100%; }
}
@media (min-width: 769px) {
    .sidebar-backdrop { display: none !important; }

    /* Collapsed icon rail (desktop) */
    .nav-collapsed .sidebar { width: 78px; }
    .nav-collapsed .main { margin-left: 78px; }
    .nav-collapsed .nav-collapse-btn { color: var(--primary); }
    .nav-collapsed .sidebar__brand { justify-content: center; padding-left: 0; padding-right: 0; gap: 0; }
    .nav-collapsed .sidebar__name { max-width: 0; opacity: 0; }
    .nav-collapsed .nav-text { max-width: 0; opacity: 0; }
    .nav-collapsed .nav-link { justify-content: center; gap: 0; padding-left: 0; padding-right: 0; }
    .nav-collapsed .nav-section { max-height: 0; opacity: 0; padding-top: .5rem; padding-bottom: 0; overflow: hidden; }
    .nav-collapsed .nav-badge { position: absolute; top: 3px; right: 13px; margin: 0; min-width: 15px; height: 15px; padding: 0 3px; font-size: .56rem; line-height: 15px; border-radius: 999px; box-shadow: 0 0 0 2px var(--sidebar); display: grid; place-items: center; }
    .nav-collapsed .nav-ext { display: none; }
    .nav-collapsed .sidebar:hover .nav-ext { display: inline-grid; }
    .nav-collapsed .sidebar:hover .nav-badge { position: static; min-width: auto; height: auto; font-size: .7rem; line-height: normal; padding: .05rem .4rem; box-shadow: none; }

    /* Hover to peek — temporarily expand the rail */
    .nav-collapsed .sidebar:hover { width: 260px; box-shadow: var(--shadow-lg); }
    .nav-collapsed .sidebar:hover .sidebar__brand { justify-content: flex-start; padding-left: 1.25rem; padding-right: 1.25rem; gap: .65rem; }
    .nav-collapsed .sidebar:hover .sidebar__name { max-width: 170px; opacity: 1; }
    .nav-collapsed .sidebar:hover .nav-text { max-width: 170px; opacity: 1; }
    .nav-collapsed .sidebar:hover .nav-link { justify-content: flex-start; gap: .75rem; padding-left: .75rem; padding-right: .75rem; }
    .nav-collapsed .sidebar:hover .nav-section { max-height: 40px; opacity: 1; padding: 1rem .75rem .4rem; }
}

/* =====================================================================
   POS terminal
   ===================================================================== */
.pos-body { background: var(--bg); height: 100vh; overflow: hidden; display: flex; flex-direction: column; }
.pos-topbar { position: sticky; top: 0; z-index: 20; flex: none; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .6rem 1rem; background: var(--sidebar-bg); color: #fff; }
.pos-back { display: inline-flex; align-items: center; gap: .4rem; color: #fff; text-decoration: none; font-weight: 600; padding: .45rem .7rem; border-radius: var(--radius); background: rgba(255,255,255,.12); }
.pos-back svg { width: 18px; height: 18px; }
.pos-brand { font-weight: 700; opacity: .95; }
.pos-meta { display: flex; align-items: center; gap: 1rem; }
.pos-meta .btn-ghost { color: #fff; border-color: rgba(255,255,255,.25); }
.pos-main { padding: 1rem; flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.pos-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(420px, 2fr); gap: 1rem; align-items: start; flex: 1; min-height: 0; }
.pos-products { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.pos-search input { width: 100%; font-size: 1.05rem; padding: .85rem 1rem; }
.pos-cats { display: flex; flex-wrap: nowrap; gap: .4rem; overflow-x: auto; overflow-y: hidden; padding: .35rem 0 .85rem; flex: none; min-height: 56px; align-items: center; }
.pos-cats .chip { white-space: nowrap; flex: none; }
.pos-product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .7rem; overflow-y: auto; padding-bottom: 1rem; align-content: start; }
.pos-product { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem; cursor: pointer; text-align: left; transition: transform .08s, border-color .15s, box-shadow .15s; display: flex; flex-direction: column; gap: .25rem; }
.pos-product:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); }
.pos-product:active { transform: scale(.97); }
.pos-product.out { opacity: .55; }
.pos-product__img { width: 100%; aspect-ratio: 1; border-radius: 10px; background: var(--surface-2) center/cover no-repeat; margin-bottom: .25rem; }
.pos-product__name { font-weight: 600; font-size: .85rem; line-height: 1.2; }
.pos-product__price { color: var(--primary); font-weight: 700; }
.pos-product__stock { font-size: .72rem; color: var(--text-muted); }

.pos-cart { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); display: flex; flex-direction: column; height: 100%; min-height: 0; box-shadow: var(--shadow-sm); position: relative; overflow: hidden; }
.pos-cart__head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.1rem; border-bottom: 1px solid var(--border); }
.pos-cart__head h2 { font-size: 1.05rem; margin: 0; }
.pos-cart__items { flex: 1; overflow-y: auto; padding: .5rem .75rem; min-height: 0; }
.pos-empty { text-align: center; color: var(--text-muted); padding: 2.5rem 1rem; }
.pos-empty svg { opacity: .5; margin-bottom: .6rem; }
.pos-line { display: grid; grid-template-columns: minmax(0, 1fr) auto 96px auto; align-items: center; gap: .6rem; padding: .6rem .25rem; border-bottom: 1px solid var(--border); }
.pos-line__info { display: flex; flex-direction: column; min-width: 0; }
.pos-line__name { font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pos-line__qty { display: inline-flex; align-items: center; gap: .15rem; }
.pos-line__qty button { width: 28px; height: 28px; border: 1px solid var(--border); background: var(--surface-2); border-radius: 8px; cursor: pointer; font-size: 1rem; color: var(--text); }
.pos-line__qty input { width: 28px; height: 28px !important; min-height: 28px !important; text-align: center; padding: 0; }
.pos-line__total { font-weight: 700; text-align: right; white-space: nowrap; }
.pos-line__rm { border: none; background: none; color: #dc2626; cursor: pointer; font-size: .9rem; }
.pos-line__disc { grid-column: 1 / -1; display: flex; align-items: center; justify-content: flex-end; gap: .5rem; padding-top: .35rem; }
.pos-line__disc span.muted { font-size: .76rem; }
.pos-line__disc input { width: 96px; text-align: right; padding: .28rem .45rem; height: auto; border-radius: 8px; }
.pos-line__save { color: #16a34a; font-weight: 700; font-size: .8rem; }
.pos-cart__foot { padding: .9rem 1.1rem; border-top: 1px solid var(--border); }
.pos-pay { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin: .75rem 0; }
/* Payment is a full-column overlay over the current sale (more room, cleaner). */
.pos-pay-panel { position: absolute; inset: 0; z-index: 8; display: flex; flex-direction: column; background: var(--surface); transform: translateY(101%); opacity: 0; pointer-events: none; transition: transform .34s cubic-bezier(.4, 0, .2, 1), opacity .25s ease; }
.pos-pay-panel.is-open { transform: translateY(0); opacity: 1; pointer-events: auto; }
.pos-pay-panel__head { display: flex; align-items: center; gap: .8rem; padding: .85rem 1.1rem; border-bottom: 1px solid var(--border); flex: none; }
.pos-pay-panel__head h2 { font-size: 1.05rem; margin: 0; }
.pos-pay-panel__body { flex: 1; overflow-y: auto; padding: 1rem 1.1rem; min-height: 0; }
.pos-pay-panel__foot { padding: .9rem 1.1rem; border-top: 1px solid var(--border); flex: none; }
.pos-pay-total { display: flex; align-items: baseline; justify-content: space-between; padding: .85rem 1rem; background: color-mix(in srgb, var(--primary) 9%, transparent); border-radius: var(--radius); }
.pos-pay-total span { color: var(--text-muted); font-weight: 600; }
.pos-pay-total strong { font-size: 1.6rem; }
.pos-tendered { display: flex; gap: .5rem; }
.pos-tendered input { flex: 1; min-width: 0; font-size: 1.3rem; text-align: right; }
.pos-tendered__exact { flex: none; padding: 0 1.1rem; border: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius); font-weight: 700; cursor: pointer; color: var(--text); }
.pos-tendered__exact:hover { border-color: var(--primary); color: var(--primary); }
.pos-pay-back { display: inline-flex; align-items: center; gap: .25rem; background: none; border: 0; color: var(--text-muted); cursor: pointer; font-weight: 600; font-size: .85rem; padding: .35rem .5rem; border-radius: 8px; }
.pos-pay-back:hover { color: var(--primary); background: var(--surface-2); }
.pos-branchbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem .9rem; margin-bottom: .8rem; box-shadow: var(--shadow-sm); }
.pos-branchbar__current { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.pos-branchbar__icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary); flex: none; }
.pos-branchbar__label { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.pos-branchbar__current strong { font-size: 1.02rem; }
.pos-branchbar__switch { display: flex; align-items: center; gap: .5rem; margin: 0; }
.pos-branchbar__switch select { width: auto; min-width: 160px; }
.pos-branchbar__switch .rm-select__btn { min-width: 170px; }
.pos-branchbar__tools { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; }
.pos-tillpick select { min-width: 130px; }
.pos-pay__btn { padding: .7rem; border: 2px solid var(--border); background: var(--surface); border-radius: var(--radius); font-weight: 700; cursor: pointer; color: var(--text); }
.pos-pay__btn.active { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); }
.pos-complete { width: 100%; margin-top: .5rem; }
.pos-complete:disabled { opacity: .5; cursor: not-allowed; }
.pos-done-check { width: 64px; height: 64px; border-radius: 50%; background: #16a34a; color: #fff; font-size: 2rem; display: grid; place-items: center; margin: 0 auto 1rem; }

@media (max-width: 900px) {
    .pos-grid { grid-template-columns: minmax(0, 1fr); height: auto; flex: none; }
    .pos-products { height: auto; min-width: 0; }
    .pos-product-grid { overflow: visible; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
    .pos-search { position: sticky; top: 0; z-index: 6; background: var(--bg); padding: .35rem 0; }
    .pos-main { padding-bottom: 76px; overflow-y: auto; }
    .pos-topbar { flex-wrap: wrap; gap: .5rem; }
    .pos-meta { gap: .5rem; flex-wrap: wrap; justify-content: flex-end; row-gap: .45rem; }

    /* The cart becomes a full-height slide-up sheet (maximum room). The payment
       overlay inside it then has space for its header, body and footer. */
    .pos-cart {
        position: fixed; left: 0; right: 0; top: 0; bottom: 0; z-index: 46;
        height: auto; max-height: none; border-radius: 0;
        transform: translateY(100%); transition: transform .32s cubic-bezier(.4, 0, .2, 1);
        box-shadow: 0 -10px 34px rgba(15, 23, 42, .28);
    }
    .pos-cart.sheet-open { transform: translateY(0); }
    .pos-cart__handle { display: block; }
    .pos-cart__items { flex: 1; max-height: none; }
    .pos-cart__foot { flex: none; }
    /* The payment overlay (base: position:absolute; inset:0) now fills the
       full-height cart, so its Back button + Complete action are never clipped. */
}
@media (min-width: 901px) {
    .pos-mobile-bar { display: none !important; }
    .pos-sheet-backdrop { display: none !important; }
}
.pos-cart__handle { display: none; width: 100%; padding: .7rem 0 .35rem; border: 0; background: none; cursor: pointer; flex: none; }
.pos-cart__handle::before { content: ""; display: block; width: 44px; height: 5px; border-radius: 999px; background: var(--border); margin: 0 auto; transition: background .15s; }
.pos-cart__handle:hover::before { background: var(--text-muted); }
.pos-sheet-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 45; opacity: 0; visibility: hidden; transition: opacity .3s, visibility .3s; }
.pos-sheet-backdrop.open { opacity: 1; visibility: visible; }
.pos-mobile-bar {
    display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    align-items: center; justify-content: space-between; gap: 1rem;
    width: 100%; border: none; border-top: 1px solid var(--border);
    padding: .85rem 1.1rem; background: var(--primary); color: #fff;
    font-weight: 700; font-size: 1rem; cursor: pointer; box-shadow: 0 -4px 16px rgba(15,23,42,.18);
}
@media (max-width: 900px) { .pos-mobile-bar { display: flex; } .pos-cart__handle { display: block; } }

/* =====================================================================
   Themed scrollbars
   ===================================================================== */
* { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--text-soft) 60%, transparent) transparent; }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--text-soft) 55%, transparent);
    border-radius: 8px; border: 2px solid transparent; background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--text-soft) 85%, transparent); background-clip: padding-box; }
::-webkit-scrollbar-corner { background: transparent; }

/* =====================================================================
   Date inputs (native, themed via color-scheme — no flatpickr)
   ===================================================================== */
input[type=date]::-webkit-calendar-picker-indicator { cursor: pointer; opacity: .7; transition: opacity .15s; }
input[type=date]::-webkit-calendar-picker-indicator:hover { opacity: 1; }

.report-range {
    display: flex; flex-wrap: wrap; align-items: center; gap: 1rem;
    margin-bottom: 1.25rem; padding: .8rem 1rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.report-range__chips { display: flex; gap: .4rem; flex-wrap: wrap; }
.report-range__custom { display: flex; gap: .6rem; align-items: flex-end; flex-wrap: wrap; margin-left: auto; }
.date-field { display: flex; flex-direction: column; gap: .25rem; }
.date-field__label { font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); font-weight: 700; }
.date-field input[type=date] { width: auto; min-width: 150px; }

/* =====================================================================
   Product specs builder + POS receipt options
   ===================================================================== */
.spec-rows { display: flex; flex-direction: column; gap: .5rem; }
.spec-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: .5rem; align-items: center; }
.spec-row .btn-icon { width: 38px; height: 38px; flex: none; }

/* Product options builder */
.opt-groups { display: flex; flex-direction: column; gap: 1rem; }
.opt-group { border: 1px solid var(--border); border-radius: var(--radius); padding: .85rem; background: var(--surface-2); }
.opt-group__head { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: .7rem; }
.opt-group__head .opt-gname { flex: 1; min-width: 150px; }
.opt-group__head .opt-gtype { width: 130px; }
.opt-values { display: flex; flex-direction: column; gap: .45rem; }
.opt-value { display: grid; grid-template-columns: 1fr 140px auto auto auto; gap: .5rem; align-items: center; }
.opt-value .opt-color, .opt-value .opt-img-btn { display: none; }
.opt-group--color .opt-value .opt-color { display: block; width: 46px; height: 38px; padding: 2px; }
.opt-group--color .opt-value .opt-img-btn { display: inline-block; cursor: pointer; }
.opt-img-prev { display: block; width: 38px; height: 38px; border-radius: 9px; border: 1px dashed var(--border); background: var(--surface) center/cover no-repeat; }
.opt-value .btn-icon { width: 36px; height: 36px; flex: none; }
@media (max-width: 768px) { .opt-value { grid-template-columns: 1fr auto auto; } .opt-value .opt-price { grid-column: 1 / -1; } }

.pos-receipt { margin: .75rem 0; padding: .75rem .85rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.pos-receipt__row { display: flex; align-items: center; justify-content: space-between; font-weight: 600; }
.pos-receipt__opts { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-top: .6rem; }

/* =====================================================================
   Table toolbar, sorting & quick filter
   ===================================================================== */
.table-toolbar { display: flex; justify-content: flex-end; padding: .65rem .75rem .15rem; }
.table-search { width: 260px; max-width: 100%; padding: .5rem .75rem; font-size: .88rem; }
.table-pager { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: .7rem .9rem; border-top: 1px solid var(--border); font-size: .85rem; }
.table-pager__info { color: var(--text-muted); }
.table-pager__nav { display: flex; align-items: center; gap: .25rem; }
.table-pager__btn { min-width: 32px; height: 32px; padding: 0 .5rem; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px; cursor: pointer; font-size: .85rem; font-weight: 600; }
.table-pager__btn:hover:not(:disabled):not(.is-active) { border-color: var(--primary); color: var(--primary); }
.table-pager__btn.is-active { background: var(--primary); border-color: var(--primary); color: #fff; }
.table-pager__btn:disabled { opacity: .4; cursor: not-allowed; }
.table-pager__gap { padding: 0 .2rem; color: var(--text-muted); }
th.th-sort { cursor: pointer; user-select: none; white-space: nowrap; transition: color .12s; }
th.th-sort:hover { color: var(--primary); }
th.th-sort::after { content: '↕'; opacity: .3; margin-left: .35rem; font-size: .85em; }
th.th-sort.sort-asc::after { content: '↑'; opacity: 1; color: var(--primary); }
th.th-sort.sort-desc::after { content: '↓'; opacity: 1; color: var(--primary); }

/* qty steppers: flat middle input when flanked by +/- buttons */
.qty-stepper input, .qty-stepper.sm input, .pos-line__qty input { border-radius: 0 !important; }

/* Document tiles (GRV / finance attachments) */
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .6rem; }
.doc-tile { position: relative; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface-2); }
.doc-tile__link { display: block; text-decoration: none; color: var(--text); }
.doc-tile__img { display: block; height: 92px; background: var(--surface-2) center/cover no-repeat; }
.doc-tile__pdf { display: grid; place-items: center; height: 92px; font-weight: 800; color: #dc2626; background: color-mix(in srgb, #dc2626 10%, var(--surface-2)); letter-spacing: .06em; }
.doc-tile__name { display: block; padding: .4rem .55rem; font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-tile__rm { position: absolute; top: 4px; right: 4px; margin: 0; }
.doc-tile__rm .btn-icon { width: 26px; height: 26px; background: rgba(15,23,42,.55); color: #fff; border: 0; }

/* POS option picker */
.pos-opt-grp { margin-bottom: 1.1rem; }
.pos-opt-grp__label { font-weight: 700; font-size: .85rem; margin-bottom: .5rem; }
.pos-opt-grp__vals { display: flex; gap: .5rem; flex-wrap: wrap; }
.pos-opt-chip { padding: .55rem .9rem; border: 2px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); font-weight: 600; cursor: pointer; }
.pos-opt-chip.active { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); }
.pos-opt-sw { width: 42px; height: 42px; border-radius: 50%; border: 2px solid var(--border); background: var(--sw); cursor: pointer; }
.pos-opt-sw.active { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 30%, transparent); }

/* =====================================================================
   Mobile: prevent horizontal overflow
   ===================================================================== */
body { overflow-x: clip; }
.main { overflow-x: clip; }
.content { max-width: 100%; }
img, canvas, svg, video, table { max-width: 100%; }
@media (max-width: 768px) {
    .report-range__custom { width: 100%; margin-left: 0; }
    .date-field { flex: 1; }
    .date-field input[type=date] { min-width: 0; width: 100%; }
    .page-head { gap: .6rem; }
    .table-search { width: 100%; }
}

/* =====================================================================
   Consistent control heights & alignment system
   ===================================================================== */
.btn { min-height: var(--control-h); }
.form-control,
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=search], input[type=tel], select {
    height: var(--control-h);
}
textarea.form-control { height: auto; }
.btn-sm { min-height: 34px; }
.btn-lg { min-height: 50px; }

/* Filter bar — keeps search / chips / buttons on one baseline */
.filter-bar { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filter-bar > * { margin: 0; }
.filter-bar .filter-grow { flex: 1; min-width: 180px; }
.filter-bar input, .filter-bar select { height: var(--control-h); }
.filter-toggle {
    display: inline-flex; align-items: center; gap: .5rem; height: var(--control-h);
    padding: 0 .95rem; border: 1px solid var(--border); border-radius: 11px;
    background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap;
    font-weight: 600; font-size: .86rem; transition: border-color .15s, background .15s, color .15s;
}
.filter-toggle input { width: 17px; height: 17px; accent-color: var(--primary); margin: 0; }
.filter-toggle:hover { border-color: var(--primary); }
.filter-toggle.active { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 10%, transparent); color: var(--primary); }

/* Settings module list */
.module-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .8rem 0; border-bottom: 1px solid var(--border); }
.module-row:last-child { border-bottom: none; }
.module-row__info { min-width: 0; }
.module-row__info strong { display: block; font-size: .95rem; }
.module-row__info small { color: var(--text-muted); }
.module-row__actions { display: flex; align-items: center; gap: .6rem; flex: none; }

/* =====================================================================
   Number steppers (− input +) — auto-applied to number inputs
   ===================================================================== */
.num-stepper { display: inline-flex; align-items: stretch; vertical-align: middle; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); max-width: 100%; }
.num-stepper:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent); }
.num-stepper input[type=number] {
    border: none !important; border-radius: 0 !important; box-shadow: none !important;
    text-align: center; height: auto; min-width: 0; -moz-appearance: textfield; background: transparent;
}
.num-stepper input[type=number]::-webkit-outer-spin-button,
.num-stepper input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.num-stepper__btn {
    flex: none; width: 38px; border: none; background: var(--surface-2); color: var(--text);
    cursor: pointer; font-size: 1.15rem; line-height: 1; display: grid; place-items: center;
    transition: background .12s, color .12s;
}
.num-stepper__btn:hover { background: var(--primary); color: #fff; }
.num-stepper__btn:active { transform: translateY(1px); }
.num-stepper__btn:first-child { border-right: 1px solid var(--border); border-radius: 10px 0 0 10px; }
.num-stepper__btn:last-child { border-left: 1px solid var(--border); border-radius: 0 10px 10px 0; }
.num-stepper.is-block { display: flex; width: 100%; }

/* =====================================================================
   Global search (top bar)
   ===================================================================== */
.global-search { position: relative; flex: 1 1 auto; max-width: 460px; display: flex; align-items: center; }
.global-search__icon { position: absolute; left: .8rem; width: 18px; height: 18px; color: var(--text-muted); pointer-events: none; }
.global-search input[type=search] {
    width: 100%; height: 40px; padding: 0 2.4rem; border-radius: 11px;
    background: var(--surface-2); border: 1px solid var(--border); color: var(--text); font-size: .9rem;
}
.global-search input[type=search]:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); outline: none; }
.global-search__kbd { position: absolute; right: .55rem; padding: .08rem .42rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text-muted); font-size: .72rem; font-family: ui-monospace, "Cascadia Code", Consolas, monospace; pointer-events: none; }
.global-search__panel {
    position: absolute; top: calc(100% + .4rem); left: 0; right: 0; min-width: 320px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-lg); max-height: 72vh; overflow-y: auto; z-index: 80; padding: .35rem;
}
.gs-group { padding: .45rem .55rem .2rem; font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 700; }
.gs-item { display: flex; align-items: center; gap: .75rem; padding: .55rem .6rem; border-radius: 9px; cursor: pointer; text-decoration: none; color: var(--text); }
.gs-item:hover, .gs-item.active { background: var(--surface-2); text-decoration: none; }
.gs-item__main { min-width: 0; flex: 1; }
.gs-item__label { font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gs-item__sub { font-size: .76rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gs-item__tag { flex: none; }
.gs-foot { padding: .5rem .6rem; border-top: 1px solid var(--border); margin-top: .25rem; }
.gs-foot a { font-size: .82rem; font-weight: 600; }
.gs-empty { padding: 1.1rem; text-align: center; color: var(--text-muted); font-size: .85rem; }
@media (max-width: 900px) { .global-search { max-width: none; } .global-search__kbd { display: none; } }
@media (max-width: 600px) {
    .global-search input[type=search] { padding-right: .8rem; }
    .global-search__panel { position: fixed; left: .5rem; right: .5rem; top: calc(var(--topbar-h) + .25rem); }
}

/* Export As dropdown (native <details>) */
.export-menu { position: relative; display: inline-block; }
.export-menu > summary { list-style: none; cursor: pointer; gap: .4rem; }
.export-menu > summary::-webkit-details-marker { display: none; }
.export-menu > summary::marker { content: ''; }
.export-menu__list {
    position: absolute; right: 0; top: calc(100% + .35rem); min-width: 210px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-lg); padding: .35rem; z-index: 50;
}
.export-menu__list a { display: block; padding: .55rem .65rem; border-radius: 9px; color: var(--text); font-size: .9rem; }
.export-menu__list a:hover { background: var(--surface-2); text-decoration: none; }
.export-menu[open] > summary { border-color: var(--primary); color: var(--primary); }

/* Notifications bell + panel */
.topbar__notif .btn-icon { position: relative; }
.topbar__chat { position: relative; }
.topbar__chat.is-pulsing { animation: chatPulse .6s ease-in-out 3; }
@keyframes chatPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.18); color: var(--primary); } }
.notif-dot { position: absolute; top: 1px; right: 1px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: #dc2626; color: #fff; font-size: .62rem; font-weight: 800; display: grid; place-items: center; line-height: 1; box-shadow: 0 0 0 2px var(--surface); }
.notif-panel { position: absolute; right: 0; top: 48px; width: 350px; max-width: 92vw; z-index: 60; padding: 0; overflow: hidden; }
.notif-panel__head { display: flex; align-items: center; justify-content: space-between; padding: .8rem 1rem; border-bottom: 1px solid var(--border); }
.notif-panel__body { max-height: 62vh; overflow-y: auto; }
.notif-group { padding: .6rem 1rem .25rem; font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 700; }
.notif-item { display: flex; align-items: center; gap: .7rem; padding: .55rem 1rem; color: var(--text); text-decoration: none; }
.notif-item:hover { background: var(--surface-2); text-decoration: none; }
.notif-item__icon { flex: none; width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; font-weight: 800; font-size: .95rem; }
.notif-item__icon.info { background: rgba(14,165,233,.14); color: #0284c7; }
.notif-item__icon.warn { background: rgba(245,158,11,.16); color: #b45309; }
.notif-item__icon.accent { background: rgba(139,92,246,.16); color: #7c3aed; }
.notif-item__main { display: flex; flex-direction: column; min-width: 0; }
.notif-item__main strong { font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-item__main small { color: var(--text-muted); font-size: .76rem; }
.notif-empty { padding: 1.6rem 1rem; text-align: center; color: var(--text-muted); font-size: .86rem; }
.notif-panel__foot { display: block; padding: .7rem 1rem; border-top: 1px solid var(--border); font-size: .84rem; font-weight: 600; text-align: center; color: var(--primary); }
.notif-panel__foot:hover { background: var(--surface-2); text-decoration: none; }
@media (max-width: 600px) { .notif-panel { position: fixed; left: .5rem; right: .5rem; top: calc(var(--topbar-h) + .25rem); width: auto; } }


/* Generic autocomplete dropdown (refund sale lookup, etc.) */
.ac-panel {
    position: absolute; left: 0; right: 0; top: calc(100% + .3rem); z-index: 50;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-lg); padding: .3rem; max-height: 320px; overflow-y: auto;
}
.ac-item { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .55rem .6rem; border-radius: 9px; color: var(--text); text-decoration: none; }
button.ac-item { width: 100%; border: 0; background: none; cursor: pointer; font: inherit; text-align: left; }
.ac-item:hover, .ac-item.active { background: var(--surface-2); text-decoration: none; }
.ac-item__main { display: flex; flex-direction: column; min-width: 0; }
.ac-item__main strong { font-size: .9rem; }
.ac-item__main small, .ac-item__meta small { color: var(--text-muted); font-size: .76rem; }
.ac-item__meta { text-align: right; display: flex; flex-direction: column; font-weight: 700; font-size: .9rem; white-space: nowrap; }
.ac-empty { padding: .9rem; text-align: center; color: var(--text-muted); font-size: .85rem; }

/* =====================================================================
   AI Insights chat
   ===================================================================== */
.ai-chat { display: flex; flex-direction: column; height: calc(100vh - 200px); min-height: 460px; overflow: hidden; }
.ai-chat__stream { flex: 1; overflow-y: auto; padding: 1.25rem; display: flex; flex-direction: column; gap: 1rem; }
.ai-msg { display: flex; gap: .75rem; max-width: 80%; }
.ai-msg--user { align-self: flex-end; flex-direction: row-reverse; }
.ai-msg__avatar { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: .72rem; font-weight: 800; color: #fff; background: linear-gradient(135deg, var(--primary), var(--secondary)); }
.ai-msg--user .ai-msg__avatar { background: var(--surface-2); color: var(--text-muted); }
.ai-msg__bubble { background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; padding: .7rem 1rem; font-size: .92rem; line-height: 1.55; }
.ai-msg--user .ai-msg__bubble { background: var(--primary); border-color: var(--primary); color: #fff; }
.ai-msg__bubble p { margin: 0 0 .5rem; }
.ai-msg__bubble p:last-child { margin-bottom: 0; }
.ai-msg__bubble ul { margin: .3rem 0 .5rem; padding-left: 1.15rem; }
.ai-msg__bubble li { margin: .15rem 0; }
.ai-examples { display: flex; flex-direction: column; gap: .4rem; margin-top: .6rem; }
.ai-example { text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: .5rem .7rem; cursor: pointer; font-size: .85rem; color: var(--text); transition: border-color .15s, background .15s; }
.ai-example:hover { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 7%, transparent); }
.ai-chat__input { display: flex; gap: .6rem; align-items: flex-end; padding: .85rem; border-top: 1px solid var(--border); background: var(--surface); }
.ai-chat__input textarea { flex: 1; resize: none; min-height: var(--control-h); max-height: 140px; padding: .6rem .8rem; line-height: 1.4; }
.ai-chat__input .btn { height: var(--control-h); flex: none; }
.ai-typing { display: inline-flex; gap: 4px; padding: .15rem 0; }
.ai-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); opacity: .5; animation: aiBlink 1.2s infinite; }
.ai-typing i:nth-child(2) { animation-delay: .2s; }
.ai-typing i:nth-child(3) { animation-delay: .4s; }
@keyframes aiBlink { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
@media (max-width: 768px) { .ai-msg { max-width: 92%; } .ai-chat { height: calc(100vh - 170px); } }

/* AI Insights — saved conversation history sidebar */
.ai-layout { display: grid; grid-template-columns: 264px 1fr; gap: 1rem; align-items: stretch; }
.ai-history { display: flex; flex-direction: column; gap: .6rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem; height: calc(100vh - 200px); min-height: 460px; overflow: hidden; }
.ai-history__head { flex: none; }
.ai-history__list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: .2rem; margin: 0 -.3rem; padding: 0 .3rem; }
.ai-hist-item { display: flex; align-items: stretch; border-radius: 10px; transition: background .15s; }
.ai-hist-item:hover { background: var(--surface-2); }
.ai-hist-item.is-active { background: color-mix(in srgb, var(--primary) 12%, transparent); }
.ai-hist-item__open { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; text-align: left; background: none; border: 0; cursor: pointer; padding: .5rem .55rem; color: var(--text); font: inherit; }
.ai-hist-item__title { font-size: .85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-hist-item__meta { font-size: .72rem; color: var(--text-muted); }
.ai-hist-item__del { flex: none; width: 34px; border: 0; background: none; color: var(--text-muted); cursor: pointer; border-radius: 8px; opacity: 0; transition: opacity .15s, color .15s; }
.ai-hist-item:hover .ai-hist-item__del, .ai-hist-item.is-active .ai-hist-item__del { opacity: 1; }
.ai-hist-item__del:hover { color: var(--danger); }
.ai-history__empty { font-size: .8rem; text-align: center; padding: 1rem .5rem; }
.ai-history-toggle { display: none; }
@media (max-width: 860px) {
    .ai-layout { grid-template-columns: 1fr; }
    .ai-history-toggle { display: inline-flex; align-items: center; gap: .35rem; }
    .ai-history { height: auto; min-height: 0; max-height: 0; padding-top: 0; padding-bottom: 0; border-width: 0; opacity: 0; transition: max-height .25s, opacity .2s, padding .25s; }
    .ai-history.is-open { max-height: 320px; padding-top: .8rem; padding-bottom: .8rem; border-width: 1px; opacity: 1; margin-bottom: .25rem; }
    .ai-history__list { max-height: 230px; }
}

/* =====================================================================
   Ad Studio (Facebook / Instagram mockups)
   ===================================================================== */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; padding: 3px; gap: 3px; }
.seg__btn { border: 0; background: none; padding: .45rem 1rem; border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--text-muted); font-size: .88rem; }
.seg__btn.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
a.seg__btn { text-decoration: none; display: inline-flex; align-items: center; }

/* Orders Kanban board ------------------------------------------------- */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(252px, 1fr); gap: 1rem; align-items: start; overflow-x: auto; padding-bottom: .6rem; }
.kanban-col { background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; padding: .65rem; display: flex; flex-direction: column; min-height: 180px; max-height: calc(100vh - 210px); transition: background .15s, box-shadow .15s; }
.kanban-col.is-over { background: color-mix(in srgb, var(--kb-accent, var(--primary)) 12%, var(--surface-2)); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--kb-accent, var(--primary)) 55%, transparent); }
.kanban-col__head { display: flex; align-items: center; justify-content: space-between; padding: .15rem .25rem; flex: none; }
.kanban-col__title { display: inline-flex; align-items: center; gap: .45rem; font-weight: 700; font-size: .92rem; }
.kanban-col__dot { width: 9px; height: 9px; border-radius: 50%; background: var(--kb-accent, var(--primary)); flex: none; }
.kanban-col__count { min-width: 22px; height: 22px; padding: 0 .4rem; display: inline-grid; place-items: center; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-size: .76rem; font-weight: 700; color: var(--text-muted); }
.kanban-col__sub { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin: .1rem .3rem .55rem; flex: none; }
.kanban-col__blurb { margin: 0; font-size: .74rem; color: var(--text-muted); }
.kanban-col__total { font-size: .8rem; font-weight: 800; color: var(--kb-accent, var(--text)); white-space: nowrap; }
.kanban-col__body { display: flex; flex-direction: column; gap: .55rem; flex: 1 1 auto; min-height: 60px; overflow-y: auto; border-radius: 10px; padding: 2px; margin: -2px; }
.kanban-col__body::-webkit-scrollbar { width: 8px; }
.kanban-col__body::-webkit-scrollbar-track { background: transparent; }
.kanban-col__body::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--text-muted) 32%, transparent); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
.kanban-col__body:hover::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--text-muted) 50%, transparent); background-clip: padding-box; }
.kanban-col__body { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--text-muted) 38%, transparent) transparent; }
.kanban-col__empty { margin: 0; padding: 1.4rem .5rem; text-align: center; font-size: .8rem; color: var(--text-muted); border: 1.5px dashed var(--border); border-radius: 10px; }
.kanban-card { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--kb-accent, var(--primary)); border-radius: 10px; padding: .6rem .7rem; box-shadow: var(--shadow-sm); transition: box-shadow .15s, transform .05s; }
.kanban-card:hover { box-shadow: var(--shadow); }
.kanban-card.is-dragging { opacity: .45; box-shadow: none; }
.kanban-card.is-saving { opacity: .6; pointer-events: none; }
.kanban-card--ghost { position: fixed; z-index: 1300; width: 240px; margin: 0; pointer-events: none; box-shadow: var(--shadow-lg, 0 16px 40px rgba(15,23,42,.28)); opacity: .96; transform: rotate(2deg); }
.kanban-card__top { display: flex; align-items: center; gap: .4rem; }
.kanban-card__grip { display: inline-flex; align-items: center; color: var(--text-muted); cursor: grab; flex: none; opacity: .5; touch-action: none; margin-left: -.2rem; }
.kanban-card__grip:hover { opacity: 1; }
.kanban-card__grip svg { display: block; }
.kanban-card.is-dragging .kanban-card__grip, .kanban-card__grip:active { cursor: grabbing; }
.kanban-card__ref { display: inline-flex; align-items: center; gap: .25rem; flex: 1; min-width: 0; font-weight: 700; font-size: .8rem; text-decoration: none; color: var(--primary); background: color-mix(in srgb, var(--primary) 10%, transparent); padding: .14rem .42rem; border-radius: 7px; transition: background .15s; }
.kanban-card__ref > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kanban-card__ref:hover { background: color-mix(in srgb, var(--primary) 22%, transparent); }
.kanban-card__refic { flex: none; opacity: .7; }
.kanban-card__total { font-weight: 700; font-size: .82rem; white-space: nowrap; flex: none; }
.kanban-card__cust { margin-top: .35rem; font-size: .9rem; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kanban-card__meta { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; margin-top: .45rem; font-size: .72rem; color: var(--text-muted); }
.kanban-card__chip { background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: .05rem .35rem; font-weight: 600; }
.kanban-card__when { margin-left: auto; }
@media (max-width: 720px) {
    .kanban { grid-auto-columns: 82%; }
    .kanban-col { max-height: none; }
    .kanban-col__body { max-height: 60vh; }
    .kanban-card__grip { opacity: .8; padding: .1rem; }
}

/* POS cash-up ---------------------------------------------------------- */
.cashup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; align-items: start; }
.cashup-denoms { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem 1rem; }
.cashup-denom { display: flex; align-items: center; gap: .5rem; }
.cashup-denom__label { min-width: 46px; font-weight: 700; font-variant-numeric: tabular-nums; }
.cashup-denom__x { color: var(--text-muted); font-size: .85rem; }
.cashup-denom__sub { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--text-muted); min-width: 64px; text-align: right; font-size: .85rem; }
.cashup-counted { display: flex; align-items: center; justify-content: space-between; margin-top: 1rem; padding-top: .9rem; border-top: 1px solid var(--border); font-weight: 600; }
.cashup-counted strong { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.cashup-line { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .5rem 0; }
.cashup-line + .cashup-line { border-top: 1px solid color-mix(in srgb, var(--border) 60%, transparent); }
.cashup-line--muted { color: var(--text-muted); }
.cashup-line--big { font-size: 1.02rem; }
.cashup-line--big strong { font-size: 1.18rem; font-variant-numeric: tabular-nums; }
.cashup-num input { width: 150px; text-align: right; }
.cashup-hr { border: 0; border-top: 1px solid var(--border); margin: .65rem 0; }
.cashup-variance { display: flex; align-items: center; gap: .6rem; padding: .85rem 1.1rem; border-radius: 12px; margin-top: .5rem; background: var(--surface-2); }
.cashup-variance__label { font-weight: 600; }
.cashup-variance strong { font-size: 1.55rem; font-variant-numeric: tabular-nums; margin-left: auto; }
.cashup-variance__tag { font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; padding: .2rem .55rem; border-radius: 999px; background: color-mix(in srgb, currentColor 16%, transparent); }
.cashup-variance.is-balanced { background: color-mix(in srgb, #10b981 13%, transparent); }
.cashup-variance.is-balanced strong, .cashup-variance.is-balanced .cashup-variance__tag { color: #059669; }
.cashup-variance.is-short { background: color-mix(in srgb, #ef4444 13%, transparent); }
.cashup-variance.is-short strong, .cashup-variance.is-short .cashup-variance__tag { color: #dc2626; }
.cashup-variance.is-over { background: color-mix(in srgb, #f59e0b 15%, transparent); }
.cashup-variance.is-over strong, .cashup-variance.is-over .cashup-variance__tag { color: #d97706; }
.cashup-var { font-weight: 700; font-size: .82rem; white-space: nowrap; }
.cashup-var.is-balanced { color: #059669; }
.cashup-var.is-short { color: #dc2626; }
.cashup-var.is-over { color: #d97706; }
@media (max-width: 860px) { .cashup-grid { grid-template-columns: 1fr; } }
@media (max-width: 520px) { .cashup-denoms { grid-template-columns: 1fr; } }

/* Cash-up till filter + tills management forms */
.cashup-filter { display: flex; align-items: center; gap: .55rem; margin-bottom: 1rem; }
.cashup-filter select { width: auto; min-width: 200px; }
.till-rename { display: flex; align-items: center; gap: .45rem; margin: 0; }
.till-rename input { width: auto; min-width: 160px; max-width: 240px; }
.till-add { display: flex; align-items: center; gap: .5rem; margin-top: .9rem; flex-wrap: wrap; }
.till-add input { width: auto; min-width: 200px; flex: 1; max-width: 320px; }
@media (max-width: 520px) { .till-rename input, .till-add input, .cashup-filter select { min-width: 0; } }

/* Cash-up: choose-a-till picker */
.till-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; }
.till-pick__card { display: flex; flex-direction: column; align-items: flex-start; gap: .35rem; padding: 1.1rem 1.2rem 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); text-decoration: none; color: var(--text); transition: transform .12s ease, border-color .15s, box-shadow .15s; }
.till-pick__card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.till-pick__icon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 12px; background: color-mix(in srgb, var(--primary) 13%, transparent); color: var(--primary); margin-bottom: .35rem; }
.till-pick__name { font-size: 1.12rem; font-weight: 700; }
.till-pick__meta { font-size: .86rem; color: var(--text-muted); }
.till-pick__meta strong { color: var(--text); }
.till-pick__since { font-size: .76rem; color: var(--text-muted); }
.till-pick__go { margin-top: .55rem; display: inline-flex; align-items: center; gap: .3rem; font-size: .82rem; font-weight: 700; color: var(--primary); }

/* Quotes --------------------------------------------------------------- */
.quote-doc { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 2rem 2.25rem; max-width: 900px; margin-inline: auto; box-shadow: var(--shadow-sm); }
.quote-doc__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1.5rem; border-bottom: 3px solid var(--q-accent, var(--primary)); padding-bottom: 1.1rem; }
.quote-doc__brand img { max-height: 56px; max-width: 190px; object-fit: contain; }
.quote-doc__name { font-size: 1.4rem; font-weight: 800; color: var(--q-accent, var(--primary)); }
.quote-doc__biz { font-size: .8rem; line-height: 1.6; margin-top: .4rem; }
.quote-doc__meta { text-align: right; flex: none; }
.quote-doc__doctitle { font-size: 1.6rem; font-weight: 800; letter-spacing: .08em; color: var(--q-accent, var(--primary)); }
.quote-doc__meta > div { font-size: .85rem; line-height: 1.7; }
.quote-doc__to { margin: 1.4rem 0 .4rem; display: flex; flex-direction: column; gap: .1rem; }
.quote-doc__to > .muted:first-child { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; }
.quote-doc__to strong { font-size: 1.05rem; }
.quote-doc__intro { color: var(--text-muted); margin: .9rem 0; }
.quote-doc__table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
.quote-doc__table th, .quote-doc__table td { padding: .6rem .7rem; text-align: left; }
.quote-doc__table thead th { border-bottom: 2px solid var(--q-accent, var(--primary)); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.quote-doc__table tbody td { border-bottom: 1px solid var(--border); }
.quote-doc__table .r { text-align: right; }
.quote-doc__table tfoot td { padding: .35rem .7rem; text-align: right; }
.quote-doc__grand td { font-size: 1.15rem; font-weight: 800; border-top: 2px solid var(--border); padding-top: .7rem; }
.quote-doc__grand td:last-child { color: var(--q-accent, var(--primary)); }
.quote-doc__terms { margin-top: 1.6rem; }
.quote-doc__terms h4 { margin: 0 0 .4rem; }
.quote-doc__terms p, .quote-doc__foot { color: var(--text-muted); font-size: .85rem; white-space: pre-line; }
.quote-doc__foot { margin-top: 1.4rem; border-top: 1px solid var(--border); padding-top: .8rem; text-align: center; }
@media (max-width: 640px) { .quote-doc { padding: 1.4rem 1.2rem; } .quote-doc__head { flex-direction: column; } .quote-doc__meta { text-align: left; } }
.qt-card { display: flex; }
.qt-card > .card__body { display: flex; flex-direction: column; flex: 1; }
.qt-card__head { display: flex; align-items: center; gap: .5rem; margin-bottom: .3rem; }
.qt-card__head h3 { margin: 0; font-size: 1.02rem; }
.qt-card__swatch { width: 14px; height: 14px; border-radius: 4px; background: var(--qt-accent, var(--primary)); flex: none; }
.qt-card__intro { font-size: .85rem; margin: .2rem 0 .6rem; }
.qt-card__meta { font-size: .78rem; }
.qt-card__actions { display: flex; gap: .4rem; margin-top: auto; padding-top: .9rem; flex-wrap: wrap; }
.ord-quotes { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.ord-quotes__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .5rem; }
.ord-quotes__head h4 { margin: 0; }
.ord-quote-row { display: flex; align-items: center; gap: .4rem; margin-bottom: .4rem; }
.ord-quote-row__main { flex: 1; display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .5rem .65rem; border: 1px solid var(--border); border-radius: 9px; text-decoration: none; color: var(--text); font-size: .85rem; }
.ord-quote-row__main:hover { border-color: var(--primary); background: var(--surface-2); }
.ord-quote-row__del { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text-muted); cursor: pointer; }
.ord-quote-row__del:hover { border-color: #dc2626; color: #dc2626; background: color-mix(in srgb, #dc2626 8%, transparent); }
.ad-preview { display: grid; place-items: start center; }
.ad-preview .ad-ig { display: none; }
.ad-preview[data-platform="instagram"] .ad-fb { display: none; }
.ad-preview[data-platform="instagram"] .ad-ig { display: block; }
.ad-fb, .ad-ig { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow-sm); }
.ad-fb__head, .ad-ig__head { display: flex; align-items: center; gap: .6rem; padding: .75rem .9rem; }
.ad-fb__avatar, .ad-ig__avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: #fff; font-size: .8rem; background: linear-gradient(135deg, var(--primary), var(--secondary)); flex: none; }
.ad-ig__avatar { width: 32px; height: 32px; font-size: .7rem; }
.ad-fb__name, .ad-ig__name { font-weight: 700; font-size: .9rem; }
.ad-fb__meta { font-size: .76rem; color: var(--text-muted); display: flex; align-items: center; gap: .3rem; }
.ad-ig__name { flex: 1; }
.ad-ig__dots { color: var(--text-muted); font-weight: 700; }
.ad-fb__primary { padding: 0 .9rem .7rem; font-size: .9rem; line-height: 1.5; }
.ad-img { width: 100%; aspect-ratio: 1.91/1; background: var(--surface-2) center/cover no-repeat; }
.ad-img--square { aspect-ratio: 1/1; }
.ad-fb__foot { display: flex; align-items: center; gap: .8rem; padding: .7rem .9rem; background: var(--surface-2); }
.ad-fb__foot-text { flex: 1; min-width: 0; }
.ad-fb__domain { font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.ad-fb__headline { font-weight: 700; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ad-fb__cta { border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: .5rem .9rem; font-weight: 700; font-size: .82rem; cursor: default; color: var(--text); flex: none; }
.ad-ig__cta-bar { display: flex; align-items: center; justify-content: space-between; padding: .5rem .9rem; background: color-mix(in srgb, var(--primary) 8%, var(--surface)); font-weight: 700; font-size: .85rem; }
.ad-ig__actions { display: flex; gap: .8rem; padding: .6rem .9rem .3rem; font-size: 1.2rem; }
.ad-ig__caption { padding: 0 .9rem .3rem; font-size: .88rem; line-height: 1.45; }
.ad-ig__tags { padding: 0 .9rem .9rem; font-size: .85rem; color: var(--primary); }
.ad-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .85rem; }
.ad-actions .btn { flex: 1 1 auto; }
.ad-actions #adCopyAll { flex: 1 1 100%; }
.ad-actions p { order: 9; word-break: break-all; }
.tpl-tags { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .7rem; }
.tpl-tag { border: 1px solid var(--border); background: var(--surface-2); color: var(--text); border-radius: 7px; padding: .22rem .5rem; font-size: .76rem; font-family: ui-monospace, Consolas, monospace; cursor: pointer; }
.tpl-tag:hover { border-color: var(--primary); color: var(--primary); }

/* Email template builder (drag-and-drop) */
.eb-bar { display: flex; gap: 1rem; flex-wrap: wrap; align-items: flex-end; }
.eb { display: grid; grid-template-columns: 178px minmax(0, 1fr) 270px; gap: 1rem; margin-top: 1rem; align-items: start; }
.eb__side, .eb__insp { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem; }
.eb-side-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); font-weight: 700; margin-bottom: .5rem; }
.eb-palette { display: grid; gap: .4rem; }
.eb-pal { display: flex; align-items: center; gap: .5rem; padding: .5rem .6rem; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; cursor: grab; font-size: .85rem; font-weight: 600; user-select: none; }
.eb-pal:hover { border-color: var(--primary); color: var(--primary); }
.eb-pal__ic { display: grid; place-items: center; color: var(--text-muted); }
.eb-pal:hover .eb-pal__ic { color: var(--primary); }
.eb-tags { display: flex; flex-wrap: wrap; gap: .3rem; }
.eb-tag { font-size: .72rem; font-family: ui-monospace, Consolas, monospace; padding: .2rem .4rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); cursor: pointer; }
.eb-tag:hover { border-color: var(--primary); color: var(--primary); }
.eb__canvas { background: #eef2f7; border: 1px solid var(--border); border-radius: var(--radius); padding: 1.2rem; min-height: 360px; }
[data-theme="dark"] .eb__canvas { background: #0b1220; }
.eb-canvas { max-width: 600px; margin: 0 auto; background: #fff; border-radius: 10px; padding: 18px; min-height: 320px; box-shadow: 0 2px 14px rgba(0,0,0,.1); }
.eb-empty { border: 2px dashed #cbd5e1; border-radius: 10px; padding: 2.4rem 1rem; text-align: center; color: #94a3b8; font-size: .9rem; }
.eb-item { position: relative; border: 1px solid transparent; border-radius: 8px; margin-bottom: .35rem; }
.eb-item:hover { border-color: #cbd5e1; }
.eb-item.is-selected { border-color: var(--primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 25%, transparent); }
.eb-item.is-dragging { opacity: .45; }
.eb-item__bar { display: flex; align-items: center; gap: .4rem; padding: .15rem .35rem; opacity: 0; transition: opacity .12s; }
.eb-item:hover .eb-item__bar, .eb-item.is-selected .eb-item__bar { opacity: 1; }
.eb-item__grip { cursor: grab; color: #94a3b8; display: grid; }
.eb-item__type { font-size: .66rem; text-transform: uppercase; letter-spacing: .04em; color: #94a3b8; font-weight: 700; flex: 1; }
.eb-item__del { border: none; background: none; color: #94a3b8; cursor: pointer; display: grid; padding: 0; }
.eb-item__del:hover { color: #dc2626; }
.eb-item__body { padding: .1rem .35rem .5rem; cursor: pointer; }
.eb-ph { border: 1px dashed #cbd5e1; border-radius: 8px; padding: .7rem; text-align: center; color: #64748b; font-size: .82rem; background: #f8fafc; }
.eb-ph .muted { color: #94a3b8; }
.eb-spacer { border: 1px dashed #cbd5e1; border-radius: 6px; display: grid; place-items: center; color: #94a3b8; font-size: .72rem; background: repeating-linear-gradient(45deg, #f8fafc, #f8fafc 6px, #fff 6px, #fff 12px); }
.eb-drop-line { height: 3px; background: var(--primary); border-radius: 3px; margin: .15rem 0; }
.eb-canvas.is-drop { outline: 2px dashed var(--primary); outline-offset: 4px; }
.eb-f { margin-bottom: .6rem; }
.eb-f > label { display: block; font-size: .76rem; font-weight: 600; color: var(--text-muted); margin-bottom: .2rem; }
.eb-f textarea, .eb-f input[type="text"], .eb-f select { width: 100%; }
.eb-f textarea { font-family: ui-monospace, Consolas, monospace; font-size: .82rem; min-height: 0; }
.eb-f input[type="range"] { width: 100%; }
.eb-imgfield { display: flex; gap: .4rem; align-items: center; }
.eb-imgfield > input { flex: 1; min-width: 0; }
.eb-imgfield .eb-imgpick { flex: none; white-space: nowrap; }
.eb-insp-head { font-weight: 800; font-size: .95rem; margin-bottom: .6rem; }
.eb-insp-empty { color: var(--text-muted); font-size: .85rem; }
.eb-seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.eb-seg button { border: none; background: var(--surface); color: var(--text); padding: .3rem .6rem; cursor: pointer; font-size: .78rem; text-transform: capitalize; }
.eb-seg button + button { border-left: 1px solid var(--border); }
.eb-seg button.is-on { background: var(--primary); color: #fff; }
@media (max-width: 1100px) { .eb { grid-template-columns: 1fr; } }

/* Social account inputs (icon + url + open-in-new-tab) */
.social-input { display: flex; align-items: stretch; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); overflow: hidden; }
.social-input:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
.social-input__icon { display: grid; place-items: center; width: 44px; flex: none; border-right: 1px solid var(--border); background: var(--surface-2); }
.social-input input { border: 0 !important; box-shadow: none !important; border-radius: 0 !important; background: transparent !important; color: var(--text); flex: 1; min-width: 0; height: var(--control-h, 42px); }
.social-input input::placeholder { color: var(--text-muted); }

/* Payment gateway cards — equal height, bottom-aligned test button + brand icon */
.pay-gateway { height: 100%; border: 1px solid var(--border); }
.pay-gateway .card__body { height: 100%; display: flex; flex-direction: column; }
.pay-gateway__head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: .5rem; }
.pay-gateway__logo { display: inline-grid; place-items: center; flex: none; }
.pay-gateway__logo svg { width: 26px; height: 26px; }
.pay-gateway__note { font-size: .8rem; margin: 0 0 .8rem; }
.pay-gateway__fields { display: flex; flex-direction: column; }
.pay-gateway__foot { margin-top: auto; padding-top: .9rem; }
.pay-gateway__hint { font-size: .74rem; margin: .45rem 0 0; }
.social-input__open { display: grid; place-items: center; width: 42px; flex: none; color: var(--text-muted); border-left: 1px solid var(--border); }
.social-input__open:hover { color: var(--primary); background: var(--surface-2); }
.social-input__icon--facebook { color: #1877f2; }
.social-input__icon--instagram { color: #e4405f; }
.social-input__icon--twitter { color: var(--text); }
.social-input__icon--tiktok { color: var(--text); }
.social-input__icon--linkedin { color: #0a66c2; }
.social-input__icon--youtube { color: #ff0000; }
.social-input__icon--whatsapp { color: #25d366; }

/* =====================================================================
   Live chat — storefront widget + shared message bubbles
   ===================================================================== */
.lc-widget { position: fixed; right: 20px; bottom: 20px; z-index: 90; }
.lc-bubble { position: relative; width: 58px; height: 58px; border-radius: 50%; border: 0; cursor: pointer; background: var(--primary, #4f46e5); color: #fff; display: grid; place-items: center; box-shadow: 0 10px 28px rgba(15,23,42,.28); transition: transform .15s; }
.lc-bubble:hover { transform: scale(1.06); }
.lc-bubble__dot { position: absolute; top: 4px; right: 4px; width: 13px; height: 13px; border-radius: 50%; background: #ef4444; box-shadow: 0 0 0 2px #fff; }
.lc-panel { position: absolute; right: 0; bottom: 72px; width: 340px; max-width: calc(100vw - 40px); height: 460px; max-height: calc(100vh - 120px); background: var(--surface, #fff); border: 1px solid var(--border, #e2e8f0); border-radius: 16px; box-shadow: 0 18px 44px rgba(15,23,42,.24); display: flex; flex-direction: column; overflow: hidden; }
.lc-panel__head { display: flex; align-items: center; justify-content: space-between; padding: .9rem 1rem; background: var(--primary, #4f46e5); color: #fff; }
.lc-panel__head strong { display: block; font-size: .95rem; }
.lc-panel__head span { font-size: .76rem; opacity: .85; }
.lc-panel__close { background: none; border: 0; color: #fff; font-size: 1.5rem; line-height: 1; cursor: pointer; opacity: .9; }
.lc-panel__body { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .6rem; background: var(--surface-2, #f8fafc); }
.lc-intro p { font-size: .88rem; color: var(--text-muted, #64748b); margin: 0 0 .7rem; }
.lc-fields { display: flex; flex-direction: column; gap: .5rem; }
.lc-fields input { width: 100%; }
.lc-msg { display: flex; flex-direction: column; max-width: 82%; }
.lc-msg--me { align-self: flex-end; align-items: flex-end; }
.lc-msg--agent { align-self: flex-start; align-items: flex-start; }
.lc-msg__bubble { padding: .55rem .8rem; border-radius: 13px; font-size: .88rem; line-height: 1.45; }
.lc-msg--me .lc-msg__bubble { background: var(--primary, #4f46e5); color: #fff; border-bottom-right-radius: 4px; }
.lc-msg--agent .lc-msg__bubble { background: var(--surface, #fff); border: 1px solid var(--border, #e2e8f0); color: var(--text, #0f172a); border-bottom-left-radius: 4px; }
.lc-msg__time { font-size: .68rem; color: var(--text-muted, #94a3b8); margin-top: .15rem; }
.lc-panel__input { display: flex; gap: .5rem; padding: .7rem; border-top: 1px solid var(--border, #e2e8f0); background: var(--surface, #fff); }
.lc-panel__input input { flex: 1; }
.lc-panel__input button { flex: none; width: 42px; border: 0; border-radius: 10px; background: var(--primary, #4f46e5); color: #fff; cursor: pointer; display: grid; place-items: center; }

/* Live chat — staff inbox */
.chat-admin { display: grid; grid-template-columns: 320px 1fr; gap: 1rem; height: calc(100vh - 190px); min-height: 440px; }
.chat-admin__list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow-y: auto; padding: .4rem; }
.chat-admin__empty { padding: 2rem 1rem; text-align: center; color: var(--text-muted); }
.chat-conv { display: flex; align-items: center; gap: .65rem; width: 100%; text-align: left; border: 0; background: none; cursor: pointer; padding: .65rem; border-radius: 11px; color: var(--text); }
.chat-conv:hover { background: var(--surface-2); }
.chat-conv.is-active { background: color-mix(in srgb, var(--primary) 12%, transparent); }
.chat-conv.is-unread { font-weight: 600; }
.chat-conv__avatar { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: .78rem; color: #fff; background: linear-gradient(135deg, var(--primary), var(--secondary)); }
.chat-conv__main { flex: 1; min-width: 0; }
.chat-conv__top { display: flex; justify-content: space-between; gap: .5rem; }
.chat-conv__top strong { font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-conv__time { font-size: .72rem; color: var(--text-muted); flex: none; }
.chat-conv__preview { font-size: .8rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-conv__badge { flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: #ef4444; color: #fff; font-size: .72rem; font-weight: 800; display: grid; place-items: center; }
.chat-admin__thread { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); display: flex; flex-direction: column; overflow: hidden; }
.chat-admin__placeholder { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .8rem; color: var(--text-muted); }
.chat-thread { display: flex; flex-direction: column; height: 100%; }
.chat-thread__head { padding: .9rem 1.1rem; border-bottom: 1px solid var(--border); }
.chat-thread__head .muted { font-size: .82rem; }
.chat-thread__body { flex: 1; overflow-y: auto; padding: 1.1rem; display: flex; flex-direction: column; gap: .55rem; background: var(--surface-2); }
.chat-thread__input { display: flex; gap: .5rem; padding: .8rem; border-top: 1px solid var(--border); }
.chat-thread__input input { flex: 1; }
.chat-ai-btn { display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; flex: none; }
.pay-demo-btn { display: inline-flex; align-items: center; gap: .35rem; }
.chat-ai-btn svg { color: var(--primary); }
.chat-ai-btn.is-loading { opacity: .65; }
.chat-ai-btn.is-loading svg { animation: rm-spin .8s linear infinite; }
@keyframes rm-spin { to { transform: rotate(360deg); } }
@media (max-width: 768px) {
    .chat-admin { grid-template-columns: 1fr; height: auto; }
    .chat-admin__list { max-height: 240px; }
    .chat-admin__thread { min-height: 420px; }
    .chat-ai-btn span { display: none; }
}

/* Website builder — template picker */
.tpl-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.tpl-card { display: block; cursor: pointer; border: 2px solid var(--border); border-radius: 14px; padding: .75rem; transition: border-color .15s, box-shadow .15s; }
.tpl-card:hover { border-color: color-mix(in srgb, var(--primary) 50%, var(--border)); }
.tpl-card.is-active { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 16%, transparent); }
.tpl-card:has(input:checked) { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 16%, transparent); }
.tpl-card input { position: absolute; opacity: 0; pointer-events: none; }
.tpl-card__preview { display: block; height: 96px; border-radius: 9px; overflow: hidden; background: var(--surface-2); padding: 10px; }
.tpl-card__preview span { display: block; border-radius: 4px; background: var(--border); margin-bottom: 6px; }
.tpl-card__preview span:nth-child(1) { height: 26px; background: color-mix(in srgb, var(--primary) 40%, var(--border)); }
.tpl-card__preview span:nth-child(2) { height: 10px; width: 70%; }
.tpl-card__preview span:nth-child(3) { height: 10px; width: 45%; }
.tpl-card__preview--bold span:nth-child(1) { height: 40px; background: var(--sidebar, #0f172a); }
.tpl-card__preview--minimal { padding: 10px 10px 10px 14px; }
.tpl-card__preview--minimal span { margin-left: 0; }
.tpl-card__preview--minimal span:nth-child(1) { width: 55%; }
.tpl-card__label { display: block; text-align: center; font-weight: 700; margin-top: .6rem; }
@media (max-width: 768px) { .tpl-grid { grid-template-columns: 1fr; } }

/* =====================================================================
   Drag-and-drop website builder (admin)
   ===================================================================== */
.bld { display: grid; grid-template-columns: 220px minmax(0, 1fr) 320px; gap: 1rem; align-items: start; }
.bld__col { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1rem; box-shadow: var(--shadow-sm); position: sticky; top: 84px; max-height: calc(100vh - 100px); overflow-y: auto; }
.bld__h { margin: 0 0 .6rem; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.bld__h:not(:first-child) { margin-top: 1.2rem; }

.bld-palette { display: grid; gap: .5rem; }
.bld-palette__item { display: flex; align-items: center; gap: .55rem; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); cursor: grab; font-weight: 600; font-size: .88rem; color: var(--text); text-align: left; }
.bld-palette__item:hover { border-color: var(--primary); }
.bld-palette__item:active { cursor: grabbing; }
.bld-palette__ic { display: inline-flex; align-items: center; justify-content: center; color: var(--primary); flex: none; }
.bld-palette__ic svg { width: 18px; height: 18px; }

.bld-templates { display: grid; gap: .45rem; }
.bld-tpl { display: flex; align-items: center; gap: .55rem; padding: .5rem .6rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer; font-weight: 600; font-size: .88rem; color: var(--text); }
.bld-tpl:hover { border-color: var(--primary); }
.bld-tpl__swatch { width: 26px; height: 26px; border-radius: 7px; flex: none; }

.bld__canvas-wrap { min-width: 0; }
.bld-devicebar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; }
.bld-seg { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.bld-seg__btn { border: none; background: var(--surface); padding: .4rem .7rem; cursor: pointer; color: var(--text-muted); display: inline-flex; align-items: center; }
.bld-seg__btn svg { width: 18px; height: 18px; }
.bld-seg__btn.is-active { background: var(--primary); color: #fff; }
.bld-canvas-scroll { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; background: var(--surface-2); }
.bld-canvas.sb-site { min-height: 560px; height: auto; max-width: 1280px; margin: 0 auto; transition: max-width .42s cubic-bezier(.4, 0, .2, 1); }
.bld-canvas.sb-site.bld-canvas--mobile { max-width: 414px; margin: 0 auto; box-shadow: 0 0 0 1px var(--border); }
.bld-rows { min-height: 520px; }
.bld-empty { width: 100%; text-align: center; padding: 4rem 1rem; border: 2px dashed color-mix(in srgb, var(--sb-text, #fff) 28%, transparent); border-radius: 14px; color: color-mix(in srgb, var(--sb-text, #fff) 65%, transparent); }

.bld-item { position: relative; box-sizing: border-box; min-width: 0; border: 2px solid transparent; border-radius: 12px; cursor: pointer; transition: border-color .12s, flex-basis .26s cubic-bezier(.4, 0, .2, 1), max-width .26s cubic-bezier(.4, 0, .2, 1), margin .26s cubic-bezier(.4, 0, .2, 1); }
.bld-item:hover { border-color: color-mix(in srgb, var(--sb-accent, #6366f1) 55%, transparent); }
.bld-item.is-selected { border-color: var(--sb-accent, #6366f1); }
.bld-item.is-dragging { opacity: .4; }
.bld-item.drop-into { box-shadow: -4px 0 0 0 var(--sb-accent, #6366f1); }
.bld-item__body { pointer-events: none; }
/* Columns block: let nested items receive clicks/drag while content stays inert */
.bld-item--columns > .bld-item__body { pointer-events: auto; }
.bld-cols { display: grid; gap: 1rem; width: 100%; }
.bld-col { border: 1.5px dashed color-mix(in srgb, var(--sb-text, #fff) 22%, transparent); border-radius: 10px; min-height: 96px; padding: .45rem; transition: border-color .12s, background .12s; }
.bld-col.drop-into { border-color: var(--sb-accent, #6366f1); background: color-mix(in srgb, var(--sb-accent, #6366f1) 12%, transparent); box-shadow: none; }
.bld-col__rows { display: flex; flex-wrap: wrap; gap: .8rem; min-height: 44px; align-content: flex-start; }
.bld-col__empty { text-align: center; color: color-mix(in srgb, var(--sb-text, #fff) 55%, transparent); font-size: .76rem; padding: .9rem .5rem; pointer-events: none; }
.bld-item__bar { position: absolute; top: -13px; left: 8px; z-index: 4; display: none; align-items: center; gap: .3rem; padding: .15rem .35rem; background: #111827; color: #fff; border-radius: 7px; font-size: .72rem; box-shadow: 0 3px 10px rgba(0,0,0,.3); }
.bld-item:hover .bld-item__bar, .bld-item.is-selected .bld-item__bar { display: inline-flex; }
.bld-item__grip { cursor: grab; }
.bld-item__type { font-weight: 700; }
.bld-item__w { opacity: .7; }
.bld-item__act { border: none; background: rgba(255,255,255,.14); color: #fff; width: 20px; height: 20px; border-radius: 5px; cursor: pointer; font-size: .72rem; line-height: 1; display: grid; place-items: center; }
.bld-item__act:hover { background: rgba(255,255,255,.28); }
.bld-item__act--del:hover { background: #dc2626; }
.bld-item__grip svg, .bld-item__act svg { display: block; }
.bld-item__resize { position: absolute; top: 0; right: -3px; width: 10px; height: 100%; cursor: ew-resize; z-index: 3; }
.bld-item__resize::after { content: ""; position: absolute; top: 50%; right: 4px; transform: translateY(-50%); width: 4px; height: 34px; border-radius: 3px; background: var(--sb-accent, #6366f1); opacity: 0; transition: opacity .12s; }
.bld-item:hover .bld-item__resize::after, .bld-item.is-selected .bld-item__resize::after { opacity: .9; }
body.bld-resizing { user-select: none; cursor: ew-resize; }

/* Inspector */
.bld__inspector .bld-inspector__empty { color: var(--text-muted); font-size: .9rem; line-height: 1.6; }
.bld-insp__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; padding-bottom: .6rem; border-bottom: 1px solid var(--border); }
.bld-insp__close { border: 1px solid var(--border); background: var(--surface-2); border-radius: 8px; padding: .25rem .6rem; cursor: pointer; font-weight: 600; font-size: .8rem; color: var(--text); }
.bld-field { margin-bottom: .85rem; }
.bld-field > label { display: block; font-weight: 600; font-size: .82rem; margin-bottom: .3rem; }
.bld-in { width: 100%; }
.bld-in[type="range"] { padding: 0; }
.bld-in[type="color"], .bld-color { height: 38px; padding: .15rem; cursor: pointer; }
.bld-rangeval { font-size: .8rem; color: var(--text-muted); margin-left: .4rem; }
.bld-hint { display: block; color: var(--text-muted); font-size: .76rem; margin-top: .25rem; }
.bld-wseg { display: grid; grid-template-columns: repeat(6, 1fr); gap: .25rem; }
.bld-posseg { grid-template-columns: repeat(3, 1fr); }
.bld-wseg__b { border: 1px solid var(--border); background: var(--surface-2); border-radius: 7px; padding: .35rem 0; cursor: pointer; font-size: .74rem; font-weight: 700; color: var(--text); }
.bld-wseg__b.is-active { background: var(--primary); border-color: var(--primary); }
.bld-rep-list { display: grid; gap: .4rem; margin-bottom: .5rem; }
.bld-rep-row { display: flex; gap: .3rem; align-items: center; }
.bld-rep-row input { flex: 1; min-width: 0; }
.bld-rep, .bld-list { width: 100%; }
.bld-rep-del { border: none; background: color-mix(in srgb, #dc2626 14%, transparent); color: #dc2626; width: 26px; height: 32px; border-radius: 7px; cursor: pointer; flex: none; display: grid; place-items: center; }
.bld-rep-pick { border: 1px solid var(--border); background: var(--surface-2); color: var(--text-muted); width: 30px; height: 32px; border-radius: 7px; cursor: pointer; flex: none; display: grid; place-items: center; }
.bld-rep-pick:hover { color: var(--primary); border-color: var(--primary); }
.bld-imgfield { display: flex; gap: .4rem; }
.bld-imgfield > input { flex: 1; min-width: 0; }
.bld-imgfield .bld-imgpick { flex: none; }
.bld-checks { display: grid; gap: .35rem; }
.bld-check { display: flex; align-items: center; gap: .5rem; font-size: .85rem; cursor: pointer; }
.bld-check input { width: 16px; height: 16px; flex: none; }
.bld-insp__section { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 700; margin: 1.1rem 0 .5rem; padding-top: .8rem; border-top: 1px solid var(--border); }
.bld-insp__section:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.bld-site-check { margin: .45rem 0; }
.bld-prod-chips { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .45rem; }
.bld-prod-chips:empty { display: none; }
.bld-prod-chip { display: inline-flex; align-items: center; gap: .3rem; background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--text); border-radius: 999px; padding: .2rem .35rem .2rem .6rem; font-size: .78rem; max-width: 100%; }
.bld-prod-rm { border: none; background: none; color: var(--text-muted); cursor: pointer; font-size: 1rem; line-height: 1; padding: 0 .1rem; }
.bld-prod-rm:hover { color: #dc2626; }
.bld-prod-pick { position: relative; }
.bld-prod-search { width: 100%; height: 36px; }
.bld-prod-sugg { max-height: 240px; overflow-y: auto; }

/* Builder: palette search, history, copy-link, dirty save, nicer repeaters */
.bld-palette-search { width: 100%; height: 36px; margin-bottom: .6rem; }
.bld-palette__empty { grid-column: 1 / -1; color: var(--text-muted); font-size: .85rem; padding: .5rem; text-align: center; }
.bld-undo { display: inline-flex; gap: .15rem; }
.bld-undo .btn-icon { font-size: 1.15rem; line-height: 1; }
.bld-copy { display: flex; gap: .4rem; }
.bld-copy input { flex: 1; min-width: 0; }
#bldSave.is-dirty { box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 32%, transparent); }
.bld-rep-row { background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: .4rem; gap: .35rem; flex-wrap: wrap; }
.bld-rep-row input { background: var(--surface); }
.bld-rep-row input[placeholder="Icon"] { flex: 0 0 46px; text-align: center; }

/* =====================================================================
   Customisable dashboard widgets
   ===================================================================== */
.dash-grid { position: relative; min-height: 120px; }
.dash-widget { position: absolute; left: calc(var(--dx, 0) * 1%); top: calc(var(--dy, 0) * 1px); width: calc(var(--dw, 50) * 1%); height: calc(var(--dh, 300) * 1px); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.dash-widget--plain { background: transparent; border: 0; box-shadow: none; }
.dash-widget__bar { display: none; align-items: center; gap: .5rem; padding: .45rem .6rem; background: var(--surface-2); border-bottom: 1px solid var(--border); font-size: .82rem; flex: none; position: relative; z-index: 3; }
.dash-grid.is-editing .dash-widget__bar, .dash-tray .dash-widget__bar { display: flex; }
.dash-grid.is-editing .dash-widget { outline: 2px dashed color-mix(in srgb, var(--primary) 40%, transparent); outline-offset: 2px; }
.dash-grid.is-editing .dash-widget__bar { cursor: grab; touch-action: none; }
.dash-grid.is-editing .dash-widget--plain { background: var(--surface); border: 1px solid var(--border); }
.dash-widget__handle { cursor: grab; color: var(--text-muted); flex: none; }
.dash-widget__title { font-weight: 700; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-widget__size { flex: none; white-space: nowrap; font-size: .72rem; font-weight: 700; color: var(--text-muted); background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: .08rem .4rem; text-align: center; font-variant-numeric: tabular-nums; }
.dash-widget.is-resizing .dash-widget__size { background: var(--primary); border-color: var(--primary); color: #fff; }
.dash-widget__act { flex: none; border: 1px solid var(--border); background: var(--surface); border-radius: 6px; padding: .15rem .45rem; cursor: pointer; font-size: .75rem; font-weight: 700; color: var(--text); white-space: nowrap; }
.dash-widget__act:hover { border-color: var(--primary); color: var(--primary); }
.dash-widget.is-dragging { opacity: .5; cursor: grabbing; box-shadow: var(--shadow-lg, 0 18px 44px rgba(15,23,42,.3)); outline-color: var(--primary) !important; }

/* Drag-to-resize handles (edit mode only) */
.dash-widget__resize { position: absolute; display: none; z-index: 2; touch-action: none; }
.dash-grid.is-editing .dash-widget__resize { display: block; }
.dash-widget__resize--e { top: 0; bottom: 0; right: 0; width: 11px; cursor: ew-resize; }
.dash-widget__resize--s { left: 0; right: 0; bottom: 0; height: 11px; cursor: ns-resize; }
.dash-widget__resize--se { right: 0; bottom: 0; width: 20px; height: 20px; z-index: 4; cursor: nwse-resize; }
.dash-widget__resize--e:hover { box-shadow: inset -3px 0 0 color-mix(in srgb, var(--primary) 70%, transparent); }
.dash-widget__resize--s:hover { box-shadow: inset 0 -3px 0 color-mix(in srgb, var(--primary) 70%, transparent); }
.dash-widget__resize--se::after { content: ""; position: absolute; right: 4px; bottom: 4px; width: 9px; height: 9px; border-right: 2px solid var(--text-muted); border-bottom: 2px solid var(--text-muted); border-bottom-right-radius: 3px; }
.dash-widget__resize--se:hover::after { border-color: var(--primary); }
.dash-widget.is-resizing { outline: 2px solid var(--primary) !important; box-shadow: var(--shadow-lg, 0 18px 44px rgba(15,23,42,.3)); z-index: 5; }
body.dash-resizing, body.dash-resizing * { cursor: nwse-resize !important; user-select: none !important; }
body.dash-moving, body.dash-moving * { cursor: grabbing !important; user-select: none !important; }
.dash-guide { position: absolute; z-index: 6; pointer-events: none; background: var(--primary); display: none; }
.dash-guide--v { top: 0; bottom: 0; width: 2px; margin-left: -1px; }
.dash-guide--h { left: 0; right: 0; height: 2px; margin-top: -1px; }

/* Widget content fills the (resizable) height; long content scrolls inside */
.dash-widget__body { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.dash-widget__body > .dash-card__head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: 1rem 1.1rem; border-bottom: 1px solid var(--border); flex: 0 0 auto; }
.dash-widget__body > .dash-card__head h3 { margin: 0; font-size: 1.02rem; }
.dash-widget__body > .dash-card__body { padding: 1.1rem; flex: 1 1 auto; min-height: 0; overflow: auto; }
.dash-widget__body > .dash-card__body.tight { padding: 0; }
.dash-widget__body > .dash-card__body.tight table { margin: 0; }
.dash-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.dash-widget--plain .dash-widget__body > .stat { flex: 1 1 auto; }
.dash-stat-tile { height: 100%; padding: .85rem 1.15rem; display: flex; flex-direction: column; justify-content: center; }
.dash-stat-tile .stat__icon { width: 36px; height: 36px; margin-bottom: .45rem; }
.dash-stat-tile .stat__icon svg { width: 19px; height: 19px; }
.dash-stat-tile .stat__value { font-size: 1.45rem; }

.dash-tray { margin-top: 1.5rem; background: var(--surface-2); border: 1px dashed var(--border); border-radius: var(--radius-lg); padding: 1rem; }
.dash-tray__head { font-size: .85rem; color: var(--text-muted); margin-bottom: .8rem; }
.dash-tray__items { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .8rem; }
.dash-tray .dash-widget { position: static; left: auto; top: auto; width: auto; height: auto; min-width: 0; }
.dash-tray .dash-widget__body { max-height: 180px; overflow: hidden; opacity: .7; pointer-events: none; -webkit-mask-image: linear-gradient(#000 60%, transparent); mask-image: linear-gradient(#000 60%, transparent); }
.dash-tray .dash-widget__body > .dash-card__body { overflow: hidden; }

.dash-links { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .8rem; }
.dash-link { display: inline-flex; align-items: center; gap: .4rem; padding: .4rem .7rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); text-decoration: none; color: var(--text); font-weight: 600; font-size: .85rem; }
.dash-link:hover { border-color: var(--primary); }
.dash-link__rm { display: none; border: none; background: none; color: var(--text-muted); cursor: pointer; font-size: .8rem; padding: 0; align-items: center; }
.dash-grid.is-editing .dash-link__rm { display: inline-flex; }
.dash-link__rm:hover { color: #dc2626; }
.dash-links__add { display: none; gap: .4rem; flex-wrap: wrap; }
.dash-grid.is-editing .dash-links__add { display: flex; }
.dash-links__add input { flex: 1; min-width: 120px; }
.dash-notes { display: grid; gap: .6rem; }
.dash-note { display: flex; align-items: center; gap: .7rem; padding: .7rem .9rem; border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; color: var(--text); }
.dash-note:hover { border-color: var(--primary); }
.dash-note__n { display: grid; place-items: center; min-width: 34px; height: 34px; padding: 0 .4rem; border-radius: 9px; background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary); font-weight: 800; }
.dash-note__ic { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary); flex: none; }
.dash-note__ic svg { width: 18px; height: 18px; }
.dash-note__txt { flex: 1; min-width: 0; font-weight: 600; font-size: .9rem; }
.dash-note.tone-warn .dash-note__ic, .dash-note.tone-warn .dash-note__n { background: rgba(245,158,11,.16); color: #b45309; }
.dash-note.tone-info .dash-note__ic, .dash-note.tone-info .dash-note__n { background: rgba(14,165,233,.14); color: #0284c7; }
.dash-note.tone-accent .dash-note__ic, .dash-note.tone-accent .dash-note__n { background: rgba(139,92,246,.16); color: #7c3aed; }
.dash-links__add select { flex: 1; min-width: 120px; }
/* Income chart fills its (resizable) widget height */
.dash-widget[data-key="income_chart"] .dash-widget__body > .dash-card__body { overflow: hidden; display: flex; }
.dash-chart { position: relative; flex: 1 1 auto; height: 100%; min-height: 150px; width: 100%; }
.dash-chart canvas { position: absolute; inset: 0; }
/* Upcoming events widget */
.dash-events { display: flex; flex-direction: column; }
.dash-event { display: flex; align-items: center; gap: .7rem; padding: .55rem .9rem; text-decoration: none; color: var(--text); border-bottom: 1px solid var(--border); }
.dash-event:last-child { border-bottom: 0; }
.dash-event:hover { background: var(--surface-2); }
.dash-event__date { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 10px; background: color-mix(in srgb, var(--c, #6366f1) 15%, transparent); color: var(--c, #6366f1); flex: none; line-height: 1; }
.dash-event__d { font-size: 1.05rem; font-weight: 800; }
.dash-event__m { font-size: .62rem; text-transform: uppercase; font-weight: 700; }
.dash-event__body { min-width: 0; display: flex; flex-direction: column; }
.dash-event__title { font-weight: 600; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-event__time { font-size: .76rem; }
.dash-leavebal { margin-top: .7rem; }
.dash-leavebal__row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: .35rem; }

@media (max-width: 760px) {
    .dash-grid { height: auto !important; }
    .dash-grid .dash-widget { position: static !important; left: auto !important; top: auto !important; width: 100% !important; margin-bottom: 1rem; }
    .dash-guide { display: none !important; }
}

/* Builder: move-up/down (touch reorder) + inspector sheet are mobile-only */
.bld-item__act--move { display: none; }
.bld-insp-backdrop { display: none; }
.bld-insp__sheet-close { display: none; }
@media (max-width: 1100px) {
    .bld { grid-template-columns: 1fr; }
    .bld__col { position: static; max-height: none; }
    /* Palette becomes a horizontal, swipeable strip so it doesn't eat the screen */
    .bld__palette .bld-palette { grid-auto-flow: column; grid-auto-columns: minmax(140px, 1fr); grid-template-columns: none; overflow-x: auto; padding-bottom: .4rem; }
    .bld-templates { grid-auto-flow: column; grid-auto-columns: minmax(150px, 1fr); overflow-x: auto; padding-bottom: .4rem; }
    .bld-item__act--move { display: inline-flex; }
    /* Inspector becomes a dismissible bottom sheet */
    .bld__inspector { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1201; max-height: 82vh; overflow-y: auto; border-radius: 18px 18px 0 0; transform: translateY(105vh); transition: transform .28s cubic-bezier(.2,.8,.2,1); box-shadow: 0 -12px 44px rgba(15,23,42,.3); }
    .bld__inspector::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--border); margin: 0 auto .7rem; }
    body.bld-insp-open .bld__inspector { transform: translateY(0); }
    .bld-insp-backdrop { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 1200; opacity: 0; pointer-events: none; transition: opacity .28s; }
    body.bld-insp-open .bld-insp-backdrop { opacity: 1; pointer-events: auto; }
    .bld-insp__sheet-close { display: inline-flex; }
}
@media (max-width: 600px) {
    .bld-devicebar { flex-wrap: wrap; }
    .bld-canvas.sb-site.bld-canvas--mobile { max-width: 320px; }
}

/* =====================================================================
   Email client + Contacts
   ===================================================================== */
.mail { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 1rem; align-items: start; }
.mail__side { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: .75rem; box-shadow: var(--shadow-sm); }
.mailbox-nav { display: grid; gap: .15rem; }
.mailbox-link { display: flex; align-items: center; gap: .6rem; padding: .55rem .7rem; border-radius: 10px; color: var(--text); text-decoration: none; font-weight: 600; font-size: .9rem; }
.mailbox-link:hover { background: var(--surface-2); }
.mailbox-link.is-active { background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary); }
.mailbox-link__icon { display: inline-flex; align-items: center; justify-content: center; width: 1.4rem; color: var(--text-muted); }
.mailbox-link.is-active .mailbox-link__icon { color: var(--primary); }
.mailbox-link__icon--star { color: #f59e0b; }
.mailbox-link__label { flex: 1; min-width: 0; }
.mailbox-link__badge { background: var(--primary); color: #fff; font-size: .72rem; font-weight: 700; padding: 0 .4rem; height: 18px; line-height: 18px; border-radius: 9px; }
.mailbox-link__count { color: var(--text-muted); font-size: .78rem; }
.mail__folders { margin-top: .8rem; border-top: 1px solid var(--border); padding-top: .7rem; }
.mail__folders-head { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); padding: 0 .7rem .4rem; }
.mail__folder-add { display: flex; gap: .3rem; margin-top: .4rem; }
.mail__folder-add input { flex: 1; min-width: 0; height: 34px; }

.mail__main { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.mail__search { padding: .7rem; border-bottom: 1px solid var(--border); }
.mail__search input { width: 100%; }
.mail-list { display: flex; flex-direction: column; }
.mail-row { display: grid; grid-template-columns: 24px 180px minmax(0, 1fr) auto; align-items: center; gap: .7rem; padding: .7rem .9rem; border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text); }
.mail-row:hover { background: var(--surface-2); }
.mail-row.is-unread { background: color-mix(in srgb, var(--primary) 6%, transparent); }
.mail-row.is-unread .mail-row__who, .mail-row.is-unread .mail-row__subject strong { font-weight: 800; }
.mail-row__star { color: var(--border); display: inline-flex; align-items: center; }
.mail-row__star.is-on { color: #f59e0b; }
.mail-row__who { font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-row__count { color: var(--text-muted); font-weight: 600; }
.mail-row__subject { min-width: 0; display: flex; gap: .5rem; align-items: baseline; overflow: hidden; }
.mail-row__subject strong { white-space: nowrap; }
.mail-row__preview { color: var(--text-muted); font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-row__meta { display: flex; align-items: center; gap: .5rem; color: var(--text-muted); font-size: .82rem; white-space: nowrap; }

/* Compose modal + reply composer recipient pills */
.mail-compose { max-width: 640px; }
.mail-compose__form { padding: 1.1rem 1.35rem 1.35rem; }
.mail-recipients { position: relative; display: grid; grid-template-columns: 56px 1fr; align-items: start; gap: .6rem; margin-bottom: .55rem; }
.mail-recipients__label { font-size: .82rem; font-weight: 700; color: var(--text-muted); padding-top: .55rem; }
.mail-recipients__field { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; min-height: var(--control-h); padding: .25rem .4rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.mail-recipients__field:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent); }
.mail-recipients__input { flex: 1; min-width: 120px; border: 0 !important; background: transparent !important; padding: .3rem .2rem !important; height: auto !important; box-shadow: none !important; outline: none; }
.mail-recipients--subject { align-items: center; }
.mail-subject-input { width: 100%; }
.mail-pill { display: inline-flex; align-items: center; gap: .25rem; background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--text); border-radius: 999px; padding: .2rem .25rem .2rem .6rem; font-size: .82rem; max-width: 100%; }
.mail-pill__txt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.mail-pill__x { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border: 0; border-radius: 50%; background: transparent; color: var(--text-muted); cursor: pointer; }
.mail-pill__x:hover { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }
.mail-compose__foot { display: flex; align-items: center; gap: .6rem; margin-top: .4rem; }
.mail-attach { cursor: pointer; }
.mail-attach__names { font-size: .8rem; }
/* styled close button (compose / composer / AI panel) */
.mail-x { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border: 0; border-radius: 8px; background: var(--surface-2); color: var(--text-muted); cursor: pointer; transition: background .15s, color .15s; }
.mail-x:hover { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
/* attachment previews while composing */
.mail-attach-previews { display: flex; flex-wrap: wrap; gap: .5rem; margin: .2rem 0 .2rem; }
.mail-att-prev { display: inline-flex; align-items: center; gap: .5rem; padding: .35rem .6rem .35rem .35rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); font-size: .8rem; max-width: 220px; }
.mail-att-prev img { width: 38px; height: 38px; border-radius: 7px; object-fit: cover; }
.mail-att-prev__ic { display: inline-flex; width: 38px; height: 38px; align-items: center; justify-content: center; color: var(--text-muted); }
.mail-att-prev__name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Conversation */
.mail-thread-actions { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.mail-thread-actions__primary { display: flex; gap: .4rem; flex-wrap: wrap; }
.mail-thread-actions__spacer { flex: 1; min-width: .5rem; }
.mail-iform { display: inline-flex; margin: 0; }
.mail-thread-actions .btn svg, .mail-composer .btn svg { vertical-align: -3px; }
.mail-move-menu { position: relative; }
.mail-move-menu > summary { list-style: none; cursor: pointer; }
.mail-move-menu > summary::-webkit-details-marker { display: none; }
.mail-move-menu__panel { position: absolute; right: 0; top: calc(100% + .35rem); z-index: 60; min-width: 210px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: .4rem; }
.mail-move-menu__title { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); padding: .3rem .5rem .4rem; }
.mail-move-menu__opt { display: flex; align-items: center; gap: .5rem; width: 100%; text-align: left; border: 0; background: none; cursor: pointer; color: var(--text); font: inherit; padding: .5rem .55rem; border-radius: 8px; }
.mail-move-menu__opt:hover { background: var(--surface-2); }
.mail-move-menu__opt svg { color: var(--text-muted); }
/* slide-in reply / forward composer */
.mail-composer { background: var(--surface); border: 1px solid color-mix(in srgb, var(--primary) 30%, var(--border)); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); margin-bottom: 1rem; max-height: 0; opacity: 0; overflow: hidden; transition: max-height .28s ease, opacity .2s ease; }
.mail-composer.is-open { max-height: 1600px; opacity: 1; }
.mail-composer__head { display: flex; align-items: center; justify-content: space-between; padding: .7rem 1.1rem; border-bottom: 1px solid var(--border); }
.mail-composer form { padding: .9rem 1.1rem 1.1rem; }
.mail-composer textarea { width: 100%; }
.mail-composer__foot { display: flex; align-items: center; gap: .6rem; margin-top: .7rem; }
.mail-composer__spacer { flex: 1; }
.mail-conv { display: flex; flex-direction: column; gap: .8rem; }
.mail-msg { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.1rem 1.25rem; box-shadow: var(--shadow-sm); }
.mail-msg--out { border-left: 3px solid var(--primary); }
.mail-msg__head { display: grid; grid-template-columns: auto 1fr auto; gap: .8rem; align-items: start; margin-bottom: .7rem; }
.mail-msg__avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--primary) 16%, transparent); color: var(--primary); font-weight: 800; font-size: .85rem; }
.mail-msg__meta { min-width: 0; line-height: 1.4; }
.mail-msg__to { font-size: .82rem; }
.mail-msg__body { line-height: 1.65; white-space: normal; }
.mail-msg__atts { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .9rem; padding-top: .8rem; border-top: 1px dashed var(--border); }
.mail-att { display: inline-flex; align-items: center; gap: .45rem; padding: .4rem .7rem; border: 1px solid var(--border); border-radius: 10px; text-decoration: none; color: var(--text); background: var(--surface-2); font-size: .85rem; }
.mail-att:hover { border-color: var(--primary); }
.mail-att__icon { display: inline-flex; color: var(--text-muted); }
.mail-att__size { font-size: .76rem; }
/* image attachment thumbnails in a message */
.mail-att--img { flex-direction: column; gap: .3rem; padding: .4rem; cursor: pointer; width: 120px; }
.mail-att--img img { width: 100%; height: 84px; object-fit: cover; border-radius: 7px; }
.mail-att--img .mail-att__cap { font-size: .74rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
/* fullscreen image lightbox */
.mail-lightbox { position: fixed; inset: 0; z-index: 2000; background: rgba(15,23,42,.82); display: none; align-items: center; justify-content: center; padding: 2rem; }
.mail-lightbox.open { display: flex; }
.mail-lightbox figure { margin: 0; max-width: 90vw; max-height: 90vh; display: flex; flex-direction: column; gap: .5rem; align-items: center; }
.mail-lightbox img { max-width: 90vw; max-height: 82vh; border-radius: 10px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.mail-lightbox figcaption { color: #fff; font-size: .85rem; }
.mail-lightbox__close { position: absolute; top: 1rem; right: 1rem; width: 40px; height: 40px; border: 0; border-radius: 50%; background: rgba(255,255,255,.15); color: #fff; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.mail-lightbox__close:hover { background: rgba(255,255,255,.3); }

/* AI panel */
.mail-ai-panel { background: var(--surface); border: 1px solid color-mix(in srgb, var(--primary) 35%, var(--border)); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); margin-bottom: 1rem; overflow: hidden; }
.mail-ai-panel__head { display: flex; align-items: center; justify-content: space-between; padding: .8rem 1.1rem; background: color-mix(in srgb, var(--primary) 8%, transparent); border-bottom: 1px solid var(--border); }
.mail-ai-panel__body { padding: 1.1rem; }
.mail-ai-loading { color: var(--text-muted); }
.mail-ai-label { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin-bottom: .35rem; }
.mail-ai-summary { margin-bottom: 1rem; }
.mail-ai-summary p { margin: 0; line-height: 1.6; }
.mail-ai-suggestions { display: grid; gap: .6rem; }
.mail-ai-sugg { display: flex; gap: .7rem; align-items: flex-start; text-align: left; padding: .8rem 1rem; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); cursor: pointer; color: var(--text); line-height: 1.5; transition: border-color .15s; }
.mail-ai-sugg:hover { border-color: var(--primary); }
.mail-ai-sugg__n { flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .78rem; }

@media (max-width: 820px) {
    .mail { grid-template-columns: 1fr; }
    .mail-row { grid-template-columns: 20px 1fr auto; }
    .mail-row__who { grid-column: 2; }
    .mail-row__subject { grid-column: 1 / -1; }
}

/* =====================================================================
   Media library + universal image picker
   ===================================================================== */
.media-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.media-tabs .seg__btn { display: inline-flex; align-items: center; gap: .4rem; padding: .45rem .9rem; border: 0; background: none; border-radius: 9px; cursor: pointer; color: var(--text-muted); font-weight: 600; font-size: .88rem; text-decoration: none; }
.media-tabs .seg__btn.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.media-tabs__n { font-size: .72rem; background: color-mix(in srgb, var(--text-muted) 18%, transparent); padding: 0 .4rem; border-radius: 8px; }
.media-search input { min-width: 220px; }
.media-drop { position: relative; border: 2px dashed var(--border); border-radius: var(--radius-lg); background: var(--surface); padding: 1.6rem; text-align: center; cursor: pointer; transition: border-color .15s, background .15s; margin-bottom: 1.2rem; }
.media-drop.is-over { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 7%, transparent); }
.media-drop__inner { display: flex; flex-direction: column; align-items: center; gap: .35rem; color: var(--text-muted); pointer-events: none; }
.media-drop__inner strong { color: var(--text); font-size: 1rem; }
.media-drop__inner .link-btn { pointer-events: auto; }
.link-btn { border: 0; background: none; color: var(--primary); cursor: pointer; font: inherit; text-decoration: underline; padding: 0; }
.media-drop__progress { margin-top: .8rem; color: var(--primary); font-weight: 600; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 1rem; }
.media-empty { grid-column: 1 / -1; }
.media-tile { margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); position: relative; }
.media-tile__thumb { position: relative; aspect-ratio: 4 / 3; background: var(--surface-2); display: grid; place-items: center; overflow: hidden; }
.media-tile__thumb img, .media-tile__thumb video { width: 100%; height: 100%; object-fit: cover; }
.media-tile__play { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; background: rgba(0,0,0,.25); }
.media-tile__cap { padding: .55rem .7rem .1rem; font-size: .82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-tile__meta { padding: 0 .7rem .6rem; font-size: .74rem; color: var(--text-muted); }
.media-tile__actions { position: absolute; top: .4rem; right: .4rem; display: flex; gap: .3rem; opacity: 0; transition: opacity .15s; }
.media-tile:hover .media-tile__actions { opacity: 1; }
.media-tile__btn { width: 28px; height: 28px; border: 0; border-radius: 7px; background: rgba(15,23,42,.62); color: #fff; cursor: pointer; display: grid; place-items: center; }
.media-tile__btn:hover { background: rgba(15,23,42,.85); }
.media-tile__btn--del:hover { background: #dc2626; }

.rm-imgpick__box { max-width: 720px; width: 92vw; }
.rm-imgpick__tabs { display: flex; gap: .3rem; padding: .6rem 1.1rem 0; border-bottom: 1px solid var(--border); }
.rm-imgpick__tab { border: 0; background: none; padding: .55rem .8rem; border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; color: var(--text-muted); font-weight: 600; font-size: .88rem; }
.rm-imgpick__tab.is-active { color: var(--primary); border-bottom-color: var(--primary); }
.rm-imgpick__panel { padding: 1.1rem; }
.rm-imgpick__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .7rem; max-height: 52vh; overflow-y: auto; }
.rm-imgpick__empty { grid-column: 1 / -1; padding: 2rem; text-align: center; }
.rm-imgpick__cell { padding: 0; border: 2px solid var(--border); border-radius: 10px; overflow: hidden; cursor: pointer; aspect-ratio: 1; background: var(--surface-2); }
.rm-imgpick__cell:hover { border-color: var(--primary); }
.rm-imgpick__cell img, .rm-imgpick__cell video { width: 100%; height: 100%; object-fit: cover; display: block; }
.rm-imgpick__drop { border: 2px dashed var(--border); border-radius: var(--radius); padding: 2.4rem 1rem; text-align: center; cursor: pointer; display: flex; flex-direction: column; gap: .3rem; align-items: center; }
.rm-imgpick__drop.is-over { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 7%, transparent); }
.rm-imgpick__lbl { display: block; font-weight: 600; margin-bottom: .4rem; }
.rm-imgpick__panel input[type="url"] { width: 100%; }
.rm-imgpick__foot { margin-top: .8rem; display: flex; justify-content: flex-end; }
.img-pick { display: flex; gap: .4rem; align-items: stretch; }
.img-pick > input { flex: 1; min-width: 0; }
.img-pick__btn { flex: none; }

/* =====================================================================
   Calendar
   ===================================================================== */
.cal-head-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.cal-syncbar { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.cal-sync-chip { display: inline-flex; align-items: center; gap: .4rem; font-size: .84rem; color: var(--text-muted); padding: .3rem .7rem; border: 1px solid var(--border); border-radius: 999px; }
.cal-sync-chip.is-on { color: var(--text); border-color: color-mix(in srgb, var(--primary) 30%, var(--border)); }
.cal-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.cal-sync-last { font-size: .8rem; margin-left: auto; }
.cal-toolbar { display: flex; align-items: center; gap: .5rem; margin-bottom: .8rem; }
.cal-month-label { font-size: 1.1rem; margin: 0 0 0 .5rem; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.cal-dow { background: var(--surface-2); padding: .5rem; text-align: center; font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.cal-cell { background: var(--surface); min-height: 110px; padding: .35rem; display: flex; flex-direction: column; gap: .25rem; }
.cal-cell.is-other { background: var(--surface-2); }
.cal-cell.is-other .cal-cell__num { color: var(--text-muted); opacity: .55; }
.cal-cell.is-today { box-shadow: inset 0 0 0 2px var(--primary); }
.cal-cell.drop-target { background: color-mix(in srgb, var(--primary) 12%, transparent); }
.cal-cell__top { display: flex; align-items: center; justify-content: space-between; }
.cal-cell__num { font-size: .82rem; font-weight: 700; padding: .1rem .35rem; }
.cal-cell.is-today .cal-cell__num { background: var(--primary); color: #fff; border-radius: 50%; min-width: 22px; height: 22px; display: grid; place-items: center; padding: 0; }
.cal-cell__add { opacity: 0; border: 0; background: none; color: var(--text-muted); cursor: pointer; border-radius: 6px; width: 22px; height: 22px; display: grid; place-items: center; transition: opacity .12s; }
.cal-cell:hover .cal-cell__add { opacity: 1; }
.cal-cell__add:hover { background: var(--surface-2); color: var(--primary); }
.cal-cell__events { display: flex; flex-direction: column; gap: .2rem; overflow: hidden; }
.cal-event { display: flex; align-items: center; gap: .3rem; width: 100%; text-align: left; border: 0; cursor: pointer; border-radius: 6px; padding: .18rem .4rem; font-size: .76rem; color: #fff; background: var(--c, #6366f1); border-left: 3px solid rgba(0,0,0,.22); }
.cal-event:hover { filter: brightness(1.06); }
.cal-event.dragging { opacity: .45; }
.cal-event__time { font-weight: 700; opacity: .95; }
.cal-event__title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.cal-event__src { font-size: .62rem; background: rgba(255,255,255,.32); border-radius: 4px; padding: 0 .25rem; font-weight: 700; }
.cal-event.is-synced { cursor: default; }
/* event modal */
.cal-modal, .cal-move-modal, .cal-connect-modal { max-width: 540px; }
.cal-modal form, .cal-move-modal .cal-move__body, .cal-connect-modal form { padding: 1.1rem 1.35rem; }
.cal-allday { margin: .2rem 0 .8rem; }
.cal-colors { display: flex; gap: .4rem; flex-wrap: wrap; }
.cal-color { width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.cal-color.is-active { border-color: var(--text); box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text); }
.cal-modal__foot { display: flex; align-items: center; gap: .6rem; padding: 1rem 1.35rem 1.2rem; border-top: 1px solid var(--border); }
.cal-move__msg { margin: 0 0 1rem; line-height: 1.5; }
.cal-move__opt { display: flex; align-items: center; gap: .55rem; padding: .6rem .7rem; border: 1px solid var(--border); border-radius: 10px; margin-bottom: .5rem; cursor: pointer; }
.cal-move__opt input[type="time"] { margin-left: .3rem; }
.cal-connect__hint { font-size: .85rem; line-height: 1.5; margin-bottom: 1rem; }
.cal-connect-modal label .cal-dot { margin-right: .3rem; }
@media (max-width: 720px) {
    .cal-cell { min-height: 76px; padding: .25rem; }
    .cal-event__time { display: none; }
    .cal-event { padding: .16rem .3rem; font-size: .68rem; }
    .cal-dow { font-size: .62rem; padding: .35rem .1rem; }
}
.cal-modal__foot { padding: 1rem 1.35rem 1.2rem; }

/* =====================================================================
   Leave management
   ===================================================================== */
.stat-card__label { font-size: .8rem; color: var(--text-muted); font-weight: 600; }
.stat-card__value { font-size: 1.5rem; font-weight: 800; margin-top: .15rem; }
.stat-card__sub { font-size: .78rem; margin-top: .1rem; }
.leave-tabs { margin-bottom: 1rem; }
.leave-tabs__n { background: var(--primary); color: #fff; font-size: .7rem; font-weight: 700; padding: 0 .35rem; border-radius: 7px; margin-left: .35rem; }
.leave-balance { margin-bottom: .6rem; }
.leave-bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.leave-bar__fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--secondary)); }
.leave-accrual { display: inline-flex; align-items: center; gap: .45rem; margin-top: .7rem; font-size: .85rem; color: var(--text-muted); }
.leave-accrual svg { color: var(--primary); flex: none; }
.leave-accrual strong { color: var(--text); }
.leave-review { border: 1px solid var(--border); border-radius: 12px; padding: 1rem; margin-bottom: .8rem; }
.leave-review:last-child { margin-bottom: 0; }
.leave-review__who { display: flex; align-items: center; gap: .5rem; margin-bottom: .4rem; }
.leave-review__detail { display: flex; gap: .8rem; flex-wrap: wrap; align-items: center; font-size: .9rem; }
.leave-review__type { font-weight: 600; }
.leave-review__reason { margin: .5rem 0 0; font-style: italic; color: var(--text-muted); }
.leave-review__form { display: flex; gap: .5rem; margin-top: .8rem; flex-wrap: wrap; }
.leave-review__note { flex: 1; min-width: 180px; }
.leave-days-note { font-size: .85rem; color: var(--primary); font-weight: 600; margin-bottom: .8rem; }
.leave-days-note.is-bad { color: #dc2626; }
.leave-bytype__row { display: flex; gap: .6rem; align-items: baseline; padding: .4rem 0; border-bottom: 1px solid var(--border); }
.leave-bytype__row:last-child { border-bottom: 0; }
.leave-modal { max-width: 520px; }
.leave-modal form { padding: 1.1rem 1.35rem 1.2rem; }
.leave-modal__foot { display: flex; align-items: center; gap: .6rem; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }

/* =====================================================================
   New modules: sub-categories, scanning, stock takes, labels, requests
   ===================================================================== */

/* Sub-category indent marker in the categories tree */
.cat-indent { color: var(--text-muted); margin-right: .35rem; }

/* Callouts (info banners on detail pages) */
.callout { border: 1px solid var(--border); border-left: 4px solid var(--text-muted); background: var(--surface-2); border-radius: 10px; padding: .8rem 1rem; margin-bottom: 1rem; font-size: .92rem; }
.callout--success { border-left-color: #16a34a; background: color-mix(in srgb, #16a34a 8%, transparent); }
.callout--muted { border-left-color: var(--text-muted); }

/* Activity / notes timeline (custom requests) */
.activity { list-style: none; margin: 0; padding: 0; }
.activity__item { padding: .65rem 0; border-bottom: 1px solid var(--border); }
.activity__item:last-child { border-bottom: 0; }
.activity__body { white-space: pre-wrap; }
.activity__meta { font-size: .78rem; margin-top: .2rem; }

/* Scan-to-add highlight + stock-take variance colours */
.st-flash { animation: stFlash 0.7s ease; }
@keyframes stFlash { 0% { background: color-mix(in srgb, var(--primary) 28%, transparent); } 100% { background: transparent; } }
.st-over { color: #16a34a; font-weight: 600; }
.st-short { color: #dc2626; font-weight: 600; }
.st-scan { display: flex; align-items: center; gap: .9rem; }
.st-scan__icon { width: 48px; height: 48px; flex: none; border-radius: 12px; display: grid; place-items: center; background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); }
.st-scan__text { display: flex; flex-direction: column; }

/* Utility: hide on print / screen */
.no-print { }
@media print {
    .no-print, .sidebar, .topbar, .toast-stack { display: none !important; }
    .layout, .main, .content { display: block !important; margin: 0 !important; padding: 0 !important; }
}

/* ---- Barcode label designer ---- */
.labels-layout { display: grid; grid-template-columns: 360px 1fr; gap: 1.25rem; align-items: start; }
.labels-controls { display: flex; flex-direction: column; gap: 1rem; }
.labels-controls .card { margin: 0; }
.labels-preview { position: sticky; top: 80px; }
.lbl-preview-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: .6rem; }
.lbl-toggles { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .4rem; }
.lbl-items { display: flex; flex-direction: column; gap: .4rem; margin-top: .5rem; }
.lbl-item { display: flex; align-items: center; gap: .6rem; padding: .45rem .6rem; border: 1px solid var(--border); border-radius: 9px; }
.lbl-item__main { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.lbl-item__main strong { font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lbl-item__main .muted { font-size: .76rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lbl-item__qty { flex: 0 0 64px; width: 64px; text-align: right; }
.lbl-item__rm { flex: 0 0 auto; }
.lbl-ac { position: absolute; z-index: 40; left: 0; right: 0; top: 100%; margin-top: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-md); padding: .35rem; max-height: 280px; overflow: auto; }
.lbl-ac__row { display: flex; flex-direction: column; width: 100%; border: 0; background: none; cursor: pointer; font: inherit; text-align: left; padding: .5rem .6rem; border-radius: 8px; color: var(--text); }
.lbl-ac__row:hover { background: var(--surface-2); }
.lbl-ac__row .muted { font-size: .76rem; }

/* Print sheet of labels */
.lbl-sheet { background: #fff; color: #000; border: 1px solid var(--border); border-radius: 10px; padding: 8mm; min-height: 200px; display: flex; flex-wrap: wrap; gap: 4mm; align-content: flex-start; }
.lbl-sheet__empty { width: 100%; text-align: center; padding: 3rem 0; }
.lbl-cell { border: 1px dashed #bbb; border-radius: 4px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 2mm; overflow: hidden; }
.lbl-cell__name { font-size: 9pt; font-weight: 600; line-height: 1.1; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #000; }
.lbl-cell__bc { margin: 1mm 0; max-width: 100%; }
.lbl-cell__bc svg { max-width: 100%; height: auto; display: block; }
.lbl-cell__code { font-size: 8pt; letter-spacing: .04em; color: #000; }
.lbl-cell__price { font-size: 11pt; font-weight: 700; color: #000; }
.lbl-sheet--sm .lbl-cell { width: 38mm; height: 21mm; }
.lbl-sheet--md .lbl-cell { width: 50mm; height: 30mm; }
.lbl-sheet--lg .lbl-cell { width: 70mm; height: 40mm; }

@media (max-width: 980px) {
    .labels-layout { grid-template-columns: 1fr; }
    .labels-preview { position: static; }
}

@media print {
    body.labels-print, .labels-print .lbl-sheet { border: 0; }
    .lbl-sheet { border: 0; border-radius: 0; padding: 0; gap: 0; }
    .lbl-cell { border-color: transparent; }
    .page-head, .labels-controls, .lbl-preview-head { display: none !important; }
    .labels-layout { display: block; }
}








