/* ============================================================================
 * TKV CRM — 2026 Redesign
 * "Clean studio" — calm, modern, productivity-app feel.
 * Reference: Linear / Notion / Stripe.
 * ============================================================================ */

/* -- Design tokens ---------------------------------------------------------- */
:root {
    /* Surfaces — Hashtask-inspired cool grays */
    --surface-app:        #f1f5f9;            /* cool app background */
    --surface-card:       #ffffff;            /* card surface */
    --surface-sunken:     #f5f6f8;            /* subtle inset surface */
    --surface-hover:      #f7f8fa;
    --surface-base:       #f5f6f8;
    --surface-overlay:    rgba(15, 23, 42, 0.45);
    --surface-selected:   #f1f3f5;

    /* Borders */
    --border-subtle:      #eef0f3;            /* hairline */
    --border-default:     #e5e7eb;            /* card border */
    --border-strong:      #d1d5db;

    /* Text */
    --text-primary:       #111827;
    --text-secondary:     #6b7280;
    --text-tertiary:      #9ca3af;
    --text-label:         #9aa1ac;
    --text-on-accent:     #ffffff;

    /* Accent — vibrant orange (operational / energetic) */
    --accent:             #f97316;
    --accent-hover:       #ea580c;
    --accent-soft:        #fff7ed;
    --accent-soft-text:   #c2410c;
    --accent-strong-bg:   #f97316;       /* solid orange pill, white text */
    --accent-strong-fg:   #ffffff;

    /* Pastel chip palette (matches reference op-board look) */
    --chip-info-bg:       #ede9fe;       /* lavender */
    --chip-info-fg:       #6d28d9;
    --chip-warning-bg:    #fef3c7;       /* soft yellow */
    --chip-warning-fg:    #92400e;
    --chip-danger-bg:     #ffe4e6;       /* coral */
    --chip-danger-fg:     #be123c;
    --chip-success-bg:    #d1fae5;       /* mint */
    --chip-success-fg:    #047857;
    --chip-neutral-bg:    #f5f5f4;
    --chip-neutral-fg:    #57534e;

    /* Status semantics */
    --positive:           #059669;
    --positive-soft:      #ecfdf5;
    --negative:           #dc2626;
    --negative-soft:      #fef2f2;
    --warning:            #d97706;
    --warning-soft:       #fffbeb;

    /* Type scale (5 steps) */
    --fs-12: 12px;
    --fs-14: 14px;
    --fs-16: 16px;
    --fs-20: 20px;
    --fs-28: 28px;

    /* Spacing scale (4px base) */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --space-7: 48px;

    /* Radii */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;

    /* Elevation — one tier */
    --shadow-card:  0 1px 0 rgba(15, 23, 42, 0.02), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-pop:   0 4px 12px -2px rgba(15, 23, 42, 0.08), 0 2px 4px rgba(15, 23, 42, 0.04);

    /* Override legacy CRM tokens so existing components inherit the redesign */
    --body-bg:            var(--surface-app);
    --body-color:         var(--text-primary);
    --container-bg:       var(--surface-card);
    --container-border:   var(--border-default);
    --sidebar-bg:         var(--surface-card);
    --input-bg:           var(--surface-card);
    --table-header-bg:    var(--surface-sunken);
    --table-hover:        var(--surface-hover);
    --border-color:       var(--border-default);
    --text-muted:         var(--text-tertiary);
    --primary:            var(--text-primary);
}

/* Warm dark mode (zinc-based, off-white text) */
.dark {
    --surface-app:        #1c1917;
    --surface-card:       #292524;
    --surface-sunken:     #1f1d1a;
    --surface-hover:      #2a2825;

    --border-subtle:      #2a2825;
    --border-default:     #3a3633;
    --border-strong:      #4d4844;

    --text-primary:       #fafaf9;
    --text-secondary:     #d6d3d1;
    --text-tertiary:      #a8a29e;

    --accent:             #fb923c;
    --accent-hover:       #f97316;
    --accent-soft:        rgba(251, 146, 60, 0.14);
    --accent-soft-text:   #fed7aa;
    --accent-strong-bg:   #f97316;
    --accent-strong-fg:   #ffffff;

    --chip-info-bg:       rgba(167, 139, 250, 0.18);
    --chip-info-fg:       #ddd6fe;
    --chip-warning-bg:    rgba(251, 191, 36, 0.18);
    --chip-warning-fg:    #fde68a;
    --chip-danger-bg:     rgba(244, 63, 94, 0.18);
    --chip-danger-fg:     #fecdd3;
    --chip-success-bg:    rgba(16, 185, 129, 0.18);
    --chip-success-fg:    #a7f3d0;
    --chip-neutral-bg:    rgba(231, 229, 228, 0.10);
    --chip-neutral-fg:    #d6d3d1;

    --positive-soft:      rgba(5, 150, 105, 0.15);
    --negative-soft:      rgba(220, 38, 38, 0.15);
    --warning-soft:       rgba(217, 119, 6, 0.15);

    --shadow-card:  0 1px 0 rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-pop:   0 4px 12px -2px rgba(0, 0, 0, 0.4), 0 2px 4px rgba(0, 0, 0, 0.2);

    --body-bg:            var(--surface-app);
    --body-color:         var(--text-primary);
    --container-bg:       var(--surface-card);
    --container-border:   var(--border-default);
    --sidebar-bg:         var(--surface-card);
    --input-bg:           var(--surface-sunken);
    --table-header-bg:    var(--surface-sunken);
    --table-hover:        var(--surface-hover);
    --border-color:       var(--border-default);
    --text-muted:         var(--text-tertiary);
}

/* -- Body & shell ----------------------------------------------------------- */
body {
    background-color: var(--surface-app);
    color: var(--text-primary);
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-font-smoothing: antialiased;
    font-size: 15px;
}

#app-container {
    width: 100% !important;
    max-width: none !important;
    height: 100vh !important;
    margin: 0 !important;
    background: var(--surface-app) !important;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
}

#app-container.fullscreen {
    background: var(--surface-app) !important;
}

/* Main content surface — soft inset card on the right of the sidebar */
#app > main,
#app > div:not(aside):not(.mobile-overlay):not(.mobile-bottom-nav) {
    background: var(--surface-app);
}

/* -- Sidebar ---------------------------------------------------------------- */
.glass-sidebar {
    background: var(--surface-card) !important;
    border-right: 1px solid var(--border-subtle) !important;
    backdrop-filter: none !important;
    padding: 12px 10px !important;
}

.sidebar-link {
    color: #4b5563 !important;
    border-radius: 7px !important;
    transition: background-color .12s, color .12s !important;
    background: transparent !important;
    padding: 0 10px !important;
    height: 32px !important;
    font-size: 13px !important;
    font-weight: 450 !important;
    gap: 10px !important;
    display: flex !important;
    align-items: center !important;
    margin-bottom: 1px !important;
}
.sidebar-link i,
.sidebar-link svg {
    width: 16px !important;
    height: 16px !important;
    color: #9ca3af;
    transition: color .12s;
    flex-shrink: 0;
    stroke-width: 1.75 !important;
}
.sidebar-link:hover {
    background: #f5f6f8 !important;
    color: var(--text-primary) !important;
}
.sidebar-link:hover i,
.sidebar-link:hover svg { color: #6b7280; }

/* Active nav: subtle gray fill (Hashtask style) */
.sidebar-link.active {
    background: #f0f1f3 !important;
    color: var(--text-primary) !important;
    font-weight: 500 !important;
}
.sidebar-link.active i,
.sidebar-link.active svg {
    color: var(--text-primary) !important;
}
.sidebar-link.active::before { display: none !important; }

.dark .sidebar-link.active { background: var(--surface-hover) !important; color: var(--text-primary) !important; }
.dark .sidebar-link.active i { color: var(--text-primary) !important; }

/* -- Nav section labels ----------------------------------------------------- */
.sb-nav-label {
    font-size: 11px;
    font-weight: 600;
    color: #9aa1ac;
    letter-spacing: .04em;
    text-transform: uppercase;
    padding: 0 10px 4px;
    margin-top: 16px;
    user-select: none;
}
.sb-nav-label:first-child {
    margin-top: 4px;
}

/* -- Topbar ----------------------------------------------------------------- */
.app-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    padding: 14px 28px;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--surface-card);
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 40;
}

/* -- Header layout (Hashtask-style) ---------------------------------------- */
.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.header-right {
    display: flex;
    align-items: center;
    gap: 14px;
}
.header-hamburger {
    display: none;
    align-items: center;
    justify-content: center;
    width: 38px; height: 38px;
    min-width: 38px;
    border-radius: 10px;
    border: 1px solid var(--border-strong);
    background: var(--surface-card);
    cursor: pointer;
    color: var(--text-primary);
    padding: 0;
    flex-shrink: 0;
}
.header-hamburger i,
.header-hamburger svg { width: 18px !important; height: 18px !important; min-width: 18px !important; }

.header-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}
.header-logo-mark {
    width: 36px; height: 36px;
    background: transparent;
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}
.header-logo-name {
    font-size: 17px;
    font-weight: 700;
    color: #111827;
    letter-spacing: -.01em;
}

/* -- Avatar & Profile Dropdown --------------------------------------------- */
.avatar-wrap { position: relative; }
.avatar-btn {
    width: 36px; height: 36px;
    border-radius: 50%;
    padding: 0;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.avatar-inner {
    width: 100%; height: 100%;
    border-radius: 50%;
    background: #e5e7eb;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    font-weight: 600;
    font-size: 12px;
    letter-spacing: .02em;
}
.avatar-inner i,
.avatar-inner svg {
    width: 18px !important;
    height: 18px !important;
    color: #6b7280 !important;
    stroke-width: 2 !important;
}

.profile-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 260px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0,0,0,.12), 0 0 0 1px rgba(0,0,0,.04);
    padding: 8px;
    z-index: 50;
    opacity: 0;
    transform: translateY(-8px) scale(.98);
    transform-origin: top right;
    pointer-events: none;
    transition: opacity .18s ease, transform .18s ease;
}
.profile-dropdown.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}
.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    border-radius: 10px;
    cursor: pointer;
    color: #111827;
    font-size: 13.5px;
    font-weight: 500;
    transition: background .12s;
}
.dropdown-item:hover { background: #f5f5f7; }
.dropdown-item i { width: 18px; height: 18px; flex-shrink: 0; }
.dropdown-divider {
    height: 1px;
    background: #ececef;
    margin: 6px 10px;
}

@media (max-width: 768px) {
    .header-hamburger { display: flex !important; }
    .header-logo { display: flex !important; }
    .header-logo-mark { width: 30px; height: 30px; }
    .header-logo-name { font-size: 15px; }
    .app-topbar { padding: 10px 16px !important; }
    .avatar-btn { width: 36px; height: 36px; padding: 2px; }
    .profile-dropdown { right: -8px; width: 240px; }
}

.icon-btn {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    background: transparent;
    border: 0;
    cursor: pointer;
    transition: background-color 120ms ease, color 120ms ease;
}
.icon-btn:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}
.icon-btn i,
.icon-btn svg { width: 16px !important; height: 16px !important; stroke-width: 2; }

/* -- Cards / surfaces ------------------------------------------------------- */
.glass-panel {
    background: var(--surface-card) !important;
    border: 1px solid var(--border-subtle) !important;
    border-radius: 12px !important;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04) !important;
    backdrop-filter: none !important;
}

/* -- Auth screen (login / reset / forgot) ----------------------------------
 * Calmer, "you're home" treatment: no card chrome, ambient warmth at top of
 * viewport, generous whitespace, decisive black CTA. The form is the focus —
 * everything else is quiet.
 * ------------------------------------------------------------------------ */
.auth-shell {
    flex: 1 1 auto;
    width: 100%;
    min-height: 100vh;
    background: var(--surface-app);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}
.dark .auth-shell { background: var(--surface-app); }
/* Hide the old orange glow */
.auth-glow { display: none !important; }
.auth-col {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 440px;
    margin: 0 auto;
    padding: 72px var(--space-4) var(--space-6) var(--space-4);
    flex: 1;
    display: flex;
    flex-direction: column;
}
.auth-pane {
    display: flex;
    flex-direction: column;
    background: var(--surface-card);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    padding: 36px 32px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 12px -4px rgba(15, 23, 42, 0.06);
}
.dark .auth-pane {
    background: var(--surface-card);
    border-color: var(--border-subtle);
    box-shadow: none;
}
.auth-mark {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--accent-soft);
    color: var(--accent);
    display: grid;
    place-items: center;
    margin-bottom: 20px;
    overflow: hidden;
    box-shadow: none;
}
.auth-mark i { width: 26px; height: 26px; }

.auth-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.018em;
    line-height: 1.2;
    margin: 0;
}
.auth-sub {
    font-size: var(--fs-14);
    color: var(--text-secondary);
    margin: var(--space-2) 0 var(--space-6) 0;
    line-height: 1.5;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}
.auth-label {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.auth-label > span {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: var(--fs-12);
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.01em;
}
.auth-inline-link {
    font-size: var(--fs-12);
    font-weight: 500;
    color: var(--text-tertiary);
    text-decoration: none;
    transition: color 120ms ease;
}
.auth-inline-link:hover { color: var(--text-primary); }

.auth-input {
    width: 100%;
    height: 44px;
    border-radius: 10px;
    border: 1px solid var(--border-default);
    background: var(--surface-card);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    padding: 0 14px;
    font-size: 14px;
    color: var(--text-primary);
    transition: border-color 120ms ease, box-shadow 120ms ease;
    outline: none;
}
.auth-input::placeholder {
    color: var(--text-tertiary);
    font-size: 14px;
}
.auth-input:focus {
    border-color: var(--text-primary);
    background: var(--surface-card);
    box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.08);
}
.dark .auth-input { background: var(--surface-card); }

.auth-cta {
    width: 100%;
    height: 44px;
    margin-top: 8px;
    border-radius: 10px;
    border: 0;
    background: var(--text-primary);
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 120ms ease, transform 120ms ease;
    box-shadow: none;
}
.auth-cta:hover { background: #1f2937; }
.auth-cta:active { transform: translateY(1px); }
.auth-inline-link { color: var(--text-secondary); font-weight: 500; }
.auth-inline-link:hover { color: var(--text-primary); }

.auth-aux {
    margin-top: var(--space-5);
    font-size: var(--fs-12);
    color: var(--text-tertiary);
}
.auth-aux a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 120ms ease;
}
.auth-aux a:hover { color: var(--text-primary); }

/* Auth footer — fixed to viewport bottom so it spans the full width and
 * never gets clipped by the 360px auth-col (which is a positioned ancestor). */
.auth-shell { padding-bottom: 72px; }
.auth-foot {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5;
    width: 100%;
    margin: 0;
    padding: var(--space-3) var(--space-5);
    border-top: 1px solid var(--border-subtle);
    background: var(--surface-app);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2) var(--space-4);
    font-size: 11px;
    color: var(--text-tertiary);
    letter-spacing: 0.01em;
}
.auth-foot__status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    font-weight: 500;
    justify-self: start;
    white-space: nowrap;
}
.auth-foot__dot {
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: var(--positive);
    box-shadow: 0 0 0 3px var(--positive-soft);
    animation: auth-foot-pulse 2.4s ease-in-out infinite;
}
@keyframes auth-foot-pulse {
    0%, 100% { box-shadow: 0 0 0 3px var(--positive-soft); }
    50%      { box-shadow: 0 0 0 5px var(--positive-soft); }
}
.auth-foot__copy {
    text-align: center;
    color: var(--text-tertiary);
    white-space: nowrap;
}
.auth-foot__links {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    justify-self: end;
}
.auth-foot__links a {
    color: var(--text-tertiary);
    text-decoration: none;
    transition: color 120ms ease;
    font-weight: 500;
}
.auth-foot__links a:hover { color: var(--text-primary); }

/* Stack vertically on narrow viewports */
@media (max-width: 480px) {
    .auth-foot {
        grid-template-columns: 1fr;
        text-align: center;
        gap: var(--space-2);
    }
    .auth-foot__status,
    .auth-foot__links { justify-self: center; }
}

/* Defensively beat the legacy --accent overrides from index.php so the
 * orange palette wins on every page that touches one of the .bg-blue-* /
 * .text-blue-* legacy utility classes. The cascade order alone is fragile. */
:root {
    --accent: #f97316 !important;
    --font-body:    'Google Sans', 'DM Sans', 'Figtree', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-heading: 'Google Sans', 'DM Sans', 'Figtree', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.dark { --accent: #fb923c !important; }

/* ============================================================================
 * Figtree everywhere — enforce one typeface across the entire app.
 * Uses !important to beat the legacy index.php inline rules that pinned
 * everything to Schibsted Grotesk, plus various Tailwind class defaults.
 * ============================================================================ */
html, body,
input, select, textarea, button,
h1, h2, h3, h4, h5, h6, p, span, div, a, li, td, th, label,
.font-heading, .font-sans, .font-body,
.dense-table th, .dense-table td,
.compact-input, .form-input,
.kpi__value, .doc-totals__grand .num,
.auth-title, .auth-input, .auth-cta,
.page-head h2, .card__title,
.btn, .pri-btn, .icon-btn, .filter-pill, .tab,
.chip, .status-pill,
.activity-row__title, .kcard__title, .kcard__id, .kcard__kv,
.fin-stat__value, .fin-period__btn,
.sidebar-link, .sb-brand__name, .sb-section-header, .sb-profile__name, .sb-profile__email {
    font-family: 'Google Sans', 'DM Sans', 'Figtree', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
}

/* Tailwind config in index.php pins fontFamily.sans/heading to Figtree;
 * override by setting an explicit font-family chain that prefers Google Sans. */
html { font-family: 'Google Sans', 'DM Sans', 'Figtree', system-ui, sans-serif; }

/* Keep monospaced numbers / IDs distinguishable when intentionally mono'd —
 * but for normal numerics inside Figtree, just use tabular-nums. */
.font-mono, code, kbd, samp, pre,
.activity-row__id, .doc-card__num input,
.cell-stack .num, .data-table .num,
[class*="num"] {
    font-feature-settings: 'tnum' 1, 'lnum' 1;
}

/* Numeric values in financial UIs should be tabular for column alignment */
.kpi__value, .doc-totals__grand .num, .fin-stat__value,
.activity-row__amount, .data-table .num {
    font-feature-settings: 'tnum' 1, 'lnum' 1, 'cv11' 1;
    font-variant-numeric: tabular-nums;
}

/* -- Dashboard -------------------------------------------------------------- */
/* Page header — title block on the left, action cluster on the right.
 * On wider screens the actions sit aligned to the title baseline; on mobile
 * everything stacks with actions in a horizontal split-row below. */
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding-bottom: var(--space-3);
    margin-bottom: var(--space-5);
    border-bottom: none;
    flex-wrap: wrap;
}
.page-head > div:first-child { min-width: 0; flex: 1; }

/* Greeting variant — dashboard welcome */
.page-head--greeting { border-bottom: none; margin-bottom: var(--space-4); padding-bottom: 0; }
.page-head--greeting h2 { font-size: 28px !important; font-weight: 700 !important; margin: 0 !important; }
.page-head--greeting .sub { color: var(--text-secondary); margin-top: 4px; }
.page-head__actions { display: flex; gap: var(--space-2); align-items: center; }
@media (max-width: 640px) {
    .page-head--greeting h2 { font-size: 22px !important; }
    .page-head--greeting { margin-bottom: 16px !important; padding-bottom: 0 !important; }
    .page-head--greeting .sub { font-size: 13px !important; }
    .page-head--greeting .page-head__actions { width: 100%; }
    .page-head--greeting .page-head__actions .btn { flex: 1; justify-content: center; font-size: 13px; }
}
.page-head h2 {
    font-size: 26px !important;
    font-weight: 600 !important;
    letter-spacing: -0.022em !important;
    color: var(--text-primary) !important;
    line-height: 1.15 !important;
    margin: 0 !important;
}
.page-head .sub {
    font-size: var(--fs-14);
    color: var(--text-tertiary);
    margin-top: 4px;
    line-height: 1.4;
}

/* Action cluster on the right — keep on one line, allow wrap on mid widths */
.page-head > div:last-child:not(:first-child) {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-shrink: 0;
}

/* Mobile (< 640px): stack title above actions; actions become a 50/50 split row */
@media (max-width: 640px) {
    .page-head {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-3);
        padding-bottom: var(--space-3);
        margin-bottom: var(--space-4);
    }
    .page-head h2 { font-size: 22px !important; }
    .page-head .sub { font-size: 13px; }
    .page-head > div:last-child:not(:first-child) {
        display: flex;
        gap: var(--space-2);
    }
    .page-head > div:last-child:not(:first-child) > .pri-btn,
    .page-head > div:last-child:not(:first-child) > .btn,
    .page-head > div:last-child:not(:first-child) > .btn--accent {
        flex: 1;
        justify-content: center;
        min-width: 0;
    }
}

/* Tablet / mid widths: prevent buttons from overflowing — wrap if needed */
@media (min-width: 641px) and (max-width: 900px) {
    .page-head { align-items: flex-start; }
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--space-3);
    margin-bottom: var(--space-5);
}
@media (max-width: 1024px) {
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
    .kpi-grid { grid-template-columns: 1fr; }
}
/* KPI card — minimal: pure white card, big number, quiet semantic dot.
 * No tinted backgrounds, no gradient icon tiles — just typography and one
 * tiny color cue per metric. */
.kpi {
    position: relative;
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 22px 24px;
    transition: border-color 160ms ease, box-shadow 160ms ease;
    min-height: 110px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}
.kpi:hover {
    border-color: var(--border-default);
    box-shadow: 0 4px 12px -4px rgba(15, 23, 42, 0.08);
}

.kpi__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
}
.kpi__label {
    font-size: var(--fs-12);
    color: var(--text-tertiary);
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
    margin: 0;
    line-height: 1.4;
}
/* Tiny semantic dot replacing the gradient icon tile */
.kpi__icon {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--text-tertiary);
    flex-shrink: 0;
    box-shadow: 0 0 0 3px var(--chip-neutral-bg);
}
.kpi__icon i, .kpi__icon svg { display: none; }
.kpi__icon--up      { background: var(--positive); box-shadow: 0 0 0 3px var(--chip-success-bg); }
.kpi__icon--down    { background: var(--negative); box-shadow: 0 0 0 3px var(--chip-danger-bg); }
.kpi__icon--accent  { background: var(--accent);   box-shadow: 0 0 0 3px var(--accent-soft); }
.kpi__icon--info    { background: #7c3aed;         box-shadow: 0 0 0 3px var(--chip-info-bg); }
.kpi__icon--neutral { background: var(--text-tertiary); box-shadow: 0 0 0 3px var(--chip-neutral-bg); }

/* Variant backgrounds removed — all cards are now uniformly white */
.kpi--positive,
.kpi--negative,
.kpi--accent,
.kpi--info,
.kpi--neutral { background: var(--surface-card); }

.kpi__value {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.018em;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.kpi__foot {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: var(--space-2);
    margin-top: auto;
}
.kpi__delta {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 500;
    padding: 0;
    border-radius: 0;
    letter-spacing: 0;
    line-height: 1;
    background: transparent;
    color: var(--text-tertiary);
    white-space: nowrap;
}
.kpi__delta i { width: 11px; height: 11px; }
.kpi__delta--up   { color: var(--positive); }
.kpi__delta--down { color: var(--negative); }

/* Full-width sparkline strip anchored to the bottom of the card */
.kpi__spark {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 36px;
    opacity: 0.9;
    pointer-events: none;
}
.kpi__spark path.line  { fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.kpi__spark path.area  { stroke: none; opacity: 0.22; }
.kpi__spark--up   path.line { stroke: var(--positive); }
.kpi__spark--up   path.area { fill:   var(--positive); }
.kpi__spark--down path.line { stroke: var(--negative); }
.kpi__spark--down path.area { fill:   var(--negative); }
.kpi__spark--flat path.line { stroke: var(--text-tertiary); opacity: 0.7; }
.kpi__spark--flat path.area { fill:   var(--text-tertiary); opacity: 0.08; }
.kpi__spark--accent path.line { stroke: var(--accent); }
.kpi__spark--accent path.area { fill:   var(--accent); }
.kpi__spark--info   path.line { stroke: #7c3aed; }
.kpi__spark--info   path.area { fill:   #7c3aed; }

.dash-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    gap: var(--space-4);
}
@media (max-width: 1024px) {
    .dash-grid { grid-template-columns: 1fr; }
}

/* Financial overview card --------------------------------------------------- */
.fin-card {
    display: flex;
    flex-direction: column;
    min-height: 380px;
}
.fin-period {
    display: inline-flex;
    background: var(--surface-sunken);
    border-radius: 999px;
    padding: 3px;
    gap: 2px;
}
.fin-period__btn {
    border: 0;
    background: transparent;
    color: var(--text-tertiary);
    font-size: var(--fs-12);
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 999px;
    cursor: pointer;
    transition: background-color 120ms ease, color 120ms ease;
    line-height: 1;
}
.fin-period__btn:hover { color: var(--text-secondary); }
.fin-period__btn.is-active {
    background: var(--surface-card);
    color: var(--text-primary);
    box-shadow: 0 1px 2px rgba(15,23,42,0.05);
}
.dark .fin-period__btn.is-active { background: var(--border-default); }

.fin-stats {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: var(--space-5);
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-subtle);
    align-items: end;
}
@media (max-width: 720px) {
    .fin-stats { grid-template-columns: 1fr 1fr; }
    .fin-legend { grid-column: 1 / -1; }
}
.fin-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.fin-stat__label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.fin-stat__value {
    font-size: var(--fs-20);
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}
.fin-stat--muted .fin-stat__value { color: var(--text-secondary); font-weight: 600; }
.fin-stat__caption {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

.fin-legend {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-end;
    font-size: var(--fs-12);
    color: var(--text-secondary);
}
.fin-legend__item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.fin-legend__dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
}

.fin-canvas-wrap {
    flex: 1;
    min-height: 220px;
    padding: var(--space-3) var(--space-4) var(--space-4);
    position: relative;
}
.fin-canvas-wrap canvas { width: 100% !important; height: 100% !important; }

/* Tasks card ---------------------------------------------------------------- */
.tasks-card {
    display: flex;
    flex-direction: column;
    min-height: 380px;
}
.task-add {
    display: flex;
    align-items: center;
    padding: var(--space-3) var(--space-5);
    border-bottom: 1px solid var(--border-subtle);
    gap: 8px;
}
.task-add input {
    flex: 1;
    height: 32px;
    border: 0;
    background: transparent;
    outline: none;
    font-size: var(--fs-14);
    color: var(--text-primary);
}
.task-add input::placeholder { color: var(--text-tertiary); }
.task-add__btn {
    width: 28px;
    height: 28px;
    border: 0;
    background: var(--accent);
    color: var(--accent-strong-fg);
    border-radius: 8px;
    display: grid;
    place-items: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color 120ms ease, transform 120ms ease;
}
.task-add__btn i,
.task-add__btn svg { width: 14px !important; height: 14px !important; stroke-width: 2.25 !important; color: #fff !important; }
.task-add__btn:hover { background: var(--accent-hover); }
.task-add__btn:active { transform: scale(0.96); }

.card {
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}
.card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-subtle);
}
.card__title {
    font-size: var(--fs-14);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}
.card__body { padding: var(--space-5); }

/* Tasks list */
.task-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    transition: background-color 120ms ease;
}
.task-row:hover { background: var(--surface-hover); }
.task-row input[type="checkbox"] {
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}
.task-row__text {
    flex: 1;
    font-size: var(--fs-14);
    color: var(--text-primary);
    line-height: 1.4;
}
.task-row__text--done {
    color: var(--text-tertiary);
    text-decoration: line-through;
}
.task-row__del {
    opacity: 0;
    background: transparent;
    border: 0;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: opacity 120ms ease, color 120ms ease, background-color 120ms ease;
}
.task-row:hover .task-row__del { opacity: 1; }
.task-row__del:hover { color: var(--negative); background: var(--negative-soft); }

.empty-state {
    text-align: center;
    color: var(--text-tertiary);
    font-size: var(--fs-14);
    padding: var(--space-7) var(--space-4);
}

/* ============================================================================
 * Recent activity timeline (dashboard)
 * Day-grouped rows with a continuous vertical rail and semantic dots.
 * ============================================================================ */
.tl-group { padding: var(--space-3) 0; }
.tl-group:not(:last-child) { border-bottom: 1px solid var(--border-subtle); }
.tl-group__label {
    padding: 0 var(--space-5) var(--space-2);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.tl-list {
    position: relative;
    padding: 0 var(--space-5);
}
.tl-row {
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr) auto;
    gap: var(--space-3);
    align-items: center;
    padding: var(--space-2) var(--space-3);
    margin: 0 calc(var(--space-3) * -1);
    border-radius: var(--radius-md);
    transition: background-color 120ms ease;
}
.tl-row:hover { background: var(--surface-hover); }
.tl-row__rail {
    position: relative;
    width: 24px;
    height: 100%;
    min-height: 36px;
    display: flex;
    justify-content: center;
    align-items: center;
}
.tl-row__rail::before {
    /* Continuous vertical rail behind the dots */
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--border-subtle);
    transform: translateX(-0.5px);
}
.tl-row:first-child .tl-row__rail::before { top: 50%; }
.tl-row:last-child  .tl-row__rail::before { bottom: 50%; }
.tl-row__dot {
    position: relative;
    width: 9px;
    height: 9px;
    border-radius: 999px;
    background: var(--text-tertiary);
    box-shadow: 0 0 0 3px var(--surface-card);
    z-index: 1;
}
.tl-row__dot--invoice { background: var(--accent); }
.tl-row__dot--payment { background: var(--positive); }
.tl-row__dot--expense { background: var(--negative); }
.tl-row__dot--client  { background: #7c3aed; }

.tl-row__body { min-width: 0; }
.tl-row__title {
    font-size: var(--fs-14);
    color: var(--text-primary);
    font-weight: 500;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tl-row__sub {
    font-size: var(--fs-12);
    color: var(--text-tertiary);
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tl-row__meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    flex-shrink: 0;
    text-align: right;
}
.tl-row__amount {
    font-size: var(--fs-14);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
    line-height: 1.2;
}
.tl-row__amount--positive { color: var(--positive); }
.tl-row__amount--negative { color: var(--negative); }
.tl-row__age {
    font-size: 11px;
    color: var(--text-tertiary);
    line-height: 1.3;
}

@media (max-width: 640px) {
    .tl-list, .tl-group__label { padding-inline: var(--space-4); }
    .tl-row { grid-template-columns: 24px minmax(0, 1fr) auto; gap: 10px; }
    .tl-row__title, .tl-row__sub { font-size: 13px; }
}

/* Pill / chip badges */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: var(--fs-12);
    font-weight: 500;
    background: var(--surface-sunken);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}
.chip--accent   { background: var(--accent-soft);  color: var(--accent-soft-text); border-color: transparent; }
.chip--positive { background: var(--positive-soft); color: var(--positive); border-color: transparent; }
.chip--negative { background: var(--negative-soft); color: var(--negative); border-color: transparent; }
.chip--warning  { background: var(--warning-soft);  color: var(--warning);  border-color: transparent; }

/* -- Buttons (small refinements) ------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 var(--space-3);
    border-radius: var(--radius-md);
    font-size: var(--fs-14);
    font-weight: 500;
    border: 1px solid var(--border-default);
    background: var(--surface-card);
    color: var(--text-primary);
    cursor: pointer;
    transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}
.btn:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.btn--ghost {
    border-color: transparent;
    background: transparent;
    color: var(--text-secondary);
}
.btn--ghost:hover { background: var(--surface-hover); color: var(--text-primary); }
.btn--accent {
    background: var(--accent);
    color: var(--text-on-accent);
    border-color: var(--accent);
}
.btn--accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn i { width: 14px; height: 14px; }

/* Inputs / selects inside the redesigned chrome */
.compact-input {
    background: var(--input-bg) !important;
    border: 1px solid var(--border-default) !important;
    border-radius: var(--radius-md) !important;
    color: var(--text-primary) !important;
}
.compact-input:focus {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 3px var(--accent-soft) !important;
}

/* -- Old "ai-btn" (Insights) ------------------------------------------------ */
.ai-btn {
    background: var(--text-primary) !important;
    color: var(--surface-card) !important;
    border-radius: 999px !important;
    padding: 6px 14px !important;
    font-size: var(--fs-12) !important;
    font-weight: 600 !important;
    box-shadow: var(--shadow-card) !important;
    border: 0 !important;
}
.ai-btn:hover { background: var(--text-secondary) !important; }
.dark .ai-btn { background: var(--surface-card) !important; color: var(--text-primary) !important; }

/* -- Footer ---------------------------------------------------------------- */
footer {
    background: var(--surface-card) !important;
    border-top: 1px solid var(--border-subtle) !important;
    color: var(--text-tertiary) !important;
    font-size: var(--fs-12) !important;
}

/* -- Misc cleanups ---------------------------------------------------------- */
/* Drop the heavy uppercase "tracking-widest" labels everywhere */
.uppercase.tracking-widest,
.uppercase.tracking-wider,
.text-xxs.uppercase {
    text-transform: none !important;
    letter-spacing: 0 !important;
    font-weight: 500 !important;
}

/* ============================================================================
 * Operator-board layout (matches reference design)
 * ============================================================================ */

/* -- Sidebar shell additions (brand block, search, sections, profile) ------ */
.sb-brand {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 0 8px 18px 8px;
}
@media (max-width: 768px) {
    .sb-brand { display: flex; }
}
.sb-brand__mark {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    background: #111827;
    color: #fff;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}
.sb-brand__mark i { width: 18px; height: 18px; }
.sb-brand__mark img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; }
.sb-brand__name {
    font-size: 17px;
    font-weight: 700;
    color: #111827;
    letter-spacing: -0.01em;
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.sb-brand__collapse {
    width: 28px; height: 28px;
    display: grid; place-items: center;
    border-radius: 6px;
    color: var(--text-tertiary);
    background: transparent;
    border: 1px solid var(--border-subtle);
    cursor: pointer;
}
.sb-brand__collapse:hover { color: var(--text-primary); background: var(--surface-hover); }
.sb-brand__collapse i { width: 14px; height: 14px; }

.sb-search {
    position: relative;
    margin: 0 4px 12px 4px;
}
.sb-search input {
    width: 100%;
    height: 34px;
    padding: 0 48px 0 32px;
    border-radius: 8px;
    border: 1px solid var(--border-default);
    background: #fff;
    font-size: 13px;
    color: var(--text-primary);
    outline: none;
    font-family: inherit;
}
.sb-search input::placeholder { color: #9aa1ac; }
.sb-search input:focus { border-color: var(--border-strong); }
.sb-search .sb-search__icon {
    position: absolute;
    left: 10px; top: 50%; transform: translateY(-50%);
    width: 14px; height: 14px;
    color: var(--text-tertiary);
    pointer-events: none;
}
.sb-search .sb-search__kbd {
    position: absolute;
    right: 8px; top: 50%; transform: translateY(-50%);
    font-size: 11px;
    color: var(--text-tertiary);
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: 5px;
    padding: 1px 6px;
    line-height: 1.5;
    pointer-events: none;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* Section group container (header + items, toggleable) */
.sb-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.sb-group--flat { padding-bottom: var(--space-2); }
.sb-group + .sb-group:not(.sb-group--flat) { margin-top: var(--space-1); }

.sb-section-header {
    width: 100%;
    padding: var(--space-3) 12px var(--space-1) 12px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 0;
    background: transparent;
    cursor: pointer;
    text-align: left;
    transition: color 120ms ease;
}
.sb-section-header:hover { color: var(--text-secondary); }
.sb-section-header__chevron {
    width: 12px; height: 12px;
    color: var(--text-tertiary);
    transition: transform 180ms ease, color 120ms ease;
}
.sb-section-header:hover .sb-section-header__chevron { color: var(--text-secondary); }

.sb-group__items {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
    transition: max-height 200ms ease, opacity 160ms ease, margin 160ms ease;
    max-height: 600px;
    opacity: 1;
}
.sb-group.is-collapsed .sb-group__items {
    max-height: 0;
    opacity: 0;
    margin: 0;
    pointer-events: none;
}
.sb-group.is-collapsed .sb-section-header__chevron {
    transform: rotate(-90deg);
}

/* Profile block at the bottom of the sidebar */
.sb-profile {
    margin: 0 8px;
    padding: var(--space-3);
    border-top: 1px solid var(--border-subtle);
    display: none;
    align-items: center;
    gap: 10px;
}
@media (max-width: 768px) {
    .sb-profile { display: flex; }
}
.sb-profile__avatar {
    width: 32px; height: 32px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--accent), #fb923c);
    color: var(--accent-strong-fg);
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}
.sb-profile__meta { flex: 1; min-width: 0; }
.sb-profile__name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.sb-profile__email {
    font-size: 11px;
    color: var(--text-tertiary);
    line-height: 1.3;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.sb-profile__action {
    width: 28px; height: 28px;
    border-radius: 6px;
    display: grid; place-items: center;
    color: var(--text-tertiary);
    background: transparent;
    border: 0;
    cursor: pointer;
}
.sb-profile__action:hover { background: var(--surface-hover); color: var(--text-primary); }

/* Replace .glass-sidebar layout to host the new structure */
.glass-sidebar.sidebar--operator {
    width: 240px !important;
    padding: 12px 10px !important;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
}
.glass-sidebar.sidebar--operator nav {
    flex: 1;
    overflow-y: auto;
    padding: 0 !important;
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.glass-sidebar.sidebar--operator .sidebar-link {
    width: 100% !important;
    justify-content: flex-start !important;
    padding: 0 10px !important;
    height: 32px !important;
}

/* -- Unified list view (used by Invoices, Payments, Expenses, etc.) ------- */
.list-view {
    display: flex;
    flex-direction: column;
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    overflow: hidden;
}
.list-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto auto auto;
    align-items: stretch;
    gap: 0;
    padding: 0;
    border-bottom: 1px solid var(--border-default);
    cursor: pointer;
    transition: background-color .12s;
    position: relative;
}
.list-row > * {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    min-width: 0;
}
.list-row > .list-row__icon { padding: 14px 0 14px 20px; }
.list-row > .list-row__main { padding-left: 14px; }
.list-row > .list-row__actions { padding-right: 20px; }
.list-row:last-child { border-bottom: 0; }
/* Full-width divider line between rows */
.list-row + .list-row::before {
    content: "";
    position: absolute;
    top: -1px;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--border-default);
}
.list-row + .list-row { border-top: 0; }
.list-view .list-row { border-bottom: 0; }
.list-row:hover { background: var(--surface-hover); }
.list-row__icon {
    color: var(--text-secondary);
    flex-shrink: 0;
    justify-content: center;
}
.list-row__icon i,
.list-row__icon svg {
    width: 36px !important;
    height: 36px !important;
    padding: 10px;
    border-radius: 10px;
    background: var(--surface-sunken);
    border: 1px solid var(--border-subtle);
    box-sizing: border-box;
}
.list-row__main {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 3px;
    min-width: 0;
    overflow: hidden;
}
.list-row__main > * {
    max-width: 100%;
    min-width: 0;
}
.list-row__meta > span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
    min-width: 0;
}
.list-row__title {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.list-row__meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-tertiary);
    flex-wrap: wrap;
}
.list-row__meta > span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}
.list-row__meta svg,
.list-row__meta i { width: 11px !important; height: 11px !important; flex-shrink: 0; }
.list-row__id {
    color: var(--text-secondary);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}
.list-row__sep { opacity: 0.5; }
.list-row__amount {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    border-left: 1px solid var(--border-default);
    justify-content: flex-end;
}
.list-row__amount--positive { color: var(--positive); }
.list-row__amount--negative { color: var(--negative); }
.list-row__status {
    border-left: 1px solid var(--border-default);
    justify-content: center;
}
.list-row__status .status-pill {
    text-transform: capitalize;
    font-size: 12px;
    white-space: nowrap;
}
.list-row__chip {
    border-left: 1px solid var(--border-default);
    justify-content: center;
}
/* Ensure the chip pill itself isn't stretched to fill the cell.
 * The grid column should size to the chip's natural width. */
.list-view .list-row > span.chip.list-row__chip {
    /* Reset cell padding/flex behaviors — span is the cell. Use inline-flex sized to content with extra padding. */
    padding: 4px 12px !important;
    margin: 14px 16px !important;
    align-self: center !important;
    border-left: 0 !important;
    background: var(--chip-neutral-bg);
    color: var(--chip-neutral-fg);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    display: inline-flex !important;
    width: fit-content;
    height: fit-content;
    white-space: nowrap;
}
/* Add a separator line before the chip cell using a wrapper trick */
.list-view .list-row > span.chip.list-row__chip {
    position: relative;
}
.list-view .list-row > span.chip.list-row__chip::before {
    content: "";
    position: absolute;
    left: -16px;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--border-default);
}
.list-row__actions {
    gap: 4px;
    border-left: 1px solid var(--border-default);
    justify-content: flex-end;
}
.list-row__actions .icon-btn {
    width: 30px;
    height: 30px;
    border: 1px solid var(--border-default);
    border-radius: 7px;
    background: #fff;
    color: var(--text-secondary);
}
.list-row__actions .icon-btn:hover { background: var(--surface-hover); color: var(--text-primary); }
.list-row__actions .icon-btn--danger:hover { color: var(--negative); border-color: var(--negative); }

/* List header strip (optional) — used in Reports for "All transactions" */
.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-bottom: 0;
    border-radius: 12px 12px 0 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}
.list-header__count {
    font-size: 12px;
    color: var(--text-tertiary);
    font-weight: 400;
}
.list-header + .list-view {
    border-radius: 0 0 12px 12px;
    border-top: 0;
}

/* Mobile list-row layout — clean stacked card with status row at bottom */
@media (max-width: 768px) {
    .list-row {
        grid-template-columns: auto minmax(0, 1fr) auto !important;
        grid-template-rows: auto auto !important;
        gap: 4px 10px !important;
        padding: 12px 14px !important;
        align-items: center !important;
    }
    .list-row > * {
        padding: 0 !important;
    }
    .list-row__amount,
    .list-row__status,
    .list-row__chip,
    .list-row__actions {
        border-left: 0 !important;
        padding-left: 0 !important;
    }
    /* Icon spans both rows on the left */
    .list-row__icon {
        grid-column: 1;
        grid-row: 1 / span 2;
        align-self: center;
    }
    /* Main content top row, full middle width */
    .list-row__main {
        grid-column: 2;
        grid-row: 1;
        padding-left: 4px !important;
    }
    /* Amount top right */
    .list-row__amount {
        grid-column: 3;
        grid-row: 1;
        font-size: 14px !important;
        justify-content: flex-end !important;
    }
    /* Status + actions on bottom row spanning cols 2-3 */
    .list-row__status {
        grid-column: 2;
        grid-row: 2;
        padding-left: 4px !important;
        justify-content: flex-start !important;
        margin-top: 4px;
    }
    .list-row__chip {
        grid-column: 2;
        grid-row: 2;
        padding-left: 4px !important;
        justify-content: flex-start !important;
        margin-top: 4px;
    }
    .list-row__actions {
        grid-column: 3;
        grid-row: 2;
        justify-content: flex-end !important;
        margin-top: 4px;
    }
    .list-row__actions .icon-btn {
        width: 28px;
        height: 28px;
    }
}

/* -- Client list (matches list-view pattern with column dividers) --------- */
.client-grid {
    display: flex;
    flex-direction: column;
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    overflow: hidden;
}
.client-card {
    cursor: pointer;
    transition: background-color .12s;
    display: grid;
    grid-template-columns: 76px minmax(0, 1.4fr) minmax(0, 1.6fr) auto;
    grid-template-areas: "avatar info contact actions";
    align-items: stretch;
    gap: 0;
    padding: 0;
    border-bottom: 1px solid var(--border-default);
    background: transparent;
    position: relative;
}
.client-card .avatar-tile { grid-area: avatar; }
.client-card__info { grid-area: info; }
.client-card__contact { grid-area: contact; }
.client-card__actions { grid-area: actions; }
.client-card:last-child { border-bottom: 0; }
.client-card:hover {
    background: var(--surface-hover);
}
.client-card > * {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    min-width: 0;
}
.client-card__top {
    display: contents;
}
.client-card__top .avatar-tile {
    width: 40px !important;
    height: 40px !important;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
    padding: 0 !important;
    background-clip: padding-box;
    justify-content: center;
}
.client-card .avatar-tile {
    justify-self: center;
    align-self: center;
}
.client-card__info {
    min-width: 0;
    display: flex !important;
    flex-direction: column !important;
    gap: 3px;
    justify-content: center;
    padding-left: 0 !important;
}
.client-card__name {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}
.client-card__company {
    font-size: 12.5px;
    color: var(--text-tertiary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.client-card__actions {
    gap: 4px;
    flex-shrink: 0;
    border-left: 1px solid var(--border-default);
    justify-content: flex-end;
}
.client-card__actions .icon-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border-default);
    border-radius: 7px;
    background: #fff;
    color: var(--text-secondary);
}
.client-card__actions .icon-btn:hover { background: var(--surface-hover); color: var(--text-primary); }
.client-card__actions .icon-btn--danger:hover { color: var(--negative); border-color: var(--negative); }

.client-card__contact {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 4px !important;
    border-left: 1px solid var(--border-default);
    flex-wrap: nowrap;
    justify-content: center;
}
.client-card__contact-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    color: var(--text-secondary);
    min-width: 0;
}
.client-card__contact-row i,
.client-card__contact-row svg {
    width: 13px !important;
    height: 13px !important;
    color: var(--text-tertiary);
    flex-shrink: 0;
}
.client-card__contact-row span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

@media (max-width: 768px) {
    .client-card {
        grid-template-columns: auto 1fr auto !important;
        grid-template-areas:
            "avatar info actions"
            "contact contact contact" !important;
        gap: 0 !important;
        padding: 0 !important;
    }
    .client-card > * { padding: 12px 14px !important; }
    .client-card .avatar-tile {
        align-self: center !important;
        justify-self: center !important;
        padding: 0 !important;
        margin: 12px 0 12px 14px;
    }
    .client-card__info {
        padding-left: 12px !important;
        padding-right: 0 !important;
        align-self: center !important;
    }
    .client-card__contact {
        padding: 10px 14px 12px 64px !important; /* indent under the name */
        border-top: 1px dashed var(--border-subtle) !important;
        border-left: 0 !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        gap: 14px !important;
        align-items: center !important;
        margin-top: -2px !important;
    }
    .client-card__actions {
        border-left: 0 !important;
        padding-right: 14px !important;
        padding-left: 0 !important;
    }
    .client-card__top .avatar-tile,
    .client-card .avatar-tile {
        width: 36px !important;
        height: 36px !important;
        font-size: 12px;
    }
}

/* -- Document toolbar (invoice/estimate view) ----------------------------- */
.doc-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.doc-toolbar__back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: 0;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    padding: 8px 4px;
    transition: color .12s;
}
.doc-toolbar__back:hover { color: var(--text-primary); }
.doc-toolbar__back i,
.doc-toolbar__back svg { width: 14px !important; height: 14px !important; }
.doc-toolbar__actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}
.doc-toolbar__actions .btn,
.doc-toolbar__actions .pri-btn {
    height: 36px;
    padding: 0 14px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.doc-toolbar__actions .btn--ghost {
    background: var(--surface-card);
    border: 1px solid var(--border-default);
    color: var(--text-secondary);
}
.doc-toolbar__actions .btn--ghost:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}
.doc-toolbar__actions .btn--danger {
    color: var(--negative);
}
.doc-toolbar__actions .btn--danger:hover {
    background: var(--negative-soft);
    color: var(--negative);
    border-color: var(--negative);
}
.doc-toolbar__actions i,
.doc-toolbar__actions svg { width: 14px !important; height: 14px !important; }

@media (max-width: 768px) {
    .doc-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    .doc-toolbar__back {
        align-self: flex-start;
    }
    .doc-toolbar__actions {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    .doc-toolbar__actions .btn,
    .doc-toolbar__actions .pri-btn {
        width: 100%;
        height: 40px;
        justify-content: center;
        font-size: 13px;
    }
    .doc-toolbar__actions .pri-btn {
        grid-column: 1 / -1;
    }

    /* --- Invoice/Estimate document body (mobile) --- */
    .invoice-view #print-node {
        padding: 20px 16px !important;
        border-radius: 12px !important;
    }
    .invoice-view #print-node .flex.justify-between {
        flex-direction: column !important;
        gap: 16px !important;
    }
    .invoice-view #print-node .text-right {
        text-align: left !important;
    }
    .invoice-view #print-node .grid.grid-cols-2 {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }
    /* Items table — make horizontally scrollable */
    .invoice-view #print-node table {
        font-size: 12px !important;
        min-width: 0 !important;
    }
    .invoice-view #print-node table th,
    .invoice-view #print-node table td {
        padding: 8px 6px !important;
        font-size: 12px !important;
    }
    /* Total section — full width */
    .invoice-view #print-node .grid.grid-cols-2.gap-8 {
        grid-template-columns: 1fr !important;
    }
    /* Big Amount Due */
    .invoice-view #print-node h1 { font-size: 16px !important; }
    .invoice-view #print-node h2 { font-size: 18px !important; }
    .invoice-view #print-node .text-xl,
    .invoice-view #print-node .text-2xl { font-size: 22px !important; }
    /* Logo on mobile */
    .invoice-view #print-node img.w-12 {
        width: 36px !important;
        height: 36px !important;
    }
}

/* -- Tab strip (under page title) ------------------------------------------ */
.tabs {
    display: flex;
    align-items: center;
    gap: var(--space-5);
    border-bottom: 1px solid var(--border-subtle);
    margin: 0 0 var(--space-4) 0;
}
.tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 2px;
    border: 0;
    background: transparent;
    color: var(--text-tertiary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    position: relative;
    transition: color 120ms ease;
}
.tab i { width: 14px; height: 14px; }
.tab:hover { color: var(--text-secondary); }
.tab.is-active {
    color: var(--accent);
}
.tab.is-active::after {
    content: '';
    position: absolute;
    left: 0; right: 0; bottom: -1px;
    height: 2px;
    background: var(--accent);
    border-radius: 2px;
}

/* -- Filter chip row (Filter 0 + dropdown pills) --------------------------- */
.filter-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: var(--space-4);
}
.filter-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 32px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid var(--border-default);
    background: var(--surface-card);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 120ms ease, border-color 120ms ease;
}
.filter-pill:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.filter-pill i { width: 14px; height: 14px; }
.filter-pill__count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px; height: 18px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--surface-sunken);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
}

/* -- Activity stream — toolbar (segments + search inline) ----------------- */
.activity-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
    flex-wrap: wrap;
}
.activity-toolbar__right {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex: 1;
    min-width: 220px;
    max-width: 380px;
    justify-content: flex-end;
}
.activity-search {
    position: relative;
    flex: 1;
}
.activity-search input {
    width: 100%;
    height: 34px;
    border-radius: 8px;
    border: 1px solid var(--border-subtle);
    background: var(--surface-sunken);
    padding: 0 12px 0 32px;
    font-size: var(--fs-12);
    color: var(--text-primary);
    outline: none;
    transition: border-color 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
}
.activity-search input::placeholder { color: var(--text-tertiary); }
.activity-search input:focus {
    background: var(--surface-card);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.activity-search__icon {
    position: absolute !important;
    left: 10px; top: 50%; transform: translateY(-50%);
    width: 14px !important; height: 14px !important;
    color: var(--text-tertiary);
    pointer-events: none;
}

@media (max-width: 720px) {
    .activity-toolbar { flex-direction: column; align-items: stretch; }
    .activity-toolbar__right { max-width: none; }
    .activity-tabs { width: 100%; }
}

/* -- Activity stream — list view ------------------------------------------ */
.activity-tabs {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    padding: 4px;
    background: var(--surface-sunken);
    border-radius: 12px;
    align-self: flex-start;
}
.activity-filter {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-tertiary);
    font-size: var(--fs-12);
    font-weight: 500;
    cursor: pointer;
    transition: background-color 120ms ease, color 120ms ease;
    line-height: 1;
}
.activity-filter:hover { color: var(--text-secondary); }
.activity-filter.is-active {
    background: var(--surface-card);
    color: var(--text-primary);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}
.dark .activity-filter.is-active { background: var(--border-default); }
.activity-filter__count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 18px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--surface-sunken);
    color: var(--text-tertiary);
    font-size: 10px;
    font-weight: 600;
}
.activity-filter.is-active .activity-filter__count {
    background: var(--accent-soft);
    color: var(--accent-soft-text);
}

.activity-list {
    display: flex;
    flex-direction: column;
}
.activity-row {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) auto auto auto auto;
    gap: 16px;
    align-items: center;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: background-color 120ms ease;
    position: relative;
}
.activity-row:last-child { border-bottom: 0; }
.activity-row:hover { background: var(--surface-hover); }
.activity-row__rail { display: none; }
.activity-row__icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    color: var(--text-secondary);
    background: var(--surface-sunken);
    border: 1px solid var(--border-subtle);
    flex-shrink: 0;
}
.activity-row__icon i,
.activity-row__icon svg { width: 16px; height: 16px; }
.activity-row__main {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}
.activity-row__title {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.activity-row__meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-tertiary);
    flex-wrap: wrap;
}
.activity-row__meta > span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}
.activity-row__meta i,
.activity-row__meta svg { width: 11px; height: 11px; flex-shrink: 0; }
.activity-row__id {
    color: var(--text-secondary);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}
.activity-row__chips {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.activity-row__chips:empty { display: none; }
.activity-row__amount {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    min-width: 100px;
    text-align: right;
    flex-shrink: 0;
}
.activity-row__status {
    flex-shrink: 0;
}
.activity-row__status .status-pill {
    text-transform: capitalize;
    font-size: 12px;
}
.activity-row__avatar {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    background: linear-gradient(135deg, #6ea8ff, #1e3a8a);
    color: #ffffff;
    display: grid;
    place-items: center;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
    letter-spacing: .02em;
}

@media (max-width: 720px) {
    .activity-row {
        grid-template-columns: 36px 1fr auto;
        gap: 12px;
        padding: 12px 14px;
    }
    .activity-row__chips,
    .activity-row__amount,
    .activity-row__avatar { display: none; }
}

/* -- Kanban board ---------------------------------------------------------- */
.kanban {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--space-4);
    align-items: start;
}
.kanban-col {
    background: var(--surface-sunken);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-3);
    min-height: 200px;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}
.kanban-col__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 4px 0 4px;
}
.kanban-col__title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}
.kanban-col__title i { width: 14px; height: 14px; color: var(--text-secondary); }
.kanban-col__count {
    font-size: 12px;
    color: var(--text-tertiary);
    font-weight: 500;
}
.kanban-col__actions {
    display: flex;
    gap: 2px;
}
.kanban-col__add {
    width: 24px; height: 24px;
    border-radius: 6px;
    display: grid; place-items: center;
    color: var(--text-tertiary);
    background: transparent;
    border: 0;
    cursor: pointer;
}
.kanban-col__add:hover { color: var(--text-primary); background: var(--surface-card); }
.kanban-col__add i { width: 14px; height: 14px; }

.kcard {
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: var(--space-4);
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    cursor: pointer;
    transition: border-color 120ms ease, transform 120ms ease, box-shadow 120ms ease;
}
.kcard:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-pop);
}
.kcard__head {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.kcard__icon {
    width: 30px; height: 30px;
    border-radius: 8px;
    display: grid; place-items: center;
    flex-shrink: 0;
    background: var(--accent-soft);
    color: var(--accent-soft-text);
}
.kcard__icon i { width: 16px; height: 16px; }
.kcard__title {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}
.kcard__id {
    font-size: 12px;
    color: var(--text-tertiary);
    font-weight: 500;
    line-height: 1.4;
    margin-top: 2px;
}
.kcard__avatar {
    width: 28px; height: 28px;
    border-radius: 999px;
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    color: white;
    display: grid; place-items: center;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
}
.kcard__rows {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 12px;
}
.kcard__kv {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    min-width: 0;
}
.kcard__kv i {
    width: 13px; height: 13px;
    color: var(--text-tertiary);
    flex-shrink: 0;
}
.kcard__kv .v {
    color: var(--text-primary);
    font-weight: 500;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.kcard__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.kcard__foot {
    display: flex;
    align-items: center;
    gap: 14px;
    padding-top: var(--space-2);
    border-top: 1px dashed var(--border-subtle);
    font-size: 12px;
    color: var(--text-tertiary);
}
.kcard__foot span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.kcard__foot i { width: 12px; height: 12px; }

/* Pastel chips */
.chip--info     { background: var(--chip-info-bg);    color: var(--chip-info-fg);    border-color: transparent; }
.chip--warning  { background: var(--chip-warning-bg); color: var(--chip-warning-fg); border-color: transparent; }
.chip--danger   { background: var(--chip-danger-bg);  color: var(--chip-danger-fg);  border-color: transparent; }
.chip--success  { background: var(--chip-success-bg); color: var(--chip-success-fg); border-color: transparent; }
.chip--neutral  { background: var(--chip-neutral-bg); color: var(--chip-neutral-fg); border-color: transparent; }

.chip i {
    width: 12px;
    height: 12px;
}

/* ============================================================================
 * Shared list/form primitives — for the redesigned existing views
 * ============================================================================ */

/* Big rounded search input that lives at the top of list pages */
.search-bar {
    position: relative;
    margin-bottom: var(--space-4);
}
.search-bar input {
    width: 100%;
    height: 44px;
    border-radius: 12px;
    border: 1px solid var(--border-subtle);
    background: var(--surface-card);
    padding: 0 var(--space-4) 0 44px;
    font-size: var(--fs-14);
    color: var(--text-primary);
    transition: border-color 120ms ease, box-shadow 120ms ease;
    outline: none;
}
.search-bar input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-bar input::placeholder { color: var(--text-tertiary); }
.search-bar .search-bar__icon {
    position: absolute !important;
    left: 16px; top: 50%; transform: translateY(-50%);
    width: 16px !important; height: 16px !important;
    color: var(--text-tertiary);
    pointer-events: none;
}

/* Data table card — clean rows, soft hairline separators */
.data-card {
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-card);
}
.data-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-5);
    border-bottom: 1px solid var(--border-subtle);
    background: var(--surface-sunken);
}
.data-card__title {
    font-size: var(--fs-14);
    font-weight: 600;
    color: var(--text-primary);
}
.data-card__count {
    font-size: var(--fs-12);
    color: var(--text-tertiary);
}

.data-card-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    min-width: 480px;
}
@media (max-width: 768px) {
    /* ===========================================
     * Convert all tables to activity-row-style cards on mobile
     * =========================================== */

    /* --- Standard .data-table --- */
    .data-table,
    .dense-table,
    table.w-full {
        min-width: 0 !important;
        display: block !important;
        border: 0 !important;
        width: 100% !important;
    }
    .data-table thead,
    .dense-table thead,
    table.w-full thead { display: none !important; }
    .data-table tbody,
    .dense-table tbody,
    table.w-full tbody { display: block !important; width: 100% !important; }

    .data-table tbody tr,
    .dense-table tbody tr,
    table.w-full tbody tr {
        display: grid !important;
        grid-template-columns: 1fr auto !important;
        gap: 6px 12px !important;
        padding: 14px 16px !important;
        border-bottom: 1px solid var(--border-subtle) !important;
        background: transparent !important;
        align-items: center !important;
        cursor: pointer;
    }
    .data-table tbody tr:last-child,
    .dense-table tbody tr:last-child,
    table.w-full tbody tr:last-child { border-bottom: 0 !important; }

    .data-table tbody td,
    .dense-table tbody td,
    table.w-full tbody td {
        display: flex !important;
        align-items: center !important;
        padding: 0 !important;
        border: 0 !important;
        font-size: 13px !important;
        color: var(--text-secondary) !important;
        white-space: normal !important;
        min-width: 0;
    }
    /* First cell — primary title (left col, row 1) */
    .data-table tbody tr td:first-child,
    .dense-table tbody tr td:first-child,
    table.w-full tbody tr td:first-child {
        grid-column: 1 / -1;
        font-size: 14px !important;
        font-weight: 600 !important;
        color: var(--text-primary) !important;
        margin-bottom: 2px;
    }
    /* When first cell contains a cell-name with avatar — let it flex naturally */
    .data-table tbody tr td:first-child .cell-name {
        width: 100%;
    }
    /* Numeric/amount cells go inline, secondary look */
    .data-table tbody td.num,
    .data-table tbody td.right,
    .dense-table tbody td.num {
        font-weight: 500 !important;
        color: var(--text-primary) !important;
    }
    /* Status pill cell — keep visible */
    .data-table .status-pill {
        font-size: 11px !important;
    }
    /* Actions cell — full row at bottom, right-aligned outlined icon buttons */
    .data-table tbody td.actions,
    .dense-table tbody td.actions,
    table.w-full tbody td.actions {
        grid-column: 1 / -1 !important;
        justify-content: flex-end !important;
        gap: 6px !important;
        margin-top: 6px !important;
        padding-top: 8px !important;
        border-top: 1px dashed var(--border-subtle) !important;
        white-space: nowrap !important;
    }
    .data-table tbody td.actions .icon-btn,
    .data-table tbody td.actions button,
    .dense-table tbody td.actions button,
    table.w-full tbody td.actions button {
        width: 32px !important;
        height: 32px !important;
        min-height: 32px !important;
        border: 1px solid var(--border-default) !important;
        border-radius: 8px !important;
        background: #fff !important;
        padding: 0 !important;
        flex-shrink: 0;
        color: var(--text-secondary) !important;
    }
    /* Text-link actions (Pause / Edit / Delete in dense-table) — convert to icon buttons */
    .dense-table tbody td:last-child {
        grid-column: 1 / -1 !important;
        justify-content: flex-end !important;
        gap: 12px !important;
        margin-top: 6px !important;
        padding-top: 8px !important;
        border-top: 1px dashed var(--border-subtle) !important;
        font-size: 13px !important;
    }

    /* Cell-name with avatar (clients/products tables) */
    .data-table .cell-name {
        display: flex !important;
        gap: 12px !important;
        align-items: center !important;
    }
    .data-table .avatar-tile {
        width: 36px !important;
        height: 36px !important;
        font-size: 12px !important;
        flex-shrink: 0;
    }
    .data-table .cell-stack {
        min-width: 0;
        flex: 1;
    }
    .data-table .cell-stack__primary {
        font-size: 14px;
        font-weight: 600;
    }
    .data-table .cell-stack__secondary {
        font-size: 12px;
        color: var(--text-tertiary);
        white-space: normal !important;
        max-width: none !important;
    }
    /* Override inline overflow-x wrappers */
    .data-card > div[style*="overflow-x"],
    .glass-panel > div[style*="overflow-x"],
    .overflow-x-auto {
        overflow-x: visible !important;
    }

    /* --- Glass panel grid (Templates / Settings forms) --- */
    .grid.grid-cols-1.lg\\:grid-cols-2,
    .grid.grid-cols-2,
    .grid.grid-cols-3,
    .grid.lg\\:grid-cols-2 {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
    .glass-panel {
        padding: 14px !important;
        border-radius: 12px !important;
    }
    .glass-panel h3 {
        font-size: 13px !important;
        margin-bottom: 12px !important;
    }

    /* Recurring Invoices header (Tailwind layout) */
    .flex.justify-between.items-center {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
    }
    .flex.justify-between.items-center > h2 {
        font-size: 20px !important;
    }
    .flex.justify-between.items-center > button {
        width: 100% !important;
        justify-content: center !important;
    }
}
.data-table thead th {
    background: var(--surface-sunken);
    color: var(--text-tertiary);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: var(--space-3) var(--space-5);
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
}
.data-table tbody td {
    padding: var(--space-3) var(--space-5);
    border-bottom: 1px solid var(--border-subtle);
    font-size: var(--fs-14);
    color: var(--text-primary);
    vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr {
    transition: background-color 120ms ease;
}
.data-table tbody tr:hover { background: var(--surface-hover); }
.data-table .muted   { color: var(--text-tertiary); }
.data-table .num     { font-variant-numeric: tabular-nums; font-weight: 500; }
.data-table .right   { text-align: right; }
.data-table .actions {
    text-align: right;
    white-space: nowrap;
}
.data-table .actions .icon-btn {
    width: 28px;
    height: 28px;
}

/* Refined client table — taller rows, always-visible action button cluster */
.data-table--clients tbody tr {
    transition: background-color 120ms ease;
}
.data-table--clients tbody td { padding: 14px var(--space-5); }
.data-table--clients tbody tr:hover { background: var(--surface-hover); }

/* Action buttons sit in a neat right-aligned row, always visible */
.data-table--clients .actions {
    text-align: right;
}
.data-table--clients .actions .action-cluster {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px;
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: 9px;
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.02);
}
.data-table--clients tbody tr:hover .action-cluster {
    background: var(--surface-card);
    border-color: var(--border-strong);
}
.data-table--clients .actions .icon-btn {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    background: transparent;
    border: 0;
    color: var(--text-secondary);
    transition: background-color 120ms ease, color 120ms ease;
}
.data-table--clients .actions .icon-btn:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}
.data-table--clients .actions .icon-btn--danger:hover {
    background: var(--chip-danger-bg);
    color: var(--negative);
}
.data-table--clients .actions .action-divider {
    width: 1px;
    height: 16px;
    background: var(--border-subtle);
    margin: 0 2px;
}

/* Client detail page — title block with avatar, contact-info card */
.client-head__title {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-width: 0;
    flex: 1;
}
.client-head__title h2 {
    font-size: 22px !important;
    font-weight: 600 !important;
    letter-spacing: -0.018em !important;
    line-height: 1.2 !important;
}
.contact-item {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-3);
    border-radius: 10px;
    background: var(--surface-sunken);
    transition: background-color 120ms ease;
}
.contact-item:hover { background: var(--surface-hover); }
.contact-item__icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--surface-card);
    color: var(--text-tertiary);
    display: grid;
    place-items: center;
    flex-shrink: 0;
}
.contact-item__icon i { width: 14px; height: 14px; }
.contact-item__label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 2px;
}
.contact-item__value {
    font-size: var(--fs-14);
    color: var(--text-primary);
    text-decoration: none;
    line-height: 1.4;
}
a.contact-item__value:hover { color: var(--accent); }

/* Inline status dot (replaces the dedicated status column) */
.status-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 999px;
    margin-left: 8px;
    vertical-align: middle;
    background: var(--text-tertiary);
    transform: translateY(-1px);
}
.status-dot.on  { background: var(--positive); box-shadow: 0 0 0 3px var(--chip-success-bg); }
.status-dot.off { background: var(--text-tertiary); box-shadow: 0 0 0 3px var(--chip-neutral-bg); }

/* Avatar tile (used in clients list) */
.avatar-tile {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 600;
    color: white;
    flex-shrink: 0;
    letter-spacing: 0.02em;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.18), inset 0 -1px 0 rgba(0,0,0,0.06);
}
.avatar-tile.tile--rose    { background: linear-gradient(135deg, #fb7185, #e11d48); }
.avatar-tile.tile--teal    { background: linear-gradient(135deg, #2dd4bf, #0d9488); }
.avatar-tile.tile--sky     { background: linear-gradient(135deg, #38bdf8, #0284c7); }
.avatar-tile.tile--amber   { background: linear-gradient(135deg, #fbbf24, #d97706); }
.avatar-tile.tile--violet  { background: linear-gradient(135deg, #a78bfa, #7c3aed); }
.avatar-tile.tile--emerald { background: linear-gradient(135deg, #34d399, #059669); }

/* Status pills (semantic — used by tables) */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: var(--fs-12);
    font-weight: 500;
    line-height: 1;
}
.status-pill::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 999px;
    background: currentColor;
}
.status-pill.active   { background: var(--chip-success-bg); color: var(--chip-success-fg); }
.status-pill.inactive { background: var(--chip-neutral-bg); color: var(--chip-neutral-fg); }
.status-pill.draft    { background: var(--chip-neutral-bg); color: var(--chip-neutral-fg); }
.status-pill.sent     { background: var(--chip-info-bg);    color: var(--chip-info-fg); }
.status-pill.partial  { background: var(--chip-warning-bg); color: var(--chip-warning-fg); }
.status-pill.overdue  { background: var(--chip-danger-bg);  color: var(--chip-danger-fg); }
.status-pill.paid     { background: var(--chip-success-bg); color: var(--chip-success-fg); }

/* Primary CTA "+" button (top-right of pages) */
.pri-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 var(--space-4);
    border-radius: 10px;
    background: var(--text-primary);
    color: var(--surface-card);
    border: 0;
    font-size: var(--fs-14);
    font-weight: 600;
    cursor: pointer;
    transition: background-color 120ms ease, transform 120ms ease;
}
.pri-btn:hover { background: var(--text-secondary); }
.pri-btn i { width: 14px; height: 14px; }
.dark .pri-btn { background: var(--surface-card); color: var(--text-primary); }
.dark .pri-btn:hover { background: var(--surface-hover); }

/* Form card — modal-style centered form */
.form-card {
    max-width: 680px;
    margin: 24px auto;
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 12px -4px rgba(15, 23, 42, 0.06);
    padding: 28px 28px 24px;
}
.form-card__title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 4px 0;
    letter-spacing: -0.01em;
}
.form-card__title + .form-card__sub,
.form-card .form-card__sub {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0 0 24px 0;
}
.form-card form { gap: 16px !important; }
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
@media (max-width: 640px) {
    .form-grid { grid-template-columns: 1fr; }
    .form-card { padding: 20px 18px; margin: 16px 0; }
}

/* Field with label wrapping */
.form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}
.form-field > label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-input,
.form-card input[type="text"],
.form-card input[type="email"],
.form-card input[type="tel"],
.form-card input[type="number"],
.form-card input[type="date"],
.form-card input[type="month"],
.form-card input[type="password"],
.form-card select,
.form-card textarea {
    width: 100%;
    height: 42px;
    border-radius: 10px;
    border: 1px solid var(--border-default);
    background: var(--surface-card);
    padding: 0 14px;
    font-size: 14px;
    color: var(--text-primary);
    outline: none;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}
.form-card textarea {
    height: auto;
    min-height: 96px;
    padding: 10px 14px;
    resize: vertical;
    line-height: 1.5;
}
.form-card select {
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'></polyline></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}
.form-card input:focus,
.form-card select:focus,
.form-card textarea:focus {
    border-color: var(--text-primary);
    box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.06);
}
.form-card input::placeholder,
.form-card textarea::placeholder { color: var(--text-tertiary); }

.form-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-subtle);
}
.form-actions .btn,
.form-actions .pri-btn,
.form-actions .btn--accent {
    height: 40px;
    padding: 0 18px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 9px;
}
.form-actions .btn--ghost {
    background: transparent;
    border: 0;
    color: var(--text-secondary);
}
.form-actions .btn--ghost:hover { color: var(--text-primary); background: var(--surface-hover); }
.form-actions .btn--accent {
    background: var(--text-primary);
    color: #fff;
    border: 0;
}
.form-actions .btn--accent:hover { background: #1f2937; }

/* ============================================================================
 * Document editor (createInvoice / createEstimate)
 * Sectioned cards with clean form fields, dedicated totals panel,
 * inline line-item table, and a hero "Total due" reveal.
 * ============================================================================ */
.doc-card {
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    /* No overflow: hidden — the product autocomplete dropdown needs to
     * escape the card vertically. Children that need clipping use their
     * own border-radius + overflow as needed. */
}
.doc-card__head,
.doc-card__section-head { border-radius: 0; }
.doc-card > :first-child { border-top-left-radius: var(--radius-lg); border-top-right-radius: var(--radius-lg); }
.doc-card > :last-child { border-bottom-left-radius: var(--radius-lg); border-bottom-right-radius: var(--radius-lg); }
.doc-card__head {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 24px;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--surface-sunken);
}
.doc-card__from { min-width: 0; }
.doc-card__brand {
    display: flex;
    gap: 12px;
    align-items: center;
}
.doc-card__mark {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--surface-card);
    color: var(--accent);
    display: grid;
    place-items: center;
    flex-shrink: 0;
    border: 1px solid var(--border-subtle);
    overflow: hidden;
}
.doc-card__mark i,
.doc-card__mark img { width: 24px; height: 24px; }
.doc-card__company {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
    letter-spacing: -0.01em;
}
.doc-card__contact {
    font-size: 12px;
    color: var(--text-tertiary);
    line-height: 1.45;
}
.doc-card__num {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-end;
    text-align: right;
}
.doc-card__num-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.doc-card__num input {
    width: 160px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border-default);
    background: var(--surface-card);
    padding: 0 12px;
    font-size: 13px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-weight: 600;
    color: var(--text-primary);
    text-align: right;
    outline: none;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}
.doc-card__num input:focus { border-color: var(--text-primary); box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.08); }

.doc-card__section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}
.doc-card__section-head > span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 11px;
    font-weight: 600;
}
.doc-card__section-head > span i,
.doc-card__section-head > span svg { width: 14px !important; height: 14px !important; color: var(--text-tertiary); }
.doc-card__section-head .btn {
    height: 32px;
    padding: 0 12px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 7px;
}
.doc-card__section-head--inner {
    border-top: 1px solid var(--border-subtle);
    border-bottom: 0;
}

/* Field grid — Bill to spans 2 cols, then 3 meta fields below */
.doc-fields {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px 20px;
    padding: 24px;
}
.doc-field--span2 { grid-column: 1 / -1; }

@media (max-width: 900px) {
    .doc-fields { grid-template-columns: 1fr 1fr; gap: 14px; padding: 20px; }
    .doc-field--span2 { grid-column: 1 / -1; }
}
@media (max-width: 600px) {
    .doc-fields { grid-template-columns: 1fr; gap: 14px; padding: 16px; }
    .doc-field--span2 { grid-column: 1; }
}
.doc-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}
.doc-field > span {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.doc-field input,
.doc-field select,
.doc-field textarea {
    width: 100%;
    height: 42px;
    border-radius: 10px;
    border: 1px solid var(--border-default);
    background: var(--surface-card);
    padding: 0 14px;
    font-size: 14px;
    color: var(--text-primary);
    outline: none;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}
.doc-field select {
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'></polyline></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}
.doc-field textarea {
    height: auto;
    min-height: 72px;
    padding: 10px 14px;
    line-height: 1.5;
    resize: vertical;
    margin-top: 8px;
}
.doc-field input:focus,
.doc-field select:focus,
.doc-field textarea:focus {
    border-color: var(--text-primary);
    box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.06);
}

/* Items table inside the doc editor.
 * No overflow on the wrapper — autocomplete dropdowns from the description
 * field need to escape vertically, and the CSS spec turns overflow-x:auto
 * into auto-on-both-axes which would clip them. The table itself just
 * overflows horizontally on narrow viewports; the page handles scrolling. */
.doc-items-wrap { width: 100%; }
.doc-items td { position: relative; }

.doc-items {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}
.doc-items thead th {
    background: var(--surface-sunken);
    color: var(--text-tertiary);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
    text-align: left;
}
.doc-items tbody td {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
}
.doc-items tbody tr:last-child td { border-bottom: 0; }
.doc-items input,
.doc-items textarea {
    width: 100%;
    border: 1px solid transparent;
    background: transparent;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: var(--fs-14);
    color: var(--text-primary);
    outline: none;
    transition: border-color 120ms ease, background 120ms ease;
}
.doc-items input:hover,
.doc-items textarea:hover {
    border-color: var(--border-subtle);
    background: var(--surface-sunken);
}
.doc-items input:focus,
.doc-items textarea:focus {
    border-color: var(--accent);
    background: var(--surface-card);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Mobile: convert doc-items table rows to stacked cards */
@media (max-width: 768px) {
    .doc-items-wrap,
    .doc-items { overflow: visible !important; }
    .doc-items { display: block !important; }
    .doc-items thead { display: none !important; }
    .doc-items tbody { display: block !important; }
    .doc-items tbody tr {
        display: grid !important;
        grid-template-columns: 70px 1fr 1fr;
        gap: 10px;
        position: relative;
        padding: 14px;
        margin-bottom: 12px;
        border: 1px solid var(--border-subtle);
        border-radius: 12px;
        background: var(--surface-card);
        overflow: visible !important;
    }
    /* Ensure description dropdown can overflow the card — relative wrapper + absolute dropdown */
    .doc-items tbody td.pl-3 .relative {
        position: relative !important;
    }
    .doc-items tbody td.pl-3 [id^="suggestions-"] {
        position: absolute !important;
        top: 100% !important;
        left: 0 !important;
        right: 0 !important;
        margin-top: 4px !important;
        z-index: 100 !important;
        max-height: 240px !important;
        width: auto !important;
    }
    .doc-items tbody td {
        display: block !important;
        padding: 0 !important;
        border: 0 !important;
        position: relative;
    }
    /* Description (first cell) — full width with right padding for X */
    .doc-items tbody td.pl-3 {
        grid-column: 1 / -1 !important;
        padding-right: 40px !important;
        position: relative !important;
    }
    /* Qty / Price / Total cells with data-label */
    .doc-items tbody td[data-label]::before {
        content: attr(data-label);
        display: block;
        font-size: 10px;
        font-weight: 600;
        color: var(--text-tertiary);
        text-transform: uppercase;
        letter-spacing: .04em;
        margin-bottom: 4px;
    }
    /* Total cell — styled readonly value box */
    .doc-items tbody td.item-total,
    .doc-items tbody td[data-label="Total"] {
        text-align: left !important;
        font-size: 14px;
        font-weight: 600;
        color: var(--text-primary);
        font-variant-numeric: tabular-nums;
        align-self: stretch !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: flex-start !important;
        padding-top: 0 !important;
    }
    .doc-items tbody td.item-total::after {
        content: attr(data-currency-symbol, "₹");
    }
    /* Display the total in a styled value box mimicking inputs */
    .doc-items tbody td.item-total {
        padding: 0 !important;
    }
    .doc-items tbody td.item-total::before {
        content: attr(data-label);
        display: block;
        font-size: 10px;
        font-weight: 600;
        color: var(--text-tertiary);
        text-transform: uppercase;
        letter-spacing: .04em;
        margin-bottom: 4px;
    }
    /* Wrap total in a styled div using counter-content trick or simpler — just style the td as a display field */
    .doc-items tbody td.item-total {
        position: relative;
    }
    /* Inputs visible on mobile */
    .doc-items input,
    .doc-items textarea {
        border: 1px solid var(--border-default) !important;
        background: var(--surface-card) !important;
        min-height: 40px !important;
        font-size: 14px !important;
    }
    /* Delete X button — absolute centered vertically with the description textarea */
    .doc-items tbody td.w-8 {
        position: absolute !important;
        top: 34px !important; /* matches center of textarea (padding-top 14px + half of 40px height) */
        right: 14px !important;
        transform: translateY(-50%) !important;
        width: auto !important;
        grid-column: unset !important;
        display: block !important;
        z-index: 2;
    }
    .doc-items tbody td.w-8 button {
        width: 20px !important;
        height: 20px !important;
        min-height: 20px !important;
        border-radius: 50% !important;
        background: var(--text-primary) !important;
        color: #fff !important;
        padding: 0 !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        border: 0 !important;
    }
    .doc-items tbody td.w-8 button:hover {
        background: var(--negative) !important;
        color: #fff !important;
    }
    .doc-items tbody td.w-8 button svg {
        width: 12px !important;
        height: 12px !important;
        stroke-width: 2.5 !important;
    }
}

/* Foot split: notes (left, 2/3) + totals (right, 1/3) */
.doc-foot {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 16px;
    align-items: stretch;
}
@media (max-width: 900px) {
    .doc-foot { grid-template-columns: 1fr; }
}
.doc-foot__totals {
    display: flex;
    flex-direction: column;
}
.doc-foot__totals .doc-totals { padding: 20px 24px; }
.doc-foot__notes {
    display: flex;
    flex-direction: column;
}

.doc-notes-wrap {
    padding: 14px 24px 20px;
}
.doc-textarea {
    width: 100%;
    min-height: 100px;
    padding: 14px 16px;
    border-radius: 10px;
    border: 1px solid var(--border-default);
    background: var(--surface-card);
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.5;
    resize: vertical;
    outline: none;
    transition: border-color 120ms ease, box-shadow 120ms ease;
    box-sizing: border-box;
    display: block;
}
.doc-textarea:focus { border-color: var(--text-primary); box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.06); }

.doc-agreements {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px 24px 20px;
}
.doc-checkbox {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    border: 1px solid var(--border-subtle);
    transition: background-color 120ms ease, border-color 120ms ease;
}
.doc-checkbox:hover {
    border-color: var(--border-default);
    background: var(--surface-sunken);
}
.doc-checkbox:has(input:checked) {
    border-color: var(--text-primary);
    background: var(--surface-sunken);
}
.doc-checkbox input[type="checkbox"] {
    accent-color: var(--text-primary);
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    cursor: pointer;
}
.doc-checkbox span strong { color: var(--text-primary); font-weight: 600; }

/* Totals panel — clean ledger-style layout */
.doc-totals {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.doc-totals__row {
    display: grid;
    grid-template-columns: minmax(0, auto) 1fr auto;
    gap: 12px;
    align-items: center;
    font-size: 13.5px;
    color: var(--text-secondary);
    min-height: 36px;
    padding: 4px 0;
}
.doc-totals__row + .doc-totals__row {
    border-top: 1px dashed var(--border-subtle);
}
.doc-totals__row > span:first-child {
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
}
.doc-totals__row .num {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--text-primary);
    text-align: right;
    white-space: nowrap;
    grid-column: 3;
}
.doc-totals__discount {
    display: flex;
    align-items: center;
    gap: 6px;
    justify-self: end;
    grid-column: 2;
}
.doc-totals__discount select,
.doc-totals__discount input {
    height: 32px;
    border-radius: 7px;
    border: 1px solid var(--border-default);
    background: var(--surface-card);
    padding: 0 10px;
    font-size: 12px;
    color: var(--text-primary);
    outline: none;
    transition: border-color 120ms ease, box-shadow 120ms ease;
    -moz-appearance: textfield;
}
.doc-totals__discount input::-webkit-outer-spin-button,
.doc-totals__discount input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.doc-totals__discount select { width: 56px; padding-right: 22px; appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'></polyline></svg>"); background-repeat: no-repeat; background-position: right 8px center; }
.doc-totals__discount input { width: 64px; text-align: right; }
.doc-totals__discount input:focus,
.doc-totals__discount select:focus { border-color: var(--text-primary); box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.06); }
.doc-totals__neg { color: var(--negative) !important; }

/* Grand total — highlighted banner with dark background */
.doc-totals__grand {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 12px;
    margin-top: 14px;
    padding: 18px 20px;
    background: var(--text-primary);
    color: rgba(255, 255, 255, 0.85);
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.doc-totals__grand .num {
    font-size: 22px;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    text-align: right;
    text-transform: none;
}
.doc-totals__words {
    font-size: 11px;
    color: var(--text-tertiary);
    font-style: italic;
    line-height: 1.4;
    grid-column: 1 / -1;
    margin-top: 4px;
}
.doc-totals__words:empty { display: none; }


/* ----- Doc editor: mobile / narrow-viewport overrides ------------------- */
@media (max-width: 640px) {
    .doc-editor { padding: 0 var(--space-3); }

    /* Page head stacks: title above, actions below as a full-width row */
    .doc-editor .page-head {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-3);
    }
    .doc-editor .page-head > div:last-child {
        display: flex;
        gap: var(--space-2);
    }
    .doc-editor .page-head .pri-btn,
    .doc-editor .page-head .btn { flex: 1; justify-content: center; }

    /* Doc card header stacks brand on top, number below, both full width */
    .doc-card__head {
        grid-template-columns: 1fr !important;
        gap: 14px !important;
        padding: 16px !important;
    }
    .doc-card__num {
        align-items: stretch;
        text-align: left;
        width: 100%;
    }
    .doc-card__num input { width: 100%; text-align: left; }

    /* All form fields stack 1-column on phones */
    .doc-fields {
        grid-template-columns: 1fr;
        padding: var(--space-4);
        gap: var(--space-3);
    }
    .doc-field--span2 { grid-column: 1 / -1; }

    /* Items: render each row as a stacked card.
     * Layout: single-line description on top with × close on the right, then
     * a 3-column grid below (Qty / Price / Total) with tiny uppercase labels.
     */
    .doc-items thead { display: none; }
    .doc-items,
    .doc-items tbody { display: block; width: 100%; }
    .doc-items-wrap { padding: 0 var(--space-3); }
    .doc-items tbody tr {
        position: relative;
        display: grid;
        /* Qty hugs (~80px), Price wider for currency digits (~110px),
         * Total takes the rest and right-aligns. No more stranded whitespace. */
        grid-template-columns: 80px 110px 1fr;
        grid-template-areas:
            "desc desc desc"
            "qty  price total";
        gap: 12px;
        padding: 12px;
        border: 1px solid var(--border-subtle);
        border-radius: 12px;
        margin: 12px 0;
        background: var(--surface-card);
    }
    .doc-items tbody td {
        display: block;
        padding: 0;
        border: 0;
        min-width: 0;
    }
    .doc-items tbody td:nth-child(1) {
        grid-area: desc;
        padding-right: 0;
    }
    .doc-items tbody td:nth-child(1) > div { width: 100%; }
    /* Pad the description's text inside the input so typed content doesn't
     * collide with the floating × button (instead of reserving cell padding). */
    .doc-items textarea.item-desc { padding-right: 36px !important; }
    .doc-items tbody td:nth-child(2) { grid-area: qty; }
    .doc-items tbody td:nth-child(3) { grid-area: price; }
    .doc-items tbody td:nth-child(4) { grid-area: total; }

    /* Float the delete cell into the top-right corner of the row card */
    .doc-items tbody td:nth-child(5) {
        position: absolute;
        top: 8px;
        right: 8px;
    }
    .doc-items tbody td:nth-child(5) button {
        width: 26px;
        height: 26px;
        border-radius: 6px;
        display: grid;
        place-items: center;
        background: var(--surface-sunken);
        color: var(--text-tertiary);
        border: 0;
        cursor: pointer;
        transition: background-color 120ms ease, color 120ms ease;
    }
    .doc-items tbody td:nth-child(5) button:hover {
        background: var(--chip-danger-bg);
        color: var(--negative);
    }
    .doc-items tbody td:nth-child(5) i,
    .doc-items tbody td:nth-child(5) svg { width: 14px !important; height: 14px !important; }

    /* Tiny uppercase labels above qty / price / total (uses data-label attr) */
    .doc-items tbody td:nth-child(2)::before,
    .doc-items tbody td:nth-child(3)::before,
    .doc-items tbody td:nth-child(4)::before {
        content: attr(data-label);
        display: block;
        font-size: 10px;
        font-weight: 600;
        color: var(--text-tertiary);
        text-transform: uppercase;
        letter-spacing: 0.04em;
        margin-bottom: 6px;
    }

    /* Total cell — right-aligned, label + value also right-aligned */
    .doc-items tbody td:nth-child(4) {
        font-size: var(--fs-14);
        font-weight: 600;
        color: var(--text-primary);
        font-variant-numeric: tabular-nums;
        text-align: right;
        align-self: end;
        padding-bottom: 9px; /* baseline-align with input fields beside it */
    }
    .doc-items tbody td:nth-child(4)::before { text-align: right; }

    /* Inputs in the stacked cards */
    .doc-items input,
    .doc-items textarea {
        border: 1px solid var(--border-subtle);
        background: var(--surface-card);
        height: 36px;
        padding: 0 10px;
        font-size: var(--fs-14);
        border-radius: 8px;
        width: 100%;
        outline: none;
        transition: border-color 120ms ease, box-shadow 120ms ease;
    }
    .doc-items input:focus,
    .doc-items textarea:focus {
        border-color: var(--accent);
        box-shadow: 0 0 0 3px var(--accent-soft);
    }

    /* Description: single-line input behaviour. The textarea is forced to a
     * single comfortable line that can't grow vertically and doesn't wrap. */
    .doc-items textarea.item-desc {
        height: 36px !important;
        min-height: 36px;
        max-height: 36px;
        line-height: 36px;
        padding: 0 10px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        resize: none;
    }
    .doc-items textarea.item-desc:focus {
        white-space: normal;
        overflow: auto;
        max-height: 96px;
        line-height: 1.4;
        padding: 8px 10px;
        height: auto !important;
    }

    /* Center-align numeric inputs to match label alignment */
    .doc-items td:nth-child(2) input { text-align: center; }
    .doc-items td:nth-child(3) input { text-align: right; }

    /* Foot grid: notes first, totals second, both full-width */
    .doc-foot { grid-template-columns: 1fr; gap: var(--space-3); }

    /* Totals: tighten control widths to fit 360px-ish viewport */
    .doc-totals { padding: var(--space-4) !important; }
    .doc-totals__discount select { width: 48px; }
    .doc-totals__discount input  { width: 56px; }

    /* Doc card section heads: smaller padding */
    .doc-card__section-head { padding: var(--space-3) var(--space-4); }
    .doc-card__section-head .btn { padding: 0 10px; height: 30px; }
}

/* Sub-row layout helper (inside table cells: name + secondary) */
.cell-stack {
    display: flex;
    flex-direction: column;
    gap: 2px;
    line-height: 1.3;
}
.cell-stack__primary   { color: var(--text-primary); font-weight: 500; }
.cell-stack__secondary { color: var(--text-tertiary); font-size: 12px; }

.cell-name {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* -- Modal redesign -------------------------------------------------------- */
#modal-container .bg-white,
#modal-container > div > div {
    background: var(--surface-card) !important;
    border: 1px solid var(--border-subtle) !important;
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-pop) !important;
    color: var(--text-primary) !important;
}
.dark #modal-container .bg-white,
.dark #modal-container > div > div {
    background: var(--surface-card) !important;
}

/* Mobile bottom nav */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 40;
    background: var(--surface-card);
    border-top: 1px solid var(--border-subtle);
    display: none;
    padding: 6px 0 env(safe-area-inset-bottom, 6px);
}
@media (max-width: 768px) {
    .mobile-bottom-nav { display: flex; }
    .app-main { padding-bottom: 56px !important; }
}
.mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 0;
    color: var(--text-tertiary);
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    transition: color 120ms ease;
}
.mobile-nav-item i, .mobile-nav-item svg { width: 20px !important; height: 20px !important; }
.mobile-nav-item.active { color: var(--accent); }
.mobile-nav-item:hover { color: var(--text-secondary); }

/* Mobile more menu */
.mobile-more-menu {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 50;
    background: var(--surface-overlay);
}
.mobile-more-menu.show { display: flex; }
.mobile-more-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface-card);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding: var(--space-5);
    max-height: 70vh;
    overflow-y: auto;
}
.mobile-more-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-4);
}
.mobile-more-header h3 {
    font-size: var(--fs-16);
    font-weight: 600;
    color: var(--text-primary);
}
.mobile-more-close {
    width: 32px; height: 32px;
    border-radius: 999px;
    display: grid; place-items: center;
    background: var(--surface-sunken);
    border: 0;
    color: var(--text-secondary);
    cursor: pointer;
}
.mobile-more-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-3);
}
.mobile-more-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: var(--space-3);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: var(--fs-12);
    font-weight: 500;
    cursor: pointer;
    transition: background-color 120ms ease;
}
.mobile-more-item:hover { background: var(--surface-hover); }
.mobile-more-item.active { color: var(--accent); }
.mobile-more-item i, .mobile-more-item svg { width: 22px !important; height: 22px !important; }
.mobile-more-item.logout-item { color: var(--negative); }

/* (form-card defined above — no duplicate needed) */

/* Form inputs universal */
.form-input {
    height: 44px;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    background: var(--surface-card);
    color: var(--text-primary);
    font-size: var(--fs-14);
    outline: none;
    padding: 0 14px;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}
.form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

/* View client KPI grid on mobile */
@media (max-width: 768px) {
    .kpi-grid[style*="grid-template-columns: repeat(4"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}
@media (max-width: 480px) {
    .kpi-grid[style*="grid-template-columns: repeat(4"] {
        grid-template-columns: 1fr !important;
    }
}

/* Contact item address span 2 fix on mobile */
@media (max-width: 640px) {
    .contact-item[style*="grid-column: span 2"] {
        grid-column: 1 / -1 !important;
    }
}

/* Glass panel — unified card surface */
.glass-panel {
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
}

/* Dense table — compact table for settings sub-views */
.dense-table th {
    font-size: var(--fs-11);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-tertiary);
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--surface-base);
}
.dense-table td {
    font-size: var(--fs-13);
    color: var(--text-primary);
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-subtle);
}
.dense-table tr:last-child td { border-bottom: 0; }

/* ─── Settings page design system (s- prefix) ─── */

/* Page wrapper */
/* Settings page — sidebar nav + content area layout */
.s-page {
    width: 100%;
    max-width: 100%;
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 32px;
    align-items: flex-start;
}
.s-page__header {
    grid-column: 1 / -1;
    margin-bottom: 8px;
}
.s-page__title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    margin: 0 0 4px 0;
}
.s-page__subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
}

/* Sidebar nav (vertical) */
.s-page__tabs {
    display: flex;
    flex-direction: column;
    gap: 1px;
    border: 0;
    margin: 0;
    padding: 8px 0;
    position: sticky;
    top: 0;
    align-self: start;
}
.s-page__tabs::-webkit-scrollbar { display: none; }

.s-page__tab {
    padding: 9px 14px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background: none;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 120ms ease, color 120ms ease;
    text-align: left;
    margin: 0;
}
.s-page__tab:hover { color: var(--text-primary); background: var(--surface-sunken); }
.s-page__tab.active {
    color: var(--text-primary);
    font-weight: 600;
    background: var(--surface-sunken);
    border: 0;
}

/* Content body */
.s-page__body {
    max-width: 720px;
    min-width: 0;
}

/* View container — wraps all sections in a tab */
.s-view {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Section — each settings group as a card */
.s-section {
    padding: 24px;
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    background: var(--surface-card);
}
.s-section:first-child { padding-top: 24px; }
.s-section:last-child { border-bottom: 1px solid var(--border-subtle); }

.s-section__head {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-subtle);
}
.s-section__title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: none;
    letter-spacing: -0.01em;
    margin: 0 0 4px 0;
}
.s-section__desc {
    font-size: 13px;
    color: var(--text-tertiary);
    margin: 0;
    line-height: 1.5;
}

/* Document Templates page — clean panel cards */
.flex-1 .glass-panel,
.w-full .glass-panel {
    background: var(--surface-card) !important;
    border: 1px solid var(--border-subtle) !important;
    border-radius: 12px !important;
    padding: 20px 22px !important;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}
.glass-panel > h3 {
    font-size: 14px !important;
    font-weight: 600 !important;
    color: var(--text-primary) !important;
    margin: 0 0 16px 0 !important;
    letter-spacing: -0.01em;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-subtle);
}
.glass-panel > h3 svg {
    width: 16px !important;
    height: 16px !important;
    color: var(--text-secondary) !important;
}
/* Checkboxes inside glass-panel forms */
.glass-panel input[type="checkbox"] {
    accent-color: var(--text-primary) !important;
    width: 16px !important;
    height: 16px !important;
}
.glass-panel label.flex.items-center {
    padding: 6px 0;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
}
/* Field labels */
.glass-panel label.block.text-xs {
    font-size: 11px !important;
    font-weight: 600 !important;
    color: var(--text-tertiary) !important;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px !important;
}
/* Inputs/selects inside glass-panel */
.glass-panel input[type="text"],
.glass-panel input[type="email"],
.glass-panel input[type="number"],
.glass-panel input[type="color"],
.glass-panel select,
.glass-panel textarea {
    width: 100%;
    height: 40px;
    padding: 0 14px;
    border-radius: 9px;
    border: 1px solid var(--border-default);
    background: var(--surface-card);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: border-color .12s, box-shadow .12s;
}
.glass-panel textarea {
    height: auto;
    min-height: 80px;
    padding: 10px 14px;
    line-height: 1.5;
    resize: vertical;
}
.glass-panel input:focus,
.glass-panel select:focus,
.glass-panel textarea:focus {
    border-color: var(--text-primary);
    box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.06);
}
.glass-panel input[type="color"] {
    height: 44px;
    padding: 4px;
    cursor: pointer;
}

/* Mobile: stack 2-col grid */
@media (max-width: 768px) {
    .flex-1 .grid.grid-cols-1.lg\\:grid-cols-2,
    .w-full .grid.grid-cols-1.lg\\:grid-cols-2 {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
    .glass-panel {
        padding: 16px !important;
    }
}

/* System Info — clean key-value cards */
.s-view .grid > div.border.border-gray-200 {
    border: 1px solid var(--border-subtle) !important;
    border-radius: 12px !important;
    padding: 18px 20px !important;
    background: var(--surface-card);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}
.s-view .grid > div.border.border-gray-200 > h4 {
    font-size: 13px !important;
    font-weight: 600 !important;
    color: var(--text-primary) !important;
    margin: 0 0 14px 0 !important;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-subtle);
    letter-spacing: -0.01em;
}
.s-view .grid > div.border.border-gray-200 > h4 svg {
    color: var(--text-secondary) !important;
    width: 16px !important;
    height: 16px !important;
}
.s-view .grid > div.border.border-gray-200 .space-y-2 > div {
    padding: 6px 0;
    font-size: 13px;
    border-bottom: 1px dashed var(--border-subtle);
}
.s-view .grid > div.border.border-gray-200 .space-y-2 > div:last-child {
    border-bottom: 0;
}
.s-view .grid > div.border.border-gray-200 .text-gray-600 {
    color: var(--text-secondary) !important;
    font-weight: 500;
}
.s-view .grid > div.border.border-gray-200 .font-mono.font-bold {
    color: var(--text-primary) !important;
    font-variant-numeric: tabular-nums;
    font-weight: 600 !important;
}

/* Security Checklist items */
.s-view > div.border.border-gray-200 {
    border: 1px solid var(--border-subtle) !important;
    border-radius: 12px !important;
    padding: 18px 20px !important;
    background: var(--surface-card);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
    margin-top: 16px;
}

/* Mobile — stack sidebar and content */
@media (max-width: 900px) {
    .s-page {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    /* Wrap tabs in a relatively-positioned container with fade + chevron */
    .s-page__tabs-wrap {
        position: relative;
        margin: 0 -4px;
        max-width: 100%;
        width: 100%;
        overflow: hidden;
    }
    .s-page__tabs {
        flex-direction: row;
        overflow-x: auto;
        gap: 4px;
        padding: 4px 36px 12px 4px;
        position: static;
        border-bottom: 1px solid var(--border-subtle);
        flex-wrap: nowrap;
        scroll-behavior: smooth;
        scrollbar-width: none;
    }
    .s-page__tab {
        flex-shrink: 0;
        padding: 8px 14px;
    }
    /* Right-edge fade + chevron indicator */
    .s-page__tabs-wrap::after {
        content: "";
        position: absolute;
        top: 0; right: 0; bottom: 0;
        width: 40px;
        background: linear-gradient(to right, transparent, var(--surface-app) 60%);
        pointer-events: none;
    }
    .s-page__tabs-wrap::before {
        content: "›";
        position: absolute;
        top: 50%;
        right: 8px;
        transform: translateY(-50%);
        font-size: 22px;
        font-weight: 600;
        color: var(--text-secondary);
        z-index: 2;
        pointer-events: none;
        line-height: 1;
        background: var(--surface-card);
        width: 24px;
        height: 24px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        padding-bottom: 2px;
        border: 1px solid var(--border-subtle);
    }
    .s-section { padding: 18px 16px; }
    .s-section__head {
        padding-bottom: 12px;
        margin-bottom: 16px;
        flex-wrap: wrap;
        gap: 10px;
    }
    /* Section head with inline action (e.g., PhonePe + Enabled toggle) — wrap on mobile */
    .s-section__head[style*="display:flex"] > div:first-child,
    .s-section__head[style*="display:flex"] > div:nth-child(2) {
        min-width: 0;
    }

    /* System info cards — stack on mobile */
    .s-view .grid.grid-cols-1.md\\:grid-cols-2,
    .s-view .grid.md\\:grid-cols-2 {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
    /* Test/Live segmented buttons — stack vertically on small screens */
    .s-page__body .s-section [style*="grid-template-columns"][style*="1fr 1fr"] {
        grid-template-columns: 1fr 1fr !important;
        gap: 6px !important;
    }
    /* Inputs full-width and proper sizing */
    .s-section input[type="text"],
    .s-section input[type="email"],
    .s-section input[type="password"],
    .s-section input[type="number"],
    .s-section textarea,
    .s-section select,
    .s-input {
        width: 100% !important;
        font-size: 14px !important;
        min-height: 42px !important;
        height: auto !important;
        padding: 10px 12px !important;
        box-sizing: border-box !important;
    }
    .s-section textarea {
        min-height: 80px !important;
    }
    /* Two-column field grids stack on mobile */
    .s-section [style*="grid-template-columns: 1fr 1fr"]:not([style*="auto"]),
    .s-section [style*="grid-template-columns:1fr 1fr"]:not([style*="auto"]) {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
    /* Callback URL rows */
    .s-section [style*="grid-template-columns: 80px 1fr auto"],
    .s-section [style*="grid-template-columns:80px 1fr auto"] {
        grid-template-columns: 1fr !important;
        gap: 6px !important;
    }
}

/* Field */
.s-field {
    margin-bottom: 16px;
}
.s-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.s-input {
    width: 100%;
    height: 42px;
    padding: 0 14px;
    border: 1px solid var(--border-default);
    border-radius: 10px;
    background: var(--surface-card);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: border-color 150ms ease, box-shadow 150ms ease;
}
.s-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.s-input--textarea {
    height: auto;
    padding: 12px 14px;
    resize: vertical;
    min-height: 80px;
    font-family: inherit;
}
select.s-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23999' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}
.s-hint {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 6px;
}

/* Field row — 2 col side by side */
.s-field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}
@media (max-width: 480px) {
    .s-field-row { grid-template-columns: 1fr; }
}

/* File input */
.s-file-input {
    display: block;
    width: 100%;
    font-size: 13px;
    color: var(--text-tertiary);
}
.s-file-input::file-selector-button {
    margin-right: 12px;
    padding: 8px 16px;
    border-radius: 20px;
    border: none;
    font-size: 12px;
    font-weight: 600;
    background: var(--surface-hover);
    color: var(--text-primary);
    cursor: pointer;
    transition: background 120ms ease;
}
.s-file-input::file-selector-button:hover {
    background: var(--border-default);
}

/* Logo preview row */
.s-logo-row {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}
.s-logo-preview {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--surface-base);
    border: 1px solid var(--border-subtle);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.s-logo-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 4px;
}

/* Checkbox */
.s-check {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    padding: 8px 0;
    font-size: 14px;
    color: var(--text-primary);
}
.s-check__input {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    flex-shrink: 0;
}

/* Color cards — Hashtask style */
.s-color-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 8px;
}

.s-color-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
@media (max-width: 480px) {
    .s-color-cards { grid-template-columns: 1fr; }
}

.s-color-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    background: var(--surface-card);
}
.s-color-card__info { flex: 1; min-width: 0; }
.s-color-card__label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}
.s-color-card__hex {
    display: block;
    font-size: 12px;
    font-family: var(--font-mono, monospace);
    color: var(--text-tertiary);
    text-transform: uppercase;
    margin-top: 2px;
}
.s-color-card__swatch {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    flex-shrink: 0;
}
.s-color-card__btn {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px 12px;
    border: 1px solid var(--border-default);
    border-radius: 8px;
    background: var(--surface-card);
    white-space: nowrap;
    transition: background 120ms ease;
}
.s-color-card__btn:hover { background: var(--surface-hover); }

/* Theme swatch circles */
.theme-swatch {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: border-color 120ms ease, transform 120ms ease;
}
.theme-swatch:hover { transform: scale(1.12); }
.theme-swatch.active {
    border-color: var(--text-primary);
    box-shadow: 0 0 0 2px var(--surface-card), 0 0 0 4px var(--text-secondary);
}

/* Action buttons row */
.s-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: var(--space-5);
}

.s-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 20px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: background 120ms ease, transform 80ms ease;
}
.s-btn:active { transform: scale(0.97); }
.s-btn--primary {
    background: var(--text-primary);
    color: var(--surface-card);
}
.s-btn--primary:hover { opacity: 0.85; }
.dark .s-btn--primary { background: var(--surface-card); color: var(--text-primary); }

.s-btn--ghost {
    background: none;
    color: var(--text-secondary);
    border: 1px solid var(--border-default);
}
.s-btn--ghost:hover { background: var(--surface-hover); }

/* Editor (for terms) */
.s-editor-wrap {
    border: 1px solid var(--border-default);
    border-radius: 12px;
    overflow: hidden;
    background: var(--surface-card);
}
.s-editor {
    min-height: 400px;
    padding: 20px;
    outline: none;
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-primary);
}

/* Compact input (legacy compat) */
.compact-input {
    height: 42px;
    border: 1px solid var(--border-default);
    border-radius: 10px;
    background: var(--surface-card);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: border-color 150ms ease, box-shadow 150ms ease;
}
.compact-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea.compact-input { height: auto; padding: 12px 14px; }

/* Mobile responsive */
@media (max-width: 640px) {
    .s-page__body { max-width: 100%; }
    .s-actions { flex-direction: column; }
    .s-actions .s-btn { width: 100%; justify-content: center; }
}

/* -- App body layout (icon-rail + sidebar + content) ----------------------- */
#app {
    display: flex;
    flex-direction: column;
    height: 100%;
}
.app-body {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}
.app-content-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}
.app-main {
    flex: 1;
    overflow-y: auto;
    padding: 28px 36px 40px;
    background: var(--surface-app);
}

/* -- Icon Rail ------------------------------------------------------------- */
.icon-rail {
    width: 60px;
    border-right: 1px solid var(--border-subtle);
    padding: 16px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: var(--surface-card);
    flex-shrink: 0;
    overflow-y: auto;
}
.icon-rail__logo {
    width: 32px; height: 32px;
    background: #111827;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    margin-bottom: 16px;
    overflow: hidden;
}
.rail-icon {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 8px;
    color: #9aa1ac;
    cursor: pointer;
    transition: background .15s, color .15s;
    background: transparent;
    border: none;
    padding: 0;
}
.rail-icon:hover { background: var(--surface-hover); color: #4b5563; }
.rail-icon.active { background: var(--surface-selected); color: #111827; }
.rail-icon i { width: 19px; height: 19px; }

/* -- Hashtask-style Footer ------------------------------------------------- */
.ht-footer {
    border-top: 1px solid var(--border-subtle);
    background: #fff;
    padding: 24px 36px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    flex-shrink: 0;
    width: 100%;
    box-sizing: border-box;
}
.footer-top-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.footer-logo-mark {
    width: 28px; height: 28px;
    background: transparent;
    border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}
.footer-logo-mark img {
    width: 100%; height: 100%;
    object-fit: contain;
}
.footer-copy {
    font-size: 13px;
    color: var(--text-secondary);
}
.footer-copy strong {
    color: var(--text-primary);
    font-weight: 600;
}
.footer-bottom-row {
    display: flex;
    align-items: center;
    gap: 24px;
}
.footer-links {
    display: flex;
    gap: 22px;
    flex-wrap: wrap;
}
.footer-links a {
    font-size: 13px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: color .12s;
}
.footer-links a:hover { color: var(--text-primary); }

.footer-social {
    display: flex;
    align-items: center;
    gap: 8px;
}
.footer-social__link {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border-strong);
    background: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    transition: background-color .12s, color .12s;
    text-decoration: none;
}
.footer-social__link:hover {
    background: #f7f8fa;
    color: #111827;
}
.footer-social__link svg {
    width: 14px !important;
    height: 14px !important;
    fill: currentColor;
    display: block;
}

/* -- Mobile responsive (≤ 768px) ------------------------------------------ */
@media (max-width: 768px) {

    /* --- Layout structure --- */
    .icon-rail { display: none !important; }
    #app { flex-direction: column; height: 100%; }
    .app-body { flex: 1; min-height: 0; }

    /* --- Header --- */
    .app-topbar {
        position: sticky !important;
        top: 0 !important;
        padding: 11px 14px !important;
        gap: 8px !important;
        z-index: 100 !important;
    }
    .header-hamburger {
        display: inline-flex !important;
        width: 38px !important; height: 38px !important;
        min-width: 38px !important;
        flex-shrink: 0 !important;
    }
    .header-hamburger i,
    .header-hamburger svg { width: 20px !important; height: 20px !important; min-width: 20px !important; }
    .header-logo { display: flex !important; gap: 8px !important; min-width: 0; }
    .header-logo-mark { width: 32px !important; height: 32px !important; border-radius: 8px; flex-shrink: 0; }
    .header-logo-name { font-size: 15px !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .avatar-btn { width: 36px !important; height: 36px !important; padding: 2px !important; flex-shrink: 0; }
    .profile-dropdown {
        right: 0 !important;
        width: 220px !important;
        max-width: 220px !important;
        min-width: 0 !important;
        padding: 6px !important;
        border-radius: 12px !important;
    }
    .profile-dropdown .dropdown-item {
        padding: 10px 12px !important;
        font-size: 14px !important;
        gap: 10px !important;
        min-height: 0 !important;
    }
    .profile-dropdown .dropdown-item svg {
        width: 16px !important;
        height: 16px !important;
        flex-shrink: 0;
    }

    /* --- Main content --- */
    .app-main {
        padding: 20px 16px 100px !important;
        margin-top: 0 !important;
    }

    /* --- Sidebar drawer --- */
    .glass-sidebar {
        display: flex !important;
        position: fixed !important;
        top: 0 !important; left: 0 !important; bottom: 0 !important;
        width: 280px !important;
        z-index: 200 !important;
        transform: translateX(-100%) !important;
        transition: transform .25s ease !important;
        box-shadow: none !important;
        background: #fff !important;
        border-right: 1px solid var(--border-subtle) !important;
    }
    .glass-sidebar.open {
        transform: translateX(0) !important;
        box-shadow: 4px 0 24px rgba(0,0,0,.12) !important;
    }
    /* Hide brand & profile on mobile sidebar — Hashtask style */
    .sb-brand { display: none !important; }
    .sb-profile { display: none !important; }
    .glass-sidebar.sidebar--operator { padding-top: 20px !important; }

    /* --- Mobile overlay --- */
    .mobile-overlay {
        position: fixed !important;
        inset: 0 !important;
        background: rgba(0,0,0,.35) !important;
        z-index: 195 !important;
        opacity: 0;
        pointer-events: none;
        transition: opacity .25s ease;
    }
    .mobile-overlay.open {
        opacity: 1;
        pointer-events: auto;
    }
    /* Sidebar must sit above overlay when open */
    .glass-sidebar.open {
        z-index: 200 !important;
    }
    /* Bottom nav must sit below overlay when sidebar open */
    body.no-scroll .mobile-bottom-nav {
        z-index: 140 !important;
    }

    /* --- Page head --- */
    .page-head {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px !important;
    }
    .page-head h2 { font-size: 20px !important; }
    .page-head > div:last-child:not(:first-child) {
        display: flex !important;
        gap: 8px;
    }
    .page-head > div:last-child:not(:first-child) > .pri-btn,
    .page-head > div:last-child:not(:first-child) > .btn {
        flex: 1;
        justify-content: center;
        font-size: 13px;
    }

    /* --- KPI cards --- */
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }
    .kpi {
        padding: 14px 16px !important;
        min-height: 90px !important;
        border-radius: 10px !important;
    }
    .kpi__value { font-size: 18px !important; }
    .kpi__label { font-size: 11px !important; }
    .kpi__foot { font-size: 11px !important; }

    /* --- Dashboard grid (Financial overview + Tasks) --- */
    .dash-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }
    .card {
        border-radius: 10px !important;
        max-width: 100% !important;
        overflow: hidden !important;
    }
    .card__head {
        padding: 12px 16px !important;
        flex-wrap: wrap !important;
        gap: 10px !important;
        align-items: flex-start !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
    }
    .card__body { padding: 12px 16px !important; }
    .card__title {
        font-size: 14px !important;
        min-width: 0 !important;
        flex: 0 0 auto !important;
    }

    /* --- Financial period tabs --- */
    .fin-period {
        gap: 2px !important;
        width: 100% !important;
        display: flex !important;
        flex: 1 1 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
    }
    .fin-period__btn {
        padding: 6px 4px !important;
        font-size: 12px !important;
        flex: 1 1 0 !important;
        min-width: 0 !important;
        min-height: 0 !important;
        height: auto !important;
        white-space: nowrap !important;
    }
    .fin-stats {
        gap: 12px !important;
        flex-wrap: wrap;
        max-width: 100% !important;
    }
    .fin-canvas-wrap { max-width: 100% !important; overflow: hidden !important; }
    .fin-canvas-wrap canvas { max-width: 100% !important; }

    /* Date inputs in fin-period custom range */
    .fin-period-custom,
    .fin-period + div {
        flex-wrap: wrap !important;
        gap: 8px !important;
    }
    input[type="date"] {
        max-width: 100% !important;
        min-width: 0 !important;
    }

    /* --- Task add form --- */
    .task-add { padding: 10px 14px !important; gap: 8px !important; }
    .task-add input {
        font-size: 14px !important;
        height: 36px !important;
        min-height: 36px !important;
        border: 1px solid var(--border-default) !important;
        border-radius: 8px !important;
        padding: 0 12px !important;
        background: #fff !important;
        margin-bottom: 0 !important;
    }
    .task-add__btn {
        width: 36px !important;
        min-height: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
        border-radius: 8px !important;
        padding: 0 !important;
    }
    .task-add__btn svg,
    .task-add__btn i { width: 16px !important; height: 16px !important; }

    /* --- Activity stream toolbar (mobile) --- */
    .activity-toolbar {
        padding: 12px !important;
        gap: 10px !important;
        flex-direction: column !important;
        align-items: stretch !important;
        border-bottom: 1px solid var(--border-subtle) !important;
    }
    /* Tabs scroll container */
    .activity-tabs {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding: 3px !important;
        border-radius: 10px !important;
        gap: 2px !important;
        width: 100% !important;
        scroll-behavior: smooth;
    }
    .activity-tabs::-webkit-scrollbar { display: none; }
    .activity-filter {
        white-space: nowrap !important;
        padding: 7px 12px !important;
        font-size: 12px !important;
        flex-shrink: 0 !important;
        gap: 6px !important;
        height: auto !important;
        min-height: 0 !important;
    }
    .activity-filter__count {
        min-width: 18px !important;
        height: 16px !important;
        font-size: 10px !important;
        padding: 0 5px !important;
    }
    .activity-toolbar__right {
        width: 100% !important;
        max-width: none !important;
        min-width: 0 !important;
        gap: 8px !important;
    }
    .activity-search {
        flex: 1 !important;
        min-width: 0 !important;
    }
    .activity-search input {
        width: 100% !important;
        height: 38px !important;
        min-height: 38px !important;
        padding: 0 12px 0 36px !important;
        font-size: 14px !important;
        border-radius: 9px !important;
        border: 1px solid var(--border-default) !important;
        background: #fff !important;
        margin-bottom: 0 !important;
    }
    .activity-search__icon {
        left: 12px !important;
        width: 14px !important;
        height: 14px !important;
    }
    .activity-toolbar__right .icon-btn {
        flex-shrink: 0 !important;
        width: 38px !important;
        height: 38px !important;
        min-height: 38px !important;
        border-radius: 9px !important;
        border: 1px solid var(--border-default) !important;
        background: #fff !important;
        padding: 0 !important;
    }
    .activity-row {
        grid-template-columns: 36px 1fr auto !important;
        gap: 10px !important;
        padding: 12px 14px !important;
    }
    .activity-row__chips,
    .activity-row__avatar { display: none !important; }

    /* --- Page heads (uniform mobile layout for all pages) --- */
    .page-head {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px !important;
        padding-bottom: 0 !important;
        margin-bottom: 16px !important;
    }
    .page-head h2 {
        font-size: 20px !important;
        font-weight: 700 !important;
        margin: 0 0 2px 0 !important;
        line-height: 1.25 !important;
    }
    .page-head .sub {
        font-size: 13px !important;
        color: var(--text-secondary) !important;
        line-height: 1.4 !important;
    }
    /* Actions row — full width, evenly split */
    .page-head > div:last-child:not(:first-child),
    .page-head__actions {
        width: 100% !important;
        display: flex !important;
        gap: 8px !important;
        align-items: stretch !important;
    }
    .page-head > div:last-child:not(:first-child) > .btn,
    .page-head > div:last-child:not(:first-child) > button,
    .page-head > div:last-child:not(:first-child) > a,
    .page-head__actions .btn,
    .page-head__actions button,
    .page-head__actions a {
        flex: 1 !important;
        justify-content: center !important;
        font-size: 13px !important;
        height: 40px !important;
        min-height: 40px !important;
        padding: 0 12px !important;
        white-space: nowrap !important;
    }
    .page-head .pri-btn,
    .page-head .btn--primary {
        flex: 1.4 !important;
    }

    /* Compact meta row on mobile — clean wrap */
    .activity-row__meta {
        gap: 6px !important;
        font-size: 11.5px !important;
        line-height: 1.4 !important;
    }
    .activity-row__meta > span {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        white-space: nowrap;
    }
    /* Hide bullet separators on mobile to save space */
    .activity-row__meta > span:not(.activity-row__id):not([class]) {
    }
    .activity-row__meta svg {
        width: 10px !important;
        height: 10px !important;
    }

    /* --- Footer (mobile, matches Hashtask themes.html exactly) --- */
    .ht-footer {
        padding: 20px 16px !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 16px !important;
        margin: 16px 0 0 0 !important;
        width: 100% !important;
        box-sizing: border-box !important;
        border-radius: 12px !important;
        border: 1px solid var(--border-subtle) !important;
        border-top: 1px solid var(--border-subtle) !important;
    }
    .footer-links { gap: 16px !important; }
    .footer-bottom-row {
        width: 100% !important;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        gap: 12px !important;
        flex-wrap: wrap !important;
    }

    /* --- Bottom nav --- */
    .mobile-bottom-nav {
        z-index: 150 !important;
    }

    /* --- Data tables --- */
    .data-table { font-size: 13px !important; }
    .data-table thead th { padding: 10px 12px !important; font-size: 10px !important; }
    .data-table tbody td { padding: 10px 12px !important; }

    /* --- Forms --- */
    .form-card { padding: 16px !important; margin: 12px auto !important; }

    /* --- Prevent body scroll when sidebar open --- */
    body.no-scroll { overflow: hidden; }
}

/* -- Small phones (≤ 480px) ----------------------------------------------- */
@media (max-width: 480px) {
    .kpi-grid { grid-template-columns: 1fr !important; }
    .header-logo-name { display: none !important; }
    .page-head h2 { font-size: 18px !important; }
}
