/* ================================================================
   Tarragona Document Tracking System
   iOS-inspired design system, adapted for Philippine government
   ================================================================ */

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

:root {
    /* Brand */
    --red:           #C8102E;   /* PH flag red — primary */
    --red-pressed:   #A50C24;
    --red-soft:      #FCE7EB;
    --red-text:      #8A0A1F;

    --navy:          #0038A8;   /* PH flag navy — official elements */
    --navy-pressed:  #002A82;
    --navy-soft:     #DCE5F6;

    --yellow:        #FCD116;   /* PH flag yellow — used very sparingly */

    /* Status (iOS system colors, gov labels) */
    --green:         #34C759;   /* Approved / Released */
    --green-soft:    #DCFCE7;
    --green-text:    #1A7A37;
    --orange:        #FF9500;   /* For Approval / Pending */
    --orange-soft:   #FEF1DC;
    --orange-text:   #9A5C00;
    --red-status:    #FF3B30;   /* Rejected / Disapproved / Cancelled */
    --red-status-soft: #FFE4E1;
    --blue-status:   #007AFF;   /* In Progress / Encoded */
    --blue-soft:     #DCEEFE;

    /* Neutrals (iOS system) */
    --bg:            #F2F2F7;   /* page background */
    --bg-grouped:    #F2F2F7;
    --surface:       #FFFFFF;   /* cards */
    --surface-2:     #F9F9FB;   /* nested */
    --hairline:      rgba(60, 60, 67, 0.10);  /* iOS separator */
    --hairline-strong: rgba(60, 60, 67, 0.18);
    --label:         #000000;   /* iOS label */
    --label-2:       #3C3C43;   /* iOS secondary label */
    --gray:          #8E8E93;   /* iOS system gray (metadata) */
    --gray-2:        #AEAEB2;
    --gray-3:        #C7C7CC;
    --fill-1:        rgba(120, 120, 128, 0.12);
    --fill-2:        rgba(120, 120, 128, 0.16);
    --fill-input:    #E5E5EA;

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

    /* Radii (iOS) */
    --r-sm: 8px;  --r-md: 12px; --r-lg: 16px; --r-xl: 20px; --r-pill: 999px;

    /* Shadows (subtle) */
    --shadow-1: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-2: 0 2px 8px rgba(15, 23, 42, 0.06);
    --shadow-3: 0 8px 24px rgba(15, 23, 42, 0.10);
    --shadow-modal: 0 20px 50px rgba(15, 23, 42, 0.20);

    /* Layout */
    --sidebar-w: 264px;
    --sidebar-w-collapsed: 72px;
    --topbar-h: 56px;
    --tabbar-h: 64px;

    /* Motion */
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --t-fast: 150ms;
    --t-base: 200ms;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

html, body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    color: var(--label);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.5;
}
body { font-feature-settings: 'cv11', 'ss01', 'ss03'; letter-spacing: -0.005em; }

/* ================================================================
   Typography helpers (iOS hierarchy)
   ================================================================ */
.title-lg   { font-size: 28px; font-weight: 800; letter-spacing: -0.025em; line-height: 1.15; color: var(--label); }
.title-md   { font-size: 22px; font-weight: 700; letter-spacing: -0.02em;  line-height: 1.2;  color: var(--label); }
.title-sm   { font-size: 17px; font-weight: 700; letter-spacing: -0.015em; line-height: 1.25; color: var(--label); }
.body       { font-size: 15px; color: var(--label); }
.body-sm    { font-size: 14px; color: var(--label-2); }
.meta       { font-size: 13px; color: var(--gray); }
.meta-tiny  { font-size: 11px; color: var(--gray); letter-spacing: 0.04em; text-transform: uppercase; font-weight: 600; }

/* ================================================================
   Top strip (Republic of the Philippines)
   ================================================================ */
.gov-topbar {
    background: #1C1C1E;
    color: rgba(255,255,255,0.85);
    font-size: 11px;
    padding: 5px 0;
    letter-spacing: 0.04em;
    border-bottom: 2px solid var(--red);
}
.gov-topbar .topbar-inner {
    max-width: 1400px; margin: 0 auto;
    padding: 0 var(--s-4);
    display: flex; align-items: center; justify-content: space-between;
}
.flag-stripe { display: inline-flex; gap: 3px; margin-right: 8px; vertical-align: middle; }
.flag-stripe span { width: 4px; height: 11px; border-radius: 1px; }
.flag-stripe .b { background: #0038A8; }
.flag-stripe .r { background: #CE1126; }
.flag-stripe .y { background: #FCD116; }

/* ================================================================
   App shell (sidebar + main)
   ================================================================ */
.app-shell { display: flex; min-height: calc(100vh - 22px); }

.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--hairline);
    display: flex; flex-direction: column;
    position: sticky; top: 0;
    height: calc(100vh - 22px);
    overflow-y: auto;
    transition: width var(--t-base) var(--ease);
}
.sidebar.collapsed { width: var(--sidebar-w-collapsed); }

.sidebar-brand {
    padding: var(--s-5) var(--s-4) var(--s-4);
    border-bottom: 1px solid var(--hairline);
    display: flex; align-items: center; gap: var(--s-3);
}
.sidebar-seal {
    width: 40px; height: 40px;
    background: var(--bg);
    border-radius: 50%;
    padding: 2px;
    flex-shrink: 0;
}
.sidebar-seal img { width: 100%; height: 100%; object-fit: contain; border-radius: 50%; }
.sidebar-brand-text {
    overflow: hidden;
    transition: opacity var(--t-fast) var(--ease);
}
.sidebar.collapsed .sidebar-brand-text { opacity: 0; pointer-events: none; }
.sidebar-brand-text .lgu {
    font-size: 10px; color: var(--gray); text-transform: uppercase;
    letter-spacing: 0.08em; font-weight: 600;
}
.sidebar-brand-text .name {
    font-size: 14px; font-weight: 700; color: var(--label);
    line-height: 1.2; margin-top: 1px;
}

.sidebar-nav { padding: var(--s-3); flex: 1; }
.sidebar-section-label {
    font-size: 11px;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    padding: var(--s-3) var(--s-3) var(--s-2);
}
.sidebar.collapsed .sidebar-section-label { opacity: 0; height: 0; padding: 0; }

.sidebar-link {
    display: flex; align-items: center; gap: var(--s-3);
    padding: 9px var(--s-3);
    border-radius: var(--r-md);
    color: var(--label-2);
    text-decoration: none;
    font-size: 14px; font-weight: 500;
    margin-bottom: 2px;
    transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
    min-height: 40px;
}
.sidebar-link i { font-size: 18px; flex-shrink: 0; width: 22px; text-align: center; }
.sidebar-link:hover { background: var(--fill-1); color: var(--label); }
.sidebar-link.active {
    background: var(--red);
    color: #fff;
    font-weight: 600;
}
.sidebar-link.active i { color: #fff; }
.sidebar.collapsed .sidebar-link span { display: none; }
.sidebar.collapsed .sidebar-link { justify-content: center; padding: 9px; }

.sidebar-footer {
    padding: var(--s-3) var(--s-4);
    border-top: 1px solid var(--hairline);
}
.user-block {
    display: flex; align-items: center; gap: var(--s-3);
    padding: var(--s-2);
    border-radius: var(--r-md);
}
.user-avatar {
    width: 36px; height: 36px; flex-shrink: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--red), var(--red-pressed));
    color: #fff; font-weight: 700; font-size: 13px;
    display: flex; align-items: center; justify-content: center;
    text-transform: uppercase;
}
.user-meta { overflow: hidden; flex: 1; min-width: 0; }
.sidebar.collapsed .user-meta, .sidebar.collapsed .user-actions { display: none; }
.user-meta .user-name {
    font-size: 13px; font-weight: 600; color: var(--label);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-meta .user-role { font-size: 11px; color: var(--gray); }
.user-actions { margin-top: var(--s-2); display: flex; gap: 6px; }

.btn-sidebar-toggle {
    background: var(--fill-1);
    border: none;
    width: 36px; height: 36px;
    border-radius: var(--r-md);
    display: flex; align-items: center; justify-content: center;
    color: var(--label-2);
    cursor: pointer;
    transition: background var(--t-fast) var(--ease);
}
.btn-sidebar-toggle:hover { background: var(--fill-2); }

/* ================================================================
   Main content area
   ================================================================ */
.main {
    flex: 1;
    min-width: 0;
    display: flex; flex-direction: column;
}
.topbar {
    height: var(--topbar-h);
    background: rgba(255,255,255,0.92);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--hairline);
    display: flex; align-items: center;
    padding: 0 var(--s-5);
    position: sticky; top: 0; z-index: 30;
}
.topbar .menu-btn { display: none; }
.topbar .topbar-title {
    font-size: 17px; font-weight: 600; color: var(--label);
    letter-spacing: -0.015em;
}
.topbar .topbar-actions { margin-left: auto; display: flex; gap: var(--s-2); }

.content {
    padding: var(--s-6) var(--s-5);
    max-width: 1280px;
    width: 100%;
    margin: 0 auto;
    flex: 1;
}

/* ================================================================
   Page header (iOS large title)
   ================================================================ */
.page-head {
    margin-bottom: var(--s-6);
    display: flex; flex-wrap: wrap; gap: var(--s-4);
    align-items: flex-end; justify-content: space-between;
}
.page-head h1 {
    font-size: 28px; font-weight: 800; letter-spacing: -0.025em;
    line-height: 1.15; color: var(--label); margin: 0;
}
.page-head .page-sub {
    font-size: 14px; color: var(--gray); margin-top: 4px;
    display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center;
}

/* ================================================================
   Cards & grouped lists
   ================================================================ */
.card {
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: var(--r-lg);
    overflow: hidden;
    box-shadow: var(--shadow-1);
}
.card-header {
    padding: var(--s-4) var(--s-5) var(--s-3);
    border-bottom: 1px solid var(--hairline);
    background: var(--surface);
    display: flex; align-items: center; gap: var(--s-2);
    font-size: 13px; font-weight: 600;
    color: var(--gray);
    text-transform: uppercase; letter-spacing: 0.05em;
}
.card-header i { color: var(--red); font-size: 15px; }
.card-body { padding: var(--s-5); }

/* Grouped list (iOS Settings-style) */
.group-list {
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: var(--r-lg);
    overflow: hidden;
    box-shadow: var(--shadow-1);
}
.group-list .group-row {
    display: flex; align-items: center;
    padding: var(--s-3) var(--s-5);
    min-height: 52px;
    border-bottom: 1px solid var(--hairline);
    background: var(--surface);
    transition: background var(--t-fast) var(--ease);
    color: var(--label); text-decoration: none;
}
.group-list .group-row:last-child { border-bottom: none; }
.group-list .group-row:hover { background: var(--fill-1); }
.group-list .group-row .row-icon {
    width: 32px; height: 32px; border-radius: 8px;
    background: var(--red-soft); color: var(--red);
    display: flex; align-items: center; justify-content: center;
    margin-right: var(--s-3);
    font-size: 16px;
}
.group-list .group-row .row-content {
    flex: 1; min-width: 0;
}
.group-list .group-row .row-title { font-weight: 500; font-size: 15px; }
.group-list .group-row .row-sub { font-size: 13px; color: var(--gray); margin-top: 2px; }
.group-list .group-row .row-trail {
    color: var(--gray); font-size: 14px;
    display: flex; align-items: center; gap: var(--s-2);
}
.group-list .group-row .chevron { color: var(--gray-3); font-size: 14px; }

/* Section label above grouped list */
.section-label {
    font-size: 12px; font-weight: 600;
    color: var(--gray);
    text-transform: uppercase; letter-spacing: 0.05em;
    padding: 0 var(--s-3) var(--s-2);
    margin-top: var(--s-5);
}

/* ================================================================
   Stat tiles (iOS dashboard tile)
   ================================================================ */
.stat-tile {
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: var(--r-lg);
    padding: var(--s-5);
    box-shadow: var(--shadow-1);
    transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
    position: relative;
}
.stat-tile:hover { transform: translateY(-1px); box-shadow: var(--shadow-2); }
.stat-tile .tile-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: var(--s-3);
}
.stat-tile .tile-label {
    font-size: 13px; font-weight: 600; color: var(--gray);
    text-transform: uppercase; letter-spacing: 0.04em;
}
.stat-tile .tile-icon {
    width: 36px; height: 36px; border-radius: var(--r-md);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
}
.stat-tile.tile-red    .tile-icon { background: var(--red-soft);    color: var(--red); }
.stat-tile.tile-navy   .tile-icon { background: var(--navy-soft);   color: var(--navy); }
.stat-tile.tile-green  .tile-icon { background: var(--green-soft);  color: var(--green-text); }
.stat-tile.tile-orange .tile-icon { background: var(--orange-soft); color: var(--orange-text); }
.stat-tile.tile-blue   .tile-icon { background: var(--blue-soft);   color: var(--blue-status); }
.stat-tile .tile-value {
    font-size: 32px; font-weight: 800; letter-spacing: -0.025em;
    line-height: 1; color: var(--label);
}
.stat-tile .tile-meta { font-size: 12px; color: var(--gray); margin-top: 6px; }

/* ================================================================
   Buttons
   ================================================================ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    border-radius: var(--r-md);
    padding: 10px 16px;
    font-size: 14px; font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
    text-decoration: none;
    min-height: 40px;
    line-height: 1;
    white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn-sm { padding: 6px 12px; font-size: 13px; min-height: 32px; border-radius: 10px; }
.btn-lg { padding: 13px 22px; font-size: 15px; min-height: 48px; }

.btn-primary, .btn-navy {
    background: var(--red); color: #fff; border-color: var(--red);
}
.btn-primary:hover, .btn-navy:hover { background: var(--red-pressed); border-color: var(--red-pressed); color: #fff; }

.btn-outline-primary, .btn-outline {
    background: var(--surface); color: var(--label); border: 1px solid var(--hairline-strong);
}
.btn-outline-primary:hover, .btn-outline:hover { background: var(--fill-1); }
.btn-outline-primary.active { background: var(--red); color: #fff; border-color: var(--red); }

.btn-ghost {
    background: transparent; color: var(--red); border: none;
    padding: 8px 12px;
}
.btn-ghost:hover { background: var(--red-soft); }

.btn-success { background: var(--green); border-color: var(--green); color: #fff; }
.btn-outline-secondary {
    background: var(--surface); color: var(--label-2); border: 1px solid var(--hairline-strong);
}
.btn-outline-secondary:hover { background: var(--fill-1); }
.btn-danger { background: var(--red-status); border-color: var(--red-status); color: #fff; }

.btn-icon {
    width: 40px; min-width: 40px; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
}

/* ================================================================
   Forms
   ================================================================ */
.form-control, .form-select {
    background: var(--fill-input);
    border: 1px solid transparent;
    border-radius: var(--r-md);
    padding: 11px 14px;
    font-size: 15px;
    color: var(--label);
    transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
    width: 100%;
}
.form-control:focus, .form-select:focus {
    background: var(--surface);
    border-color: var(--red);
    box-shadow: 0 0 0 4px rgba(200, 16, 46, 0.14);
    outline: none;
}
.form-control::placeholder { color: var(--gray-2); }
.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--label-2);
    margin-bottom: 6px;
}
.form-label .required { color: var(--red); margin-left: 2px; }
.form-text { color: var(--gray); font-size: 12px; margin-top: 4px; }

/* Search input (rounded full) */
.input-search {
    position: relative;
    display: flex; align-items: center;
}
.input-search .form-control {
    border-radius: var(--r-pill);
    padding-left: 38px;
    background: var(--fill-input);
}
.input-search i.search-icon {
    position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
    color: var(--gray); font-size: 15px; pointer-events: none;
}

/* Bootstrap input-group compatibility */
.input-group { display: flex; align-items: stretch; }
.input-group .form-control { border-radius: 0; }
.input-group > :first-child { border-top-left-radius: var(--r-md) !important; border-bottom-left-radius: var(--r-md) !important; }
.input-group > :last-child  { border-top-right-radius: var(--r-md) !important; border-bottom-right-radius: var(--r-md) !important; }
.input-group-text {
    background: var(--fill-input); border: 1px solid transparent; color: var(--gray);
    padding: 11px 14px; font-size: 14px;
}
.input-group .btn { border-radius: var(--r-md); }
.form-check-input { accent-color: var(--red); }

/* ================================================================
   Status badges (Philippine government conventions)
   ================================================================ */
.badge, .status-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px;
    font-size: 11.5px; font-weight: 600;
    border-radius: var(--r-pill);
    letter-spacing: 0.02em;
    line-height: 1.5;
    border: 1px solid transparent;
}
.badge.bg-primary, .status-encoded { background: var(--blue-soft) !important; color: var(--blue-status) !important; }
.badge.bg-info { background: var(--fill-1) !important; color: var(--label-2) !important; }
.badge.bg-secondary { background: var(--fill-1) !important; color: var(--label-2) !important; }
.badge.bg-success, .status-approved, .status-released {
    background: var(--green-soft) !important; color: var(--green-text) !important;
}
.badge.bg-warning, .badge.bg-warning-subtle, .status-pending, .status-for-approval {
    background: var(--orange-soft) !important; color: var(--orange-text) !important;
}
.badge.bg-danger, .status-disapproved, .status-cancelled, .status-rejected {
    background: var(--red-status-soft) !important; color: var(--red-status) !important;
}

/* Role badge tone */
.role-chip {
    display: inline-flex; align-items: center;
    background: var(--red-soft); color: var(--red-text);
    padding: 2px 8px; border-radius: var(--r-pill);
    font-size: 11px; font-weight: 600;
    letter-spacing: 0.02em;
}

/* ================================================================
   Tables (dense, scannable — gov register style)
   ================================================================ */
.table-card {
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: var(--r-lg);
    overflow: hidden;
    box-shadow: var(--shadow-1);
}
.table {
    width: 100%; margin: 0;
    color: var(--label);
    border-collapse: separate; border-spacing: 0;
}
.table th {
    font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--gray);
    background: var(--surface-2);
    border-bottom: 1px solid var(--hairline);
    padding: 10px 14px;
    text-align: left;
    white-space: nowrap;
    position: sticky; top: 0;
}
.table td {
    font-size: 13.5px;
    padding: 11px 14px;
    border-bottom: 1px solid var(--hairline);
    vertical-align: middle;
    color: var(--label);
}
.table tbody tr { transition: background var(--t-fast) var(--ease); }
.table tbody tr:hover { background: var(--fill-1); }
.table tbody tr:last-child td { border-bottom: none; }
.table-light { background: var(--surface-2) !important; }
.table-hover tbody tr:hover { background: var(--fill-1); }

/* Reference / control numbers — tabular figures, copyable */
.ref-no {
    font-family: 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px; font-weight: 600;
    color: var(--label);
    background: var(--fill-input);
    padding: 2px 8px; border-radius: 6px;
    user-select: all;
}

/* ================================================================
   Alerts (iOS toast-ish but inline)
   ================================================================ */
.alert {
    border: 1px solid transparent;
    border-radius: var(--r-md);
    padding: 12px 16px;
    font-size: 14px;
    display: flex; align-items: flex-start; gap: 10px;
}
.alert i { margin-top: 2px; font-size: 16px; }
.alert-success {
    background: var(--green-soft); color: var(--green-text); border-color: rgba(52,199,89,0.25);
}
.alert-danger {
    background: var(--red-status-soft); color: var(--red-status); border-color: rgba(255,59,48,0.25);
}
.alert-info {
    background: var(--blue-soft); color: var(--blue-status); border-color: rgba(0,122,255,0.20);
}
.alert-warning {
    background: var(--orange-soft); color: var(--orange-text); border-color: rgba(255,149,0,0.25);
}

/* Toast banner (slides in from top) */
.toast-stack {
    position: fixed; top: 16px; left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    display: flex; flex-direction: column; gap: 8px;
    pointer-events: none;
}
.toast-banner {
    background: rgba(28,28,30,0.95);
    color: #fff;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 12px 18px;
    border-radius: var(--r-pill);
    font-size: 14px; font-weight: 500;
    box-shadow: var(--shadow-3);
    pointer-events: auto;
    display: flex; align-items: center; gap: 8px;
    animation: toastIn 200ms var(--ease);
}
@keyframes toastIn {
    from { transform: translateY(-20px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}

/* ================================================================
   Segmented control (iOS)
   ================================================================ */
.segmented {
    display: inline-flex;
    background: var(--fill-input);
    padding: 3px;
    border-radius: var(--r-md);
    gap: 2px;
}
.segmented button {
    border: none; background: transparent;
    padding: 6px 14px; font-size: 13px; font-weight: 600;
    color: var(--label-2);
    border-radius: 9px;
    cursor: pointer;
    transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.segmented button.active {
    background: var(--surface); color: var(--label);
    box-shadow: var(--shadow-1);
}

/* ================================================================
   Modals (centered with backdrop blur)
   ================================================================ */
.modal-backdrop.show { background: rgba(0,0,0,0.35); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.modal-content {
    border-radius: var(--r-xl);
    border: 1px solid var(--hairline);
    box-shadow: var(--shadow-modal);
    overflow: hidden;
}
.modal-header { padding: var(--s-5); border-bottom: 1px solid var(--hairline); }
.modal-header.bg-navy {
    background: linear-gradient(135deg, var(--red), var(--red-pressed)) !important;
    color: #fff;
}
.modal-body { padding: var(--s-5); }
.modal-footer { padding: var(--s-4) var(--s-5); border-top: 1px solid var(--hairline); }

/* ================================================================
   Login page (split)
   ================================================================ */
.login-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    background: var(--bg);
}
.login-brand {
    background: linear-gradient(160deg, var(--red) 0%, var(--red-pressed) 60%, #6e0719 100%);
    color: #fff;
    padding: 56px;
    display: flex; flex-direction: column; justify-content: space-between;
    position: relative; overflow: hidden;
}
.login-brand::before {
    content: ''; position: absolute;
    top: -40%; right: -30%;
    width: 700px; height: 700px;
    background: radial-gradient(circle, rgba(255,255,255,0.06) 0%, transparent 70%);
    pointer-events: none;
}
.login-gov-strip {
    font-size: 11px; color: rgba(255,255,255,0.78);
    letter-spacing: 0.1em; text-transform: uppercase;
    display: inline-flex; align-items: center; gap: 10px;
}
.login-seal-row { display: flex; align-items: center; gap: 20px; margin-bottom: 28px; }
.login-seal {
    width: 96px; height: 96px;
    background: #fff; border-radius: 50%; padding: 4px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.3);
}
.login-seal img { width: 100%; height: 100%; object-fit: contain; border-radius: 50%; }
.login-brand h1 {
    font-size: 32px; font-weight: 800; letter-spacing: -0.025em;
    margin: 0 0 8px; line-height: 1.1;
}
.login-tagline { font-size: 14px; color: rgba(255,255,255,0.85); margin-bottom: 32px; }
.login-blurb {
    font-size: 14px; color: rgba(255,255,255,0.88); line-height: 1.7;
    max-width: 420px;
}
.login-footer-text {
    font-size: 11px; color: rgba(255,255,255,0.55);
    border-top: 1px solid rgba(255,255,255,0.15);
    padding-top: 18px;
}
.login-form-side {
    display: flex; align-items: center; justify-content: center;
    padding: 48px 32px;
}
.login-form-card { width: 100%; max-width: 400px; }
.login-form-side h2 {
    font-size: 28px; font-weight: 800; letter-spacing: -0.025em;
    margin: 0 0 4px;
}
.login-subtle { font-size: 14px; color: var(--gray); margin-bottom: 32px; }
.btn-login {
    background: var(--red); color: #fff; border: none;
    padding: 13px; border-radius: var(--r-md);
    font-weight: 700; font-size: 15px;
    width: 100%;
    cursor: pointer;
    transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.btn-login:hover { background: var(--red-pressed); }
.btn-login:active { transform: scale(0.98); }
.audit-strip {
    margin-top: 32px;
    padding-top: 16px;
    border-top: 1px solid var(--hairline);
    font-size: 11px; color: var(--gray);
    text-align: center;
}
.audit-strip i { margin-right: 4px; }

@media (max-width: 900px) {
    .login-shell { grid-template-columns: 1fr; }
    .login-brand { padding: 32px; min-height: 280px; }
    .login-brand h1 { font-size: 26px; }
}

/* ================================================================
   Footer (COA audit)
   ================================================================ */
.audit-footer {
    background: var(--surface);
    border-top: 1px solid var(--hairline);
    padding: var(--s-4) var(--s-5);
    margin-top: var(--s-7);
    font-size: 11.5px;
    color: var(--gray);
    display: flex; flex-wrap: wrap; gap: var(--s-4);
    justify-content: space-between;
    line-height: 1.5;
}
.audit-footer .audit-meta { display: flex; flex-wrap: wrap; gap: var(--s-4); }
.audit-footer .audit-meta span strong { color: var(--label-2); font-weight: 600; }

/* ================================================================
   Empty states
   ================================================================ */
.empty {
    text-align: center; padding: var(--s-8) var(--s-5);
    color: var(--gray);
}
.empty .empty-icon {
    width: 56px; height: 56px;
    border-radius: 50%;
    background: var(--fill-1);
    color: var(--gray);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 26px; margin-bottom: var(--s-3);
}
.empty .empty-title { font-size: 16px; font-weight: 600; color: var(--label-2); margin-bottom: 4px; }
.empty .empty-sub { font-size: 13px; color: var(--gray); margin-bottom: var(--s-4); }

/* ================================================================
   Skeleton loaders
   ================================================================ */
.skeleton {
    background: linear-gradient(90deg, var(--fill-1) 25%, var(--fill-2) 50%, var(--fill-1) 75%);
    background-size: 200% 100%;
    animation: skel 1.4s ease-in-out infinite;
    border-radius: 6px;
    height: 14px;
}
@keyframes skel { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ================================================================
   Timeline (document detail)
   ================================================================ */
.timeline-container { padding: var(--s-3) 0; }
.timeline-item {
    position: relative; padding-left: 28px; padding-bottom: 16px;
    border-left: 2px solid var(--hairline-strong);
    margin-left: 8px;
}
.timeline-item:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline-item.active { border-left-color: var(--red); }
.timeline-dot {
    position: absolute; left: -7px; top: 4px;
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--gray-3);
    border: 2px solid var(--surface);
    box-shadow: 0 0 0 1px var(--hairline-strong);
}
.timeline-item.active .timeline-dot {
    background: var(--red);
    box-shadow: 0 0 0 1px var(--red), 0 0 0 4px rgba(200,16,46,0.18);
}
.timeline-content { padding-bottom: 6px; font-size: 14px; }

/* ================================================================
   Mobile bottom tab bar
   ================================================================ */
.mobile-tabbar {
    display: none;
    position: fixed; bottom: 0; left: 0; right: 0;
    height: var(--tabbar-h);
    background: rgba(255,255,255,0.95);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-top: 1px solid var(--hairline);
    z-index: 50;
    padding-bottom: env(safe-area-inset-bottom);
}
.mobile-tabbar .tab {
    flex: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    color: var(--gray); text-decoration: none;
    font-size: 10px; font-weight: 600;
    gap: 2px;
    min-height: 44px;
}
.mobile-tabbar .tab i { font-size: 22px; }
.mobile-tabbar .tab.active { color: var(--red); }

/* Sidebar overlay (mobile) */
.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 90;
    backdrop-filter: blur(2px);
}
.sidebar-overlay.show { display: block; }

/* ================================================================
   Responsive
   ================================================================ */
@media (max-width: 992px) {
    .sidebar {
        position: fixed; top: 0; bottom: 0; left: 0;
        height: 100vh;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform var(--t-base) var(--ease);
    }
    .sidebar.open { transform: translateX(0); }
    .topbar .menu-btn { display: inline-flex; }
    .mobile-tabbar { display: flex; }
    .content { padding-bottom: calc(var(--tabbar-h) + var(--s-6)); }
    .audit-footer { margin-bottom: var(--tabbar-h); }
    .login-shell { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    .content { padding: var(--s-4); padding-bottom: calc(var(--tabbar-h) + var(--s-4)); }
    .page-head h1 { font-size: 24px; }
    .stat-tile .tile-value { font-size: 26px; }
    .table th, .table td { padding: 9px 10px; }
}

/* ================================================================
   Accessibility — focus indicators
   ================================================================ */
:focus-visible {
    outline: 3px solid rgba(200, 16, 46, 0.45);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ================================================================
   Scan input pulse
   ================================================================ */
#scanInput { font-size: 16px; padding: 14px 16px; border-radius: var(--r-md); }
#scanInput:focus {
    background: var(--surface);
    border-color: var(--red);
    box-shadow: 0 0 0 4px rgba(200, 16, 46, 0.18);
}

/* ================================================================
   Print (gov-formal: keep serif for documents)
   ================================================================ */
@media print {
    .gov-topbar, .topbar, .sidebar, .mobile-tabbar, .audit-footer,
    .btn, form, .card-header, .page-head .btn { display: none !important; }
    body { background: #fff; font-family: 'Times New Roman', Times, serif; color: #000; }
    .card, .table-card { border: none !important; box-shadow: none !important; }
    .content { padding: 0; max-width: none; }
}

/* ================================================================
   Misc compatibility (Bootstrap leftovers)
   ================================================================ */
.text-navy { color: var(--red-text) !important; }
.text-muted { color: var(--gray) !important; }
.text-success { color: var(--green-text) !important; }
.text-danger { color: var(--red-status) !important; }
.text-warning { color: var(--orange-text) !important; }
.text-info { color: var(--blue-status) !important; }
.bg-navy { background: var(--red) !important; color: #fff !important; }
.bg-white { background: var(--surface) !important; }
.bg-light { background: var(--surface-2) !important; }
.fw-bold { font-weight: 700; }
.fw-semibold { font-weight: 600; }
.text-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
hr { border: 0; border-top: 1px solid var(--hairline); margin: var(--s-4) 0; }
code {
    background: var(--fill-input);
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 12.5px;
    color: var(--label);
    font-family: 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;
}
.shadow-sm { box-shadow: var(--shadow-1) !important; }
.shadow { box-shadow: var(--shadow-2) !important; }
.border-0 { border: none !important; }
