/* ============================================================
   AccountsSagaLite — Premium Design System v3
   Clean · Modern · Professional · Lightweight
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ─── Design Tokens ──────────────────────────────────────── */
:root {
    /* Core Palette — Crisp B&W */
    --black:     #09090b;
    --gray-950:  #0f0f11;
    --gray-900:  #18181b;
    --gray-800:  #27272a;
    --gray-700:  #3f3f46;
    --gray-600:  #52525b;
    --gray-500:  #71717a;
    --gray-400:  #a1a1aa;
    --gray-300:  #d4d4d8;
    --gray-200:  #e4e4e7;
    --gray-150:  #ebebed;
    --gray-100:  #f4f4f5;
    --gray-75:   #f7f7f8;
    --gray-50:   #fafafa;
    --white:     #ffffff;

    /* Accent — Subtle, not flashy */
    --accent:         #09090b;
    --accent-hover:   #27272a;

    /* Semantic */
    --danger:         #dc2626;
    --danger-light:   #fef2f2;
    --danger-border:  #fecaca;
    --success:        #16a34a;
    --success-light:  #f0fdf4;
    --success-border: #bbf7d0;
    --warning:        #d97706;
    --warning-light:  #fffbeb;
    --warning-border: #fde68a;
    --info:           #2563eb;
    --info-light:     #eff6ff;

    /* Typography */
    --font:      'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    /* Radius */
    --r-xs:   3px;
    --r-sm:   6px;
    --r:      8px;
    --r-md:   10px;
    --r-lg:   12px;
    --r-xl:   16px;
    --r-2xl:  20px;
    --r-full: 9999px;

    /* Shadows — very subtle */
    --shadow-xs:  0 1px 2px rgba(0,0,0,.05);
    --shadow-sm:  0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
    --shadow:     0 4px 8px rgba(0,0,0,.07), 0 1px 3px rgba(0,0,0,.04);
    --shadow-md:  0 8px 20px rgba(0,0,0,.08), 0 2px 6px rgba(0,0,0,.05);
    --shadow-lg:  0 16px 36px rgba(0,0,0,.10), 0 4px 12px rgba(0,0,0,.06);
    --shadow-xl:  0 24px 48px rgba(0,0,0,.12), 0 8px 20px rgba(0,0,0,.07);

    /* Layout */
    --sidebar-w: 240px;
    --topbar-h:  56px;

    /* 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:    350ms cubic-bezier(.4,0,.2,1);
}

/* ─── 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(--gray-100);
    color: var(--gray-900);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
    transition: color var(--t-fast);
}
a:hover { text-decoration: none; }

img, svg { display: block; }

/* ═══════════════════════════════════════════════════════════
   APP SHELL
════════════════════════════════════════════════════════════ */
.app-shell {
    display: flex;
    min-height: 100vh;
}

/* ═══════════════════════════════════════════════════════════
   SIDEBAR
════════════════════════════════════════════════════════════ */
.sidebar {
    width: var(--sidebar-w);
    background: var(--gray-900);
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    z-index: 200;
    transition: transform var(--t-slow);
    scrollbar-width: none;
}
.sidebar::-webkit-scrollbar { display: none; }

/* ── Brand ── */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 16px;
    border-bottom: 1px solid rgba(255,255,255,.07);
    flex-shrink: 0;
}

.sidebar-brand-icon {
    width: 32px;
    height: 32px;
    background: var(--white);
    border-radius: var(--r-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.sidebar-brand-icon svg {
    width: 17px; height: 17px;
    stroke: var(--black);
}

.sidebar-brand-text { min-width: 0; }
.sidebar-brand-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--white);
    letter-spacing: -.1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-brand-sub {
    font-size: 10px;
    font-weight: 500;
    color: var(--gray-500);
    letter-spacing: .5px;
    margin-top: 1px;
}

/* ── Navigation ── */
.sidebar-nav {
    padding: 10px 8px;
    flex: 1;
}

.sidebar-section {
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--gray-600);
    padding: 14px 10px 5px;
    user-select: none;
}
.sidebar-section:first-child { padding-top: 6px; }

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 10px;
    border-radius: var(--r-sm);
    font-size: 12.5px;
    font-weight: 500;
    color: var(--gray-400);
    text-decoration: none;
    transition: all var(--t-fast);
    margin-bottom: 1px;
    white-space: nowrap;
    overflow: hidden;
}
.sidebar-link svg {
    width: 15px; height: 15px;
    flex-shrink: 0;
    opacity: .65;
    transition: opacity var(--t-fast);
    stroke: currentColor;
}
.sidebar-link:hover {
    background: rgba(255,255,255,.06);
    color: var(--white);
}
.sidebar-link:hover svg { opacity: 1; }

.sidebar-link.active {
    background: rgba(255,255,255,.12);
    color: var(--white);
    font-weight: 600;
}
.sidebar-link.active svg { opacity: 1; }

/* Sidebar bottom padding */
.sidebar::after {
    content: '';
    display: block;
    height: 20px;
    flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════
   MAIN CONTENT
════════════════════════════════════════════════════════════ */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--gray-100);
}

/* ─── Topbar ─────────────────────────────────────────────── */
.topbar {
    height: var(--topbar-h);
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 0 rgba(0,0,0,.04);
    gap: 16px;
}

.topbar-left, .topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.topbar-left { flex: 1; min-width: 0; }

/* Mobile Hamburger */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--r-sm);
    color: var(--gray-600);
    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 */
.company-switcher {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    padding: 4px 10px;
    border-radius: var(--r-sm);
    transition: all var(--t-fast);
}
.company-switcher:hover {
    border-color: var(--gray-300);
    background: var(--gray-75);
}
.company-switcher-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .8px;
    text-transform: uppercase;
    color: var(--gray-500);
    flex-shrink: 0;
}
.company-switcher-select {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--black);
    background: transparent;
    border: none;
    padding: 2px 20px 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='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23222' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 2px center;
    transition: all var(--t-fast);
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.company-switcher-select:focus { outline: none; }

/* Topbar separator */
.topbar-sep {
    width: 1px;
    height: 18px;
    background: var(--gray-200);
    margin: 0 4px;
    flex-shrink: 0;
}

/* Breadcrumb */
.topbar-page {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-800);
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* User pill */
.user-pill {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 5px 10px 5px 7px;
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: var(--r-full);
}
.user-avatar {
    width: 22px;
    height: 22px;
    background: var(--gray-800);
    border-radius: var(--r-full);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 10px;
    font-weight: 700;
    color: var(--white);
    text-transform: uppercase;
}
.user-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-800);
    white-space: nowrap;
}
.user-role {
    font-size: 10px;
    font-weight: 600;
    color: var(--gray-500);
    background: var(--gray-200);
    padding: 1px 6px;
    border-radius: var(--r-full);
    text-transform: capitalize;
}

/* ─── Page Content ───────────────────────────────────────── */
.page-content {
    padding: 24px 28px;
    flex: 1;
    max-width: 1680px;
    width: 100%;
}

/* ─── Page Header ────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 22px;
    gap: 16px;
    flex-wrap: wrap;
}

.page-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--black);
    letter-spacing: -.3px;
    line-height: 1.2;
}

.page-subtitle {
    font-size: 12.5px;
    color: var(--gray-500);
    margin-top: 3px;
    font-weight: 400;
}

.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: 6px;
    padding: 7px 14px;
    border-radius: var(--r-sm);
    font-size: 12.5px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    border: 1px solid transparent;
    transition: all var(--t-fast);
    white-space: nowrap;
    text-decoration: none !important;
    line-height: 1.2;
    user-select: none;
    letter-spacing: .01em;
    position: relative;
    vertical-align: middle;
}
.btn:active { transform: scale(.97); }
.btn svg { width: 13px; height: 13px; flex-shrink: 0; }

/* Primary */
.btn-primary {
    background: var(--black);
    color: var(--white);
    border-color: var(--black);
    box-shadow: 0 1px 2px rgba(0,0,0,.15);
}
.btn-primary:hover {
    background: var(--gray-800);
    border-color: var(--gray-800);
    color: var(--white);
    box-shadow: 0 2px 6px rgba(0,0,0,.2);
}

/* Secondary */
.btn-secondary {
    background: var(--white);
    color: var(--gray-700);
    border-color: var(--gray-200);
    box-shadow: var(--shadow-xs);
}
.btn-secondary:hover {
    background: var(--gray-50);
    border-color: var(--gray-300);
    color: var(--black);
}

/* Outline */
.btn-outline {
    background: transparent;
    color: var(--gray-600);
    border-color: var(--gray-200);
}
.btn-outline:hover {
    background: var(--gray-100);
    border-color: var(--gray-300);
    color: var(--black);
}

/* Ghost */
.btn-ghost {
    background: transparent;
    color: var(--gray-500);
    border-color: transparent;
}
.btn-ghost:hover { background: var(--gray-100); color: var(--black); }

/* Danger */
.btn-danger {
    background: var(--danger);
    color: var(--white);
    border-color: var(--danger);
}
.btn-danger:hover { background: #b91c1c; color: var(--white); }

/* Sizes */
.btn-xs { padding: 3px 9px; font-size: 11px; border-radius: var(--r-xs); }
.btn-sm { padding: 5px 11px; font-size: 12px; border-radius: var(--r-xs); }
.btn-lg { padding: 10px 20px; font-size: 13.5px; }

/* Icon button */
.btn-icon {
    padding: 6px;
    aspect-ratio: 1;
}
.btn-icon svg { width: 15px; height: 15px; }

/* ═══════════════════════════════════════════════════════════
   CARDS
════════════════════════════════════════════════════════════ */
.card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--r-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--gray-150);
    background: var(--white);
    gap: 12px;
    min-height: 50px;
}

.card-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--gray-900);
    letter-spacing: -.1px;
}

.card-subtitle {
    font-size: 11.5px;
    color: var(--gray-500);
    font-weight: 400;
    margin-top: 1px;
}

.card-body { padding: 18px; }

.card-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 18px;
    border-top: 1px solid var(--gray-150);
    background: var(--gray-50);
}

/* ═══════════════════════════════════════════════════════════
   STAT / KPI CARDS
════════════════════════════════════════════════════════════ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
    width: 100%;
}

.stats-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 20px;
    width: 100%;
}

.stats-grid-6 {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 16px;
    margin-bottom: 20px;
    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(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--r-lg);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
    transition: all var(--t);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.stat-card::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--black), transparent);
    opacity: 0;
    transition: opacity var(--t);
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.stat-card:hover::after { opacity: 1; }

.stat-icon {
    width: 32px;
    height: 32px;
    background: var(--gray-100);
    border-radius: var(--r-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    flex-shrink: 0;
}
.stat-icon svg { width: 15px; height: 15px; stroke: var(--gray-600); }

.stat-label {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .8px;
    text-transform: uppercase;
    color: var(--gray-500);
    margin-bottom: 6px;
}

.stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--black);
    font-family: var(--font-mono);
    letter-spacing: -.5px;
    line-height: 1;
    margin-bottom: 6px;
}

.stat-meta {
    font-size: 11px;
    color: var(--gray-400);
    font-weight: 500;
}
.stat-meta a { color: var(--gray-500); }
.stat-meta a:hover { color: var(--black); }

/* Colored stat variants */
.stat-card.stat-up .stat-value { color: var(--success); }
.stat-card.stat-down .stat-value { color: var(--danger); }

/* ═══════════════════════════════════════════════════════════
   TABLES
════════════════════════════════════════════════════════════ */
.table-container {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--r-lg);
    overflow-x: auto;
    overflow-y: visible;
    box-shadow: var(--shadow-sm);
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
    min-width: 0;
}

.data-table thead th {
    padding: 10px 14px;
    text-align: left;
    font-size: 10.5px;
    font-weight: 700;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: .7px;
    background: var(--gray-75);
    border-bottom: 1px solid var(--gray-200);
    white-space: nowrap;
}
.data-table thead th.num { text-align: right; }

.data-table tbody tr {
    border-bottom: 1px solid var(--gray-100);
    transition: background var(--t-fast);
}
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: var(--gray-75); }

.data-table tbody td {
    padding: 10px 14px;
    color: var(--gray-700);
    vertical-align: middle;
}

.data-table tbody td.num {
    text-align: right;
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    color: var(--gray-800);
}

/* Table footer (totals row) */
.data-table tfoot tr {
    background: var(--gray-900);
}
.data-table tfoot td {
    padding: 11px 14px;
    font-weight: 700;
    font-size: 12px;
    color: var(--white);
    font-family: var(--font-mono);
    text-align: right;
    border-top: 1px solid var(--gray-700);
}
.data-table tfoot td:first-child {
    text-align: left;
    font-family: var(--font);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .5px;
    text-transform: uppercase;
}

/* Numeric helpers */
.num { text-align: right; font-family: var(--font-mono); }
.num-pos { color: var(--success) !important; }
.num-neg { color: var(--danger) !important; }

/* ═══════════════════════════════════════════════════════════
   BADGES
════════════════════════════════════════════════════════════ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: var(--r-full);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .1px;
    white-space: nowrap;
    border: 1px solid transparent;
}
.badge-success { background: var(--success-light); color: #15803d; border-color: var(--success-border); }
.badge-danger  { background: var(--danger-light);  color: #dc2626; border-color: var(--danger-border); }
.badge-warning { background: var(--warning-light); color: #b45309; border-color: var(--warning-border); }
.badge-default { background: var(--gray-100);       color: var(--gray-600); border-color: var(--gray-200); }
.badge-info    { background: var(--info-light);    color: #1d4ed8; border-color: #bfdbfe; }
.badge-dark    { background: var(--gray-800); color: var(--white); border-color: var(--gray-800); }

/* Chip */
.chip {
    display: inline-flex;
    align-items: center;
    padding: 2px 7px;
    background: var(--gray-100);
    color: var(--gray-600);
    border-radius: var(--r-full);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    border: 1px solid var(--gray-200);
}

/* ═══════════════════════════════════════════════════════════
   FORMS
════════════════════════════════════════════════════════════ */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
    justify-content: flex-start;
}
.form-group:last-child { margin-bottom: 0; }

.form-label {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--gray-700);
    letter-spacing: .1px;
    display: flex;
    align-items: flex-end;
    min-height: 20px;
}
.form-label .req { color: var(--danger); margin-left: 2px; }

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--r-sm);
    font-size: 13px;
    font-family: var(--font);
    color: var(--gray-900);
    background: var(--white);
    transition: all var(--t-fast);
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    line-height: 1.5;
    min-height: 38px;
}
.form-control::placeholder { color: var(--gray-300); }
.form-control:hover { border-color: var(--gray-400); }
.form-control:focus {
    border-color: var(--black);
    box-shadow: 0 0 0 3px rgba(0,0,0,.07);
    background: var(--white);
}
.form-control:disabled,
.form-control[readonly] {
    background: var(--gray-75);
    color: var(--gray-500);
    border-color: var(--gray-200);
    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='11' height='11' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 32px;
    cursor: pointer;
}

.form-textarea { resize: vertical; min-height: 80px; }

.form-hint {
    font-size: 11px;
    color: var(--gray-400);
    font-style: italic;
}

.form-checkbox-box {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    min-height: 38px;
    border: 1px solid var(--gray-200);
    border-radius: var(--r-sm);
    background: var(--gray-50);
    transition: all var(--t-fast);
    cursor: pointer;
    width: 100%;
}
.form-checkbox-box:hover {
    border-color: var(--gray-300);
    background: var(--white);
}

.invalid-feedback { color: var(--danger); font-size: 11.5px; font-weight: 500; }

/* ─── Card Container Layouts ─────────────────────────────── */
.card-container-centered {
    max-width: 920px;
    margin: 0 auto;
    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; }
.row { display: flex; gap: 18px; align-items: stretch; }

@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: 12.5px;
}
.invoice-lines-table thead th {
    padding: 9px 8px;
    text-align: left;
    font-size: 10px;
    font-weight: 700;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: .6px;
    background: var(--gray-75);
    border-bottom: 1px solid var(--gray-200);
    white-space: nowrap;
}
.invoice-lines-table tbody td {
    padding: 4px 5px;
    border-bottom: 1px solid var(--gray-100);
    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: 6px 9px;
    font-size: 12.5px;
    border-color: var(--gray-200);
}
.invoice-lines-table .form-control:focus { border-color: var(--black); }

/* ═══════════════════════════════════════════════════════════
   DOCUMENT PRINT
════════════════════════════════════════════════════════════ */
.document-print {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--r-xl);
    padding: 32px 36px;
    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(--gray-150);
}

.doc-company-name {
    font-size: 20px;
    font-weight: 800;
    color: var(--black);
    letter-spacing: -.4px;
    line-height: 1.2;
}
.doc-company-sub {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 3px;
}

.doc-type-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--gray-600);
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: var(--r-sm);
    padding: 4px 10px;
    margin-bottom: 8px;
}

.doc-number {
    font-size: 20px;
    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: 12px 14px;
    background: var(--gray-75);
    border-radius: var(--r);
    border: 1px solid var(--gray-150);
}
.doc-meta-label {
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--gray-400);
    margin-bottom: 4px;
}
.doc-meta-value {
    font-size: 13px;
    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: 360px;
    border: 1px solid var(--gray-200);
    border-radius: var(--r-md);
    overflow: hidden;
}
.doc-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 14px;
    border-bottom: 1px solid var(--gray-100);
    font-size: 12.5px;
    color: var(--gray-700);
}
.doc-total-row:last-child { border-bottom: none; }
.doc-total-row.grand {
    background: var(--gray-900);
    color: var(--white);
    font-weight: 700;
    font-size: 14px;
}
.doc-total-amount {
    font-family: var(--font-mono);
    font-weight: 600;
    text-align: right;
    min-width: 100px;
    color: var(--gray-800);
}
.doc-total-row.grand .doc-total-amount { color: var(--white); }

/* ═══════════════════════════════════════════════════════════
   FINANCIAL REPORTS
════════════════════════════════════════════════════════════ */
.fin-section-header {
    background: var(--gray-900);
    color: var(--white);
    padding: 8px 16px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    border-radius: var(--r-sm) var(--r-sm) 0 0;
    margin-top: 12px;
}

.fin-group-header {
    padding: 6px 16px;
    font-size: 10px;
    font-weight: 700;
    color: var(--gray-600);
    background: var(--gray-100);
    border-bottom: 1px solid var(--gray-150);
    text-transform: uppercase;
    letter-spacing: .5px;
}

.fin-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 16px;
    border-bottom: 1px solid var(--gray-100);
    font-size: 12.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-700); }
.fin-row-amount {
    font-family: var(--font-mono);
    font-size: 12.5px;
    font-weight: 600;
    text-align: right;
    min-width: 130px;
    color: var(--gray-800);
}

.fin-subtotal {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: var(--gray-100);
    border-bottom: 2px solid var(--gray-200);
    font-weight: 700;
    font-size: 12.5px;
}

.fin-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--gray-900);
    color: var(--white);
    font-weight: 800;
    font-size: 13.5px;
    border-radius: 0 0 var(--r-sm) var(--r-sm);
}
.fin-total .fin-row-amount { color: var(--white); font-size: 15px; }

/* SOA Header */
.soa-header-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
    padding: 16px;
    background: var(--gray-75);
    border-radius: var(--r-md);
    border: 1px solid var(--gray-200);
}

/* GL Table */
.gl-table { margin-top: 4px; }
.gl-table thead th { background: var(--gray-75) !important; }

/* ═══════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
════════════════════════════════════════════════════════════ */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--r-md);
    font-size: 13px;
    font-weight: 500;
    min-width: 260px;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    animation: toast-in 300ms var(--ease) both;
    pointer-events: all;
}
@keyframes toast-in {
    from { transform: translateX(110%); opacity: 0; }
    to   { transform: translateX(0);   opacity: 1; }
}

.toast-success {
    background: var(--gray-900);
    color: var(--white);
    border: 1px solid var(--gray-700);
}
.toast-error {
    background: var(--danger);
    color: var(--white);
}

/* ═══════════════════════════════════════════════════════════
   FILTER BAR
════════════════════════════════════════════════════════════ */
.filter-bar {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--r-lg);
    padding: 14px 18px;
    margin-bottom: 20px;
    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: 5px;
    justify-content: flex-end;
}
.filter-label {
    font-size: 10.5px;
    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: 38px;
    margin-bottom: 0;
    align-self: flex-end;
}

/* ═══════════════════════════════════════════════════════════
   ALERTS
════════════════════════════════════════════════════════════ */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--r-md);
    margin-bottom: 16px;
    font-size: 12.5px;
    font-weight: 500;
    border: 1px solid;
}
.alert-danger  { background: var(--danger-light);  border-color: var(--danger-border);  color: var(--danger); }
.alert-success { background: var(--success-light); border-color: var(--success-border); color: #15803d; }
.alert-warning { background: var(--warning-light); border-color: var(--warning-border); color: var(--warning); }

/* ═══════════════════════════════════════════════════════════
   JOURNAL BALANCE
════════════════════════════════════════════════════════════ */
#journal-balance {
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    letter-spacing: .4px;
    border-radius: var(--r-full);
    transition: all var(--t);
}

/* ═══════════════════════════════════════════════════════════
   TABS
════════════════════════════════════════════════════════════ */
.tabs {
    display: flex;
    border-bottom: 1.5px solid var(--gray-200);
    margin-bottom: 20px;
    gap: 0;
    overflow-x: auto;
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab-link {
    padding: 9px 16px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--gray-500);
    border-bottom: 2px solid transparent;
    margin-bottom: -1.5px;
    cursor: pointer;
    transition: all var(--t-fast);
    text-decoration: none !important;
    white-space: nowrap;
    flex-shrink: 0;
}
.tab-link:hover { color: var(--gray-800); }
.tab-link.active { color: var(--black); border-bottom-color: var(--black); }

/* ═══════════════════════════════════════════════════════════
   EMPTY STATE
════════════════════════════════════════════════════════════ */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--gray-400);
}
.empty-state-icon {
    width: 48px;
    height: 48px;
    background: var(--gray-100);
    border-radius: var(--r-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}
.empty-state-icon svg { width: 22px; height: 22px; stroke: var(--gray-400); }
.empty-state h3 { font-size: 15px; font-weight: 700; color: var(--gray-600); margin-bottom: 6px; }
.empty-state p  { font-size: 12.5px; max-width: 320px; margin: 0 auto 16px; }

/* ═══════════════════════════════════════════════════════════
   DIVIDERS & UTILS
════════════════════════════════════════════════════════════ */
.divider {
    border: none;
    border-top: 1px solid var(--gray-150);
    margin: 16px 0;
}

.text-muted { color: var(--gray-500) !important; }
.text-sm    { font-size: 11.5px; }
.text-xs    { font-size: 10.5px; }
.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(0,0,0,.4);
    z-index: 150;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* ═══════════════════════════════════════════════════════════
   PRINT
════════════════════════════════════════════════════════════ */
@media print {
    .sidebar, .topbar, .page-actions,
    .no-print, .filter-bar, .toast-container,
    .btn:not(.print-btn) {
        display: none !important;
    }
    .main-content { margin-left: 0 !important; }
    .page-content { padding: 0 !important; max-width: 100% !important; }
    body { background: white !important; font-size: 11px !important; color: #000 !important; }
    .document-print {
        box-shadow: none !important; border: none !important;
        padding: 0 !important; border-radius: 0 !important;
    }
    .data-table thead th {
        background: #eee !important; color: #000 !important;
        -webkit-print-color-adjust: exact; print-color-adjust: exact;
    }
    .card { box-shadow: none !important; border: 1px solid #ddd !important; }
    a { color: #000 !important; }
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
════════════════════════════════════════════════════════════ */
@media (max-width: 1100px) {
    :root { --sidebar-w: 220px; }
}

@media (max-width: 860px) {
    :root { --sidebar-w: 0px; }
    .sidebar {
        width: 240px;
        transform: translateX(-100%);
    }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .sidebar-toggle { display: flex; align-items: center; justify-content: center; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr !important; }
    .doc-meta-grid { grid-template-columns: 1fr; }
    .page-content { padding: 16px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .soa-header-grid { grid-template-columns: 1fr; }
    .doc-totals { max-width: 100%; }
}

@media (max-width: 560px) {
    .stats-grid { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .topbar { padding: 0 14px; }
    .topbar-sep { display: none; }
}

@media (max-width: 640px) {
    .d-none-mobile { 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: 12px 14px;
    border-radius: var(--r-md);
    background: var(--info-light);
    border: 1px solid #bfdbfe;
    color: #1e40af;
    font-size: 12.5px;
    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: 1px; }
