/* 
 * Premium Vanilla CSS Framework 
 * Inspired by modern financial & SaaS dashboards 
 */

:root {
    /* Color Palette */
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;

    --secondary: #475569;
    --background: #f8fafc;
    --surface: #ffffff;

    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;

    /* Text Colors */
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-inverse: #ffffff;

    /* Borders & Shadows */
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

    /* Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--background);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--primary-hover);
}

/* Layout */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: linear-gradient(135deg, var(--background) 0%, var(--primary-light) 100%);
}

.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    width: 100%;
    overflow: hidden;
}

.card-auth {
    max-width: 440px;
}

.card-header {
    padding: 2rem 2rem 1rem;
    text-align: center;
}

.card-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.card-header p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.card-body {
    padding: 1.5rem 2rem 2rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--secondary);
    margin-bottom: 0.5rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text-main);
    background-color: var(--surface);
    background-clip: padding-box;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-control.is-invalid {
    border-color: var(--danger);
}

.invalid-feedback {
    display: block;
    margin-top: 0.375rem;
    font-size: 0.875rem;
    color: var(--danger);
}

.form-check {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
}

.form-check-input {
    width: 1rem;
    height: 1rem;
    margin-top: 0;
    margin-right: 0.5rem;
    color: var(--primary);
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    cursor: pointer;
}

.form-check-label {
    font-size: 0.875rem;
    color: var(--secondary);
    cursor: pointer;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 1px solid transparent;
}

.btn-primary {
    background-color: var(--primary);
    color: var(--text-inverse);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-block {
    width: 100%;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

/* Topbar Context */
.topbar {
    background-color: var(--surface);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.topbar-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.025em;
}

/* Utilities */
.mt-4 {
    margin-top: 1rem;
}

.text-center {
    text-align: center;
}

.text-sm {
    font-size: 0.875rem;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .topbar {
        padding: 1rem;
        flex-direction: column;
        gap: 1rem;
    }

    .card-body {
        padding: 1rem;
    }

    .form-group.flex-row {
        flex-direction: column;
        align-items: stretch;
    }

    .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    h1 {
        font-size: 1.5rem !important;
    }

    /* Stack flex-based rows automatically */
    .mobile-stack {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    /* Ensure tables can be swiped horizontally without breaking layout */
    .table-responsive {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Padding adjustments for mobile containers */
    .container {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    /* Grids stacking */
    .grid-mobile-stack {
        grid-template-columns: 1fr !important;
    }
}
/* Receipts Grid Styles */
.receipts-header {
    display: grid;
    grid-template-columns: 2fr 1fr 3fr auto;
    gap: 1rem;
    align-items: end;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--secondary);
    margin-bottom: 0.5rem;
    padding: 0 0.5rem;
}

.receipt-row-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 3fr auto;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1rem;
}

@media (max-width: 768px) {
    .receipts-header {
        display: none; /* Hide header on mobile */
    }

    .receipt-row-grid {
        grid-template-columns: 1fr;
        background: var(--surface);
        padding: 1rem;
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-sm);
    }

    .receipt-row-grid button {
        width: 100%;
        border: 1px solid var(--danger);
        background: #fef2f2;
    }
}

/* Form Card and Payee Details */
.form-card {
    padding: 3rem;
}

.payee-grid {
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
    background: var(--surface);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.state-zip-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 768px) {
    .form-card {
        padding: 1rem;
    }

    .payee-grid {
        grid-template-columns: 1fr;
    }

    .state-zip-grid {
        grid-template-columns: 1fr;
    }
}

/* Grid Utilities */
.span-2 {
    grid-column: span 2;
}

@media (max-width: 768px) {
    .span-2 {
        grid-column: span 1;
    }
}

/* ============================================================
   v2 SHELL — sidebar layout, stat cards, tabs, rail
   Added alongside the original styles; nothing above is removed,
   so any page not yet converted keeps working unchanged.
   ============================================================ */

:root {
    --sidebar-w: 248px;
    --rail-w: 320px;

    --tint-warn-bg:    #fffbeb;
    --tint-warn-fg:    #b45309;
    --tint-warn-chip:  #fcd34d;
    --tint-danger-bg:  #fef2f2;
    --tint-danger-fg:  #b91c1c;
    --tint-danger-chip:#fca5a5;
    --tint-ok-bg:      #f0fdf4;
    --tint-ok-fg:      #15803d;
    --tint-ok-chip:    #86efac;
    --tint-info-bg:    #eff6ff;
    --tint-info-fg:    #1d4ed8;
    --tint-info-chip:  #93c5fd;
}

/* ---------- shell ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 1.4rem 1.25rem;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text-main);
    border-bottom: 1px solid var(--border-color);
}
.sidebar-brand:hover { color: var(--text-main); }
.sidebar-mark {
    width: 30px; height: 30px; flex: 0 0 30px;
    border-radius: 9px;
    background: var(--primary);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.85rem; font-weight: 700;
}

.sidebar-nav { padding: 0.85rem 0.7rem; display: flex; flex-direction: column; gap: 0.15rem; flex: 1; overflow-y: auto; }
.sidebar-section {
    font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em;
    text-transform: uppercase; color: var(--text-muted);
    padding: 1rem 0.6rem 0.4rem;
}
.nav-link {
    display: flex; align-items: center; gap: 0.7rem;
    padding: 0.6rem 0.65rem;
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-size: 0.9rem; font-weight: 500;
    transition: background var(--transition-fast), color var(--transition-fast);
}
.nav-link:hover { background: var(--background); color: var(--text-main); }
.nav-link.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.nav-link svg { width: 18px; height: 18px; flex: 0 0 18px; }

.sidebar-foot { padding: 0.7rem; border-top: 1px solid var(--border-color); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar-v2 {
    display: flex; align-items: center; justify-content: flex-end; gap: 1rem;
    padding: 0.85rem 1.75rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
    position: sticky; top: 0; z-index: 20;
}
.user-chip { display: flex; align-items: center; gap: 0.6rem; }
.avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--primary-light); color: var(--primary);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.78rem;
}
.user-chip-name { font-weight: 600; font-size: 0.875rem; }
.user-chip-role { font-size: 0.75rem; color: var(--text-muted); }

.page { padding: 2rem 1.75rem 3rem; max-width: 1500px; width: 100%; }

/* ---------- page header ---------- */
.page-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 1.25rem; flex-wrap: wrap; margin-bottom: 1.75rem;
}
.page-eyebrow {
    font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em;
    text-transform: uppercase; color: var(--text-muted); margin-bottom: 0.35rem;
}
.page-title { font-size: 1.85rem; font-weight: 700; letter-spacing: -0.02em; }
.page-sub { color: var(--text-muted); margin-top: 0.25rem; }
.page-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }

/* ---------- stat cards ---------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
    gap: 1rem;
    margin-bottom: 1.75rem;
}
.stat {
    display: flex; align-items: center; gap: 0.9rem;
    padding: 1.15rem 1.25rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    background: var(--surface);
}
.stat-icon {
    width: 42px; height: 42px; flex: 0 0 42px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
}
.stat-icon svg { width: 20px; height: 20px; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; }
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.15; letter-spacing: -0.02em; }
.stat-note { font-size: 0.75rem; color: var(--text-muted); }

.stat--warn   { background: var(--tint-warn-bg);   border-color: var(--tint-warn-chip); }
.stat--warn   .stat-icon { background: var(--tint-warn-chip);   color: var(--tint-warn-fg); }
.stat--danger { background: var(--tint-danger-bg); border-color: var(--tint-danger-chip); }
.stat--danger .stat-icon { background: var(--tint-danger-chip); color: var(--tint-danger-fg); }
.stat--ok     { background: var(--tint-ok-bg);     border-color: var(--tint-ok-chip); }
.stat--ok     .stat-icon { background: var(--tint-ok-chip);     color: var(--tint-ok-fg); }
.stat--info   { background: var(--tint-info-bg);   border-color: var(--tint-info-chip); }
.stat--info   .stat-icon { background: var(--tint-info-chip);   color: var(--tint-info-fg); }

/* ---------- split: content + right rail ---------- */
.content-split { display: grid; grid-template-columns: minmax(0, 1fr) var(--rail-w); gap: 1.25rem; align-items: start; }
.rail { display: flex; flex-direction: column; gap: 1.25rem; }

/* ---------- panels ---------- */
.panel {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.panel-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; padding: 1.15rem 1.35rem;
    border-bottom: 1px solid var(--border-color);
}
.panel-title { font-size: 1.05rem; font-weight: 600; margin: 0; }
.panel-body { padding: 1.35rem; }
.panel-body--flush { padding: 0; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 0.35rem; padding: 0 1.35rem; border-bottom: 1px solid var(--border-color); overflow-x: auto; }
.tab {
    display: inline-flex; align-items: center; gap: 0.45rem;
    padding: 0.85rem 0.5rem; margin-bottom: -1px;
    border-bottom: 2px solid transparent;
    color: var(--text-muted); font-size: 0.9rem; font-weight: 600;
    white-space: nowrap;
}
.tab:hover { color: var(--text-main); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-count {
    background: var(--background); color: var(--text-muted);
    border-radius: 999px; padding: 0.05rem 0.45rem;
    font-size: 0.72rem; font-weight: 700;
}
.tab.active .tab-count { background: var(--primary-light); color: var(--primary); }

/* ---------- data table ---------- */
.data-table { width: 100%; border-collapse: collapse; text-align: left; }
.data-table thead th {
    padding: 0.8rem 1.35rem;
    font-size: 0.75rem; font-weight: 700; letter-spacing: 0.03em;
    text-transform: uppercase; color: var(--text-muted);
    background: var(--background);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}
.data-table thead th a { color: inherit; }
.data-table tbody td { padding: 0.95rem 1.35rem; border-bottom: 1px solid var(--border-color); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: var(--background); }
.td-strong { font-weight: 600; }
.td-muted { color: var(--text-muted); }
.td-num { font-weight: 700; font-variant-numeric: tabular-nums; }
.td-actions { text-align: right; white-space: nowrap; }
.row-actions { display: inline-flex; gap: 0.4rem; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- rail items ---------- */
.rail-item {
    display: flex; align-items: center; gap: 0.8rem;
    padding: 0.85rem 1.35rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
}
.rail-item:last-child { border-bottom: 0; }
.rail-item:hover { background: var(--background); color: var(--text-main); }
.rail-item-icon {
    width: 36px; height: 36px; flex: 0 0 36px; border-radius: 10px;
    background: var(--primary-light); color: var(--primary);
    display: flex; align-items: center; justify-content: center;
}
.rail-item-icon svg { width: 17px; height: 17px; }
.rail-item-title { font-weight: 600; font-size: 0.875rem; }
.rail-item-sub { font-size: 0.775rem; color: var(--text-muted); }
.rail-item-chevron { margin-left: auto; color: var(--text-muted); }

/* ---------- buttons ---------- */
.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.75rem; }
.btn-ghost { border: 1px solid var(--border-color); background: var(--surface); color: var(--text-main); }
.btn-ghost:hover { background: var(--background); }
.btn-quiet { border: 1px solid transparent; background: transparent; color: var(--primary); }
.btn-quiet:hover { background: var(--primary-light); }
.btn-danger-soft { border: 1px solid var(--tint-danger-chip); background: var(--tint-danger-bg); color: var(--tint-danger-fg); }
.btn-danger-soft:hover { background: #fee2e2; }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(0.95); color: #fff; }

/* ---------- alerts ---------- */
.alert { padding: 0.9rem 1.15rem; border-radius: var(--radius-md); margin-bottom: 1.5rem; font-size: 0.9rem; border: 1px solid; }
.alert-success { background: var(--tint-ok-bg); border-color: var(--tint-ok-chip); color: var(--tint-ok-fg); }
.alert-danger  { background: var(--tint-danger-bg); border-color: var(--tint-danger-chip); color: var(--tint-danger-fg); }
.alert-warn    { background: var(--tint-warn-bg); border-color: var(--tint-warn-chip); color: var(--tint-warn-fg); }
.alert ul { margin: 0; padding-left: 1.2rem; }

/* ---------- filter bar ---------- */
.filter-bar { display: flex; gap: 0.9rem; align-items: flex-end; flex-wrap: wrap; }
.filter-bar .form-group { margin-bottom: 0; flex: 1; min-width: 155px; }
.filter-bar .form-label { font-size: 0.78rem; margin-bottom: 0.3rem; }

/* ---------- empty state ---------- */
.empty-state { padding: 3.25rem 1.5rem; text-align: center; color: var(--text-muted); }
.empty-state svg { opacity: 0.4; margin-bottom: 0.85rem; }
.empty-state p { margin-bottom: 0.4rem; }

/* ---------- misc ---------- */
.meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1.5rem; }
.meta-label { color: var(--text-muted); font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 0.3rem; }
.meta-value { font-weight: 500; }
.divider { border: 0; border-top: 1px solid var(--border-color); margin: 2rem 0; }
.table-scroll { overflow-x: auto; }

/* ---------- responsive ---------- */
@media (max-width: 1150px) {
    .content-split { grid-template-columns: minmax(0, 1fr); }
    .rail { flex-direction: row; flex-wrap: wrap; }
    .rail > * { flex: 1; min-width: 280px; }
}

@media (max-width: 900px) {
    .layout { flex-direction: column; }
    .sidebar {
        width: 100%; flex: none; height: auto; position: static;
        border-right: 0; border-bottom: 1px solid var(--border-color);
    }
    .sidebar-nav { flex-direction: row; flex-wrap: wrap; overflow-x: auto; padding: 0.6rem; }
    .sidebar-section { display: none; }
    .nav-link { padding: 0.5rem 0.7rem; font-size: 0.85rem; }
    .sidebar-foot { display: none; }
    .topbar-v2 { padding: 0.7rem 1rem; }
    .page { padding: 1.25rem 1rem 2.5rem; }
    .page-title { font-size: 1.45rem; }
    .data-table thead th, .data-table tbody td { padding: 0.75rem 0.9rem; }
}

/* Row-level flag for a receipt total that differs from what was approved.
   The badge already shows the direction and size; this makes the row itself
   impossible to scroll past. */
.data-table tbody tr.row-variance { background: var(--tint-warn-bg); }
.data-table tbody tr.row-variance:hover { background: #fef3c7; }
.data-table tbody tr.row-variance td:first-child { box-shadow: inset 3px 0 0 var(--warning); }
