/* ════════════════════════════════════════════════════════════════
   AngTinda design system
   Smart tools for smarter business.
   ════════════════════════════════════════════════════════════════ */

@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url("../fonts/inter-latin-wght-normal.woff2") format("woff2");
}

:root {
    /* Brand */
    --brand-primary: #10B981;
    --brand-primary-dark: #059669;
    --brand-primary-darker: #047857;
    --brand-secondary: #0EA5E9;
    --brand-teal: #14B8A6;
    --brand-accent: #6366F1;
    --brand-accent-2: #8B5CF6;

    --gradient-primary: linear-gradient(135deg, #10B981 0%, #059669 100%);
    --gradient-secondary: linear-gradient(135deg, #14B8A6 0%, #0EA5E9 100%);
    --gradient-accent: linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%);
    --gradient-soft: linear-gradient(135deg, rgba(16,185,129,.12) 0%, rgba(20,184,166,.06) 100%);

    /* Surfaces & text */
    --background: #F8FAFC;
    --surface: #FFFFFF;
    --surface-muted: #F8FAFC;
    --surface-sunken: #F1F5F9;
    --text-primary: #0F172A;
    --text-body: #334155;
    --text-secondary: #64748B;
    --text-tertiary: #94A3B8;
    --border: #E2E8F0;
    --border-strong: #CBD5E1;
    --border-soft: #EEF2F6;

    /* Status */
    --success: #10B981;
    --success-soft: #ECFDF5;
    --success-text: #047857;
    --warning: #F59E0B;
    --warning-soft: #FFFBEB;
    --warning-text: #B45309;
    --danger: #EF4444;
    --danger-soft: #FEF2F2;
    --danger-text: #B91C1C;
    --info: #0EA5E9;
    --info-soft: #F0F9FF;
    --info-text: #0369A1;
    --accent-soft: #EEF2FF;
    --accent-text: #4338CA;

    /* Shape */
    --radius-xs: 6px;
    --radius-sm: 8px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;
    --radius-full: 999px;

    --shadow-xs: 0 1px 2px rgba(15, 23, 42, .04);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
    --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, .08), 0 2px 4px -2px rgba(15, 23, 42, .04);
    --shadow-lg: 0 16px 40px -12px rgba(15, 23, 42, .18), 0 4px 12px -4px rgba(15, 23, 42, .06);
    --shadow-brand: 0 6px 16px -6px rgba(5, 150, 105, .55);
    --ring: 0 0 0 3px rgba(16, 185, 129, .22);
    --ring-danger: 0 0 0 3px rgba(239, 68, 68, .18);

    /* Layout */
    --sidebar-w: 264px;
    --sidebar-w-collapsed: 76px;
    --header-h: 64px;
    --control-h: 42px;
    --page-pad-x: 32px;
    --page-pad-y: 28px;

    --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --ease: cubic-bezier(.2, .8, .2, 1);
}

/* ── Reset ─────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-body);
    background: var(--background);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "cv11", "ss01";
}
h1, h2, h3, h4, h5, h6 { margin: 0; color: var(--text-primary); font-weight: 650; letter-spacing: -0.01em; line-height: 1.25; }
p { margin: 0; }
a { color: var(--brand-primary-dark); text-decoration: none; }
a:hover { color: var(--brand-primary-darker); }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
table { border-collapse: collapse; width: 100%; }
hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
:focus-visible { outline: 2px solid var(--brand-primary); outline-offset: 2px; }
::selection { background: rgba(16, 185, 129, .2); }

.icon { width: 18px; height: 18px; flex-shrink: 0; vertical-align: middle; }
.icon-xs { width: 13px; height: 13px; }
.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 22px; height: 22px; }
.icon-xl { width: 28px; height: 28px; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* ── Brand mark ────────────────────────────────────────────── */

.brand { display: flex; align-items: center; gap: 10px; color: var(--text-primary); }
.brand:hover { color: var(--text-primary); }
.brand-mark { width: 34px; height: 34px; flex-shrink: 0; filter: drop-shadow(0 4px 8px rgba(5,150,105,.28)); }
.brand-word { font-size: 17px; font-weight: 800; letter-spacing: .02em; line-height: 1; white-space: nowrap; }
.brand-word span { background: var(--gradient-primary); -webkit-background-clip: text; background-clip: text; color: transparent; }

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

.app { min-height: 100vh; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 40;
    transition: width .22s var(--ease), transform .25s var(--ease);
}
.sidebar-head { height: var(--header-h); display: flex; align-items: center; justify-content: space-between; padding: 0 18px 0 20px; flex-shrink: 0; }
.sidebar-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 8px 12px 16px; scrollbar-width: thin; }
.nav-section { margin-top: 18px; padding: 0 12px 6px; font-size: 11px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--text-tertiary); white-space: nowrap; }
.nav-link {
    position: relative;
    display: flex; align-items: center; gap: 12px;
    height: 40px; padding: 0 12px; margin: 2px 0;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-weight: 550; font-size: 14px;
    white-space: nowrap;
    transition: background .15s, color .15s;
}
.nav-link .icon { width: 19px; height: 19px; color: var(--text-tertiary); transition: color .15s; }
.nav-link:hover { background: var(--surface-sunken); color: var(--text-primary); }
.nav-link:hover .icon { color: var(--text-secondary); }
.nav-link.is-active {
    background: linear-gradient(90deg, rgba(16,185,129,.13), rgba(20,184,166,.06));
    color: var(--brand-primary-darker);
    box-shadow: inset 0 0 0 1px rgba(16,185,129,.14), 0 4px 14px -8px rgba(16,185,129,.55);
}
.nav-link.is-active .icon { color: var(--brand-primary-dark); }
.nav-link.is-active::before {
    content: ""; position: absolute; left: -12px; top: 9px; bottom: 9px; width: 3px;
    border-radius: 0 3px 3px 0; background: var(--gradient-primary);
}
.nav-link .nav-badge { margin-left: auto; font-size: 11px; font-weight: 650; padding: 1px 7px; border-radius: var(--radius-full); background: var(--danger-soft); color: var(--danger-text); }

.sidebar-foot { padding: 12px; border-top: 1px solid var(--border-soft); flex-shrink: 0; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius); min-width: 0; }
.user-chip:hover { background: var(--surface-sunken); }
.user-chip-text { min-width: 0; flex: 1; }
.user-chip-name { font-size: 13.5px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip-role { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; transition: margin-left .22s var(--ease); min-width: 0; }

/* Collapsed sidebar (desktop) */
@media (min-width: 1024px) {
    .sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
    .sidebar-collapsed .main { margin-left: var(--sidebar-w-collapsed); }
    .sidebar-collapsed .brand-word,
    .sidebar-collapsed .nav-link span,
    .sidebar-collapsed .nav-badge,
    .sidebar-collapsed .user-chip-text,
    .sidebar-collapsed .sidebar-foot .logout-btn,
    .sidebar-collapsed .sidebar-head .sidebar-close { display: none; }
    .sidebar-collapsed .nav-section { font-size: 0; padding: 0; margin: 14px 12px 8px; border-top: 1px solid var(--border-soft); }
    .sidebar-collapsed .sidebar-head { justify-content: center; padding: 0; }
    .sidebar-collapsed .nav-link { justify-content: center; padding: 0; }
    .sidebar-collapsed .user-chip { justify-content: center; }
    .sidebar-collapsed .sidebar-foot-row { flex-direction: column; }
}

.sidebar-foot-row { display: flex; align-items: center; gap: 4px; }

/* Topbar */
.topbar {
    position: sticky; top: 0; z-index: 30;
    height: var(--header-h);
    display: flex; align-items: center; gap: 16px;
    padding: 0 var(--page-pad-x);
    background: rgba(255, 255, 255, .88);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--border);
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.topbar-titles { min-width: 0; }
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-tertiary); white-space: nowrap; overflow: hidden; }
.breadcrumb a { color: var(--text-secondary); }
.breadcrumb a:hover { color: var(--text-primary); }
.breadcrumb .icon { width: 12px; height: 12px; }
.topbar-title { font-size: 15px; font-weight: 650; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

.global-search { position: relative; width: 340px; }
.global-search .form-control { padding-left: 38px; padding-right: 52px; background: var(--surface-muted); height: 40px; }
.global-search .form-control:focus { background: var(--surface); }
.global-search > .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-tertiary); pointer-events: none; }
.kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: 11px; font-weight: 600; color: var(--text-tertiary); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; background: var(--surface); pointer-events: none; }
.search-results { position: absolute; top: calc(100% + 8px); left: 0; right: 0; min-width: 320px; max-height: 420px; overflow-y: auto; }
.search-group { padding: 8px 0; }
.search-group + .search-group { border-top: 1px solid var(--border-soft); }
.search-group-title { padding: 4px 14px; font-size: 11px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--text-tertiary); }

.icon-btn {
    position: relative;
    width: 40px; height: 40px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid transparent; border-radius: var(--radius);
    background: transparent; color: var(--text-secondary);
    transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { background: var(--surface-sunken); color: var(--text-primary); }
.icon-btn .dot { position: absolute; top: 9px; right: 10px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 2px var(--surface); }

.mobile-only { display: none !important; }

/* Page */
.page { padding: var(--page-pad-y) var(--page-pad-x) 48px; width: 100%; max-width: 1600px; margin: 0 auto; flex: 1; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-title { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.page-subtitle { margin-top: 4px; color: var(--text-secondary); font-size: 14.5px; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.app-footer { padding: 18px var(--page-pad-x); font-size: 12px; color: var(--text-tertiary); display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ── Grid helpers ──────────────────────────────────────────── */

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main-side { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid-side-main { grid-template-columns: minmax(280px, 1fr) minmax(0, 2.4fr); }
.span-2 { grid-column: span 2; }
.stack { display: flex; flex-direction: column; gap: 20px; }
.stack-sm { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; min-width: 0; }
.mt-0 { margin-top: 0 !important; } .mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-5 { margin-top: 24px; } .mt-6 { margin-top: 32px; }
.mb-0 { margin-bottom: 0 !important; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; } .mb-5 { margin-bottom: 24px; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.w-full { width: 100%; }

.text-muted { color: var(--text-secondary); }
.text-faint { color: var(--text-tertiary); }
.text-primary { color: var(--text-primary); }
.text-success { color: var(--success-text); }
.text-danger { color: var(--danger-text); }
.text-warning { color: var(--warning-text); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.text-lg { font-size: 16px; }
.fw-500 { font-weight: 500; } .fw-600 { font-weight: 600; } .fw-700 { font-weight: 700; }
.tabular { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }

/* ── Cards ─────────────────────────────────────────────────── */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    min-width: 0;
}
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px 0; flex-wrap: wrap; }
.card-header.bordered { padding-bottom: 16px; border-bottom: 1px solid var(--border-soft); }
.card-title { font-size: 15px; font-weight: 650; color: var(--text-primary); display: flex; align-items: center; gap: 8px; }
.card-subtitle { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.card-body { padding: 18px 22px 22px; }
.card-footer { padding: 14px 22px; border-top: 1px solid var(--border-soft); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card-link { font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.card-flush .card-body { padding: 0; }

/* KPI cards */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }
.kpi {
    position: relative; overflow: hidden;
    padding: 20px 22px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    transition: box-shadow .2s, transform .2s;
}
.kpi::after {
    content: ""; position: absolute; right: -40px; top: -40px; width: 140px; height: 140px; border-radius: 50%;
    background: radial-gradient(circle, var(--kpi-glow, rgba(16,185,129,.10)) 0%, transparent 70%);
    pointer-events: none;
}
.kpi:hover { box-shadow: var(--shadow-md); }
.kpi-top { display: flex; align-items: center; gap: 12px; }
.kpi-icon { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; flex-shrink: 0; background: var(--success-soft); color: var(--brand-primary-dark); }
.kpi-icon .icon { width: 20px; height: 20px; }
.kpi-label { font-size: 13.5px; font-weight: 550; color: var(--text-secondary); }
.kpi-value { margin-top: 14px; font-size: 28px; font-weight: 700; letter-spacing: -0.025em; color: var(--text-primary); font-variant-numeric: tabular-nums; line-height: 1.15; white-space: nowrap; }
.kpi-value small { font-size: 15px; font-weight: 600; color: var(--text-secondary); margin-left: 2px; }
.kpi-foot { margin-top: 10px; display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-secondary); min-height: 20px; flex-wrap: wrap; }
.kpi-spark { position: absolute; right: 18px; bottom: 18px; width: 92px; height: 34px; opacity: .95; pointer-events: none; }
.kpi-spark canvas { width: 100% !important; height: 100% !important; }
.kpi .kpi-value, .kpi .kpi-foot { position: relative; z-index: 1; }
.kpi:has(.kpi-spark) .kpi-foot { padding-right: 96px; }
.kpi.tone-teal { --kpi-glow: rgba(14,165,233,.10); } .kpi.tone-teal .kpi-icon { background: var(--info-soft); color: var(--info-text); }
.kpi.tone-violet { --kpi-glow: rgba(99,102,241,.10); } .kpi.tone-violet .kpi-icon { background: var(--accent-soft); color: var(--accent-text); }
.kpi.tone-amber { --kpi-glow: rgba(245,158,11,.10); } .kpi.tone-amber .kpi-icon { background: var(--warning-soft); color: var(--warning-text); }
.kpi.tone-rose { --kpi-glow: rgba(239,68,68,.08); } .kpi.tone-rose .kpi-icon { background: var(--danger-soft); color: var(--danger-text); }
.kpi.tone-slate { --kpi-glow: rgba(100,116,139,.08); } .kpi.tone-slate .kpi-icon { background: var(--surface-sunken); color: var(--text-secondary); }
.kpi-featured { background: linear-gradient(145deg, #0B3B2E 0%, #065F46 55%, #047857 100%); border-color: transparent; box-shadow: var(--shadow-brand); }
.kpi-featured::after { --kpi-glow: rgba(52,211,153,.35); }
.kpi-featured .kpi-label, .kpi-featured .kpi-foot { color: rgba(236, 253, 245, .78); }
.kpi-featured .kpi-value { color: #fff; }
.kpi-featured .kpi-icon { background: rgba(255,255,255,.14); color: #A7F3D0; }
.kpi-featured .trend-up { background: rgba(167, 243, 208, .16); color: #A7F3D0; }
.kpi-featured .trend-down { background: rgba(254, 202, 202, .16); color: #FECACA; }
.kpi-featured .trend-flat { background: rgba(255,255,255,.12); color: #E2E8F0; }

.trend { display: inline-flex; align-items: center; gap: 3px; padding: 2px 8px 2px 6px; border-radius: var(--radius-full); font-size: 12px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.trend-up { background: var(--success-soft); color: var(--success-text); }
.trend-down { background: var(--danger-soft); color: var(--danger-text); }
.trend-flat { background: var(--surface-sunken); color: var(--text-secondary); }
.trend-suffix { font-weight: 500; opacity: .8; }

/* Compact stat rows inside cards */
.stat-list { display: flex; flex-direction: column; }
.stat-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border-soft); min-width: 0; }
.stat-item:last-child { border-bottom: 0; padding-bottom: 0; }
.stat-item:first-child { padding-top: 0; }
.stat-item-main { flex: 1; min-width: 0; }
.stat-item-title { font-weight: 600; color: var(--text-primary); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-item-sub { font-size: 12.5px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-item-value { font-weight: 650; color: var(--text-primary); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.rank { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--surface-sunken); color: var(--text-secondary); flex-shrink: 0; }
.rank.r1 { background: var(--gradient-primary); color: #fff; }

.progress { height: 6px; background: var(--surface-sunken); border-radius: var(--radius-full); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--gradient-primary); }
.progress.warning > span { background: linear-gradient(90deg, #FBBF24, #F59E0B); }
.progress.danger > span { background: linear-gradient(90deg, #F87171, #EF4444); }

/* Summary strip (financial figures in a row) */
.summary-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); overflow: hidden; }
.summary-strip > div { padding: 16px 20px; border-right: 1px solid var(--border-soft); }
.summary-strip > div:last-child { border-right: 0; }
.summary-strip .label { font-size: 12.5px; color: var(--text-secondary); font-weight: 550; }
.summary-strip .value { margin-top: 4px; font-size: 19px; font-weight: 700; color: var(--text-primary); font-variant-numeric: tabular-nums; }

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

.btn {
    --btn-h: var(--control-h);
    position: relative;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: var(--btn-h); padding: 0 16px;
    border: 1px solid transparent; border-radius: var(--radius);
    font-size: 14px; font-weight: 600; line-height: 1; white-space: nowrap;
    text-decoration: none; user-select: none;
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .05s, filter .15s;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn .icon { width: 17px; height: 17px; }
.btn[disabled], .btn.is-disabled { opacity: .55; pointer-events: none; }

.btn-primary { background: var(--gradient-primary); color: #fff; box-shadow: 0 1px 2px rgba(5,150,105,.3), inset 0 1px 0 rgba(255,255,255,.18); }
.btn-primary:hover { color: #fff; filter: brightness(1.05) saturate(1.05); box-shadow: var(--shadow-brand), inset 0 1px 0 rgba(255,255,255,.18); }
.btn-secondary { background: var(--surface); color: var(--text-primary); border-color: var(--border); box-shadow: var(--shadow-xs); }
.btn-secondary:hover { background: var(--surface-muted); border-color: var(--border-strong); color: var(--text-primary); }
.btn-danger { background: var(--danger-soft); color: var(--danger-text); border-color: #FECACA; }
.btn-danger:hover { background: #FEE2E2; color: #991B1B; }
.btn-danger-solid { background: var(--danger); color: #fff; }
.btn-danger-solid:hover { background: #DC2626; color: #fff; }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--surface-sunken); color: var(--text-primary); }
.btn-accent { background: var(--gradient-accent); color: #fff; }
.btn-accent:hover { color: #fff; filter: brightness(1.06); }

.btn-sm { --btn-h: 34px; padding: 0 12px; font-size: 13px; border-radius: var(--radius-sm); }
.btn-sm .icon { width: 15px; height: 15px; }
.btn-lg { --btn-h: 50px; padding: 0 22px; font-size: 15px; border-radius: 12px; }
.btn-xl { --btn-h: 56px; padding: 0 24px; font-size: 16px; border-radius: 14px; }
.btn-block { width: 100%; }
.btn-icon { width: var(--btn-h); padding: 0; }

.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading > * { visibility: hidden; }
.btn.is-loading::after {
    content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
    border: 2px solid currentColor; border-color: rgba(255,255,255,.4) rgba(255,255,255,.4) #fff #fff;
    animation: spin .7s linear infinite;
}
.btn-secondary.is-loading::after, .btn-ghost.is-loading::after, .btn-danger.is-loading::after { border-color: var(--border) var(--border) var(--brand-primary) var(--brand-primary); }
@keyframes spin { to { transform: rotate(360deg); } }

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

/* Segmented control (date filters, toggles) */
.segmented { display: inline-flex; padding: 3px; background: var(--surface-sunken); border-radius: var(--radius); gap: 2px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.segmented::-webkit-scrollbar { display: none; }
.segmented a, .segmented button, .segmented label {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 32px; padding: 0 14px; border: 0; border-radius: 8px;
    background: transparent; color: var(--text-secondary);
    font-size: 13px; font-weight: 600; white-space: nowrap; cursor: pointer;
    transition: background .15s, color .15s, box-shadow .15s;
}
.segmented a:hover, .segmented button:hover, .segmented label:hover { color: var(--text-primary); }
.segmented .is-active, .segmented input:checked + label { background: var(--surface); color: var(--text-primary); box-shadow: var(--shadow-sm); }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }

/* Underline tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { display: inline-flex; align-items: center; gap: 8px; padding: 12px 14px; margin-bottom: -1px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--text-secondary); font-weight: 600; font-size: 14px; white-space: nowrap; }
.tab:hover { color: var(--text-primary); }
.tab.is-active { color: var(--brand-primary-darker); border-bottom-color: var(--brand-primary); }
.tab .count { font-size: 11.5px; padding: 1px 7px; border-radius: var(--radius-full); background: var(--surface-sunken); color: var(--text-secondary); }
.tab-panel[hidden] { display: none; }

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

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 20px; }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.form-group { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.form-label { font-size: 13px; font-weight: 600; color: var(--text-primary); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.form-label .optional { font-weight: 500; color: var(--text-tertiary); font-size: 12px; }
.form-label .req { color: var(--danger); margin-left: 2px; }
.form-hint { font-size: 12.5px; color: var(--text-secondary); }
.form-section-title { font-size: 14px; font-weight: 650; color: var(--text-primary); margin-bottom: 4px; }
.form-section + .form-section { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--border-soft); }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; flex-wrap: wrap; }

.form-control {
    width: 100%;
    height: var(--control-h);
    padding: 0 13px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 14px;
    transition: border-color .15s, box-shadow .15s, background .15s;
    box-shadow: var(--shadow-xs);
    appearance: none;
    -webkit-appearance: none;
}
.form-control::placeholder { color: var(--text-tertiary); }
.form-control:hover { border-color: var(--border-strong); }
.form-control:focus { outline: none; border-color: var(--brand-primary); box-shadow: var(--ring); }
.form-control[readonly], .form-control:disabled { background: var(--surface-muted); color: var(--text-secondary); }
textarea.form-control { height: auto; min-height: 96px; padding: 10px 13px; resize: vertical; line-height: 1.5; }
select.form-control {
    padding-right: 36px; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center;
}
input[type="date"].form-control, input[type="time"].form-control, input[type="month"].form-control { padding-right: 10px; }
input[type="number"].form-control { font-variant-numeric: tabular-nums; }
.form-control.is-invalid { border-color: var(--danger); }
.form-control.is-invalid:focus { box-shadow: var(--ring-danger); }
.form-control-sm { height: 36px; font-size: 13px; border-radius: var(--radius-sm); }
.form-control-lg { height: 50px; font-size: 16px; border-radius: 12px; }

.field-error { display: flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--danger-text); font-weight: 500; }

.input-wrap { position: relative; }
.input-wrap > .icon, .input-wrap > .prefix { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-tertiary); pointer-events: none; }
.input-wrap > .prefix { font-weight: 600; font-size: 14px; color: var(--text-secondary); }
.input-wrap > .icon ~ .form-control, .input-wrap > .prefix ~ .form-control { padding-left: 38px; }
.input-wrap > .suffix-btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 36px; height: 34px; border: 0; background: transparent; color: var(--text-tertiary); border-radius: 8px; display: grid; place-items: center; }
.input-wrap > .suffix-btn:hover { color: var(--text-primary); background: var(--surface-sunken); }
.input-wrap > .suffix-btn ~ .form-control, .input-wrap .form-control.has-suffix { padding-right: 44px; }

.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; color: var(--text-body); user-select: none; min-height: 24px; }
.check input { appearance: none; -webkit-appearance: none; width: 18px; height: 18px; margin: 0; border: 1.5px solid var(--border-strong); border-radius: 5px; background: var(--surface); display: grid; place-items: center; transition: background .15s, border-color .15s; flex-shrink: 0; cursor: pointer; }
.check input[type="radio"] { border-radius: 50%; }
.check input::after { content: ""; width: 10px; height: 10px; transform: scale(0); transition: transform .12s; background: #fff; clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%); }
.check input[type="radio"]::after { clip-path: circle(50%); width: 8px; height: 8px; }
.check input:checked { background: var(--brand-primary); border-color: var(--brand-primary); }
.check input:checked::after { transform: scale(1); }
.check input:focus-visible { box-shadow: var(--ring); outline: none; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { appearance: none; -webkit-appearance: none; width: 38px; height: 22px; border-radius: 99px; background: var(--border-strong); margin: 0; position: relative; transition: background .2s; cursor: pointer; flex-shrink: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .2s var(--ease); }
.switch input:checked { background: var(--brand-primary); }
.switch input:checked::after { transform: translateX(16px); }

/* Option cards (payment method, report types) */
.option-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.option-card { position: relative; }
.option-card input { position: absolute; opacity: 0; pointer-events: none; }
.option-card label {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    min-height: 60px; padding: 8px 6px; border: 1.5px solid var(--border); border-radius: var(--radius);
    background: var(--surface); color: var(--text-secondary); font-size: 12.5px; font-weight: 600; text-align: center; cursor: pointer;
    transition: border-color .15s, background .15s, color .15s, box-shadow .15s;
}
.option-card label .icon { width: 20px; height: 20px; }
.option-card label:hover { border-color: var(--border-strong); color: var(--text-primary); }
.option-card input:checked + label { border-color: var(--brand-primary); background: var(--success-soft); color: var(--brand-primary-darker); box-shadow: 0 0 0 3px rgba(16,185,129,.12); }
.option-card input:focus-visible + label { box-shadow: var(--ring); }

/* Toolbar / filters */
.toolbar { display: flex; align-items: center; gap: 10px; padding: 16px 18px; flex-wrap: wrap; border-bottom: 1px solid var(--border-soft); }
.toolbar .search-input { flex: 1 1 260px; max-width: 360px; }
.toolbar .form-control { height: 38px; font-size: 13.5px; }
@media (max-width: 1023px) { .toolbar .form-control, .pos-search .form-control { font-size: 16px; } .toolbar .form-control { height: 42px; } }
.toolbar select.form-control { width: auto; min-width: 150px; }
.toolbar-spacer { flex: 1; }
.filter-chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: var(--radius-full); background: var(--success-soft); color: var(--brand-primary-darker); font-size: 12.5px; font-weight: 600; }

/* ── Tables ────────────────────────────────────────────────── */

.table-wrap { position: relative; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap.sticky { max-height: 640px; overflow-y: auto; }
.table-wrap:not(.sticky) .table th { position: static; }
.table { font-size: 13.5px; }
.table th {
    position: sticky; top: 0; z-index: 1;
    padding: 11px 16px; text-align: left; white-space: nowrap;
    font-size: 12px; font-weight: 600; color: var(--text-secondary);
    background: var(--surface-muted); border-bottom: 1px solid var(--border);
}
.table th:first-child, .table td:first-child { padding-left: 22px; }
.table th:last-child, .table td:last-child { padding-right: 22px; }
.table td { padding: 13px 16px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; color: var(--text-body); }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: #FAFCFD; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .actions { text-align: right; white-space: nowrap; width: 1%; }
.table tfoot td { padding: 13px 16px; font-weight: 700; color: var(--text-primary); background: var(--surface-muted); border-top: 1px solid var(--border); }
.table-compact td { padding: 9px 14px; }
.table-compact th { padding: 9px 14px; }
.row-link { cursor: pointer; }
.cell-main { font-weight: 600; color: var(--text-primary); }
.cell-main a { color: inherit; }
.cell-main a:hover { color: var(--brand-primary-dark); }
.cell-sub { font-size: 12.5px; color: var(--text-secondary); margin-top: 1px; }
.cell-media { display: flex; align-items: center; gap: 12px; min-width: 200px; }
.thumb { width: 40px; height: 40px; border-radius: 10px; background: var(--surface-sunken); display: grid; place-items: center; overflow: hidden; flex-shrink: 0; color: var(--text-tertiary); border: 1px solid var(--border-soft); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-lg { width: 72px; height: 72px; border-radius: 14px; }
.sort-link { display: inline-flex; align-items: center; gap: 4px; color: inherit; }
.sort-link .icon { opacity: .4; }
.sort-link.is-active { color: var(--text-primary); }
.sort-link.is-active .icon, .sort-link:hover .icon { opacity: 1; }
.amount-pos { color: var(--success-text); font-weight: 600; }
.amount-neg { color: var(--danger-text); font-weight: 600; }

/* Pagination */
.pagination-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 22px; border-top: 1px solid var(--border-soft); flex-wrap: wrap; font-size: 13px; color: var(--text-secondary); }
.pagination { display: flex; gap: 4px; align-items: center; }
.pagination a, .pagination span { min-width: 34px; height: 34px; padding: 0 8px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); font-weight: 600; font-size: 13px; color: var(--text-secondary); border: 1px solid transparent; }
.pagination a:hover { background: var(--surface-sunken); color: var(--text-primary); }
.pagination .is-active { background: var(--surface); border-color: var(--border); color: var(--text-primary); box-shadow: var(--shadow-xs); }
.pagination .is-disabled { opacity: .4; pointer-events: none; }

/* ── Badges, avatars ───────────────────────────────────────── */

.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: var(--radius-full); font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 1; }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.badge-success { background: var(--success-soft); color: var(--success-text); }
.badge-warning { background: var(--warning-soft); color: var(--warning-text); }
.badge-danger { background: var(--danger-soft); color: var(--danger-text); }
.badge-info { background: var(--info-soft); color: var(--info-text); }
.badge-neutral { background: var(--surface-sunken); color: #475569; }
.badge-accent { background: var(--accent-soft); color: var(--accent-text); }
.badge-outline { background: transparent; border: 1px solid var(--border); color: var(--text-secondary); }

.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; color: #fff; flex-shrink: 0; letter-spacing: .02em; background: var(--gradient-primary); }
.avatar-sm { width: 30px; height: 30px; font-size: 11.5px; }
.avatar-lg { width: 56px; height: 56px; font-size: 19px; }
.avatar.tone-0 { background: linear-gradient(135deg, #10B981, #059669); }
.avatar.tone-1 { background: linear-gradient(135deg, #14B8A6, #0EA5E9); }
.avatar.tone-2 { background: linear-gradient(135deg, #6366F1, #8B5CF6); }
.avatar.tone-3 { background: linear-gradient(135deg, #F59E0B, #F97316); }
.avatar.tone-4 { background: linear-gradient(135deg, #EC4899, #F43F5E); }
.avatar.tone-5 { background: linear-gradient(135deg, #64748B, #334155); }

.chip-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; background: var(--surface-sunken); color: var(--text-secondary); }
.chip-icon.success { background: var(--success-soft); color: var(--success-text); }
.chip-icon.warning { background: var(--warning-soft); color: var(--warning-text); }
.chip-icon.danger { background: var(--danger-soft); color: var(--danger-text); }
.chip-icon.info { background: var(--info-soft); color: var(--info-text); }
.chip-icon.accent { background: var(--accent-soft); color: var(--accent-text); }

.network-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }

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

.dropdown { position: relative; }
.dropdown-menu {
    position: absolute; right: 0; top: calc(100% + 8px); z-index: 50;
    min-width: 220px; padding: 6px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg);
    opacity: 0; visibility: hidden; transform: translateY(-4px) scale(.98); transform-origin: top right;
    transition: opacity .14s, transform .14s, visibility .14s;
}
.dropdown.is-open > .dropdown-menu, .dropdown-menu.is-open { opacity: 1; visibility: visible; transform: none; }
.dropdown-menu.left { right: auto; left: 0; transform-origin: top left; }
.dropdown-menu.up { top: auto; bottom: calc(100% + 8px); }
.dropdown-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: 8px; background: none; color: var(--text-body); font-size: 13.5px; font-weight: 500; text-align: left; }
.dropdown-item .icon { width: 16px; height: 16px; color: var(--text-tertiary); }
.dropdown-item:hover, .dropdown-item.is-focused { background: var(--surface-sunken); color: var(--text-primary); }
.dropdown-item.danger { color: var(--danger-text); }
.dropdown-item.danger .icon { color: var(--danger); }
.dropdown-divider { height: 1px; background: var(--border-soft); margin: 6px 0; }
.dropdown-header { padding: 10px 10px 8px; }

.notif-menu { width: 380px; padding: 0; max-width: calc(100vw - 24px); }
.notif-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border-soft); }
.notif-list { max-height: 400px; overflow-y: auto; }
.notif-item { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border-soft); color: var(--text-body); }
.notif-item:hover { background: var(--surface-muted); color: var(--text-body); }
.notif-item.unread { background: linear-gradient(90deg, rgba(16,185,129,.05), transparent); }
.notif-item .chip-icon { width: 34px; height: 34px; }
.notif-title { font-size: 13.5px; font-weight: 600; color: var(--text-primary); }
.notif-text { font-size: 12.5px; color: var(--text-secondary); margin-top: 1px; }
.notif-time { font-size: 11.5px; color: var(--text-tertiary); margin-top: 4px; }

/* ── Modals ────────────────────────────────────────────────── */

.modal {
    width: min(560px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    padding: 0; border: 0; border-radius: var(--radius-xl);
    background: var(--surface); color: var(--text-body);
    box-shadow: 0 24px 64px -16px rgba(15, 23, 42, .35);
    overflow: hidden;
}
.modal[open] { display: flex; flex-direction: column; animation: modal-in .2s var(--ease); }
.modal::backdrop { background: rgba(15, 23, 42, .45); backdrop-filter: blur(3px); }
.modal-lg { width: min(760px, calc(100vw - 32px)); }
.modal-sm { width: min(420px, calc(100vw - 32px)); }
.modal-form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 20px 24px 16px; border-bottom: 1px solid var(--border-soft); }
.modal-title { font-size: 17px; font-weight: 650; }
.modal-desc { font-size: 13.5px; color: var(--text-secondary); margin-top: 3px; }
.modal-body { padding: 20px 24px; overflow-y: auto; flex: 1; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--border-soft); background: var(--surface-muted); }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

.confirm-icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--danger-soft); color: var(--danger); margin-bottom: 14px; }

/* ── Toasts ────────────────────────────────────────────────── */

.toast-stack { position: fixed; top: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast {
    pointer-events: auto;
    display: flex; align-items: flex-start; gap: 12px;
    padding: 14px 14px 14px 16px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg);
    animation: toast-in .25s var(--ease);
    position: relative; overflow: hidden;
}
.toast::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--toast-color, var(--success)); }
.toast-icon { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; background: var(--toast-soft, var(--success-soft)); color: var(--toast-color, var(--success)); }
.toast-icon .icon { width: 15px; height: 15px; stroke-width: 2.5; }
.toast-msg { flex: 1; font-size: 13.5px; font-weight: 550; color: var(--text-primary); padding-top: 3px; }
.toast-close { border: 0; background: none; color: var(--text-tertiary); padding: 2px; border-radius: 6px; display: grid; place-items: center; }
.toast-close:hover { color: var(--text-primary); background: var(--surface-sunken); }
.toast.warning { --toast-color: var(--warning); --toast-soft: var(--warning-soft); }
.toast.error { --toast-color: var(--danger); --toast-soft: var(--danger-soft); }
.toast.info { --toast-color: var(--info); --toast-soft: var(--info-soft); }
.toast.is-leaving { animation: toast-out .2s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(16px); } }

/* Inline alerts */
.alert { display: flex; gap: 12px; padding: 13px 16px; border-radius: var(--radius); font-size: 13.5px; border: 1px solid; }
.alert .icon { margin-top: 1px; }
.alert-danger { background: var(--danger-soft); border-color: #FECACA; color: var(--danger-text); }
.alert-warning { background: var(--warning-soft); border-color: #FDE68A; color: var(--warning-text); }
.alert-info { background: var(--info-soft); border-color: #BAE6FD; color: var(--info-text); }
.alert-success { background: var(--success-soft); border-color: #A7F3D0; color: var(--success-text); }

/* ── Empty & loading states ───────────────────────────────── */

.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 56px 24px; }
.empty-state.compact { padding: 32px 16px; }
.empty-icon { width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; background: var(--gradient-soft); color: var(--brand-primary-dark); margin-bottom: 18px; box-shadow: inset 0 0 0 1px rgba(16,185,129,.15); }
.empty-icon .icon { width: 28px; height: 28px; }
.empty-state.compact .empty-icon { width: 48px; height: 48px; border-radius: 14px; margin-bottom: 12px; }
.empty-state.compact .empty-icon .icon { width: 22px; height: 22px; }
.empty-title { font-size: 16px; font-weight: 650; color: var(--text-primary); }
.empty-state.compact .empty-title { font-size: 14px; }
.empty-text { margin-top: 6px; max-width: 380px; color: var(--text-secondary); font-size: 13.5px; }
.empty-state .btn { margin-top: 20px; }

.skeleton { position: relative; overflow: hidden; background: var(--surface-sunken); border-radius: 8px; }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.65), transparent); animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }
.sk-line { height: 12px; margin: 8px 0; }
.sk-title { height: 28px; width: 55%; margin-top: 14px; }
.sk-chart { height: 260px; border-radius: 12px; }
.sk-circle { width: 40px; height: 40px; border-radius: 11px; }
.is-loaded .skeleton-only { display: none; }
.loaded-only { display: none; }
.is-loaded .loaded-only { display: block; }

.chart-box { position: relative; height: 280px; }
.chart-box.sm { height: 220px; }
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-secondary); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ── Detail page bits ──────────────────────────────────────── */

.profile-head { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.dl { display: grid; grid-template-columns: 140px 1fr; gap: 10px 16px; font-size: 13.5px; }
.dl dt { color: var(--text-secondary); }
.dl dd { margin: 0; color: var(--text-primary); font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
.balance-hero { padding: 22px; border-radius: var(--radius-lg); background: linear-gradient(145deg, #0B3B2E 0%, #065F46 60%, #047857 100%); color: #ECFDF5; position: relative; overflow: hidden; }
.balance-hero::after { content: ""; position: absolute; right: -60px; bottom: -80px; width: 220px; height: 220px; border-radius: 50%; background: radial-gradient(circle, rgba(52,211,153,.35), transparent 70%); }
.balance-hero .label { font-size: 13px; opacity: .8; font-weight: 550; }
.balance-hero .value { font-size: 34px; font-weight: 750; letter-spacing: -0.03em; color: #fff; margin-top: 6px; font-variant-numeric: tabular-nums; }
.balance-hero.clear { background: linear-gradient(145deg, #F8FAFC, #F1F5F9); color: var(--text-secondary); border: 1px solid var(--border); }
.balance-hero.clear .value { color: var(--text-primary); }
.balance-hero.clear::after { display: none; }

.timeline { position: relative; }
.timeline-item { position: relative; display: flex; gap: 14px; padding-bottom: 18px; }
.timeline-item::before { content: ""; position: absolute; left: 17px; top: 38px; bottom: 0; width: 1px; background: var(--border); }
.timeline-item:last-child::before { display: none; }

/* ── POS ───────────────────────────────────────────────────── */

.pos-page .page { padding: 0; max-width: none; }
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 400px; min-width: 0; height: calc(100vh - var(--header-h)); }
.pos-catalog { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.pos-catalog-head { padding: 20px 24px 12px; display: flex; flex-direction: column; gap: 14px; }
.pos-search { position: relative; }
.pos-search .form-control { height: 48px; padding-left: 44px; font-size: 15px; border-radius: 12px; }
.pos-search > .icon { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--text-tertiary); }
.pos-categories { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.pos-categories::-webkit-scrollbar { display: none; }
.cat-chip { flex-shrink: 0; height: 38px; padding: 0 16px; border-radius: var(--radius-full); border: 1px solid var(--border); background: var(--surface); color: var(--text-secondary); font-weight: 600; font-size: 13px; transition: all .15s; }
.cat-chip:hover { border-color: var(--border-strong); color: var(--text-primary); }
.cat-chip.is-active { background: var(--text-primary); border-color: var(--text-primary); color: #fff; }
.pos-grid { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 24px 24px; display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); grid-auto-rows: max-content; gap: 14px; align-content: start; }
.product-tile {
    position: relative; display: flex; flex-direction: column; text-align: left;
    padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface);
    box-shadow: var(--shadow-xs); transition: border-color .15s, box-shadow .15s, transform .08s; width: 100%; font: inherit; color: inherit;
}
.product-tile:hover { border-color: rgba(16,185,129,.5); box-shadow: var(--shadow-md); }
.product-tile:active { transform: scale(.98); }
.product-tile.is-out { opacity: .55; }
.product-tile-media { aspect-ratio: 4 / 3; border-radius: 10px; background: linear-gradient(145deg, var(--surface-muted), var(--surface-sunken)); display: grid; place-items: center; overflow: hidden; margin-bottom: 10px; color: var(--text-tertiary); font-weight: 700; font-size: 22px; letter-spacing: .02em; }
.product-tile-media img { width: 100%; height: 100%; object-fit: cover; }
.product-tile-name { font-size: 13.5px; font-weight: 600; color: var(--text-primary); line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 35px; }
.product-tile-foot { margin-top: 8px; display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.product-tile-price { font-weight: 700; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.product-tile-stock { font-size: 11.5px; color: var(--text-tertiary); white-space: nowrap; }
.product-tile-stock.low { color: var(--warning-text); font-weight: 600; }
.product-tile .in-cart { position: absolute; top: 8px; right: 8px; min-width: 24px; height: 24px; padding: 0 7px; border-radius: 99px; background: var(--gradient-primary); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; box-shadow: var(--shadow-brand); }

.pos-cart { display: flex; flex-direction: column; min-height: 0; background: var(--surface); border-left: 1px solid var(--border); }
.pos-cart-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border-soft); }
.pos-cart-items { flex: 1; overflow-y: auto; padding: 6px 20px; }
.cart-line { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; padding: 14px 0; border-bottom: 1px solid var(--border-soft); }
.cart-line-name { font-weight: 600; color: var(--text-primary); font-size: 13.5px; }
.cart-line-price { font-size: 12.5px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.cart-line-total { font-weight: 700; color: var(--text-primary); text-align: right; font-variant-numeric: tabular-nums; }
.qty { display: inline-flex; justify-self: start; align-items: center; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; height: 36px; }
.qty button { width: 36px; height: 100%; border: 0; background: var(--surface); color: var(--text-secondary); display: grid; place-items: center; }
.qty button:hover { background: var(--surface-sunken); color: var(--text-primary); }
.qty input { width: 50px; height: 100%; border: 0; border-left: 1px solid var(--border); border-right: 1px solid var(--border); text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; -moz-appearance: textfield; }
.qty input::-webkit-outer-spin-button, .qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.qty input:focus { outline: none; background: var(--success-soft); }
.cart-line-remove { border: 0; background: none; color: var(--text-tertiary); padding: 4px; border-radius: 6px; display: grid; place-items: center; }
.cart-line-remove:hover { color: var(--danger); background: var(--danger-soft); }
.pos-cart-foot { padding: 16px 20px 20px; border-top: 1px solid var(--border); background: var(--surface-muted); display: flex; flex-direction: column; gap: 12px; }
.totals-row { display: flex; justify-content: space-between; align-items: center; font-size: 13.5px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.totals-row strong { color: var(--text-primary); font-weight: 600; }
.grand-total { display: flex; justify-content: space-between; align-items: baseline; padding-top: 10px; border-top: 1px dashed var(--border-strong); }
.grand-total .label { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.grand-total .value { font-size: 32px; font-weight: 800; letter-spacing: -0.03em; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.discount-input { width: 120px; height: 34px; text-align: right; }
.change-display { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-radius: 10px; background: var(--success-soft); color: var(--success-text); font-weight: 600; font-variant-numeric: tabular-nums; }
.change-display.short { background: var(--danger-soft); color: var(--danger-text); }
.quick-cash { display: flex; gap: 6px; flex-wrap: wrap; }
.quick-cash button { flex: 1; min-width: 60px; height: 34px; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; font-weight: 600; font-size: 12.5px; color: var(--text-body); font-variant-numeric: tabular-nums; }
.quick-cash button:hover { border-color: var(--brand-primary); color: var(--brand-primary-darker); }
.pos-mobile-bar { display: none; }
.customer-pick { position: relative; }
/* Opens upward above the field (it sits at the bottom of the cart); top must be released or the base dropdown squeezes it flat */
.customer-results { position: absolute; left: 0; right: 0; top: auto; bottom: calc(100% + 6px); z-index: 20; min-width: 0; max-height: min(300px, 50vh); overflow-y: auto; transform: translateY(4px) scale(.98); transform-origin: bottom center; }
.customer-results.is-open { transform: none; }
.customer-results .dropdown-item { padding: 8px 10px; }
.customer-results .customer-add { border-top: 1px solid var(--border-soft); border-radius: 0 0 8px 8px; margin-top: 4px; padding-top: 10px; color: var(--brand-primary-darker); }
.customer-results .customer-add .avatar { background: var(--success-soft); color: var(--brand-primary-dark); font-size: 18px; font-weight: 600; }
#customer-search-wrap .btn-icon { flex-shrink: 0; width: var(--control-h, 42px); height: var(--control-h, 42px); }

/* Receipt */
.receipt { width: 100%; max-width: 380px; margin: 0 auto; background: #fff; padding: 28px 24px; border-radius: var(--radius-lg); border: 1px solid var(--border); font-size: 13px; color: var(--text-primary); }
.receipt-head { text-align: center; padding-bottom: 14px; border-bottom: 1px dashed var(--border-strong); }
.receipt-row { display: flex; justify-content: space-between; gap: 12px; font-variant-numeric: tabular-nums; }
.receipt-items { padding: 12px 0; border-bottom: 1px dashed var(--border-strong); display: flex; flex-direction: column; gap: 8px; }
.receipt-totals { padding: 12px 0; display: flex; flex-direction: column; gap: 4px; }
.receipt-total { font-size: 18px; font-weight: 800; }
.receipt-foot { text-align: center; padding-top: 14px; border-top: 1px dashed var(--border-strong); color: var(--text-secondary); font-size: 12px; }
.receipt.voided { position: relative; }
.receipt.voided::after { content: "VOIDED"; position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%) rotate(-18deg); font-size: 48px; font-weight: 800; color: rgba(239,68,68,.22); border: 4px solid rgba(239,68,68,.22); padding: 4px 18px; border-radius: 12px; pointer-events: none; }

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

.report-tile { display: flex; gap: 14px; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); color: var(--text-body); transition: border-color .15s, box-shadow .15s, transform .15s; height: 100%; }
.report-tile:hover { border-color: rgba(16,185,129,.45); box-shadow: var(--shadow-md); color: var(--text-body); transform: translateY(-1px); }
.report-tile-title { font-weight: 650; color: var(--text-primary); font-size: 14.5px; }
.report-tile-text { font-size: 13px; color: var(--text-secondary); margin-top: 3px; }
.report-group-title { display: flex; align-items: center; gap: 10px; margin: 28px 0 14px; font-size: 13px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--text-secondary); }
.report-group-title::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.report-doc { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); overflow: hidden; }
.report-doc-head { display: flex; justify-content: space-between; gap: 24px; padding: 28px 32px 22px; border-bottom: 1px solid var(--border); flex-wrap: wrap; position: relative; }
.report-doc-head::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: linear-gradient(90deg, #10B981, #14B8A6, #0EA5E9); }
.report-business { font-size: 13px; color: var(--text-secondary); font-weight: 550; }
.report-title { font-size: 22px; font-weight: 700; color: var(--text-primary); letter-spacing: -0.02em; margin-top: 4px; }
.report-meta { display: grid; grid-template-columns: auto auto; gap: 4px 16px; font-size: 12.5px; color: var(--text-secondary); align-content: start; }
.report-meta strong { color: var(--text-primary); font-weight: 600; text-align: right; }
.report-section { padding: 22px 32px; }
.report-section + .report-section { border-top: 1px solid var(--border-soft); }
.report-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.report-summary > div { padding: 14px 16px; border-radius: 12px; background: var(--surface-muted); border: 1px solid var(--border-soft); }
.report-summary .label { font-size: 12px; color: var(--text-secondary); font-weight: 550; }
.report-summary .value { font-size: 18px; font-weight: 700; color: var(--text-primary); margin-top: 3px; font-variant-numeric: tabular-nums; }
.report-doc .table th:first-child, .report-doc .table td:first-child { padding-left: 32px; }
.report-doc .table th:last-child, .report-doc .table td:last-child { padding-right: 32px; }
.report-foot { display: flex; justify-content: space-between; gap: 16px; padding: 16px 32px; border-top: 1px solid var(--border); background: var(--surface-muted); font-size: 12px; color: var(--text-tertiary); flex-wrap: wrap; }
.report-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; align-items: end; }

.builder-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.builder-fields .check { padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.builder-fields .check:has(input:checked) { border-color: rgba(16,185,129,.5); background: var(--success-soft); }
.step-num { width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--gradient-primary); color: #fff; flex-shrink: 0; }

/* Permission matrix */
.perm-yes { color: var(--brand-primary-dark); }
.perm-no { color: var(--border-strong); }

/* ── Auth pages ────────────────────────────────────────────── */

.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: var(--surface); }
.auth-brand {
    position: relative; overflow: hidden;
    padding: 48px 56px; display: flex; flex-direction: column; justify-content: space-between;
    background: radial-gradient(1200px 600px at -10% -20%, rgba(52,211,153,.35), transparent 60%),
                radial-gradient(800px 500px at 110% 120%, rgba(14,165,233,.35), transparent 60%),
                linear-gradient(150deg, #052E24 0%, #064E3B 45%, #065F46 75%, #0F766E 100%);
    color: #ECFDF5;
}
.auth-brand::before {
    content: ""; position: absolute; inset: 0; opacity: .14;
    background-image: linear-gradient(rgba(255,255,255,.5) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.5) 1px, transparent 1px);
    background-size: 44px 44px;
    mask-image: radial-gradient(ellipse at 30% 40%, #000 20%, transparent 70%);
    -webkit-mask-image: radial-gradient(ellipse at 30% 40%, #000 20%, transparent 70%);
}
.auth-brand > * { position: relative; }
.auth-brand .brand-word { color: #fff; font-size: 19px; }
.auth-brand .brand-word span { background: linear-gradient(135deg, #6EE7B7, #5EEAD4); -webkit-background-clip: text; background-clip: text; }
.auth-headline { font-size: 44px; line-height: 1.08; font-weight: 750; letter-spacing: -0.035em; color: #fff; max-width: 520px; }
.auth-headline em { font-style: normal; background: linear-gradient(135deg, #6EE7B7, #67E8F9); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-lead { margin-top: 18px; font-size: 16px; line-height: 1.6; color: rgba(236,253,245,.78); max-width: 460px; }
.auth-points { margin-top: 32px; display: flex; flex-direction: column; gap: 12px; }
.auth-point { display: flex; align-items: center; gap: 12px; font-size: 14.5px; color: rgba(236,253,245,.9); }
.auth-point .icon { width: 30px; height: 30px; padding: 7px; border-radius: 9px; background: rgba(255,255,255,.1); color: #6EE7B7; box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }
.auth-preview { display: flex; gap: 14px; margin-top: 40px; flex-wrap: wrap; }
.auth-preview-card { padding: 16px 18px; border-radius: 14px; background: rgba(255,255,255,.08); box-shadow: inset 0 0 0 1px rgba(255,255,255,.14); backdrop-filter: blur(10px); min-width: 170px; }
.auth-preview-card .l { font-size: 12px; color: rgba(236,253,245,.7); }
.auth-preview-card .v { font-size: 22px; font-weight: 700; color: #fff; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.auth-preview-card .t { font-size: 12px; color: #6EE7B7; font-weight: 600; margin-top: 2px; }
.auth-copy { font-size: 12.5px; color: rgba(236,253,245,.55); }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 48px 24px; background: var(--surface); }
.auth-card { width: 100%; max-width: 410px; }
.auth-card-title { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.auth-card-sub { margin-top: 6px; color: var(--text-secondary); font-size: 14.5px; }
.auth-form { margin-top: 28px; display: flex; flex-direction: column; gap: 18px; }
.auth-form .form-control { height: 46px; }
.auth-mobile-brand { display: none; }
.auth-foot { margin-top: 28px; text-align: center; font-size: 12.5px; color: var(--text-tertiary); }
.secure-note { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 22px; font-size: 12.5px; color: var(--text-tertiary); }

/* Error page */
.error-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(800px 400px at 50% 0%, rgba(16,185,129,.08), transparent 70%), var(--background); }
.error-card { max-width: 480px; text-align: center; }
.error-code { font-size: 64px; font-weight: 800; letter-spacing: -0.04em; background: var(--gradient-primary); -webkit-background-clip: text; background-clip: text; color: transparent; line-height: 1; }
.debug-box { margin-top: 24px; text-align: left; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; background: #0F172A; color: #E2E8F0; padding: 16px; border-radius: 12px; overflow: auto; max-height: 320px; white-space: pre-wrap; }

/* Sidebar backdrop (mobile) */
.backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.45); backdrop-filter: blur(2px); z-index: 35; opacity: 0; visibility: hidden; transition: opacity .2s, visibility .2s; }
.sidebar-open .backdrop { opacity: 1; visibility: visible; }

/* ════════════════════════════════════════════════════════════════
   Responsive
   ════════════════════════════════════════════════════════════════ */

@media (max-width: 1439px) {
    .global-search { width: 280px; }
}

@media (max-width: 1279px) {
    :root { --page-pad-x: 24px; }
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .pos { grid-template-columns: minmax(0, 1fr) 360px; }
    .auth-headline { font-size: 38px; }
    .auth-brand { padding: 40px; }
}

@media (max-width: 1023px) {
    .sidebar { transform: translateX(-100%); width: 288px; box-shadow: var(--shadow-lg); }
    .sidebar-open .sidebar { transform: none; }
    .main { margin-left: 0; }
    .mobile-only { display: inline-flex !important; }
    .desktop-only { display: none !important; }
    .grid-main-side, .grid-side-main, .grid-3 { grid-template-columns: minmax(0, 1fr); }
    .span-2 { grid-column: auto; }
    .global-search { width: 240px; }
    .auth { grid-template-columns: 1fr; }
    .auth-brand { display: none; }
    .auth-mobile-brand { display: flex; flex-direction: column; gap: 10px; margin-bottom: 32px; }
    .auth-mobile-tagline { font-size: 13.5px; font-weight: 600; color: var(--brand-primary-dark); }
    .auth-main { align-items: flex-start; padding-top: 56px; background: radial-gradient(700px 300px at 50% -10%, rgba(16,185,129,.12), transparent 70%), var(--surface); }

    /* POS becomes single column with a slide-up cart */
    .pos { grid-template-columns: minmax(0, 1fr); height: auto; min-height: calc(100vh - var(--header-h)); }
    .pos-grid { padding-bottom: 110px; overflow: visible; }
    .pos-cart { position: fixed; inset: auto 0 0 0; z-index: 45; max-height: 92vh; border-left: 0; border-radius: 20px 20px 0 0; box-shadow: 0 -16px 48px rgba(15,23,42,.25); transform: translateY(105%); transition: transform .28s var(--ease); }
    .cart-open .pos-cart { transform: none; }
    .cart-open .backdrop { opacity: 1; visibility: visible; }
    .pos-cart-head::before { content: ""; position: absolute; left: 50%; top: 7px; width: 40px; height: 4px; margin-left: -20px; border-radius: 4px; background: var(--border-strong); }
    .pos-cart-head { position: relative; }
    .pos-mobile-bar { display: flex; position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 30; }
    .pos-mobile-bar .btn { width: 100%; justify-content: space-between; box-shadow: 0 10px 30px -6px rgba(5,150,105,.6); }
}

@media (max-width: 767px) {
    :root { --page-pad-x: 16px; --page-pad-y: 20px; --header-h: 58px; --control-h: 44px; }
    body { font-size: 14.5px; }
    .page-header { align-items: stretch; flex-direction: column; margin-bottom: 18px; gap: 12px; }
    .page-title { font-size: 22px; }
    .page-subtitle { font-size: 13.5px; }
    .page-actions { width: 100%; }
    .page-actions > .btn, .page-actions > .dropdown { flex: 1; }
    .page-actions > .dropdown > .btn { width: 100%; }
    .grid, .grid-2, .grid-4 { grid-template-columns: minmax(0, 1fr); gap: 14px; }
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .kpi-grid .kpi { padding: 14px; }
    .kpi-grid .kpi-value { font-size: 20px; margin-top: 10px; }
    .kpi-grid .kpi-icon { width: 32px; height: 32px; border-radius: 9px; }
    .kpi-grid .kpi-icon .icon { width: 16px; height: 16px; }
    .kpi-grid .kpi-label { font-size: 12.5px; }
    .kpi-grid .kpi-spark { display: none; }
    .kpi-grid .kpi .kpi-foot { padding-right: 0; }
    .stack { gap: 14px; }
    .form-grid, .form-grid-3 { grid-template-columns: minmax(0, 1fr); }
    .card-header { padding: 16px 16px 0; }
    .card-header.bordered { padding-bottom: 14px; }
    .card-body { padding: 16px; }
    .card-footer { padding: 12px 16px; }
    .btn { --btn-h: 44px; }
    .btn-sm { --btn-h: 38px; }
    .icon-btn { width: 44px; height: 44px; }
    .topbar { gap: 8px; }
    .topbar-title { font-size: 16px; }
    .breadcrumb { display: none; }
    .global-search { display: none; }
    .toolbar { padding: 12px 16px; }
    .toolbar .search-input { max-width: none; flex-basis: 100%; }
    .toolbar select.form-control { flex: 1 1 140px; min-width: 0; }
    .toolbar .btn { flex: 1; }
    .summary-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .summary-strip > div:nth-child(2n) { border-right: 0; }
    .summary-strip > div { border-bottom: 1px solid var(--border-soft); }
    .chart-box { height: 230px; }
    .option-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dl { grid-template-columns: 1fr; gap: 2px; }
    .dl dd { margin-bottom: 10px; }
    .toast-stack { top: auto; bottom: 16px; right: 16px; left: 16px; width: auto; }
    .modal { width: 100vw; max-width: 100vw; max-height: 92vh; margin: auto 0 0; border-radius: 20px 20px 0 0; }
    .modal[open] { animation: sheet-in .25s var(--ease); }
    .modal-header, .modal-body { padding-left: 18px; padding-right: 18px; }
    .modal-footer { padding: 14px 18px calc(14px + env(safe-area-inset-bottom)); }
    .modal-footer .btn { flex: 1; }
    .notif-menu { position: fixed; left: 12px; right: 12px; top: 64px; width: auto; }
    .report-doc-head, .report-section { padding-left: 18px; padding-right: 18px; }
    .report-foot { padding: 14px 18px; }
    .report-doc .table th:first-child, .report-doc .table td:first-child { padding-left: 18px; }
    .report-doc .table th:last-child, .report-doc .table td:last-child { padding-right: 18px; }
    .pos-catalog-head { padding: 14px 16px 10px; }
    .pos-grid { padding: 4px 16px 110px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
    .product-tile { padding: 10px; }
    .grand-total .value { font-size: 28px; }
    .tabs { margin: 0 -16px; padding: 0 16px; }

    .pagination-bar { padding: 12px 16px; justify-content: center; }
    .pagination-bar .pagination-info { width: 100%; text-align: center; }
}

@media (max-width: 374px) {
    :root { --page-pad-x: 12px; }
    .kpi-grid { grid-template-columns: minmax(0, 1fr); }
    .pos-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); padding-left: 12px; padding-right: 12px; }
    .option-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .brand-word { font-size: 15px; }
    .grand-total .value { font-size: 24px; }
}

@keyframes sheet-in { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (hover: none) {
    .btn-sm { --btn-h: 40px; }
    .cart-line-remove { padding: 10px; }
}

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

/* ════════════════════════════════════════════════════════════════
   Print (reports & receipts)
   ════════════════════════════════════════════════════════════════ */

@media print {
    @page { margin: 14mm; }
    body { background: #fff; font-size: 11.5px; color: #0F172A; }
    .sidebar, .topbar, .app-footer, .no-print, .toast-stack, .backdrop, .page-header .page-actions, .pos-mobile-bar { display: none !important; }
    .main { margin: 0 !important; }
    .page { padding: 0 !important; max-width: none; }
    .card, .report-doc, .kpi { box-shadow: none !important; break-inside: avoid; }
    .report-doc { border: 0; border-radius: 0; }
    .report-doc-head::before { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .table th { position: static; background: #F1F5F9 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .table tr { break-inside: avoid; }
    .table-wrap { overflow: visible !important; max-height: none !important; }
    .chart-box { height: 220px; }
    .receipt { border: 0; max-width: 300px; padding: 0; }
    a { color: inherit; }
}

/* Color swatches */
.swatch-wrap { position: relative; display: inline-flex; }
.swatch-wrap input { position: absolute; opacity: 0; pointer-events: none; }
.swatch { width: 34px; height: 34px; border-radius: 10px; cursor: pointer; transition: box-shadow .15s, transform .1s; }
.swatch:hover { transform: scale(1.06); }
.swatch-wrap input:checked + .swatch { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text-primary); }
.swatch-wrap input:focus-visible + .swatch { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--brand-primary); }

.option-grid.cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.option-grid.cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
@media (max-width: 767px) {
    .option-grid.cols-5, .option-grid.cols-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .mobile-only.form-actions, div.mobile-only { display: flex !important; }
}

/* Attendance calendar */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-head { font-size: 11.5px; font-weight: 600; color: var(--text-tertiary); text-align: center; padding-bottom: 4px; text-transform: uppercase; letter-spacing: .04em; }
.cal-day { aspect-ratio: 1 / 1; max-height: 64px; border-radius: 10px; background: var(--surface-muted); border: 1px solid var(--border-soft); display: flex; align-items: flex-start; justify-content: flex-start; padding: 6px 8px; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); position: relative; }
.cal-day::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: 7px; height: 4px; border-radius: 4px; background: transparent; }
.cal-day.is-present { background: var(--success-soft); border-color: #A7F3D0; color: var(--success-text); }
.cal-day.is-present::after { background: var(--success); }
.cal-day.is-half_day { background: var(--warning-soft); border-color: #FDE68A; color: var(--warning-text); }
.cal-day.is-half_day::after { background: var(--warning); right: 50%; }
.cal-day.is-absent { background: var(--danger-soft); border-color: #FECACA; color: var(--danger-text); }
.cal-day.is-absent::after { background: var(--danger); }
.cal-day.is-leave::after { background: #94A3B8; }
.cal-day.is-today { box-shadow: 0 0 0 2px var(--brand-primary); }
.cal-day.is-future { opacity: .45; }
@media (max-width: 767px) { .cal { gap: 4px; } .cal-day { padding: 4px 5px; font-size: 11px; border-radius: 8px; } }

/* Profit & loss statement rows */
.table tr.pl-heading td { background: var(--surface-muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-secondary) !important; font-weight: 650 !important; padding-top: 16px; }
.table tr.pl-subtotal td { font-weight: 700; color: var(--text-primary); border-top: 1px solid var(--border); }
.table tr.pl-indent td:first-child { padding-left: 44px; font-weight: 500 !important; color: var(--text-body) !important; }
.report-brand .brand-mark { width: 26px; height: 26px; filter: none; }
.report-brand .brand-word { font-size: 14px; }
@media print {
    .report-doc .report-summary > div { background: #fff; }
    .report-doc .table th:first-child, .report-doc .table td:first-child { padding-left: 8px; }
    .report-doc-head, .report-section { padding-left: 0; padding-right: 0; }
    .report-foot { background: #fff; padding-left: 0; padding-right: 0; }
}

/* Mobile search overlay */
@media (max-width: 767px) {
    .topbar.search-open .global-search { display: block; position: absolute; left: 12px; right: 12px; top: 7px; width: auto; z-index: 5; }
    .topbar.search-open .global-search .form-control { height: 44px; background: var(--surface); box-shadow: var(--shadow-md); }
    .topbar.search-open .global-search .kbd { display: none; }
    .global-search .search-results { min-width: 0; }
}

/* POS: services */
.product-tile-media.is-service { background: linear-gradient(145deg, #EEF2FF, #E0E7FF); color: #6366F1; }
.product-tile-stock.service { color: #6366F1; font-weight: 600; }

/* Notes */
.notes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.dash-notes { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1279px) { .dash-notes { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 767px) {
    .dash-notes { grid-template-columns: minmax(0, 1fr); }
    .dash-notes > :nth-child(n+3) { display: none; }
}
.note-card { display: flex; flex-direction: column; gap: 8px; padding: 16px 16px 10px; border-radius: 14px; background: var(--note, #FEF3C7); border: 1px solid rgba(15,23,42,.06); box-shadow: 0 1px 2px rgba(15,23,42,.05); min-height: 150px; }
.note-card.is-done { opacity: .6; }
.note-card.is-done .note-title { text-decoration: line-through; }
.note-title { font-size: 15px; font-weight: 650; color: var(--text-primary); line-height: 1.35; overflow-wrap: anywhere; }
.note-body { font-size: 13.5px; color: #334155; white-space: pre-line; line-height: 1.55; overflow-wrap: anywhere; flex: 1; }
.note-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: #64748B; margin-top: auto; }
.note-meta span { display: inline-flex; align-items: center; gap: 4px; }
.note-actions { display: flex; align-items: center; gap: 2px; border-top: 1px solid rgba(15,23,42,.08); padding-top: 6px; margin: 2px -6px 0; }
.note-actions form { display: inline; }
.note-actions .btn { background: transparent; }
.note-actions .btn:hover { background: rgba(255,255,255,.6); }

/* Sidebar: colourful icons + collapsible groups */
.nav-link .icon { color: var(--nav-color, var(--text-tertiary)); opacity: .9; }
.nav-link:hover .icon, .nav-link.is-active .icon { color: var(--nav-color, var(--brand-primary-dark)); opacity: 1; }
.nav-toggle { display: flex; align-items: center; justify-content: space-between; width: 100%; border: 0; background: none; cursor: pointer; text-align: left; border-radius: 6px; padding-top: 4px; padding-bottom: 6px; }
.nav-toggle:hover { color: var(--text-secondary); }
.nav-toggle .icon { transition: transform .18s var(--ease); }
.nav-group.is-collapsed .nav-toggle .icon { transform: rotate(-90deg); }
.nav-group.is-collapsed .nav-group-items { display: none; }
@media (min-width: 1024px) {
    .sidebar-collapsed .nav-toggle .icon { display: none; }
    .sidebar-collapsed .nav-group.is-collapsed .nav-group-items { display: block; }
    .sidebar-collapsed .nav-toggle { pointer-events: none; }
}

/* ── Dashboard: banners, quick actions, bright tiles ───────────────── */
.banner { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: var(--radius-lg); border: 1px solid var(--border); background: var(--surface); flex-wrap: wrap; }
.banner strong { color: var(--text-primary); }
.banner p { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.banner-icon { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; flex-shrink: 0; background: var(--surface-sunken); color: var(--text-secondary); }
.banner-trial { background: linear-gradient(100deg, #FFFBEB, #FFFFFF 60%); border-color: #FDE68A; }
.banner-trial .banner-icon { background: #FEF3C7; color: #B45309; }
.banner-install { background: #F0FDF4; border-color: #BBF7D0; color: #166534; font-size: 14px; }
.banner-install strong { color: #14532D; }
.banner-install .banner-icon { background: #fff; color: var(--brand-primary-dark); box-shadow: var(--shadow-xs); }
.section-label { font-size: 12px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--text-secondary); margin-bottom: 10px; }
.quick-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.quick-actions .btn .icon { color: currentColor; }
.quick-actions .btn-secondary .icon { color: var(--brand-primary-dark); }

.tile-grid { display: grid; grid-template-columns: minmax(0, 1.9fr) repeat(3, minmax(0, 1fr)); grid-auto-rows: minmax(142px, auto); gap: 16px; }
.tile-grid .tile-hero { grid-row: span 2; }
.tile-grid-sm { grid-template-columns: minmax(0, 1.9fr) repeat(3, minmax(0, 1fr)); }
.tile-grid-sm .tile-hero { grid-row: span 1; }
.tile {
    --tile-a: #15803D; --tile-b: #166534;
    position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between;
    border-radius: var(--radius-lg); color: #fff; text-decoration: none; isolation: isolate;
    background: linear-gradient(140deg, var(--tile-a), var(--tile-b));
    box-shadow: 0 12px 24px -16px var(--tile-b);
    transition: transform .15s var(--ease), box-shadow .15s;
}
.tile:hover { color: #fff; transform: translateY(-2px); box-shadow: 0 18px 30px -16px var(--tile-b); }
.tile:focus-visible { outline: 3px solid #fff; outline-offset: -5px; }
.tile-blue { --tile-a: #2563EB; --tile-b: #1D4ED8; }
.tile-green { --tile-a: #16A34A; --tile-b: #15803D; }
.tile-orange { --tile-a: #EA580C; --tile-b: #C2410C; }
.tile-hero { --tile-a: #16A34A; --tile-b: #14532D; }
.tile-body { position: relative; z-index: 1; padding: 18px 20px 12px; }
.tile-value { font-size: 28px; font-weight: 750; letter-spacing: -0.02em; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-hero .tile-value { font-size: 44px; letter-spacing: -0.03em; }
.tile-peso { font-size: .62em; font-weight: 700; opacity: .9; margin-right: 2px; vertical-align: .18em; }
.tile-label { margin-top: 6px; font-size: 14.5px; font-weight: 550; color: rgba(255,255,255,.92); }
.tile-hero .tile-label { font-size: 17px; }
.tile-sub { margin-top: 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 13px; color: rgba(255,255,255,.85); }
.tile-trend { display: inline-flex; padding: 2px 8px; border-radius: 99px; background: rgba(255,255,255,.18); font-weight: 650; color: #fff; }
.tile-sep { opacity: .6; }
.tile-foot { position: relative; z-index: 1; display: flex; align-items: center; justify-content: space-between; padding: 10px 20px; background: rgba(0,0,0,.14); font-size: 13.5px; font-weight: 650; }
.tile:hover .tile-foot .icon { transform: translateX(3px); }
.tile-foot .icon { transition: transform .15s; }
.tile-art { position: absolute; right: -6px; bottom: 26px; z-index: 0; color: rgba(255,255,255,.16); }
.tile-art .icon { width: 84px; height: 84px; stroke-width: 1.6; }
.tile-spark { position: absolute; left: 0; right: 0; bottom: 40px; height: 46%; z-index: 0; opacity: .55; pointer-events: none; }
.tile-spark canvas { width: 100% !important; height: 100% !important; }

@media (max-width: 1279px) {
    .tile-grid, .tile-grid-sm { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .tile-grid .tile-hero { grid-column: 1 / -1; grid-row: auto; min-height: 190px; }
}
@media (max-width: 767px) {
    .tile-grid, .tile-grid-sm { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; grid-auto-rows: minmax(118px, auto); }
    .tile-body { padding: 14px 14px 8px; }
    .tile-value { font-size: 21px; }
    .tile-hero .tile-value { font-size: 34px; }
    .tile-label { font-size: 13px; }
    .tile-foot { padding: 8px 14px; font-size: 12.5px; }
    .tile-art .icon { width: 60px; height: 60px; }
    .quick-actions { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 0 16px 4px; scrollbar-width: none; }
    .quick-actions::-webkit-scrollbar { display: none; }
    .quick-actions .btn { flex-shrink: 0; }
    .banner .btn { flex: 1; }
}

/* Topbar trial badge */
.trial-badge { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 99px; background: #FFFBEB; border: 1px solid #FDE68A; color: #92400E; font-size: 12.5px; font-weight: 650; white-space: nowrap; }
.trial-badge:hover { color: #78350F; background: #FEF3C7; }
@media (max-width: 767px) { .trial-badge span { display: none; } .trial-badge { padding: 0 10px; } }

/* ── In-app bottom tab bar (phones & tablets) ─────────────────────── */
.app-tabbar { display: none; }
@media (max-width: 1023px) {
    .app-tabbar {
        display: grid; grid-auto-columns: minmax(0, 1fr); grid-auto-flow: column;
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 34;
        padding: 6px max(8px, env(safe-area-inset-left)) calc(6px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-right));
        background: rgba(255,255,255,.96); backdrop-filter: saturate(180%) blur(14px); -webkit-backdrop-filter: saturate(180%) blur(14px);
        border-top: 1px solid var(--border); box-shadow: 0 -8px 24px -18px rgba(15,23,42,.4);
    }
    .app-tab {
        position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
        min-height: 54px; padding: 4px 2px; border: 0; background: none; border-radius: 12px;
        color: var(--text-secondary); font-size: 11.5px; font-weight: 600; -webkit-tap-highlight-color: transparent;
    }
    .app-tab-icon { width: 34px; height: 28px; border-radius: 10px; display: grid; place-items: center; transition: background .15s, transform .15s; }
    .app-tab-icon .icon { width: 21px; height: 21px; color: var(--tab-color); }
    .app-tab:active .app-tab-icon { transform: scale(.92); }
    .app-tab.is-active { color: var(--brand-primary-darker); }
    .app-tab.is-active .app-tab-icon { background: var(--success-soft); }
    .app-tab.is-active::before { content: ""; position: absolute; top: -6px; left: 32%; right: 32%; height: 3px; border-radius: 0 0 3px 3px; background: var(--gradient-primary); }
    .main { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
    .toast-stack { bottom: calc(84px + env(safe-area-inset-bottom)) !important; }
    /* The POS has its own bottom checkout bar */
    .pos-page .app-tabbar { display: none; }
    .pos-page .main { padding-bottom: 0; }
}
@media (min-width: 768px) and (max-width: 1023px) {
    .app-tabbar { padding-left: max(12%, env(safe-area-inset-left)); padding-right: max(12%, env(safe-area-inset-right)); }
    .app-tab { font-size: 12.5px; }
}
@media (max-width: 767px) {
    .banner { align-items: flex-start; }
    .banner > .flex-1 { flex: 1 1 calc(100% - 64px); }
    .banner-install [data-install-dismiss] { position: absolute; right: 8px; top: 8px; }
    .banner-install { position: relative; padding-right: 48px; }
}

/* ════════════════════════════════════════════════════════════════
   Mobile polish — applies across every module
   ════════════════════════════════════════════════════════════════ */
.main { min-width: 0; overflow-x: clip; }

@media (max-width: 1023px) {
    /* 16px stops iOS/iPadOS from zooming in when a field is focused */
    .form-control, .form-control-sm, .input-wrap .form-control, .pos-search .form-control, .toolbar .form-control { font-size: 16px; }
    .nav-toggle { min-height: 40px; }
    .table-wrap { scrollbar-width: thin; }
}

@media (max-width: 767px) {
    /* Date range control: presets on one row, dates share the next */
    .range-filter { width: 100%; }
    .range-filter .segmented { display: flex; width: 100%; }
    .range-filter .segmented a { flex: 1 0 auto; justify-content: center; text-align: center; }
    .range-dates { width: 100%; }
    .range-dates .form-control { flex: 1 1 0; min-width: 0; width: auto !important; height: 40px; }

    /* Menus in the page header open at full button width instead of off-screen */
    .page-actions .dropdown { position: relative; }
    .page-actions .dropdown-menu { left: 0; right: 0; min-width: 0; }
    .card-header .dropdown-menu, .toolbar .dropdown-menu { max-width: calc(100vw - 32px); }


    /* Wide reference tables (permission matrix) scroll inside their card */
    .table-matrix td:first-child { min-width: 132px; }
    .table-matrix th { white-space: nowrap; }

    /* Long words and codes never push the layout sideways */
    .card, .modal-body { overflow-wrap: break-word; }
    .page-title { overflow-wrap: break-word; }
}

/* Collapsible filter bars (button added by app.js) */
.filter-toggle { display: none; }
.filter-count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--brand-primary); color: #fff; font-size: 11.5px; font-weight: 700; }
@media (max-width: 767px) {
    .toolbar.is-collapsible .search-input { flex: 1 1 0; min-width: 0; }
    .toolbar.is-collapsible .filter-toggle { display: inline-flex; flex: 0 0 auto; height: 42px; --btn-h: 42px; }
    .toolbar.is-collapsible:not(.is-expanded) > .filter-ctl { display: none !important; }
    .toolbar.is-expanded .filter-toggle { background: var(--success-soft); border-color: #A7F3D0; color: var(--brand-primary-darker); }
    .toolbar .filter-ctl[type=date] { flex: 1 1 40%; min-width: 0; width: auto !important; }
    .toolbar.is-collapsible .search-input:only-of-type { flex-basis: 0; }

    /* Report rows styled as section headings / subtotals keep a single column */
}
@media (max-width: 767px) {
    .kpi-grid > .kpi-featured:first-child:nth-last-child(odd) { grid-column: 1 / -1; }
    .kpi-grid .kpi-foot { font-size: 12px; }
}
@media (min-width: 768px) { .kpi-grid.kpi-auto { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); } }
@media (max-width: 767px) {
    .dl, .dl[style] { grid-template-columns: minmax(84px, 40%) minmax(0, 1fr) !important; gap: 9px 12px; }
    .dl dd { margin-bottom: 0; }
}
@media (max-width: 767px) {
    .report-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .report-summary > div { padding: 12px 14px; }
    .report-summary .value { font-size: 17px; }
}
/* Forms inside tabbed flush cards keep their breathing room */
.card-flush .tab-panel > .card-body, .card-flush .tab-panel > form.card-body { padding: 20px 22px 22px; }
@media (max-width: 767px) {
    .card-flush .tab-panel > .card-body, .card-flush .tab-panel > form.card-body { padding: 16px; }
    .card > .tabs { margin: 0; padding: 0 12px !important; }
}

/* Record tables become cards on phones and tablets */
@media (max-width: 1023px) {
    .table-cards thead { display: none; }
    .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
    .table-cards tbody { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
    .table-cards tr { border: 1px solid var(--border); border-radius: 12px; padding: 6px 14px; background: var(--surface); }
    .table-cards tbody tr:hover { background: var(--surface); }
    .table-cards td { display: flex; justify-content: flex-end; align-items: center; gap: 6px; padding: 9px 0 !important; border-bottom: 1px solid var(--border-soft); text-align: right; min-height: 40px; }
    .table-cards td:last-child { border-bottom: 0; }
    .table-cards td::before { content: attr(data-label); font-size: 12.5px; font-weight: 550; color: var(--text-secondary); text-align: left; flex-shrink: 0; margin-right: auto; padding-right: 12px; }
    .table-cards td.card-primary { display: block; text-align: left; padding: 10px 0 !important; }
    .table-cards td.card-primary::before { display: none; }
    .table-cards td.actions { width: 100%; justify-content: flex-end; }
    .table-cards td.actions::before { display: none; }
    .table-cards td.num { text-align: right; }
    .table-cards .cell-media { min-width: 0; }
    .table-cards tfoot { display: block; }
    .table-cards tfoot tr { display: flex; justify-content: space-between; border: 0; background: var(--surface-muted); }
    .table-cards tfoot td { display: none; }
    .table-cards tfoot td.num, .table-cards tfoot td:first-child { display: block; width: auto; border: 0; }
    .table-cards tfoot td::before { display: none; }
    .table-cards tfoot { display: block; padding: 0 12px 12px; }
    .table-cards tfoot tr { display: block; border: 1px solid var(--border); border-radius: 12px; padding: 4px 14px; background: var(--surface-muted); }
    .table-cards tfoot td { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 8px 0 !important; border: 0; border-bottom: 1px solid var(--border-soft); font-weight: 700; }
    .table-cards tfoot td:first-child { font-weight: 700; color: var(--text-primary); }
    .table-cards tfoot td:last-child { border-bottom: 0; }
    .table-cards tfoot td:empty { display: none; }
    .table-cards tfoot td::before { display: block; content: attr(data-label); font-size: 12.5px; font-weight: 550; color: var(--text-secondary); }
    .table-cards tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 14px; padding: 4px 14px 6px; }
    .table-cards tbody td { display: block; min-height: 0; padding: 8px 0 !important; border-bottom: 0; text-align: left; }
    .table-cards tbody td::before { display: block; margin: 0 0 3px; padding: 0; font-size: 11.5px; font-weight: 600; letter-spacing: .01em; color: var(--text-tertiary); }
    .table-cards tbody td.num { text-align: left; }
    .table-cards tbody td.card-primary { order: -1; grid-column: 1 / -1; border-bottom: 1px solid var(--border-soft); margin-bottom: 2px; }
    .table-cards tbody td.actions { display: flex; order: 99; grid-column: 1 / -1; flex-direction: row; align-items: center; justify-content: flex-end; border-top: 1px solid var(--border-soft); margin-top: 2px; padding: 6px 0 2px !important; }
    .table-cards tbody td.actions:not(:has(*)) { display: none; }
    .table-cards tbody td.card-wide { grid-column: 1 / -1; }
    .table-cards tbody td > .row, .table-cards tbody td > .badge { justify-content: flex-start; }
    .table-cards tbody tr.pl-heading, .table-cards tbody tr.pl-subtotal { grid-template-columns: minmax(0, 1fr); }
    .table-cards tbody td.nowrap { white-space: normal; }
    .table-cards td.card-wide .segmented { display: flex; width: 100%; }
    .table-cards td.card-wide .segmented label { flex: 1; justify-content: center; }
    .table-cards tbody td, .table-cards tbody td * { white-space: normal; }
    .table-cards tbody td .badge, .table-cards tbody td .btn, .table-cards tbody td .mono { white-space: nowrap; }
    .table-cards td.card-wide .segmented label { flex: 1 1 0; min-width: 0; padding-left: 4px; padding-right: 4px; font-size: 12.5px; white-space: nowrap; }
}
@media (min-width: 768px) and (max-width: 1023px) {
    .table-cards tbody { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 14px; }
    .table-cards tfoot { padding: 0 14px 14px; }
}

/* ════════════════════════════════════════════════════════════════
   Sidebar — deep emerald theme
   ════════════════════════════════════════════════════════════════ */
.sidebar {
    --sb-text: rgba(236, 253, 245, .80);
    --sb-muted: rgba(167, 243, 208, .55);
    --sb-hover: rgba(255, 255, 255, .07);
    --sb-line: rgba(255, 255, 255, .08);
    background: radial-gradient(420px 260px at 0% 0%, rgba(52, 211, 153, .18), transparent 70%), linear-gradient(180deg, #065F46 0%, #064E3B 45%, #022C22 100%);
    border-right: 0;
    color: var(--sb-text);
    scrollbar-color: rgba(255, 255, 255, .22) transparent;
}
.sidebar .brand-word { color: #fff; }
.sidebar .brand-word span { background: linear-gradient(135deg, #6EE7B7, #5EEAD4); -webkit-background-clip: text; background-clip: text; color: transparent; }
.sidebar .brand-mark { filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .25)); }
.sidebar .icon-btn { color: var(--sb-text); }
.sidebar .icon-btn:hover { background: var(--sb-hover); color: #fff; }

.sidebar .nav-section, .sidebar .nav-toggle { color: var(--sb-muted); }
.sidebar .nav-toggle:hover { color: #D1FAE5; }
.sidebar .nav-link { color: var(--sb-text); }
.sidebar .nav-link .icon { color: var(--nav-color, #A7F3D0); color: color-mix(in srgb, var(--nav-color, #A7F3D0) 62%, #fff); opacity: 1; }
.sidebar .nav-link:hover { background: var(--sb-hover); color: #fff; }
.sidebar .nav-link.is-active {
    background: linear-gradient(90deg, rgba(52, 211, 153, .26), rgba(45, 212, 191, .10));
    color: #fff;
    box-shadow: inset 0 0 0 1px rgba(110, 231, 183, .22), 0 6px 18px -10px rgba(0, 0, 0, .5);
}
.sidebar .nav-link.is-active::before { background: linear-gradient(180deg, #6EE7B7, #2DD4BF); }
.sidebar .nav-link .nav-badge { background: #F43F5E; color: #fff; }

.sidebar-foot { border-top-color: var(--sb-line); }
.sidebar .user-chip:hover { background: var(--sb-hover); }
.sidebar .user-chip-name { color: #fff; }
.sidebar .user-chip-role { color: var(--sb-muted); }
.sidebar .avatar { box-shadow: 0 0 0 2px rgba(255, 255, 255, .15); }
@media (min-width: 1024px) {
    .sidebar-collapsed .sidebar .nav-section { border-top-color: var(--sb-line); }
}

/* ── Dashboard greeting animation ─────────────────────────── */
.greet-title { animation: greet-up .6s var(--ease) both; }
.greet-sub { animation: greet-up .6s var(--ease) .15s both; }
.greet-sub .live-dot { display: inline-block; vertical-align: middle; position: relative; top: -1px; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: var(--brand-primary); box-shadow: 0 0 0 0 rgba(16, 185, 129, .55); animation: live-pulse 2s ease-out infinite; }
.greet-name {
    background: linear-gradient(90deg, #059669, #14B8A6, #10B981, #0D9488, #059669);
    background-size: 300% 100%;
    -webkit-background-clip: text; background-clip: text; color: transparent;
    animation: greet-shimmer 6s linear infinite;
}
.wave { display: inline-block; transform-origin: 70% 75%; animation: wave 2.8s ease-in-out .5s infinite; }

@keyframes greet-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes greet-shimmer { to { background-position: 300% 0; } }
@keyframes wave {
    0% { transform: rotate(0); }
    8% { transform: rotate(16deg); }
    16% { transform: rotate(-10deg); }
    24% { transform: rotate(16deg); }
    32% { transform: rotate(-6deg); }
    40% { transform: rotate(12deg); }
    50%, 100% { transform: rotate(0); }
}
@keyframes live-pulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, .55); }
    70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Product photos: show the whole picture (any shape) on white instead of cropping it */
.product-tile-media:has(img), .thumb:has(img), .image-drop:has(img) { background: #fff; }
.product-tile-media img, .thumb img { object-fit: contain; }
.product-tile-media img { padding: 6px; }
