/* ============================================================
   AccountsSagaLite — Design System v4
   Soft frame · Light sidebar · Rounded cards · Light & dark
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:opsz,wght@9..40,400;9..40,500;9..40,600;9..40,700;9..40,800&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ─── Design Tokens ──────────────────────────────────────── */
:root {
    color-scheme: light;

    /* Neutral scale — views reference these directly, so dark mode
       re-maps the scale rather than individual components */
    --black:     #111113;
    --gray-950:  #141416;
    --gray-900:  #1b1b1f;
    --gray-800:  #2a2a2f;
    --gray-700:  #3f3f46;
    --gray-600:  #55555d;
    --gray-500:  #6e6e76;
    --gray-400:  #9d9da5;
    --gray-300:  #d2d2d8;
    --gray-200:  #e6e6ea;
    --gray-150:  #ececef;
    --gray-100:  #f3f3f5;
    --gray-75:   #f7f7f8;
    --gray-50:   #fafafb;
    --white:     #ffffff;

    /* Surfaces */
    --canvas:        #e9e9ec;
    --surface:       #ffffff;
    --surface-muted: #f6f6f7;
    --border:        #e6e6ea;
    --border-strong: #d6d6dc;

    /* Accent */
    --accent:         #18181b;
    --accent-hover:   #2e2e33;
    --accent-ink:     #ffffff;

    /* Data colours */
    --blue:     #3b8fdc;
    --blue-soft:#dbeafa;
    --mint:     #dcefe7;
    --green:    #5cbf7c;
    --magenta:  #c54ec4;

    /* Semantic */
    --danger:         #dc2626;
    --danger-light:   #fdecec;
    --danger-border:  #f8caca;
    --danger-ink:     #9b1c1c;
    --success:        #16a34a;
    --success-light:  #ecfbf1;
    --success-border: #bbf0cc;
    --warning:        #d97706;
    --warning-light:  #fff8e8;
    --warning-border: #fbe2a6;
    --info:           #2563eb;
    --info-light:     #eef4ff;

    /* Typography */
    --font:      'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    /* Radius */
    --r-xs:   6px;
    --r-sm:   8px;
    --r:      10px;
    --r-md:   12px;
    --r-lg:   14px;
    --r-xl:   18px;
    --r-2xl:  28px;
    --r-full: 9999px;

    /* Shadows */
    --shadow-xs:  0 1px 2px rgba(17,17,19,.04);
    --shadow-sm:  0 1px 2px rgba(17,17,19,.04), 0 1px 3px rgba(17,17,19,.03);
    --shadow:     0 4px 12px rgba(17,17,19,.06), 0 1px 3px rgba(17,17,19,.04);
    --shadow-md:  0 8px 24px rgba(17,17,19,.07), 0 2px 6px rgba(17,17,19,.04);
    --shadow-lg:  0 16px 40px rgba(17,17,19,.10), 0 4px 12px rgba(17,17,19,.05);
    --shadow-xl:  0 24px 56px rgba(17,17,19,.12), 0 8px 20px rgba(17,17,19,.06);
    --shadow-frame: 0 1px 0 rgba(17,17,19,.03), 0 20px 50px rgba(17,17,19,.08);

    /* Layout */
    --sidebar-w: 268px;
    --topbar-h:  84px;
    --frame-gap: 18px;

    /* Transitions */
    --ease:      cubic-bezier(.4, 0, .2, 1);
    --t-fast:    120ms cubic-bezier(.4,0,.2,1);
    --t:         200ms cubic-bezier(.4,0,.2,1);
    --t-slow:    320ms cubic-bezier(.4,0,.2,1);
}

/* ─── Dark theme ─────────────────────────────────────────── */
:root[data-theme="dark"] {
    color-scheme: dark;

    --black:     #f4f4f6;
    --gray-950:  #ededf0;
    --gray-900:  #e4e4e8;
    --gray-800:  #d4d4da;
    --gray-700:  #babac2;
    --gray-600:  #a0a0a9;
    --gray-500:  #888891;
    --gray-400:  #6c6c75;
    --gray-300:  #45454c;
    --gray-200:  #33333a;
    --gray-150:  #2c2c32;
    --gray-100:  #24242a;
    --gray-75:   #202025;
    --gray-50:   #1c1c21;
    --white:     #17171b;

    --canvas:        #0c0c0e;
    --surface:       #17171b;
    --surface-muted: #1e1e23;
    --border:        #2c2c32;
    --border-strong: #3a3a42;

    --accent:         #f4f4f6;
    --accent-hover:   #ffffff;
    --accent-ink:     #111113;

    --blue-soft: #1d3550;
    --mint:      #1f3a2f;

    --danger:         #f87171;
    --danger-light:   #3a1717;
    --danger-border:  #5c2323;
    --danger-ink:     #fca5a5;
    --success:        #4ade80;
    --success-light:  #12291b;
    --success-border: #1f4d31;
    --warning:        #fbbf24;
    --warning-light:  #2f2410;
    --warning-border: #5a4314;
    --info:           #60a5fa;
    --info-light:     #172338;

    --shadow-xs:  0 1px 2px rgba(0,0,0,.3);
    --shadow-sm:  0 1px 2px rgba(0,0,0,.3);
    --shadow:     0 4px 12px rgba(0,0,0,.35);
    --shadow-md:  0 8px 24px rgba(0,0,0,.4);
    --shadow-lg:  0 16px 40px rgba(0,0,0,.45);
    --shadow-xl:  0 24px 56px rgba(0,0,0,.5);
    --shadow-frame: 0 0 0 1px rgba(255,255,255,.04), 0 20px 50px rgba(0,0,0,.5);
}

/* ─── Reset & Base ───────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 14px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: var(--font);
    background: var(--canvas);
    color: var(--gray-900);
    line-height: 1.55;
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
    transition: color var(--t-fast);
}
a:hover { text-decoration: none; }

img, svg { display: block; }

::selection { background: var(--blue-soft); }

/* ═══════════════════════════════════════════════════════════
   APP SHELL — a rounded frame floating on the canvas
════════════════════════════════════════════════════════════ */
.app-shell {
    display: flex;
    min-height: calc(100vh - var(--frame-gap) * 2);
    margin: var(--frame-gap);
    background: var(--surface);
    border-radius: var(--r-2xl);
    box-shadow: var(--shadow-frame);
    position: relative;
}

/* ═══════════════════════════════════════════════════════════
   SIDEBAR
════════════════════════════════════════════════════════════ */
.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    border-radius: var(--r-2xl) 0 0 var(--r-2xl);
    position: sticky;
    top: var(--frame-gap);
    height: calc(100vh - var(--frame-gap) * 2);
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 200;
    transition: transform var(--t-slow);
    scrollbar-width: thin;
    scrollbar-color: var(--gray-200) transparent;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 6px; }

/* ── Brand ── */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 18px;
    padding: 24px 4px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-brand-icon {
    width: 38px;
    height: 38px;
    background: var(--accent);
    color: var(--accent-ink);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 19px;
    font-weight: 800;
}
.sidebar-brand-icon svg {
    width: 19px; height: 19px;
    stroke: var(--accent-ink);
}
.sidebar-brand-icon.has-logo { background: var(--white); border: 1px solid var(--border); }

.sidebar-brand-text { min-width: 0; }
.sidebar-brand-name {
    font-size: 16px;
    font-weight: 800;
    color: var(--black);
    letter-spacing: -.3px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-brand-sub {
    font-size: 11px;
    font-weight: 500;
    color: var(--gray-500);
    letter-spacing: .3px;
    margin-top: 2px;
}

/* ── Navigation ── */
.sidebar-nav {
    padding: 16px 14px 20px;
    flex: 1;
}

.sidebar-section {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 1.1px;
    text-transform: uppercase;
    color: var(--gray-500);
    padding: 20px 12px 8px;
    user-select: none;
}
.sidebar-section:first-child { padding-top: 6px; }

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 12px;
    border-radius: 12px;
    font-size: 14.5px;
    font-weight: 500;
    color: var(--gray-800);
    text-decoration: none;
    transition: background var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
}
.sidebar-link svg {
    width: 17px; height: 17px;
    flex-shrink: 0;
    color: var(--black);
    stroke: currentColor;
}
.sidebar-link:hover {
    background: var(--gray-75);
    color: var(--black);
}

.sidebar-link.active {
    background: var(--gray-100);
    color: var(--black);
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(17,17,19,.06), 0 2px 8px rgba(17,17,19,.04);
}

/* ═══════════════════════════════════════════════════════════
   MAIN CONTENT
════════════════════════════════════════════════════════════ */
.main-content {
    flex: 1;
    min-height: 100%;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--surface);
    border-radius: 0 var(--r-2xl) var(--r-2xl) 0;
}

/* ─── Announcement banner ────────────────────────────────── */
.app-banner {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 4px 18px;
    padding: 14px 28px;
    background: var(--danger-light);
    color: var(--danger-ink);
    font-size: 13px;
    font-weight: 500;
    border-bottom: 1px solid var(--danger-border);
    border-top-right-radius: var(--r-2xl);
}
.app-banner strong {
    font-weight: 700;
    letter-spacing: .6px;
    text-transform: uppercase;
    font-size: 12.5px;
}
.app-banner + .topbar { border-top-right-radius: 0; }

/* ─── Topbar ─────────────────────────────────────────────── */
.topbar {
    min-height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    border-top-right-radius: var(--r-2xl);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 28px 14px 36px;
    position: sticky;
    top: 0;
    z-index: 100;
    gap: 18px;
}

.topbar-left, .topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}
.topbar-left { flex: 1; min-width: 0; gap: 28px; }
.topbar-right { flex-shrink: 0; }

.topbar-greeting { flex-shrink: 0; max-width: 340px; }
.topbar-greeting h2 {
    font-size: 20px;
    font-weight: 800;
    color: var(--black);
    letter-spacing: -.4px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.topbar-greeting p {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--gray-600);
    margin-top: 3px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* Mobile Hamburger */
.sidebar-toggle {
    display: none;
    background: none;
    border: 1px solid var(--border);
    cursor: pointer;
    padding: 9px;
    border-radius: 12px;
    color: var(--gray-700);
    transition: all var(--t-fast);
    flex-shrink: 0;
}
.sidebar-toggle:hover { background: var(--gray-100); color: var(--black); }
.sidebar-toggle svg { width: 18px; height: 18px; display: block; }

/* Company Switcher (select styled like the reference "FY 2026" dropdown) */
.company-switcher {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    padding: 0 12px 0 14px;
    height: 44px;
    border-radius: 10px;
    transition: border-color var(--t-fast);
    min-width: 0;
}
.company-switcher:hover { border-color: var(--gray-400); }
.company-switcher-label {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .8px;
    text-transform: uppercase;
    color: var(--gray-500);
    flex-shrink: 0;
}
.company-switcher-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--black);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}
.company-switcher-select {
    font-size: 13px;
    font-weight: 700;
    font-family: var(--font);
    color: var(--black);
    background: transparent;
    border: none;
    padding: 2px 24px 2px 0;
    cursor: pointer;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5' stroke-linecap='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 2px center;
    max-width: 240px;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.company-switcher-select:focus { outline: none; }
#fy-switcher-form { flex-shrink: 0; }
#fy-switcher-form .company-switcher-select { min-width: 96px; }
.company-switcher-select option { background: var(--surface); color: var(--black); }

/* Topbar separator (kept for older markup) */
.topbar-sep {
    width: 1px;
    height: 22px;
    background: var(--border);
    flex-shrink: 0;
}

/* Breadcrumb */
.topbar-page {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Global search */
.topbar-search {
    position: relative;
    width: 320px;
}
.topbar-search svg {
    position: absolute;
    left: 16px; top: 50%;
    transform: translateY(-50%);
    width: 15px; height: 15px;
    color: var(--gray-700);
    pointer-events: none;
}
.topbar-search input {
    width: 100%;
    height: 48px;
    padding: 0 16px 0 42px;
    border: 1.5px solid var(--gray-800);
    border-radius: 12px;
    font-family: var(--font);
    font-size: 14px;
    color: var(--black);
    background: var(--surface);
    outline: none;
    transition: box-shadow var(--t-fast), border-color var(--t-fast);
}
.topbar-search input::placeholder { color: var(--gray-500); }
.topbar-search input:focus { box-shadow: 0 0 0 4px var(--gray-100); }

/* Square icon button (alerts, theme) */
.icon-btn {
    position: relative;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--black);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background var(--t-fast), border-color var(--t-fast);
    flex-shrink: 0;
}
.icon-btn:hover { background: var(--gray-75); border-color: var(--gray-400); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn-count {
    position: absolute;
    top: -7px; right: -7px;
    min-width: 21px;
    height: 21px;
    padding: 0 5px;
    border-radius: var(--r-full);
    background: #e5484d;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--surface);
}

/* Theme toggle shows the icon for the theme you'd switch to */
.theme-icon-light { display: none; }
:root[data-theme="dark"] .theme-icon-light { display: block; }
:root[data-theme="dark"] .theme-icon-dark { display: none; }

/* User menu */
.user-menu { position: relative; }
.user-menu > summary { list-style: none; cursor: pointer; }
.user-menu > summary::-webkit-details-marker { display: none; }
.user-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 48px;
    padding: 0 12px 0 6px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    transition: background var(--t-fast);
}
.user-pill:hover { background: var(--gray-75); }
.user-avatar {
    width: 34px;
    height: 34px;
    background: var(--accent);
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 13px;
    font-weight: 800;
    color: var(--accent-ink);
    text-transform: uppercase;
}
.user-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--black);
    white-space: nowrap;
    line-height: 1.2;
}
.user-role {
    font-size: 11px;
    font-weight: 500;
    color: var(--gray-500);
    line-height: 1.2;
}
.user-menu-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 220px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    z-index: 300;
}
.user-menu-panel .menu-head {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 6px;
}
.user-menu-panel a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--gray-800);
}
.user-menu-panel a:hover { background: var(--gray-100); color: var(--black); }
.user-menu-panel a svg { width: 16px; height: 16px; }

/* Alerts dropdown */
.notif-menu { position: relative; }
.notif-menu > summary { list-style: none; }
.notif-menu > summary::-webkit-details-marker { display: none; }
.notif-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    width: 340px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    z-index: 300;
    overflow: hidden;
}
.notif-panel-head {
    padding: 14px 16px;
    font-size: 14px;
    font-weight: 700;
    color: var(--black);
    border-bottom: 1px solid var(--border);
}
.notif-item {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-100);
    font-size: 13px;
    color: var(--gray-700);
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--gray-75); }
.notif-item strong { display: block; color: var(--black); font-weight: 700; }
.notif-dot { width: 8px; height: 8px; border-radius: 50%; background: #e5484d; margin-top: 6px; flex-shrink: 0; }
.notif-dot.warn { background: var(--warning); }
.notif-empty { padding: 28px 16px; text-align: center; font-size: 13px; color: var(--gray-500); }

/* ─── Page Content ───────────────────────────────────────── */
.page-content {
    padding: 28px;
    flex: 1;
    width: 100%;
    max-width: none;
}

/* ─── Page Header ────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 16px;
    flex-wrap: wrap;
}

.page-title {
    font-size: 24px;
    font-weight: 800;
    color: var(--black);
    letter-spacing: -.5px;
    line-height: 1.2;
}

.page-subtitle {
    font-size: 13px;
    color: var(--gray-500);
    margin-top: 4px;
    font-weight: 500;
}

.page-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

/* ═══════════════════════════════════════════════════════════
   BUTTONS
════════════════════════════════════════════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 16px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    border: 1px solid transparent;
    transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
    white-space: nowrap;
    text-decoration: none !important;
    line-height: 1.2;
    user-select: none;
    position: relative;
    vertical-align: middle;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 14px; height: 14px; flex-shrink: 0; }

/* Primary */
.btn-primary {
    background: var(--accent);
    color: var(--accent-ink);
    border-color: var(--accent);
    box-shadow: 0 1px 2px rgba(17,17,19,.18);
}
.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: var(--accent-ink);
    box-shadow: 0 4px 12px rgba(17,17,19,.18);
}

/* Secondary */
.btn-secondary {
    background: var(--surface);
    color: var(--gray-900);
    border-color: var(--border-strong);
    box-shadow: var(--shadow-xs);
}
.btn-secondary:hover {
    background: var(--gray-75);
    border-color: var(--gray-400);
    color: var(--black);
}

/* Outline */
.btn-outline {
    background: transparent;
    color: var(--gray-800);
    border-color: var(--border-strong);
}
.btn-outline:hover {
    background: var(--gray-75);
    border-color: var(--gray-400);
    color: var(--black);
}

/* Ghost */
.btn-ghost {
    background: transparent;
    color: var(--gray-600);
    border-color: transparent;
}
.btn-ghost:hover { background: var(--gray-100); color: var(--black); }

/* Danger */
.btn-danger {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}
.btn-danger:hover { filter: brightness(.92); color: #fff; }

/* Sizes */
.btn-xs { padding: 4px 10px; font-size: 11.5px; border-radius: 8px; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 9px; }
.btn-lg { padding: 0 20px; height: 48px; font-size: 15px; border-radius: 12px; font-weight: 700; }
.btn-lg svg { width: 16px; height: 16px; }

/* Icon button */
.btn-icon {
    padding: 7px;
    aspect-ratio: 1;
}
.btn-icon svg { width: 15px; height: 15px; }

/* ═══════════════════════════════════════════════════════════
   CARDS
════════════════════════════════════════════════════════════ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    gap: 12px;
    min-height: 64px;
}

.card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--black);
    letter-spacing: -.2px;
}

.card-subtitle {
    font-size: 12.5px;
    color: var(--gray-500);
    font-weight: 500;
    margin-top: 2px;
}

.card-body { padding: 22px; }

.card-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 22px;
    border-top: 1px solid var(--border);
    background: var(--surface-muted);
}

/* "..." menu trigger used in card corners */
.card-menu {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--black);
    flex-shrink: 0;
    transition: background var(--t-fast);
}
.card-menu:hover { background: var(--gray-100); }
.card-menu svg { width: 18px; height: 18px; }

/* ═══════════════════════════════════════════════════════════
   STAT / KPI CARDS
════════════════════════════════════════════════════════════ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    margin-bottom: 22px;
    width: 100%;
}

.stats-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
    margin-bottom: 22px;
    width: 100%;
}

.stats-grid-6 {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 18px;
    margin-bottom: 22px;
    width: 100%;
}

@media (max-width: 1200px) {
    .stats-grid-4 { grid-template-columns: repeat(2, 1fr); }
    .stats-grid-6 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 768px) {
    .stats-grid, .stats-grid-4, .stats-grid-6 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
    .stats-grid, .stats-grid-4, .stats-grid-6 { grid-template-columns: 1fr; }
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 20px 22px 22px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--t), border-color var(--t);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.stat-card:hover { box-shadow: var(--shadow); border-color: var(--border-strong); }

.stat-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 18px;
}
.stat-head .stat-label { margin-bottom: 0; }

.stat-icon {
    width: 34px;
    height: 34px;
    background: var(--gray-100);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
    flex-shrink: 0;
}
.stat-icon svg { width: 16px; height: 16px; stroke: var(--gray-700); }

.stat-label {
    font-size: 15px;
    font-weight: 700;
    color: var(--black);
    letter-spacing: -.1px;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 30px;
    font-weight: 800;
    color: var(--black);
    font-family: var(--font);
    font-variant-numeric: tabular-nums;
    letter-spacing: -.8px;
    line-height: 1.1;
    margin-bottom: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.stat-value .stat-ccy { font-size: .8em; margin-right: 2px; }

.stat-meta {
    font-size: 12.5px;
    color: var(--gray-700);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}
.stat-meta svg { width: 13px; height: 13px; }
.stat-meta a { color: var(--gray-700); }
.stat-meta a:hover { color: var(--black); }
.stat-meta.trend-up { color: var(--success); }
.stat-meta.trend-down { color: var(--danger); }

/* Colored stat variants */
.stat-card.stat-up .stat-value { color: var(--success); }
.stat-card.stat-down .stat-value { color: var(--danger); }

/* ═══════════════════════════════════════════════════════════
   CHARTS & PROGRESS
════════════════════════════════════════════════════════════ */
.chart-total {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}
.chart-total strong {
    font-size: 30px;
    font-weight: 800;
    letter-spacing: -.8px;
    color: var(--black);
    font-variant-numeric: tabular-nums;
}
.chart-total span { font-size: 13.5px; color: var(--gray-600); font-weight: 500; }

.bar-chart {
    position: relative;
    height: 260px;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    align-items: end;
    gap: 8px;
    padding-bottom: 28px;
    background-image: linear-gradient(var(--gray-150) 1px, transparent 1px);
    background-size: 100% 20%;
    background-position: 0 -1px;
    border-bottom: 1px solid var(--border-strong);
}
.bar-group {
    position: relative;
    height: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 6px;
}
.bar {
    width: min(22px, 32%);
    border-radius: 4px 4px 0 0;
    min-height: 2px;
    background: var(--blue);
    transition: filter var(--t-fast);
}
.bar.bar-alt { background: var(--mint); }
.bar:hover { filter: brightness(.9); }
.bar-label {
    position: absolute;
    bottom: -26px;
    left: 0; right: 0;
    text-align: center;
    font-size: 12px;
    font-weight: 500;
    color: var(--gray-600);
}
.chart-legend {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
    margin-top: 40px;
    font-size: 12.5px;
    color: var(--gray-600);
    font-weight: 500;
}
.chart-legend i {
    display: inline-block;
    width: 10px; height: 10px;
    border-radius: 3px;
    margin-right: 6px;
    vertical-align: -1px;
}

.perf-item { padding: 22px 22px 24px; border-bottom: 1px solid var(--border); }
.perf-item:last-child { border-bottom: none; }
.perf-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
}
.perf-title {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 15px;
    font-weight: 700;
    color: var(--black);
}
.perf-title svg { width: 15px; height: 15px; }
.perf-pct { font-size: 13.5px; font-weight: 700; color: var(--black); font-variant-numeric: tabular-nums; }
.perf-sub { font-size: 12.5px; color: var(--gray-600); margin: 6px 0 12px; }
.progress {
    height: 8px;
    background: var(--gray-100);
    border-radius: var(--r-full);
    overflow: hidden;
}
.progress > span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--blue);
}
.progress.green > span   { background: var(--green); }
.progress.magenta > span { background: var(--magenta); }

/* ═══════════════════════════════════════════════════════════
   TABLES
════════════════════════════════════════════════════════════ */
.table-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    overflow-x: auto;
    overflow-y: visible;
    box-shadow: var(--shadow-sm);
    -webkit-overflow-scrolling: touch;
}

.data-table, .table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
    min-width: 0;
}

.data-table thead th, .table thead th {
    padding: 12px 16px;
    text-align: left;
    font-size: 11.5px;
    font-weight: 700;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: .6px;
    background: var(--surface-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.data-table thead th.num, .table thead th.num { text-align: right; font-family: var(--font); }

.data-table tbody tr, .table tbody tr {
    border-bottom: 1px solid var(--gray-150);
    transition: background var(--t-fast);
}
.data-table tbody tr:last-child, .table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover, .table tbody tr:hover { background: var(--gray-75); }

.data-table tbody td, .table tbody td {
    padding: 12px 16px;
    color: var(--gray-800);
    vertical-align: middle;
}

.data-table tbody td.num, .table tbody td.num {
    text-align: right;
    font-family: var(--font);
    font-variant-numeric: tabular-nums;
    font-size: 13.5px;
    font-weight: 600;
    white-space: nowrap;
    color: var(--black);
}

/* Table footer (totals row) */
.data-table tfoot tr {
    background: var(--surface-muted);
}
.data-table tfoot td {
    padding: 13px 16px;
    font-weight: 800;
    font-size: 13.5px;
    color: var(--black);
    font-family: var(--font);
    font-variant-numeric: tabular-nums;
    text-align: right;
    border-top: 1.5px solid var(--border-strong);
}
.data-table tfoot td:first-child {
    text-align: left;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .5px;
    text-transform: uppercase;
}

/* Numeric helpers */
.num { text-align: right; font-variant-numeric: tabular-nums; }
.num-pos { color: var(--success) !important; }
.num-neg { color: var(--danger) !important; }

/* ═══════════════════════════════════════════════════════════
   BADGES
════════════════════════════════════════════════════════════ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--r-full);
    font-size: 11.5px;
    font-weight: 700;
    white-space: nowrap;
    border: 1px solid transparent;
}
.badge-success { background: var(--success-light); color: var(--success); border-color: var(--success-border); }
.badge-danger  { background: var(--danger-light);  color: var(--danger); border-color: var(--danger-border); }
.badge-warning { background: var(--warning-light); color: var(--warning); border-color: var(--warning-border); }
.badge-default { background: var(--gray-100);      color: var(--gray-700); border-color: var(--border); }
.badge-info    { background: var(--info-light);    color: var(--info); border-color: transparent; }
.badge-dark    { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* Chip */
.chip {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    background: var(--gray-100);
    color: var(--gray-700);
    border-radius: var(--r-full);
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    border: 1px solid var(--border);
}

/* ═══════════════════════════════════════════════════════════
   FORMS
════════════════════════════════════════════════════════════ */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-bottom: 18px;
    justify-content: flex-start;
}
.form-group:last-child { margin-bottom: 0; }

.form-label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--gray-800);
    display: flex;
    align-items: flex-end;
    min-height: 20px;
}
.form-label .req, th .req { color: var(--danger); margin-left: 3px; font-weight: 700; }

/* Show / hide password (added by ui.js to every password field) */
.pw-wrap { position: relative; }
.pw-wrap .form-control { padding-right: 46px; }
/* Same outlined 32px button as the copy and suggest-password icons */
.pw-toggle {
    position: absolute;
    right: 6px; top: 50%;
    transform: translateY(-50%);
    width: 32px; height: 32px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 8px;
    color: var(--gray-600);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; padding: 0;
}
.pw-toggle:hover { background: var(--gray-100); color: var(--black); border-color: var(--border-strong); }
.pw-toggle svg { width: 15px; height: 15px; }
.pw-toggle .eye-off { display: none; }
.pw-toggle[aria-pressed="true"] .eye-on { display: none; }
.pw-toggle[aria-pressed="true"] .eye-off { display: block; }

.form-control {
    width: 100%;
    padding: 9px 13px;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    font-size: 13.5px;
    font-family: var(--font);
    color: var(--black);
    background: var(--surface);
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    line-height: 1.5;
    min-height: 42px;
}
.form-control::placeholder { color: var(--gray-400); }
.form-control:hover { border-color: var(--gray-400); }
.form-control:focus {
    border-color: var(--black);
    box-shadow: 0 0 0 4px var(--gray-100);
    background: var(--surface);
}
.form-control:disabled,
.form-control[readonly] {
    background: var(--surface-muted);
    color: var(--gray-600);
    border-color: var(--border);
    cursor: default;
}

.form-control-mono {
    font-family: var(--font-mono);
    font-size: 12.5px;
    letter-spacing: .2px;
}

.form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5' stroke-linecap='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 34px;
    cursor: pointer;
}

.form-textarea { resize: vertical; min-height: 84px; }

.form-hint {
    font-size: 11.5px;
    color: var(--gray-500);
}

.form-checkbox-box {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 13px;
    min-height: 42px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-muted);
    transition: border-color var(--t-fast), background var(--t-fast);
    cursor: pointer;
    width: 100%;
}
.form-checkbox-box:hover {
    border-color: var(--border-strong);
    background: var(--surface);
}

input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }

/* White-label web address choice (Platform → client form) */
.web-address-option { align-items: flex-start; padding: 12px 14px; }
.web-address-option input { margin-top: 3px; }
.web-address-option:has(input:checked) { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 1px var(--accent); }
.web-address-option.is-disabled { opacity: .6; cursor: not-allowed; }
.web-address-preview {
    display: block;
    margin-top: 8px;
    font-size: 11.5px;
    color: var(--gray-700);
    word-break: break-all;
}
.web-address-dns code { word-break: break-all; }

.invalid-feedback { color: var(--danger); font-size: 12px; font-weight: 500; }

/* ─── Card Container Layouts ─────────────────────────────── */
.card-container-centered {
    max-width: none;
    margin: 0;
    width: 100%;
}
.card-container-full {
    width: 100%;
}

/* ─── Grid Layouts ───────────────────────────────────────── */
.grid-2, .row.grid-2 { display: grid !important; grid-template-columns: repeat(2, 1fr) !important; gap: 18px; align-items: start; }
.grid-3, .row.grid-3 { display: grid !important; grid-template-columns: repeat(3, 1fr) !important; gap: 18px; align-items: start; }
.grid-4, .row.grid-4 { display: grid !important; grid-template-columns: repeat(4, 1fr) !important; gap: 18px; align-items: start; }
.grid-main-side { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 18px; align-items: stretch; }
.row { display: flex; gap: 18px; align-items: stretch; }

@media (max-width: 1280px) {
    .grid-main-side { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
    .grid-2, .grid-3, .grid-4,
    .row.grid-2, .row.grid-3, .row.grid-4 { grid-template-columns: 1fr !important; }
}

/* ═══════════════════════════════════════════════════════════
   INVOICE LINES TABLE
════════════════════════════════════════════════════════════ */
.invoice-lines-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.invoice-lines-table thead th {
    padding: 10px 8px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: .6px;
    background: var(--surface-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.invoice-lines-table tbody td {
    padding: 5px 5px;
    border-bottom: 1px solid var(--gray-150);
    vertical-align: middle;
}
.invoice-lines-table tbody tr:hover td { background: var(--gray-75); }
.invoice-lines-table tbody tr:last-child td { border-bottom: none; }
.invoice-lines-table .form-control {
    padding: 7px 10px;
    font-size: 13px;
    min-height: 38px;
    border-color: var(--border);
}
.invoice-lines-table .form-control:focus { border-color: var(--black); }

/* ═══════════════════════════════════════════════════════════
   DOCUMENT PRINT
════════════════════════════════════════════════════════════ */
.document-print {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: 36px 40px;
    box-shadow: var(--shadow-md);
    margin-bottom: 20px;
}

.doc-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1.5px solid var(--border);
}

.doc-company-logo {
    max-height: 65px;
    max-width: 180px;
    object-fit: contain;
    display: block;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

.doc-company-name {
    font-size: 21px;
    font-weight: 800;
    color: var(--black);
    letter-spacing: -.4px;
    line-height: 1.2;
}
.doc-company-sub {
    font-size: 12.5px;
    color: var(--gray-500);
    margin-top: 3px;
}

.doc-type-badge {
    display: inline-block;
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--gray-700);
    background: var(--gray-100);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 4px 10px;
    margin-bottom: 8px;
}

.doc-number {
    font-size: 21px;
    font-weight: 800;
    color: var(--black);
    font-family: var(--font-mono);
    letter-spacing: -1px;
}

.doc-meta-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.doc-meta-block {
    padding: 14px 16px;
    background: var(--surface-muted);
    border-radius: var(--r-md);
    border: 1px solid var(--border);
}
.doc-meta-label {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--gray-500);
    margin-bottom: 4px;
}
.doc-meta-value {
    font-size: 13.5px;
    color: var(--gray-800);
    font-weight: 500;
}
.doc-meta-value strong { color: var(--black); font-weight: 700; }

/* Totals block */
.doc-totals {
    margin-top: 16px;
    margin-left: auto;
    max-width: 380px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    overflow: hidden;
}
.doc-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 9px 16px;
    border-bottom: 1px solid var(--gray-150);
    font-size: 13px;
    color: var(--gray-700);
}
.doc-total-row:last-child { border-bottom: none; }
.doc-total-row.grand {
    background: var(--accent);
    color: var(--accent-ink);
    font-weight: 700;
    font-size: 14.5px;
}
.doc-total-amount {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    text-align: right;
    min-width: 100px;
    color: var(--black);
}
.doc-total-row.grand .doc-total-amount { color: var(--accent-ink); }

/* ═══════════════════════════════════════════════════════════
   FINANCIAL REPORTS
════════════════════════════════════════════════════════════ */
.fin-section-header {
    background: var(--surface-muted);
    color: var(--black);
    padding: 10px 18px;
    font-size: 11.5px;
    font-weight: 800;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: var(--r-md) var(--r-md) 0 0;
    margin-top: 14px;
}

.fin-group-header {
    padding: 8px 18px;
    font-size: 11px;
    font-weight: 700;
    color: var(--gray-600);
    background: var(--gray-75);
    border-bottom: 1px solid var(--border);
    text-transform: uppercase;
    letter-spacing: .5px;
}

.fin-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 9px 18px;
    border-bottom: 1px solid var(--gray-150);
    font-size: 13.5px;
    transition: background var(--t-fast);
}
.fin-row:hover { background: var(--gray-75); }
.fin-row:last-child { border-bottom: none; }
.fin-row-label { flex: 1; color: var(--gray-800); }
.fin-row-amount {
    font-variant-numeric: tabular-nums;
    font-size: 13.5px;
    font-weight: 600;
    text-align: right;
    min-width: 130px;
    color: var(--black);
}

.fin-subtotal {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 18px;
    background: var(--gray-75);
    border-bottom: 1.5px solid var(--border-strong);
    font-weight: 700;
    font-size: 13.5px;
}

.fin-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    background: var(--accent);
    color: var(--accent-ink);
    font-weight: 800;
    font-size: 14.5px;
    border-radius: 0 0 var(--r-md) var(--r-md);
}
.fin-total .fin-row-amount { color: var(--accent-ink); font-size: 16px; }

/* SOA Header */
.soa-header-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
    padding: 18px;
    background: var(--surface-muted);
    border-radius: var(--r-md);
    border: 1px solid var(--border);
}

/* GL Table */
.gl-table { margin-top: 4px; }
.gl-table thead th { background: var(--surface-muted) !important; }

/* ═══════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
════════════════════════════════════════════════════════════ */
.toast-container {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-radius: var(--r-lg);
    font-size: 13.5px;
    font-weight: 600;
    min-width: 260px;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    animation: toast-in 300ms var(--ease) both;
    pointer-events: all;
}
@keyframes toast-in {
    from { transform: translateY(16px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

.toast-success {
    background: var(--accent);
    color: var(--accent-ink);
}
.toast-error {
    background: var(--danger);
    color: #fff;
}

/* ═══════════════════════════════════════════════════════════
   FILTER BAR
════════════════════════════════════════════════════════════ */
.filter-bar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 16px 20px;
    margin-bottom: 22px;
    display: flex;
    gap: 14px;
    align-items: flex-end;
    flex-wrap: wrap;
    box-shadow: var(--shadow-sm);
}

.filter-bar form {
    display: flex;
    align-items: flex-end;
    gap: 14px;
    flex-wrap: wrap;
    width: 100%;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    justify-content: flex-end;
}
.filter-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .7px;
    text-transform: uppercase;
    color: var(--gray-500);
    line-height: 1.2;
}

.filter-bar .btn,
.filter-bar button[type="submit"] {
    height: 42px;
    margin-bottom: 0;
    align-self: flex-end;
}

/* ═══════════════════════════════════════════════════════════
   ALERTS
════════════════════════════════════════════════════════════ */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 13px 16px;
    border-radius: var(--r-md);
    margin-bottom: 16px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid;
}
.alert-danger  { background: var(--danger-light);  border-color: var(--danger-border);  color: var(--danger-ink); }
.alert-success { background: var(--success-light); border-color: var(--success-border); color: var(--success); }
.alert-warning { background: var(--warning-light); border-color: var(--warning-border); color: var(--warning); }

/* ═══════════════════════════════════════════════════════════
   JOURNAL BALANCE
════════════════════════════════════════════════════════════ */
#journal-balance {
    font-size: 11.5px;
    font-weight: 700;
    padding: 4px 10px;
    letter-spacing: .4px;
    border-radius: var(--r-full);
    transition: all var(--t);
}

/* ═══════════════════════════════════════════════════════════
   TABS
════════════════════════════════════════════════════════════ */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin-bottom: 22px;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab-link {
    padding: 10px 16px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--gray-500);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    cursor: pointer;
    transition: color var(--t-fast), border-color var(--t-fast);
    text-decoration: none !important;
    white-space: nowrap;
    flex-shrink: 0;
}
.tab-link:hover { color: var(--gray-900); }
.tab-link.active { color: var(--black); border-bottom-color: var(--black); }

/* ═══════════════════════════════════════════════════════════
   EMPTY STATE
════════════════════════════════════════════════════════════ */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--gray-500);
}
.empty-state-icon {
    width: 52px;
    height: 52px;
    background: var(--gray-100);
    border-radius: var(--r-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}
.empty-state-icon svg { width: 22px; height: 22px; stroke: var(--gray-500); }
.empty-state h3 { font-size: 16px; font-weight: 700; color: var(--gray-800); margin-bottom: 6px; }
.empty-state p  { font-size: 13px; max-width: 340px; margin: 0 auto 16px; }
.empty-state .btn { display: inline-flex; }

/* ═══════════════════════════════════════════════════════════
   DIVIDERS & UTILS
════════════════════════════════════════════════════════════ */
.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 16px 0;
}

.text-muted { color: var(--gray-500) !important; }
.text-sm    { font-size: 12.5px; }
.text-xs    { font-size: 11px; }
.font-mono  { font-family: var(--font-mono); }
.fw-600     { font-weight: 600; }
.fw-700     { font-weight: 700; }

/* ═══════════════════════════════════════════════════════════
   SIDEBAR OVERLAY
════════════════════════════════════════════════════════════ */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10,10,12,.4);
    z-index: 150;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* ═══════════════════════════════════════════════════════════
   PRINT — always light, regardless of theme
════════════════════════════════════════════════════════════ */
@media print {
    @page {
        size: A4 portrait;
        margin: 10mm 12mm;
    }

    :root, :root[data-theme="dark"] {
        --black: #111113; --gray-900: #1b1b1f; --gray-800: #2a2a2f; --gray-700: #3f3f46;
        --gray-600: #55555d; --gray-500: #6e6e76; --gray-400: #9d9da5; --gray-300: #d2d2d8;
        --gray-200: #e6e6ea; --gray-150: #ececef; --gray-100: #f3f3f5; --gray-75: #f7f7f8;
        --gray-50: #fafafb; --white: #ffffff; --surface: #ffffff; --surface-muted: #f6f6f7;
        --border: #e6e6ea; --border-strong: #d6d6dc; --accent: #18181b; --accent-ink: #ffffff;
    }

    *, *::before, *::after {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    html, body {
        background: #ffffff !important;
        color: #111113 !important;
        margin: 0 !important;
        padding: 0 !important;
        min-height: auto !important;
        height: auto !important;
        width: 100% !important;
    }

    .app-shell, .main-content, .page-content {
        background: #ffffff !important;
        min-height: auto !important;
        height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        box-shadow: none !important;
        border: none !important;
        border-radius: 0 !important;
    }

    .sidebar, .topbar, .app-banner, .page-actions,
    .no-print, .filter-bar, .toast-container,
    .btn, .print-btn, .sidebar-overlay {
        display: none !important;
    }

    .document-print {
        box-shadow: none !important;
        border: none !important;
        border-radius: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
        background: #ffffff !important;
        overflow: visible !important;
    }

    .data-table thead th {
        background: #f3f3f5 !important;
        color: #111113 !important;
    }

    .card {
        box-shadow: none !important;
        border: 1px solid #e6e6ea !important;
        background: #ffffff !important;
    }

    a {
        color: inherit !important;
        text-decoration: none !important;
    }
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
════════════════════════════════════════════════════════════ */
@media (max-width: 1600px) {
    .topbar-search { width: 240px; }
    .user-pill-text { display: none; }
    .user-pill { padding: 0 6px; }
}

@media (max-width: 1360px) {
    .topbar-search { width: 200px; }
}

@media (max-width: 1200px) {
    :root { --sidebar-w: 240px; }
}

@media (max-width: 960px) {
    :root { --frame-gap: 0px; --r-2xl: 0px; }
    .app-shell { min-height: 100vh; box-shadow: none; }
    .sidebar {
        position: fixed;
        top: 0; left: 0;
        height: 100vh;
        width: 268px;
        transform: translateX(-100%);
        box-shadow: var(--shadow-xl);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-toggle { display: flex; align-items: center; justify-content: center; }
    .topbar { padding: 12px 16px; }
    .topbar-left { gap: 12px; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr !important; }
    .doc-meta-grid { grid-template-columns: 1fr; }
    .page-content { padding: 20px 16px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .soa-header-grid { grid-template-columns: 1fr; }
    .doc-totals { max-width: 100%; }
}

@media (max-width: 640px) {
    .d-none-mobile { display: none !important; }
    .stats-grid { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .topbar-sep { display: none; }
    .icon-btn, .user-pill { height: 42px; }
    .icon-btn { width: 42px; }
    .btn-lg { height: 42px; padding: 0 14px; }
    .notif-panel { width: calc(100vw - 32px); right: -60px; }
}

/* ═══════════════════════════════════════════════════════════
   MOTION — page transitions, section entrance, loading states
════════════════════════════════════════════════════════════ */

/* Cross-document page transition (Chrome / Edge / Safari 18+; others just navigate) */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: vt-out 160ms ease-in both; }
::view-transition-new(root) { animation: vt-in 260ms ease-out both; }
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in  { from { opacity: 0; } }

@keyframes rise {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: none; }
}
@keyframes fade-in { from { opacity: 0; } }
@keyframes pop {
    from { opacity: 0; transform: translateY(-6px) scale(.98); }
    to   { opacity: 1; transform: none; }
}
@keyframes grow-y { from { transform: scaleY(0); } }
@keyframes grow-x { from { transform: scaleX(0); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* Page sections lift in one after another */
.page-content > * { animation: rise 520ms cubic-bezier(.2,.7,.2,1) both; }
.page-content > *:nth-child(2) { animation-delay: 60ms; }
.page-content > *:nth-child(3) { animation-delay: 120ms; }
.page-content > *:nth-child(4) { animation-delay: 180ms; }
.page-content > *:nth-child(5) { animation-delay: 240ms; }
.page-content > *:nth-child(n+6) { animation-delay: 300ms; }

/* Cards inside grids stagger within their row */
.stats-grid > *, .stats-grid-4 > *, .stats-grid-6 > *,
.grid-2 > *, .grid-3 > *, .grid-4 > *, .grid-main-side > * {
    animation: rise 520ms cubic-bezier(.2,.7,.2,1) both;
}
:is(.stats-grid, .stats-grid-4, .stats-grid-6, .grid-2, .grid-3, .grid-4, .grid-main-side) > :nth-child(2) { animation-delay: 70ms; }
:is(.stats-grid, .stats-grid-4, .stats-grid-6, .grid-2, .grid-3, .grid-4, .grid-main-side) > :nth-child(3) { animation-delay: 140ms; }
:is(.stats-grid, .stats-grid-4, .stats-grid-6, .grid-2, .grid-3, .grid-4, .grid-main-side) > :nth-child(n+4) { animation-delay: 210ms; }

/* Lift on hover */
.stat-card, .card { transition: box-shadow var(--t), border-color var(--t), transform var(--t); }
.stat-card:hover { transform: translateY(-2px); }

/* Data graphics grow in */
.bar { transform-origin: bottom; animation: grow-y 700ms cubic-bezier(.2,.7,.2,1) both; }
.bar-group:nth-child(2) .bar { animation-delay: 40ms; }
.bar-group:nth-child(3) .bar { animation-delay: 80ms; }
.bar-group:nth-child(4) .bar { animation-delay: 120ms; }
.bar-group:nth-child(n+5) .bar { animation-delay: 160ms; }
.progress > span { transform-origin: left; animation: grow-x 900ms cubic-bezier(.2,.7,.2,1) 200ms both; }

/* Menus and dialogs */
.notif-panel, .user-menu-panel { animation: pop 160ms ease-out both; }
.sidebar-link { transition: background var(--t-fast), color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast); }
.sidebar-link:active { transform: scale(.98); }

/* Top progress bar while a page or form is loading */
.nav-progress {
    position: fixed;
    top: 0; left: 0;
    height: 3px;
    width: 0;
    background: linear-gradient(90deg, var(--blue), var(--magenta));
    box-shadow: 0 0 10px rgba(59,143,220,.5);
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
}
.nav-progress.active {
    opacity: 1;
    width: 85%;
    transition: width 6s cubic-bezier(.08,.7,.2,1), opacity 120ms;
}
.nav-progress.done {
    opacity: 0;
    width: 100%;
    transition: width 200ms ease, opacity 300ms ease 200ms;
}

/* Spinner (also used inside buttons while their form submits) */
.spinner {
    display: inline-block;
    width: 15px; height: 15px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 700ms linear infinite;
    flex-shrink: 0;
}
.spinner-lg { width: 28px; height: 28px; border-width: 3px; }
.btn.is-loading { pointer-events: none; opacity: .85; }
.btn.is-loading > svg { display: none; }

.loading-block {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 32px;
    color: var(--gray-500);
    font-size: 13px;
}

/* Update notes dialog */
.whats-new {
    position: fixed;
    inset: 0;
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(10,10,12,.45);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    animation: fade-in 200ms ease both;
}
.whats-new[hidden] { display: none; }
.whats-new-card {
    width: 100%;
    max-width: 560px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-xl);
    animation: rise 380ms cubic-bezier(.2,.7,.2,1) 60ms both;
}
.whats-new-head { padding: 24px 26px 8px; }
.whats-new-head .badge { margin-bottom: 10px; }
.whats-new-head h2 { font-size: 22px; font-weight: 800; letter-spacing: -.4px; color: var(--black); }
.whats-new-head p { font-size: 13px; color: var(--gray-500); margin-top: 4px; }
.whats-new-body { padding: 8px 26px 4px; }
.release { padding: 14px 0; border-bottom: 1px solid var(--border); }
.release:last-child { border-bottom: none; }
.release-title { display: flex; justify-content: space-between; gap: 10px; font-size: 14.5px; font-weight: 700; color: var(--black); }
.release-title span { font-size: 12px; font-weight: 500; color: var(--gray-500); white-space: nowrap; }
.release ul { margin: 8px 0 0 18px; color: var(--gray-700); font-size: 13.5px; }
.release li { margin: 4px 0; }
.whats-new-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 16px 26px 22px; }
.whats-new-foot .text-sm { color: var(--gray-500); }

@media (prefers-reduced-motion: reduce) {
    @view-transition { navigation: none; }
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-delay: 0s !important;
        transition-duration: .01ms !important;
    }
}

@media print {
    *, *::before, *::after { animation: none !important; transition: none !important; }
    .nav-progress, .whats-new { display: none !important; }
}

/* ─── Section spacer ─────────────────────────────────────── */
.mb-0  { margin-bottom: 0 !important; }
.mb-4  { margin-bottom: 4px !important; }
.mb-8  { margin-bottom: 8px !important; }
.mb-12 { margin-bottom: 12px !important; }
.mb-16 { margin-bottom: 16px !important; }
.mb-20 { margin-bottom: 20px !important; }
.mb-24 { margin-bottom: 24px !important; }
.mt-8  { margin-top: 8px !important; }
.mt-16 { margin-top: 16px !important; }

/* ─── Section Info Box ───────────────────────────────────── */
.info-box {
    padding: 13px 16px;
    border-radius: var(--r-md);
    background: var(--info-light);
    border: 1px solid transparent;
    color: var(--info);
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
}
.info-box svg { width: 14px; height: 14px; flex-shrink: 0; margin-top: 2px; }

/* Unit of measure on document lines */
.unit-field { text-transform: uppercase; min-width: 84px; }

/* ─── Sign-in and sign-up pages (split brand panel + form) ─── */

body { background: var(--canvas); }

.login-shell {
    min-height: calc(100vh - 36px);
    margin: 18px;
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    background: var(--surface);
    border-radius: 28px;
    box-shadow: var(--shadow-frame);
    overflow: hidden;
}

/* Brand panel */
.login-brand-panel {
    position: relative;
    background: var(--brand);
    color: var(--brand-ink);
    padding: 48px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    isolation: isolate;
}
.login-brand-panel::before,
.login-brand-panel::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    background: currentColor;
    opacity: .07;
    z-index: -1;
}
.login-brand-panel::before { width: 520px; height: 520px; right: -180px; bottom: -200px; }
.login-brand-panel::after  { width: 260px; height: 260px; right: 120px; top: -110px; opacity: .05; }

.login-mark {
    display: flex;
    align-items: center;
    gap: 14px;
}
.login-mark-logo {
    width: 52px; height: 52px;
    border-radius: 14px;
    background: #fff;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
    box-shadow: 0 6px 20px rgba(0,0,0,.12);
    flex-shrink: 0;
}
.login-mark-logo img { width: 100%; height: 100%; object-fit: contain; }
.login-mark-logo span { font-size: 24px; font-weight: 800; color: var(--brand); }
.login-mark-name { font-size: 17px; font-weight: 800; letter-spacing: -.2px; line-height: 1.25; }

.login-hero h1 {
    font-size: clamp(30px, 3.4vw, 44px);
    font-weight: 800;
    letter-spacing: -1.2px;
    line-height: 1.08;
    margin-bottom: 14px;
    max-width: 520px;
}
.login-hero p { font-size: 15.5px; opacity: .82; max-width: 440px; line-height: 1.55; }
.login-foot { font-size: 12.5px; opacity: .7; }

/* Form panel */
.login-form-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px 32px;
}
.login-form { width: 100%; max-width: 380px; }
.login-form h2 { font-size: 26px; font-weight: 800; letter-spacing: -.6px; color: var(--black); }
.login-form .lead { font-size: 14px; color: var(--gray-500); margin: 6px 0 28px; }

.login-submit {
    width: 100%;
    height: 48px;
    font-size: 15px;
    font-weight: 700;
    border-radius: 12px;
    margin-top: 6px;
    background: var(--brand);
    border-color: var(--brand);
    color: var(--brand-ink);
}
.login-submit:hover { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); filter: brightness(1.08); }

.login-switch { margin-top: 22px; text-align: center; font-size: 13px; color: var(--gray-500); }
.login-switch a { color: var(--black); font-weight: 600; }

.login-rise { animation: rise .55s cubic-bezier(.2,.7,.2,1) both; }
.login-rise.d1 { animation-delay: .08s; }
.login-rise.d2 { animation-delay: .16s; }
.login-rise.d3 { animation-delay: .24s; }

@media (max-width: 900px) {
    .login-shell { grid-template-columns: 1fr; margin: 0; border-radius: 0; min-height: 100vh; }
    .login-brand-panel { padding: 28px 24px; gap: 28px; }
    .login-hero h1 { font-size: 28px; }
    .login-foot { display: none; }
}

/* Unbranded sign-in / sign-up: the button follows the theme; dark brand colours keep a visible edge in dark mode */
.login-submit.is-neutral { background: var(--black); border-color: var(--black); color: var(--white); }
.login-submit.is-neutral:hover { background: var(--black); border-color: var(--black); color: var(--white); }
[data-theme="dark"] .login-submit { border-color: rgba(255,255,255,.22); }

/* ─── UAE tax invoice / credit note (PINT-AE layout, Views/Shared/_TaxDocument) ─── */
.tax-doc { font-size: 12.5px; color: var(--gray-700); }
.tax-doc-head {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 24px;
    padding-bottom: 18px; margin-bottom: 18px; border-bottom: 2px solid var(--black);
}
.tax-doc-brand { display: flex; align-items: center; gap: 16px; }
.tax-doc-trn { margin-top: 4px; font-size: 12px; font-weight: 700; color: var(--gray-700); letter-spacing: .3px; }
.tax-doc-title { text-align: right; }
.tax-doc-title-en { font-size: 22px; font-weight: 800; letter-spacing: 1.5px; text-transform: uppercase; color: var(--black); }
.tax-doc-title-ar { font-size: 16px; font-weight: 700; color: var(--gray-600); margin: 2px 0 6px; }
.tax-doc-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.tax-doc-party {
    border: 1px solid var(--border); border-radius: var(--r-lg); padding: 14px 16px; line-height: 1.55;
}
.tax-doc-party-name { font-size: 14.5px; font-weight: 800; color: var(--black); margin: 4px 0 2px; }
.tax-doc-ids { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 8px 0 0; }
.tax-doc-ids dt { color: var(--gray-500); font-weight: 600; }
.tax-doc-ids dd { margin: 0; color: var(--black); font-weight: 600; word-break: break-word; }
.tax-doc-details {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0;
    border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; margin-bottom: 18px;
}
.tax-doc-details > div { padding: 9px 12px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.tax-doc-details span { display: block; font-size: 10px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--gray-500); }
.tax-doc-details strong { display: block; color: var(--black); font-weight: 700; margin-top: 2px; word-break: break-word; }
.tax-doc-details .tax-doc-uuid { grid-column: span 2; }
.tax-doc-details .tax-doc-uuid strong { font-family: var(--font-mono); font-size: 11px; font-weight: 600; }
.tax-doc-lines th, .tax-doc-lines td { font-size: 12px; }
.tax-doc-cat {
    display: inline-block; min-width: 20px; padding: 0 5px; border-radius: 4px; text-align: center;
    background: var(--gray-100); border: 1px solid var(--border); font-weight: 700; font-size: 10.5px; color: var(--black);
}
.tax-doc-bottom { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; margin-top: 18px; align-items: start; }
.tax-doc-left { display: grid; gap: 14px; }
.tax-doc-vat { width: 100%; border-collapse: collapse; font-size: 12px; }
.tax-doc-vat th { text-align: left; font-size: 10px; letter-spacing: .6px; text-transform: uppercase; color: var(--gray-500); border-bottom: 1px solid var(--border); padding: 6px 8px; }
.tax-doc-vat td { padding: 6px 8px; border-bottom: 1px solid var(--border); color: var(--black); }
.tax-doc-vat .num { text-align: right; font-variant-numeric: tabular-nums; }
.tax-doc-words div { color: var(--black); font-weight: 600; margin-top: 3px; }
.tax-doc-payment { border: 1px solid var(--border); border-radius: var(--r-lg); padding: 12px 14px; }
.tax-doc-totals { margin-left: 0; max-width: none; }
.tax-doc-due { font-weight: 800; color: var(--black); font-size: 14px; }
.tax-doc-notes { margin-top: 18px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--r-lg); }
.tax-doc-notes div { margin-top: 3px; color: var(--black); white-space: pre-line; }
.tax-doc-foot { margin-top: 22px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 10.5px; color: var(--gray-500); text-align: center; }

/* E-invoice readiness (screen only) */
.einv-check {
    margin-bottom: 14px; padding: 11px 14px; border-radius: var(--r-lg); font-size: 13px;
    background: var(--warning-light); border: 1px solid var(--warning-border); color: var(--warning);
}
.einv-check.is-ready { background: var(--success-light); border-color: var(--success-border); color: var(--success); }
.einv-check summary { cursor: pointer; }
.einv-check ul { margin: 10px 0 2px; padding-left: 18px; display: grid; gap: 4px; color: var(--gray-700); }
.einv-check .einv-area { font-weight: 700; color: var(--black); margin-right: 4px; }
.einv-check a { margin-left: 6px; font-weight: 700; color: var(--info); }

@media (max-width: 900px) {
    .tax-doc-parties, .tax-doc-bottom { grid-template-columns: 1fr; }
    .tax-doc-details { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media print {
    .tax-doc { font-size: 10.5px; }
    .tax-doc-head { border-bottom-color: #000; }
    .tax-doc-parties, .tax-doc-bottom { break-inside: avoid; }
    .tax-doc-details { grid-template-columns: repeat(4, 1fr); }
    .tax-doc-bottom { grid-template-columns: 1fr 300px; }
    .tax-doc-lines tr { break-inside: avoid; }
}

.tax-doc-prepared { margin-top: 16px; color: var(--black); font-weight: 600; }
.tax-doc-prepared .doc-meta-label { display: inline; margin-right: 8px; }

/* ─── VAT return (FTA VAT 201) ─── */
.vat201-section { font-size: 13px; font-weight: 800; letter-spacing: .4px; text-transform: uppercase; color: var(--black); margin: 22px 0 8px; }
.vat201-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.vat201-table th { text-align: left; font-size: 10px; letter-spacing: .6px; text-transform: uppercase; color: var(--gray-500); padding: 7px 10px; border-bottom: 1.5px solid var(--border); }
.vat201-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); color: var(--gray-700); }
.vat201-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.vat201-table td.num { color: var(--black); }
.vat201-no { width: 44px; font-weight: 800; color: var(--black) !important; }
.vat201-total td { font-weight: 800; color: var(--black); background: var(--gray-50, var(--surface-muted)); border-bottom: 1.5px solid var(--black); }
.vat201-warn td { color: var(--warning); }
.vat201-net { max-width: 640px; margin-left: auto; }
.vat201-note { margin-top: 18px; font-size: 11.5px; color: var(--gray-500); line-height: 1.6; }

/* Roles & permissions matrix */
.perm-matrix .perm-col { text-align: center; width: 110px; }
.perm-matrix input[type=checkbox] { width: 17px; height: 17px; cursor: pointer; }
.perm-matrix .perm-group td { font-size: 10.5px; font-weight: 800; letter-spacing: .7px; text-transform: uppercase; color: var(--gray-500); background: var(--surface-muted); }

/* Fixed company identity fields */
.form-control[readonly], .form-select:disabled { background: var(--surface-muted); color: var(--gray-600); cursor: not-allowed; }
.lock-hint { display: block; margin-top: 4px; }

/* ─── Logistics jobs ─── */
.job-facts { display: grid; gap: 10px; font-size: 13px; color: var(--black); }
.job-facts span { display: block; font-size: 10px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--gray-500); margin-bottom: 1px; }
.cost-sheet td, .cost-sheet th { font-size: 12.5px; white-space: nowrap; }
.cost-sheet td:first-child { white-space: normal; min-width: 180px; }
.add-charge { border-top: 1px solid var(--border); background: var(--surface-muted); }
.add-charge-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px; align-items: end; }
.add-charge-grid .charge-wide { grid-column: span 2; }
.add-charge-grid .charge-actions { grid-column: 1 / -1; justify-self: end; }
.add-charge-grid .form-control, .add-charge-grid .btn { height: 44px; min-height: 44px; }
.add-charge-grid .form-group { margin: 0; }
@media (max-width: 1200px) {
    .add-charge-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .add-charge-grid .charge-wide { grid-column: auto; }
}
@media (max-width: 600px) {
    .add-charge-grid { grid-template-columns: minmax(0, 1fr); }
    .add-charge-grid .charge-actions { width: 100%; }
    .add-charge-grid .charge-actions .btn { width: 100%; }
}
.job-timeline { list-style: none; margin: 0; padding: 0 0 0 16px; border-left: 2px solid var(--border); display: grid; gap: 14px; }
.job-timeline li { position: relative; }
.job-timeline li::before { content: ""; position: absolute; left: -22px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--black); border: 2px solid var(--surface); }
.job-timeline-when { font-size: 11px; color: var(--gray-500); }
.cost-sheet td:nth-child(10) { white-space: normal; min-width: 110px; }
.cost-sheet td:nth-child(10) .badge { margin: 1px 0; }

/* Industry operations panel on the overview */
.ops-panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.ops-panel-head .card-title { font-size: 17px; }
a.stat-card.ops-link { text-decoration: none; color: inherit; transition: border-color var(--t-fast), transform var(--t-fast); }
a.stat-card.ops-link:hover { border-color: var(--border-strong); transform: translateY(-1px); }

.company-initials { width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-muted); display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; color: var(--gray-600); flex-shrink: 0; }
.alert-info { background: var(--info-light, #eff6ff); border-color: var(--info-border, #bfdbfe); color: var(--info, #1d4ed8); }

/* Department groups keep the sidebar compact; the current section opens automatically. */
.sidebar-group { margin: 6px 0; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.sidebar-group-heading { display: flex; align-items: center; gap: 10px; padding: 12px; cursor: pointer; list-style: none; font-size: 12px; font-weight: 700; color: var(--gray-700); border-radius: 8px; }
.sidebar-group-heading::-webkit-details-marker { display: none; }
.sidebar-group-heading:hover { background: var(--gray-100); }
.sidebar-group-heading:focus-visible { outline: 2px solid var(--black); outline-offset: -2px; }
.sidebar-group-heading > svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-group-chevron { margin-left: auto; font-size: 22px; line-height: 1; transition: transform 150ms; }
.sidebar-group[open] > summary .sidebar-group-chevron { transform: rotate(90deg); }
.sidebar-group-links { margin: 2px 0 6px 20px; padding-left: 6px; border-left: 1px solid var(--border); }
.sidebar-group-links .sidebar-link { min-height: 38px; padding: 9px 12px; font-size: 12px; }
.grid-2 > *, .grid-3 > * { min-width: 0; }
.form-control[readonly] { background: var(--gray-100); color: var(--gray-500); cursor: default; }

/* Printed tables must fit the sheet rather than retain the screen's horizontal scroll area. */
@media print {
    .app-shell, .main-content, .page-content { display: block !important; overflow: visible !important; }
    .page-content > * { animation: none !important; transform: none !important; }
    .table-container, .card, .card-body { overflow: visible !important; max-width: 100% !important; min-width: 0 !important; }
    .table-container { border: none !important; border-radius: 0 !important; box-shadow: none !important; }
    .data-table, .table { width: 100% !important; max-width: 100% !important; min-width: 0 !important; }
    .data-table th, .data-table td, .table th, .table td {
        min-width: 0 !important;
        white-space: normal !important;
        overflow-wrap: anywhere;
        padding: 5px 6px !important;
        font-size: 9pt !important;
        letter-spacing: normal !important;
    }
    thead { display: table-header-group; }
    tfoot { display: table-row-group; }
    tr { break-inside: avoid; page-break-inside: avoid; }
    .document-print { break-inside: auto; }
}

/* Job upload controls share one baseline; helper text sits on its own row. */
.job-document-checklist { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.job-document-upload { display: grid; grid-template-columns: minmax(190px, 250px) minmax(0, 1fr) auto; gap: 10px 16px; align-items: end; }
.job-document-upload .form-group { margin: 0; min-width: 0; }
.job-document-upload .form-control, .job-document-save .btn { height: 44px; min-height: 44px; width: 100%; }
.job-document-upload input[type="file"] { padding: 6px 10px; font-size: 13px; line-height: 30px; }
.job-document-upload input[type="file"]::file-selector-button { height: 30px; margin: 0 10px 0 0; padding: 0 12px; border: 0; border-radius: 5px; background: var(--gray-100); color: var(--black); font: inherit; cursor: pointer; }
.job-upload-limits { grid-column: 1 / -1; margin: 0; line-height: 1.5; }
.job-workflow-table { border: 0; border-top: 1px solid var(--border); border-radius: 0; box-shadow: none; }
.job-task-update { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.job-task-update .form-control, .job-task-update .btn { height: 36px; min-height: 36px; }
@media (max-width: 1100px) {
    .job-document-upload { grid-template-columns: minmax(160px, 1fr) minmax(0, 2fr); }
    .job-document-save { grid-column: 1 / -1; justify-self: end; }
}
@media (max-width: 700px) {
    .job-document-upload { grid-template-columns: minmax(0, 1fr); }
    .job-document-save { width: 100%; }
}

/* ═══════════════════════════════════════════════════════════
   PHONES & TABLETS — app-style layout (spec 8.6)
   Tables become cards (ui.js labels each cell from its column
   heading), a bottom tab bar replaces the top actions, and
   inputs are 16px so iOS does not zoom on focus.
════════════════════════════════════════════════════════════ */
.topbar-title { display: none; }
.bottom-nav { display: none; }

@media (max-width: 960px) {
    /* The off-canvas sidebar must not cast its shadow onto the page */
    .sidebar { box-shadow: none; visibility: hidden; transition: transform var(--t-slow), visibility 0s linear var(--t-slow); }
    .sidebar.open { box-shadow: var(--shadow-xl); visibility: visible; transition: transform var(--t-slow); }
    .card-header { flex-wrap: wrap; min-height: 0; }
    .card-header > * { min-width: 0; }
}
@media screen and (max-width: 960px) {
    /* Printable statements: wide tables scroll inside the document, never the page */
    .document-print { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

@media (max-width: 640px) {
    /* Top bar: menu, page title, then icons — nothing overlaps */
    .topbar { padding: 10px 12px; gap: 8px; min-height: 60px; }
    .topbar-left { gap: 10px; }
    .topbar-right { gap: 6px; }
    .topbar-greeting { display: none; }
    .topbar-title {
        display: block;
        min-width: 0;
        font-size: 17px;
        font-weight: 800;
        letter-spacing: -.3px;
        color: var(--black);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .sidebar-toggle { padding: 8px; }
    .icon-btn, .user-pill { width: 40px; height: 40px; border-radius: 11px; }
    .user-pill { padding: 0; justify-content: center; }
    .topbar-right > .btn-lg { display: none; } /* primary action moves to the bottom bar */
    .notif-panel { position: fixed; top: 64px; left: 12px; right: 12px; width: auto; }
    .user-menu-panel { position: fixed; top: 64px; right: 12px; left: auto; }

    /* Banners: compact, one block */
    .app-banner { padding: 9px 14px; font-size: 12.5px; gap: 2px 10px; line-height: 1.4; }
    .app-banner strong { font-size: 11px; letter-spacing: .4px; }

    .page-content { padding: 16px 12px calc(84px + env(safe-area-inset-bottom)); }
    .page-header { margin-bottom: 16px; gap: 12px; }
    .page-title { font-size: 21px; }
    .page-actions { width: 100%; }
    .page-actions > .btn { flex: 1 1 auto; justify-content: center; }

    /* KPI tiles: two per row */
    .stats-grid, .stats-grid-4, .stats-grid-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
    .stat-card { padding: 14px; min-width: 0; }
    .stat-value { font-size: 20px; overflow-wrap: anywhere; }
    .stat-label { font-size: 12px; }

    .card-header { padding: 14px 16px; }
    .card-body { padding: 16px; }
    .grid-2, .grid-3, .grid-4 { gap: 12px; }

    /* Touch-friendly form controls */
    .form-control, .form-select, select, textarea, input[type="text"], input[type="number"], input[type="date"],
    input[type="email"], input[type="search"], input[type="password"], input[type="tel"] { font-size: 16px; }
    .form-control { min-height: 46px; }
    .btn { min-height: 42px; }
    .btn-sm { min-height: 36px; }

    /* Filter bars stack; each control is full width */
    .filter-bar { padding: 12px; gap: 10px; }
    .filter-bar form { gap: 10px; }
    .filter-group { flex: 1 1 100%; min-width: 0; }
    .filter-group .form-control, .filter-group select, .filter-group input { width: 100% !important; max-width: none !important; }
    .filter-bar form > .btn, .filter-bar form > button { flex: 1 1 auto; }

    /* ─── Tables as cards ─── */
    .table-container:has(> table.m-cards) { background: none; border: 0; box-shadow: none; overflow: visible; border-radius: 0; }
    table.m-cards, table.m-cards tbody, table.m-cards tfoot, table.m-cards tr, table.m-cards td { display: block; width: 100%; }
    table.m-cards { min-width: 0 !important; border: 0; background: none; }
    table.m-cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    table.m-cards tr {
        background: var(--surface);
        border: 1px solid var(--border) !important;
        border-radius: 14px;
        padding: 10px 14px;
        margin-bottom: 10px;
        box-shadow: var(--shadow-sm);
    }
    table.m-cards tbody tr:hover { background: var(--surface); }
    table.m-cards td, table.m-cards tfoot td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 6px 0 !important;
        border: 0 !important;
        text-align: right !important;
        white-space: normal;
        min-height: 0;
        overflow-wrap: anywhere;
    }
    table.m-cards td::before {
        content: attr(data-label);
        flex: 0 0 auto;
        max-width: 45%;
        text-align: left;
        font-size: 11px;
        font-weight: 700;
        letter-spacing: .5px;
        text-transform: uppercase;
        color: var(--gray-500);
        font-family: var(--font);
    }
    table.m-cards td[data-label=""]::before, table.m-cards td.m-span::before { content: none; }
    table.m-cards td[data-label=""] { justify-content: flex-end; }
    table.m-cards td:empty { display: none; }
    /* Read-only lists: the first column is the card title */
    table.m-cards-read tbody td:first-child { justify-content: flex-start; text-align: left !important; font-size: 15px; font-weight: 700; padding-bottom: 8px !important; }
    table.m-cards-read tbody td:first-child::before { content: none; }
    table.m-cards td.m-span { display: block; text-align: left !important; }
    table.m-cards tr.m-heading { background: var(--surface-muted); box-shadow: none; padding: 8px 14px; }
    table.m-cards tfoot tr { background: var(--surface-muted); }
    /* Line editors: label above each input */
    table.m-cards-edit td { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; text-align: left !important; justify-content: stretch; }
    table.m-cards-edit td::before { max-width: none; }
    table.m-cards-edit td .form-control, table.m-cards-edit td select, table.m-cards-edit td input:not([type="checkbox"]):not([type="radio"]) { width: 100% !important; max-width: none !important; min-width: 0 !important; }
    table.m-cards-edit td[data-label=""] { display: flex; justify-content: flex-end; }
    table.m-cards-edit tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 10px; }
    table.m-cards-edit tbody td:has(select), table.m-cards-edit tbody td:has(textarea),
    table.m-cards-edit tbody td:has(input[name$="Description"]), table.m-cards-edit tbody td[data-label=""],
    table.m-cards-edit tbody td.m-span { grid-column: 1 / -1; }
    .doc-totals { width: 100%; min-width: 0 !important; max-width: none; margin-left: 0; }
    table.m-cards td .btn + .btn, table.m-cards td form + form, table.m-cards td .btn + form, table.m-cards td form + .btn { margin-left: 6px; }
    table.m-cards td > div[style*="display:flex"] { flex-wrap: wrap; justify-content: flex-end; }

    /* Inline multi-column grids in views collapse to one column (label/value pairs stay side by side) */
    main [style*="grid-template-columns:repeat(4,1fr)"] { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
    main [style*="grid-template-columns:1fr 1fr"],
    main [style*="grid-template-columns:repeat(2, 1fr)"], main [style*="grid-template-columns:1fr 1fr 1fr"],
    main [style*="grid-template-columns:1.15fr 0.85fr"] { grid-template-columns: minmax(0, 1fr) !important; }
    main [style*="grid-template-columns"] > [style*="grid-column:span"] { grid-column: 1 / -1 !important; }

    .document-print { padding: 16px !important; border-radius: 14px; }
    .document-print table.m-cards tr { box-shadow: none; }

    /* Bottom tab bar */
    .bottom-nav {
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        position: fixed;
        left: 0; right: 0; bottom: 0;
        z-index: 140;
        background: var(--surface);
        border-top: 1px solid var(--border);
        padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
        box-shadow: 0 -4px 18px rgba(0,0,0,.06);
    }
    .bottom-nav a, .bottom-nav button {
        position: relative;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 3px;
        padding: 5px 0;
        border: 0;
        background: none;
        color: var(--gray-500);
        font: 600 11px/1.1 var(--font);
        text-decoration: none;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }
    .bottom-nav svg { width: 22px; height: 22px; }
    .bottom-nav .active { color: var(--black); }
    .bottom-nav .bottom-nav-add svg { width: 40px; height: 40px; margin-top: -4px; padding: 9px; border-radius: 13px; background: var(--black); color: var(--surface); }
    .bottom-nav .icon-btn-count { top: -2px; right: calc(50% - 22px); min-width: 18px; height: 18px; font-size: 10px; }
    .toast-container { bottom: calc(80px + env(safe-area-inset-bottom)); }
}
@media print { .bottom-nav { display: none !important; } }

/* ─── Freight modules: inline forms on the job page, pipeline and delivery screens ─── */
.form-grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px 14px; align-items: end; margin-top: 14px; }
.form-grid-auto .form-group { margin: 0; min-width: 0; }
.job-inline-form > summary { list-style: none; display: inline-flex; }
.job-inline-form > summary::-webkit-details-marker { display: none; }
.job-inline-form[open] > summary { margin-bottom: 4px; }
.cost-actual-form { display: inline-flex; gap: 4px; align-items: center; justify-content: flex-end; }
.cost-actual-form .form-control { width: 92px; min-height: 32px; height: 32px; padding: 4px 8px; text-align: right; font-size: 13px; }
.cost-actual-form select.form-control { width: 120px; text-align: left; }
.print-only { display: none; }
@media print { .print-only { display: inline; } .cost-actual-form { display: none !important; } }
.pipeline { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.pipeline a { display: block; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); color: var(--gray-700); text-decoration: none; box-shadow: var(--shadow-sm); }
.pipeline a.active { border-color: var(--black); box-shadow: 0 0 0 1px var(--black); }
.pipeline strong { display: block; font-size: 24px; font-weight: 800; color: var(--black); }
.pipeline span { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; }
.kyc-panel { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.signature-pad { width: 100%; height: 200px; border: 1.5px dashed var(--border-strong); border-radius: 12px; background: #fff; touch-action: none; display: block; }
.pod-card { max-width: 640px; margin: 0 auto; }
@media (max-width: 640px) {
    .pipeline { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .pipeline strong { font-size: 20px; }
    .form-grid-auto { grid-template-columns: minmax(0, 1fr); }
    .cost-actual-form { width: 100%; }
    .cost-actual-form .form-control { flex: 1; width: auto; min-height: 40px; }
}
@media (max-width: 960px) {
    /* Spanning fields inside collapsed grids must not create a phantom extra column */
    :is(.grid-2, .grid-3, .grid-4, .row.grid-2, .row.grid-3, .row.grid-4) > [style*="grid-column"] { grid-column: 1 / -1 !important; }
}
.text-warning { color: var(--warning); }
@media (min-width: 641px) {
    /* Cost sheet has 12 columns: keep it within the page on laptops */
    .cost-sheet thead th, .cost-sheet tbody td, .cost-sheet tfoot td { padding-left: 9px; padding-right: 9px; }
    .cost-sheet thead th { letter-spacing: .3px; }
    .cost-sheet .cost-actual-form .form-control { width: 78px; }
}

/* ═══════════════════════════════════════════════════════════
   TOP-MENU LAYOUT (Tenant.AppLayout = TopMenu)
   Menu groups become tabs across the header; the side menu is
   only used off-canvas on phones (More / hamburger).
════════════════════════════════════════════════════════════ */
.top-brand, .top-tabs { display: none; }
.link-button { background: none; border: 0; padding: 0; font: inherit; color: inherit; text-decoration: underline; cursor: pointer; }

@media (min-width: 961px) {
    .layout-top .app-shell { flex-direction: column; }
    .layout-top .sidebar { display: none; }
    .layout-top .main-content { border-radius: var(--r-2xl); }
    .layout-top .topbar {
        flex-wrap: wrap;
        padding: 14px 24px 0;
        gap: 0 18px;
        border-top-left-radius: var(--r-2xl);
        border-top-right-radius: var(--r-2xl);
        border-bottom: 1px solid var(--border);
    }
    .layout-top .app-banner { border-radius: var(--r-2xl) var(--r-2xl) 0 0; }
    .layout-top .app-banner + .app-banner, .layout-top .app-banner + .topbar { border-radius: 0; }
    .layout-top .top-brand {
        order: 1; display: flex; align-items: center; gap: 10px; min-width: 0; max-width: 240px; flex-shrink: 0;
        color: var(--black); text-decoration: none; padding-bottom: 14px;
    }
    .layout-top .top-brand-icon {
        width: 36px; height: 36px; border-radius: 11px; flex-shrink: 0; display: grid; place-items: center;
        background: var(--black); color: var(--surface); font-weight: 800; font-size: 15px; overflow: hidden;
    }
    .layout-top .top-brand-icon.has-logo { background: var(--white); border: 1px solid var(--border); }
    .layout-top .top-brand-icon img { width: 100%; height: 100%; object-fit: contain; }
    .layout-top .top-brand-name { font-weight: 800; font-size: 16px; letter-spacing: -.3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .layout-top .top-tabs { order: 2; flex: 1; display: flex; align-items: center; justify-content: flex-start; gap: 2px; min-width: 0; padding-bottom: 14px; }
    .layout-top .topbar-right { order: 3; padding-bottom: 14px; }
    .layout-top .topbar-left .topbar-search { display: block; margin-left: auto; width: 300px; }
    .layout-top .topbar-right .user-pill-text { display: none; }
    .layout-top .topbar-left { order: 4; flex-basis: 100%; gap: 18px; padding: 12px 0 14px; border-top: 1px solid var(--border); }
    .layout-top .topbar-greeting h2 { font-size: 17px; }
}
@media (min-width: 961px) and (max-width: 1520px) {
    .layout-top .top-brand-name { display: none; }
}
@media (min-width: 961px) {
    /* Tabs never run under the header icons */
    .layout-top .top-tabs { overflow: visible; }
    .layout-top .top-tab-menu, .layout-top .top-tabs > .top-tab { flex-shrink: 0; }
}
@media (min-width: 961px) and (max-width: 1200px) {
    .layout-top .top-tab { padding: 8px 9px; font-size: 13px; }
    .layout-top .top-tab-caret { display: none; }
    .layout-top .topbar-right > .btn-lg span { display: none; }
    .layout-top .topbar-left .topbar-search { width: 220px; }
}
/* Panels near the right edge open leftwards */
.top-tab-menu:nth-last-child(-n+2) .top-tab-panel { left: auto; right: 0; }

.top-tab-menu { position: relative; }
.top-tab-menu > summary { list-style: none; }
.top-tab-menu > summary::-webkit-details-marker { display: none; }
.top-tab {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 9px 14px; border-radius: 999px;
    font-size: 13.5px; font-weight: 600; color: var(--gray-600); white-space: nowrap;
    cursor: pointer; text-decoration: none;
    border: 1px solid transparent;
    transition: background var(--t-fast), color var(--t-fast);
}
.top-tab:hover { color: var(--black); background: var(--gray-75); }
.top-tab.active { color: var(--black); font-weight: 700; background: var(--surface); border-color: var(--border); box-shadow: var(--shadow-sm); }
.top-tab-menu[open] > .top-tab { color: var(--black); background: var(--gray-75); }
.top-tab-caret { width: 14px; height: 14px; opacity: .6; transition: transform var(--t-fast); }
.top-tab-menu[open] .top-tab-caret { transform: rotate(180deg); }
.top-tab-panel {
    position: absolute; top: calc(100% + 8px); left: 0;
    z-index: 300; min-width: 260px; padding: 8px;
    display: grid; grid-template-columns: 1fr; gap: 2px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-xl);
    animation: pop 160ms ease-out both;
}
.top-tab-panel.two-col { grid-template-columns: 1fr 1fr; min-width: 480px; }
.top-tab-link {
    display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px;
    font-size: 13.5px; font-weight: 600; color: var(--gray-800); text-decoration: none; white-space: nowrap;
}
.top-tab-link:hover { background: var(--gray-75); color: var(--black); }
.top-tab-link.active { background: var(--gray-100); color: var(--black); }
.top-tab-icon { width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0; display: grid; place-items: center; background: var(--surface-muted); border: 1px solid var(--border); }
.top-tab-icon svg { width: 16px; height: 16px; }

/* Warm, soft-colour look of the top-menu layout (light theme) */
html:not([data-theme="dark"]) body.layout-top { background: linear-gradient(160deg, #f2c5b2 0%, #f5d9c8 45%, #f3e3d3 100%); }
html:not([data-theme="dark"]) .layout-top .app-shell,
html:not([data-theme="dark"]) .layout-top .main-content,
html:not([data-theme="dark"]) .layout-top .topbar { background: #fbf7f1; }
html:not([data-theme="dark"]) .layout-top .card,
html:not([data-theme="dark"]) .layout-top .table-container,
html:not([data-theme="dark"]) .layout-top .filter-bar { background: #fffdfa; }
html:not([data-theme="dark"]) .layout-top .top-tab.active { background: #fff; }
html:not([data-theme="dark"]) .layout-top .top-tab:hover, html:not([data-theme="dark"]) .layout-top .top-tab-menu[open] > .top-tab { background: #f1e9de; }
html:not([data-theme="dark"]) .layout-top :is(.stats-grid, .stats-grid-4, .stats-grid-6) > .stat-card { border-color: transparent; border-radius: 22px; }
html:not([data-theme="dark"]) .layout-top :is(.stats-grid, .stats-grid-4, .stats-grid-6) > .stat-card:nth-child(6n+1) { background: #f1d7a9; }
html:not([data-theme="dark"]) .layout-top :is(.stats-grid, .stats-grid-4, .stats-grid-6) > .stat-card:nth-child(6n+2) { background: #a9c6ef; }
html:not([data-theme="dark"]) .layout-top :is(.stats-grid, .stats-grid-4, .stats-grid-6) > .stat-card:nth-child(6n+3) { background: #cfaef1; }
html:not([data-theme="dark"]) .layout-top :is(.stats-grid, .stats-grid-4, .stats-grid-6) > .stat-card:nth-child(6n+4) { background: #efb79d; }
html:not([data-theme="dark"]) .layout-top :is(.stats-grid, .stats-grid-4, .stats-grid-6) > .stat-card:nth-child(6n+5) { background: #ebaee6; }
html:not([data-theme="dark"]) .layout-top :is(.stats-grid, .stats-grid-4, .stats-grid-6) > .stat-card:nth-child(6n+6) { background: #f0a9bf; }
html:not([data-theme="dark"]) .layout-top .stat-card :is(.stat-label, .stat-meta, .stat-value) { color: #1c1917; }
html:not([data-theme="dark"]) .layout-top .stat-card .stat-icon { background: rgba(255,255,255,.55); border-color: transparent; }

/* ─── Console: layout picker previews ─── */
.layout-options .layout-option { align-items: flex-start; flex-direction: column; gap: 10px; padding: 12px; cursor: pointer; }
.layout-options .layout-option > input { position: absolute; opacity: 0; pointer-events: none; }
.layout-options .layout-option { position: relative; }
.layout-options .layout-option:has(input:checked) { border-color: var(--black); box-shadow: 0 0 0 1px var(--black); background: var(--surface); }
.layout-options .layout-option:has(input:focus-visible) { outline: 2px solid var(--info); outline-offset: 2px; }
.layout-preview { display: flex; width: 100%; height: 132px; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); background: var(--surface); }
.layout-preview i { display: block; }
.layout-preview.is-side .lp-sidebar { width: 26%; padding: 8px 6px; border-right: 1px solid var(--border); display: flex; flex-direction: column; gap: 5px; background: var(--surface-muted); }
.layout-preview .lp-logo { width: 18px; height: 18px; border-radius: 5px; background: var(--black); margin-bottom: 4px; }
.layout-preview .lp-line { height: 6px; border-radius: 3px; background: var(--gray-200); }
.layout-preview .lp-line.on { background: var(--gray-500); }
.layout-preview .lp-main { flex: 1; padding: 8px; display: flex; flex-direction: column; gap: 7px; }
.layout-preview .lp-bar { height: 12px; border-radius: 4px; background: var(--gray-100); }
.layout-preview .lp-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.layout-preview .lp-tiles i { height: 26px; border-radius: 6px; background: var(--gray-100); border: 1px solid var(--border); }
.layout-preview .lp-table { flex: 1; border-radius: 6px; background: repeating-linear-gradient(var(--surface) 0 9px, var(--gray-100) 9px 10px); border: 1px solid var(--border); }
.layout-preview.is-top { flex-direction: column; background: linear-gradient(160deg, #f2c5b2, #f3e3d3); padding: 5px; gap: 5px; }
.layout-preview.is-top .lp-header { display: flex; align-items: center; gap: 5px; padding: 5px 7px; border-radius: 7px; background: #fbf7f1; }
.layout-preview.is-top .lp-logo { margin: 0 6px 0 0; width: 14px; height: 14px; }
.layout-preview .lp-tab { width: 26px; height: 7px; border-radius: 4px; background: #e7ded3; }
.layout-preview .lp-tab.on { background: #b9ab9b; }
.layout-preview .lp-dot { width: 9px; height: 9px; border-radius: 50%; background: #e7ded3; }
.layout-preview .lp-dot:first-of-type { margin-left: auto; }
.layout-preview.is-top .lp-body { flex: 1; display: grid; grid-template-columns: 1fr 34%; gap: 5px; padding: 6px; border-radius: 7px; background: #fbf7f1; }
.layout-preview.is-top .lp-tiles { grid-template-columns: repeat(3, 1fr); }
.layout-preview.is-top .lp-tiles i { height: auto; min-height: 30px; border: 0; border-radius: 7px; }
.layout-preview.is-top .t1 { background: #f1d7a9; } .layout-preview.is-top .t2 { background: #a9c6ef; } .layout-preview.is-top .t3 { background: #cfaef1; }
.layout-preview.is-top .t4 { background: #efb79d; } .layout-preview.is-top .t5 { background: #ebaee6; } .layout-preview.is-top .t6 { background: #f0a9bf; }
.layout-preview.is-top .lp-side-card { border-radius: 7px; background: #fffdfa; border: 1px solid #eee4d8; }

/* ─── VAT return reminder countdown ─── */
.vat-countdown { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 6px 0 10px; }
.vat-countdown > div { text-align: center; padding: 14px 6px; border-radius: 14px; background: var(--surface-muted); border: 1px solid var(--border); }
.vat-countdown strong { display: block; font-size: 30px; font-weight: 800; letter-spacing: -1px; color: var(--black); font-variant-numeric: tabular-nums; line-height: 1.1; }
.vat-countdown span { font-size: 11px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--gray-500); }
.vat-reminder.is-late .vat-countdown > div { background: var(--danger-light); border-color: var(--danger-border); }
.vat-reminder.is-late .vat-countdown strong, .vat-reminder.is-late .vat-countdown-note { color: var(--danger); }
.vat-countdown-note { font-size: 13px; color: var(--gray-600); margin-bottom: 4px; }
.vat-reminder-foot { flex-wrap: wrap; justify-content: flex-end; }
.vat-reminder-foot > :first-child { margin-right: auto; }
@media (max-width: 640px) {
    .vat-countdown { gap: 6px; }
    .vat-countdown strong { font-size: 22px; }
    .vat-reminder-foot > * { flex: 1 1 100%; }
    .vat-reminder-foot .btn { width: 100%; justify-content: center; }
}
.app-banner + .app-banner { border-top-right-radius: 0; }
.layout-options { align-items: stretch !important; margin-bottom: 10px; }
.layout-options .layout-option { height: 100%; }
@media (max-width: 640px) { .doc-notes { max-width: none !important; } }

/* Pill tabs between related pages (Pricing, Alerts…) */
.pill-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.pill-tabs a { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--gray-700); font-size: 13px; font-weight: 600; text-decoration: none; }
.pill-tabs a:hover { border-color: var(--border-strong); color: var(--black); }
.pill-tabs a.active { background: var(--black); border-color: var(--black); color: var(--surface); }
@media (max-width: 640px) {
    /* Label / value tables on printable documents: two columns per row on phones */
    table.doc-kv, table.doc-kv tbody { display: block; }
    table.doc-kv tr { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); border-bottom: 1px solid var(--gray-150); }
    table.doc-kv td { display: block; padding: 8px 10px !important; overflow-wrap: anywhere; }
}

/* ─── Every button looks like a button ─── */
.btn-ghost {
    background: var(--surface);
    color: var(--gray-800);
    border-color: var(--border-strong);
}
.btn-ghost:hover { background: var(--gray-75); border-color: var(--gray-400); color: var(--black); }
.link-button {
    display: inline-flex; align-items: center; margin-left: 6px; padding: 3px 10px; border-radius: 8px;
    border: 1px solid currentColor; background: transparent; color: inherit; font: inherit; font-size: 12px; font-weight: 700;
    text-decoration: none; cursor: pointer;
}
.link-button:hover { background: rgba(0,0,0,.05); }

/* ─── Copy icons inside fields and next to usernames ─── */
.field-icons { position: relative; }
.field-icons > .form-control, .field-icons .pw-wrap .form-control { padding-right: 46px; }
.field-icons.has-eye > .form-control, .field-icons.has-eye .pw-wrap .form-control { padding-right: 82px; }
.field-copy, .icon-copy {
    width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface);
    color: var(--gray-600); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0;
    vertical-align: middle;
}
.field-copy { position: absolute; top: 50%; right: 6px; transform: translateY(-50%); z-index: 2; }
.field-icons.has-eye .field-copy { right: 42px; }
.field-copy:hover, .icon-copy:hover { background: var(--gray-100); color: var(--black); border-color: var(--border-strong); }
.field-copy svg, .icon-copy svg { width: 15px; height: 15px; }
.field-copy.is-done, .icon-copy.is-done { color: var(--success); border-color: var(--success); }
.icon-copy { width: 28px; height: 28px; margin-left: 6px; }
/* Password fields: suggest, copy and show/hide icons inside the field */
.field-generate {
    position: absolute; top: 50%; right: 78px; transform: translateY(-50%); z-index: 2;
    width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface);
    color: var(--gray-600); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0;
}
.field-generate:hover { background: var(--gray-100); color: var(--black); border-color: var(--border-strong); }
.field-generate svg { width: 15px; height: 15px; }
.field-icons.has-generate > .form-control, .field-icons.has-generate .pw-wrap .form-control { padding-right: 118px; }
/* Error summaries only show when there are errors */
.validation-summary-valid { display: none !important; }
.validation-summary-errors ul { margin: 0; padding-left: 18px; }
[hidden] { display: none !important; }

/* ─── Choice pills (radio cards) and form action rows ─── */
.form-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-bottom: 24px; }
.choice-pills { display: flex; gap: 10px; flex-wrap: wrap; }
.choice-pill { position: relative; flex: 1 1 200px; margin: 0; }
.choice-pill input { position: absolute; opacity: 0; pointer-events: none; }
.choice-pill > span { display: flex; flex-direction: column; gap: 2px; height: 100%; padding: 12px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.choice-pill > span strong { font-size: 14px; color: var(--black); }
.choice-pill > span small { font-size: 12px; color: var(--gray-500, #6b7280); }
.choice-pill:hover > span { border-color: var(--border-strong); }
.choice-pill input:checked + span { border-color: var(--black); box-shadow: 0 0 0 1px var(--black); }
.choice-pill input:focus-visible + span { outline: 2px solid var(--black); outline-offset: 2px; }

/* ─── Department focus: fields for other departments fold away ─── */
.dept-other { display: none !important; }
.dept-focus-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 16px; border: 1px dashed var(--border-strong); border-radius: 10px; background: var(--surface); font-size: 13px; color: var(--gray-700); }
.dept-focus-bar strong { color: var(--black); }

/* ─── Activity lists (message, then who / when) ─── */
.notice-list { list-style: none; margin: 0; padding: 0; }
.notice-list li { display: flex; flex-direction: column; gap: 3px; padding: 12px 22px; border-top: 1px solid var(--border); }
.notice-list li:first-child { border-top: 0; }
.notice-list a { color: var(--black); font-weight: 500; text-decoration: none; }
.notice-list a:hover { text-decoration: underline; }

/* ─── Document preview ─── */
.doc-preview { position: fixed; inset: 0; margin: auto; width: min(1000px, 94vw); height: min(90vh, 900px); max-width: none; max-height: none; padding: 0; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--black); overflow: hidden; }
.doc-preview[open] { display: flex; flex-direction: column; }
.doc-preview::backdrop { background: rgba(15, 23, 42, .55); }
.doc-preview-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.doc-preview-head strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.doc-preview-body { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; background: var(--gray-100, #f3f4f6); }
.doc-preview-body iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.doc-preview-body img { max-width: 100%; max-height: 100%; object-fit: contain; }
@media (max-width: 640px) { .doc-preview { width: 100vw; height: 100dvh; max-width: none; max-height: none; border-radius: 0; } }

/* ─── Getting started checklist (new clients) ─── */
.setup-steps { list-style: none; margin: 0; padding: 0; }
.setup-steps li { display: flex; align-items: center; gap: 14px; padding: 12px 22px; border-top: 1px solid var(--border); }
.setup-steps li:first-child { border-top: 0; }
.setup-steps li > div { flex: 1; min-width: 0; }
.setup-steps a { color: var(--black); font-weight: 600; text-decoration: none; }
.setup-steps a:hover { text-decoration: underline; }
.setup-check { flex: none; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--border-strong); display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; }
.setup-steps li.is-done .setup-check { background: var(--success); border-color: var(--success); color: #fff; }
.setup-steps li.is-done a { color: var(--gray-500); }

/* Copyright line at the end of every page */
.app-footer { margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--gray-200); color: var(--gray-500); font-size: 13px; }
@media print { .app-footer { display: none; } }

/* Results that open under the search box */
.topbar-search { position: relative; }
.search-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; min-width: 280px; z-index: 200; background: var(--white); border: 1px solid var(--gray-200); border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .18); overflow: hidden; }
.search-results a { display: block; padding: 9px 12px; color: inherit; text-decoration: none; }
.search-results a:hover, .search-results a:focus { background: var(--gray-100); }
.search-results strong { display: block; font-size: 13px; overflow-wrap: anywhere; }
.search-results span { font-size: 12px; color: var(--gray-500); }
.search-empty { padding: 10px 12px; font-size: 13px; color: var(--gray-500); }
@media (max-width: 640px) {
    .topbar-search { width: 120px; }
    .topbar-search input { font-size: 13px; padding-left: 30px; padding-right: 6px; }
    .search-results { position: fixed; top: 74px; left: 12px; right: 12px; min-width: 0; }
}

.search-results { max-height: min(70vh, 520px); overflow-y: auto; }
.search-group { padding: 8px 12px 2px; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--gray-500); }

/* Company settings sections */
.company-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.company-tabs a { padding: 7px 14px; border: 1px solid var(--gray-200); border-radius: 8px; font-size: 14px; color: inherit; text-decoration: none; }
.company-tabs a.is-active { background: var(--black); color: var(--white); }

/* The copyright line sits at the very bottom, even on short pages */
.page-content { display: flex; flex-direction: column; }
.page-content > * { min-width: 0; flex-shrink: 0; }
.page-content > .app-footer { margin-top: auto; }
.page-content > :nth-last-child(2) { margin-bottom: 32px; }

/* SagaVault overview */
.overview-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 20px; margin-top: 20px; align-items: start; }
.overview-side { display: grid; gap: 20px; min-width: 0; }
.overview-list > * { display: block; padding: 11px 20px; border-top: 1px solid var(--gray-200); color: inherit; text-decoration: none; }
.overview-list > *:first-child { border-top: 0; }
.overview-list a:hover { background: var(--gray-100); }
.overview-list strong { display: block; font-size: 14px; overflow-wrap: anywhere; }
.overview-list span { font-size: 12.5px; color: var(--gray-500); }
.overview-list .is-done strong { color: var(--gray-500); font-weight: 500; }
.overview-empty { display: grid; justify-items: center; gap: 6px; padding: 44px 20px; text-align: center; color: var(--gray-500); }
.overview-empty strong { color: var(--black); }
@media (max-width: 900px) { .overview-grid { grid-template-columns: minmax(0, 1fr); } }
.page-content > .card-container-centered, .page-content > .company-tabs { width: 100%; }
