/* =============================================================================
   SBS Expense Report — Main Stylesheet
   ============================================================================= */

:root {
    --color-primary:    #1a56db;
    --color-primary-h:  #1045b5;
    --color-danger:     #dc2626;
    --color-success:    #16a34a;
    --color-warning:    #d97706;
    --color-bg:         #f8fafc;
    --color-surface:    #ffffff;
    --color-border:     #e2e8f0;
    --color-text:       #1e293b;
    --color-muted:      #64748b;

    /* Match confidence row colors */
    --match-high-bg:    #f0fdf4;
    --match-high-border:#86efac;
    --match-med-bg:     #fefce8;
    --match-med-border: #fde68a;
    --row-complete-bg:  #f0f9ff;

    --font:  -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --radius: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,.1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font);
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 14px;
    line-height: 1.5;
}

/* ---- Navbar ---- */
.navbar {
    background: #0f172a;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 0 24px;
    height: 52px;
    position: sticky;
    top: 0;
    z-index: 100;
}
.navbar-brand a { color: #fff; text-decoration: none; font-weight: 700; font-size: 15px; display: flex; align-items: center; }
.navbar-logo { height: 32px; width: auto; display: block; }
.navbar-menu { display: flex; gap: 2px; flex: 1; align-items: center; }
.navbar-link, .navbar-menu > a {
    color: #94a3b8; text-decoration: none; padding: 6px 12px;
    border-radius: var(--radius); transition: background .15s; font-size: 14px;
}
.navbar-link:hover, .navbar-menu > a:hover { background: #1e293b; color: #fff; }
.navbar-user { display: flex; align-items: center; gap: 12px; color: #94a3b8; font-size: 13px; }
.navbar-user a { color: #94a3b8; text-decoration: none; }
.navbar-user a:hover { color: #fff; }

/* ---- Navbar dropdowns ---- */
.nav-dropdown { position: relative; }
.nav-dropdown-btn {
    background: none; border: none; cursor: pointer;
    color: #94a3b8; padding: 6px 12px; border-radius: var(--radius);
    font-size: 14px; font-family: var(--font);
    display: flex; align-items: center; gap: 5px;
    transition: background .15s; height: 52px;
}
.nav-dropdown-btn:hover,
.nav-dropdown.open .nav-dropdown-btn { background: #1e293b; color: #fff; }
.nav-caret { font-size: 9px; opacity: .7; }
.nav-dropdown-menu {
    display: none; position: absolute; top: calc(100% + 4px); left: 0;
    background: #1e293b; border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0,0,0,.4); min-width: 190px;
    padding: 4px 0; z-index: 300;
}
.nav-dropdown.open .nav-dropdown-menu { display: block; }
.nav-dropdown-menu a {
    display: block; padding: 9px 16px; color: #94a3b8;
    text-decoration: none; font-size: 13px; transition: background .1s;
}
.nav-dropdown-menu a:hover { color: #fff; background: #334155; }
.nav-dropdown-divider { height: 1px; background: #334155; margin: 4px 0; }

/* ---- Main ---- */
.main-content { max-width: 1400px; margin: 0 auto; padding: 24px 24px 60px; }

/* ---- Page header ---- */
.page-header {
    display: flex; align-items: center; gap: 16px;
    margin-bottom: 20px; flex-wrap: wrap;
}
.page-header h2 { font-size: 20px; font-weight: 700; }
.page-header-left, .page-header-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-header-left { flex: 1; }
.back-link { color: var(--color-primary); text-decoration: none; font-size: 13px; }
.back-link:hover { text-decoration: underline; }

/* ---- Current period badge ---- */
.current-period-badge {
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius); padding: 8px 14px;
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    font-size: 13px;
}
.current-period-badge .label { color: var(--color-muted); }
.current-period-badge strong { color: var(--color-primary); }
.current-period-badge .deadline { color: var(--color-warning); font-weight: 600; }

/* ---- Alerts ---- */
.alert {
    padding: 12px 16px; border-radius: var(--radius);
    margin-bottom: 16px; font-size: 14px;
}
.alert-success { background: #dcfce7; border: 1px solid #86efac; color: #166534; }
.alert-error   { background: #fee2e2; border: 1px solid #fca5a5; color: #991b1b; }
.alert-info    { background: #dbeafe; border: 1px solid #93c5fd; color: #1e40af; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 7px 16px; border-radius: var(--radius);
    font-size: 14px; font-weight: 500; cursor: pointer;
    border: 1px solid transparent; text-decoration: none;
    transition: background .15s, border-color .15s;
    white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary  { background: var(--color-primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--color-primary-h); }
.btn-secondary{ background: #e2e8f0; color: var(--color-text); border-color: #cbd5e1; }
.btn-secondary:hover:not(:disabled) { background: #cbd5e1; }
.btn-outline  { background: transparent; color: var(--color-primary); border-color: var(--color-primary); }
.btn-outline:hover:not(:disabled) { background: #eff6ff; }
.btn-danger   { background: var(--color-danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-lg       { padding: 10px 24px; font-size: 15px; }
.btn-sm       { padding: 5px 12px; font-size: 13px; }
.btn-xs       { padding: 3px 8px; font-size: 12px; }
.btn-full     { width: 100%; }
.btn-icon     { padding: 4px 8px; }

/* ---- Tables ---- */
.table-scroll { overflow-x: auto; }
.table {
    width: 100%; border-collapse: collapse;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
}
.table th, .table td {
    padding: 10px 12px; text-align: left;
    border-bottom: 1px solid var(--color-border);
    font-size: 13px;
}
.table th { background: #f1f5f9; font-weight: 600; color: var(--color-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #f8fafc; }
.text-right  { text-align: right !important; }
.text-center { text-align: center !important; }
.text-nowrap { white-space: nowrap; }

/* ---- Report grid row colors ---- */
tr.match-high   { background: var(--match-high-bg); }
tr.match-high:hover { background: #e0fce8; }
tr.match-high td:first-child { border-left: 3px solid var(--match-high-border); }
tr.match-medium { background: var(--match-med-bg); }
tr.match-medium:hover { background: #fef9c3; }
tr.match-medium td:first-child { border-left: 3px solid var(--match-med-border); }
tr.row-complete td:first-child { border-left-color: #6ee7b7 !important; }
tr.match-none   {}

/* ---- Inline inputs in grid ---- */
.inline-input, .inline-select {
    width: 100%; padding: 5px 8px;
    border: 1px solid transparent; border-radius: 4px;
    font-size: 13px; background: transparent;
    font-family: var(--font); color: var(--color-text);
}
.inline-input:hover, .inline-select:hover { border-color: var(--color-border); background: #fff; }
.inline-input:focus, .inline-select:focus {
    outline: none; border-color: var(--color-primary);
    background: #fff; box-shadow: 0 0 0 3px rgba(26,86,219,.15);
}

/* ---- Progress bar ---- */
.progress-bar-wrap {
    position: relative; background: #e2e8f0; border-radius: 20px;
    height: 24px; margin-bottom: 16px; overflow: hidden;
}
.progress-bar-inner {
    height: 100%; background: var(--color-primary);
    border-radius: 20px; transition: width .3s;
    min-width: 4px;
}
.progress-label {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%,-50%);
    font-size: 12px; font-weight: 600; color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,.3);
}

/* ---- Import bar ---- */
.import-bar {
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius); padding: 12px 16px;
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    margin-bottom: 12px;
}
.file-name-label { font-size: 13px; color: var(--color-muted); }
.import-hint     { font-size: 12px; color: var(--color-muted); }

/* ---- Match legend ---- */
.match-legend {
    display: flex; gap: 16px; font-size: 12px; margin-bottom: 12px;
    flex-wrap: wrap;
}
.legend-item { display: flex; align-items: center; gap: 4px; }
.match-high   .legend-item::before, .match-high   { color: #16a34a; }
.match-medium .legend-item::before, .match-medium { color: #d97706; }

/* ---- Desc column ---- */
.desc-clean { font-size: 13px; }
.matched-badge { color: var(--color-primary); font-size: 11px; margin-left: 4px; cursor: help; }

/* ---- Receipt status ---- */
.receipt-ok   { color: var(--color-success); }
.receipt-note { color: var(--color-warning); cursor: help; }
.receipt-missing { color: var(--color-danger); font-size: 12px; }

/* ---- Report actions ---- */
.report-actions {
    margin-top: 20px; display: flex; align-items: center; gap: 16px;
    flex-wrap: wrap;
}
.submit-hint { font-size: 13px; color: var(--color-muted); }
.submitted-notice { color: var(--color-success); font-weight: 600; }

/* ---- Dashboard stat cards ---- */
.dash-stats {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 28px;
}
@media (max-width: 768px) { .dash-stats { grid-template-columns: repeat(2, 1fr); } }
.dash-stat {
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius); padding: 20px 24px; text-align: center;
    border-top: 4px solid transparent;
}
.dash-stat-submitted { border-top-color: var(--color-success); }
.dash-stat-draft     { border-top-color: var(--color-primary); }
.dash-stat-overdue   { border-top-color: var(--color-danger); }
.dash-stat-none      { border-top-color: #cbd5e1; }
.dash-stat-num { font-size: 40px; font-weight: 800; line-height: 1; margin-bottom: 4px; }
.dash-stat-submitted .dash-stat-num { color: var(--color-success); }
.dash-stat-draft     .dash-stat-num { color: var(--color-primary); }
.dash-stat-overdue   .dash-stat-num { color: var(--color-danger); }
.dash-stat-none      .dash-stat-num { color: #94a3b8; }
.dash-stat-label { font-size: 13px; color: var(--color-muted); font-weight: 600; }

/* ---- Dashboard progress mini bar ---- */
.dash-progress-wrap {
    display: inline-block; width: 80px; height: 6px;
    background: #e2e8f0; border-radius: 3px; vertical-align: middle; margin-right: 6px;
}
.dash-progress-bar { height: 100%; background: var(--color-primary); border-radius: 3px; }
.dash-progress-label { font-size: 12px; color: var(--color-muted); }

/* ---- Period current column highlight ---- */
.period-col-current { background: #eff6ff !important; }
.text-muted { color: var(--color-muted); }

/* ---- Dashboard cards ---- */
.reports-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 14px;
    margin-top: 12px;
}
.report-card {
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius); padding: 16px;
    box-shadow: var(--shadow); transition: box-shadow .15s;
}
.report-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.1); }
.report-card.is-current { border-color: var(--color-primary); }
.report-card-header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.period-label { font-weight: 600; font-size: 14px; }
.report-card-dates { font-size: 12px; color: var(--color-muted); margin-bottom: 4px; }
.report-card-meta  { font-size: 12px; color: var(--color-muted); margin-bottom: 12px; }
.report-card-action { }

/* ---- Badges ---- */
.badge {
    display: inline-block; padding: 2px 8px; border-radius: 12px;
    font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
}
.badge-current         { background: #dbeafe; color: #1e40af; }
.badge-status-submitted{ background: #dcfce7; color: #166534; }
.badge-status-draft    { background: #f1f5f9; color: #475569; }
.badge-status-overdue  { background: #fee2e2; color: #991b1b; }
.badge-status-none     { background: #f1f5f9; color: #94a3b8; }

/* ---- Status grid (admin dashboard) ---- */
.status-cell { text-align: center; font-size: 14px; }
.status-submitted a { color: var(--color-success); text-decoration: none; }
.status-draft a      { color: var(--color-muted); text-decoration: none; }
.status-overdue a    { color: var(--color-danger); text-decoration: none; }
.status-legend { display: flex; gap: 16px; font-size: 12px; margin-top: 8px; }
.status-legend .status-submitted { color: var(--color-success); }
.status-legend .status-draft     { color: var(--color-muted); }
.status-legend .status-overdue   { color: var(--color-danger); }

/* ---- Role badges ---- */
.role-badge {
    display: inline-block; padding: 2px 8px; border-radius: 12px;
    font-size: 11px; font-weight: 600; text-transform: uppercase;
}
.role-super_admin { background: #fef3c7; color: #92400e; }
.role-admin       { background: #dbeafe; color: #1e40af; }
.role-user        { background: #f1f5f9; color: #475569; }

/* ---- Filter bar ---- */
.filter-bar {
    display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap;
    background: var(--color-surface); border: 1px solid var(--color-border);
    padding: 14px 16px; border-radius: var(--radius);
    margin-bottom: 16px;
}
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-group label { font-size: 12px; font-weight: 600; color: var(--color-muted); }
.filter-group select { padding: 6px 10px; border: 1px solid var(--color-border); border-radius: 4px; font-size: 13px; }

/* ---- Export bar ---- */
.export-bar {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 12px; flex-wrap: wrap;
}

/* ---- Modals ---- */
.modal { position: fixed; inset: 0; z-index: 1000; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.45); }
.modal-dialog {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
    background: var(--color-surface); border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
    min-width: 360px; max-width: 520px; width: 90%;
    max-height: 90vh; overflow-y: auto;
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--color-border);
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--color-muted); }
.modal-body  { padding: 20px; }

/* ---- Forms ---- */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.form-group input[type=text],
.form-group input[type=email],
.form-group input[type=password],
.form-group input[type=number],
.form-group select,
.form-group textarea {
    width: 100%; padding: 8px 10px;
    border: 1px solid var(--color-border); border-radius: 4px;
    font-size: 14px; font-family: var(--font); color: var(--color-text);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none; border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(26,86,219,.15);
}
.form-group small { display: block; font-size: 12px; color: var(--color-muted); margin-top: 3px; }
.form-actions { display: flex; gap: 8px; margin-top: 16px; }
.required { color: var(--color-danger); }

/* ---- Login page ---- */
.login-page { background: #0f172a; min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-container { width: 100%; max-width: 380px; padding: 16px; }
.login-card { background: var(--color-surface); border-radius: 10px; padding: 36px; box-shadow: 0 20px 60px rgba(0,0,0,.4); }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo h1 { font-size: 20px; font-weight: 800; color: var(--color-text); }
.login-logo p  { color: var(--color-muted); font-size: 13px; }

/* Login divider */
.login-divider {
    display: flex; align-items: center; gap: 12px;
    margin: 20px 0; color: var(--color-muted); font-size: 13px;
}
.login-divider::before,
.login-divider::after { content: ''; flex: 1; height: 1px; background: var(--color-border); }

/* Google Sign-In button */
.btn-google {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    width: 100%; padding: 10px 16px;
    background: #fff; color: #3c4043;
    border: 1px solid #dadce0; border-radius: var(--radius);
    font-size: 14px; font-weight: 500; font-family: var(--font);
    text-decoration: none; cursor: pointer;
    transition: background .15s, box-shadow .15s;
    box-shadow: 0 1px 2px rgba(0,0,0,.08);
}
.btn-google:hover {
    background: #f8f9fa;
    box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
.btn-google-icon { width: 18px; height: 18px; flex-shrink: 0; }

/* ---- Settings ---- */
.settings-section {
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius); padding: 20px 24px; margin-bottom: 20px;
}
.settings-section h3 { font-size: 16px; margin-bottom: 14px; }
.section-note { font-size: 12px; color: var(--color-muted); font-weight: 400; margin-left: 8px; }
.read-only-note { font-size: 13px; color: var(--color-muted); margin-bottom: 12px; }

/* ---- Toggle switch ---- */
.toggle-label { position: relative; display: inline-block; width: 40px; height: 22px; cursor: pointer; }
.toggle-label input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; inset: 0; background: #cbd5e1; border-radius: 22px;
    transition: background .2s;
}
.toggle-slider::before {
    content: ''; position: absolute; width: 16px; height: 16px;
    background: #fff; border-radius: 50%; top: 3px; left: 3px; transition: transform .2s;
}
.toggle-label input:checked + .toggle-slider { background: var(--color-primary); }
.toggle-label input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ---- Toggle button (rules page) ---- */
.toggle-btn { border: none; cursor: pointer; border-radius: 4px; padding: 3px 10px; font-size: 12px; font-weight: 700; }
.toggle-on  { background: #dcfce7; color: #166534; }
.toggle-off { background: #f1f5f9; color: #94a3b8; }

/* ---- Rules table ---- */
.rule-inactive td { opacity: .5; }

/* ---- Receipts ---- */
.receipt-transaction-info {
    background: var(--color-surface); border: 1px solid var(--color-border);
    padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px;
    display: flex; gap: 20px; flex-wrap: wrap; font-size: 13px;
}
.receipt-transaction-info .label { font-weight: 600; color: var(--color-muted); margin-right: 4px; }
.receipts-list { display: flex; flex-direction: column; gap: 10px; }
.receipt-item {
    background: var(--color-surface); border: 1px solid var(--color-border);
    padding: 12px 16px; border-radius: var(--radius);
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.receipt-filename { font-weight: 500; font-size: 13px; }
.receipt-date     { font-size: 12px; color: var(--color-muted); }
.receipt-item-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 4px; }

/* ---- Tabs ---- */
.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 2px solid var(--color-border); }
.tab-btn {
    padding: 8px 16px; border: none; background: none; cursor: pointer;
    font-size: 13px; color: var(--color-muted); border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}
.tab-btn.active { color: var(--color-primary); border-bottom-color: var(--color-primary); font-weight: 600; }
.tab-content[hidden] { display: none; }

/* ---- Viewing-as indicator ---- */
.viewing-as {
    background: #fef9c3; color: #92400e; font-size: 12px; font-weight: 600;
    padding: 3px 10px; border-radius: 12px;
}

/* ---- User inactive row ---- */
.user-inactive td { opacity: .5; }

/* ---- Footer ---- */
.site-footer {
    text-align: center; padding: 20px; color: var(--color-muted);
    font-size: 12px; border-top: 1px solid var(--color-border); margin-top: 40px;
}

/* ---- Report status row colors (accounting) ---- */
.status-row-submitted { }
.status-row-overdue td { background: #fff5f5 !important; }
.status-row-draft td  { }

/* ---- Period detection modal ---- */
.period-detect-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.period-detect-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px; border: 1px solid var(--color-border);
    border-radius: var(--radius); gap: 12px; flex-wrap: wrap;
}
.period-detect-item.period-current { border-color: var(--color-primary); background: #eff6ff; }
.period-detect-info { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; flex: 1; }
.period-detect-dates { font-size: 12px; color: var(--color-muted); }
.period-detect-count { font-size: 12px; font-weight: 600; color: var(--color-primary); }
.import-spinner { font-size: 13px; color: var(--color-muted); font-style: italic; }

/* ---- Location multi-select ---- */
.location-multiselect { position: relative; }
.location-trigger {
    width: 100%; text-align: left; background: transparent;
    border: 1px solid transparent; border-radius: 4px;
    padding: 5px 8px; cursor: pointer; font-size: 13px;
    display: flex; align-items: center; justify-content: space-between; gap: 4px;
    font-family: var(--font); color: var(--color-text);
}
.location-trigger:hover { border-color: var(--color-border); background: #fff; }
.location-trigger:focus { outline: none; border-color: var(--color-primary); background: #fff; box-shadow: 0 0 0 3px rgba(26,86,219,.15); }
.location-trigger .placeholder { color: #94a3b8; }
.dropdown-arrow { font-size: 10px; color: var(--color-muted); flex-shrink: 0; }
.location-dropdown {
    position: fixed; z-index: 500;
    background: #fff; border: 1px solid var(--color-border);
    border-radius: var(--radius); box-shadow: 0 4px 16px rgba(0,0,0,.15);
    min-width: 160px; padding: 6px 0;
    max-height: 260px; overflow-y: auto;
}
.loc-checkbox-label {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 12px; cursor: pointer; font-size: 13px;
    white-space: nowrap;
}
.loc-checkbox-label:hover { background: #f1f5f9; }
.loc-checkbox-label input { cursor: pointer; }

/* ---- Location tags ---- */
.location-tags, .location-tags-inline { display: flex; flex-wrap: wrap; gap: 3px; }
.loc-tag {
    display: inline-block; background: #dbeafe; color: #1e40af;
    border-radius: 10px; padding: 1px 7px; font-size: 11px; font-weight: 500;
}

/* ---- Form note ---- */
.form-note { font-size: 12px; color: var(--color-muted); padding: 6px 0; }
.form-note-inline { font-size: 11px; color: var(--color-muted); font-weight: 400; }

/* ---- Totals row ---- */
.totals-row td { border-top: 2px solid var(--color-border) !important; background: #f8fafc; }

/* ---- Incomplete row highlight (submit validation) ---- */
tr.row-incomplete td { background: #fff1f2 !important; }
tr.row-incomplete td:first-child { border-left: 3px solid #f87171 !important; }
.missing-field { color: #dc2626; font-weight: 600; font-size: 12px; }

/* ---- Empty state ---- */
.empty-state {
    text-align: center; padding: 48px 24px; color: var(--color-muted); font-size: 14px;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .main-content { padding: 16px; }
    .modal-dialog { min-width: unset; }
    .reports-grid { grid-template-columns: 1fr; }
}

/* ---- Section header ---- */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; flex-wrap: wrap; gap: 8px; }
.section-header h3 { font-size: 16px; font-weight: 700; }

/* ---- Page description ---- */
.page-description { font-size: 13px; color: var(--color-muted); margin-bottom: 16px; }

/* ---- 403 ---- */
.error-page { text-align: center; padding: 80px 24px; }
.error-page h2 { font-size: 24px; margin-bottom: 8px; }

/* ---- Recurring tag (type column) ---- */
.recurring-tag {
    display: inline-flex; align-items: center; gap: 4px;
    color: var(--color-primary); font-size: 12px; font-weight: 600;
    white-space: nowrap;
}

/* ---- Checkbox column ---- */
.col-checkbox {
    width: 36px !important; text-align: center !important;
    padding: 0 8px !important;
}
.tx-checkbox { cursor: pointer; width: 15px; height: 15px; accent-color: var(--color-primary); }
#select-all-checkbox { cursor: pointer; width: 15px; height: 15px; accent-color: var(--color-primary); }

/* ---- Sortable headers ---- */
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--color-primary); }
.sort-icon { font-size: 10px; margin-left: 3px; opacity: .4; }
th.sortable:hover .sort-icon,
th.sort-asc .sort-icon,
th.sort-desc .sort-icon { opacity: 1; color: var(--color-primary); }

/* ---- Filter + sort toolbar ---- */
.table-toolbar {
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius); padding: 12px 16px;
    margin-bottom: 8px;
}
.toolbar-filters { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.filter-group { display: flex; flex-direction: column; gap: 3px; }
.filter-group > label { font-size: 11px; font-weight: 700; color: var(--color-muted); text-transform: uppercase; letter-spacing: .04em; }
.filter-group-btn { justify-content: flex-end; }
.toolbar-input {
    padding: 5px 10px; border: 1px solid var(--color-border);
    border-radius: 4px; font-size: 13px; font-family: var(--font);
    color: var(--color-text); background: var(--color-surface);
    height: 32px;
}
.toolbar-input:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 2px rgba(26,86,219,.12); }
.filter-desc { min-width: 180px; }
.toolbar-input[type=date] { width: 140px; }
.toolbar-select {
    padding: 5px 10px; border: 1px solid var(--color-border);
    border-radius: 4px; font-size: 13px; font-family: var(--font);
    color: var(--color-text); background: var(--color-surface);
    height: 32px;
}
.toolbar-select:focus { outline: none; border-color: var(--color-primary); }
.filter-amount-range { display: flex; align-items: center; gap: 4px; }
.filter-amount-range .toolbar-input { width: 82px; }
.filter-range-sep { font-size: 12px; color: var(--color-muted); }
.toolbar-count { font-size: 12px; color: var(--color-primary); font-weight: 600; margin-top: 8px; display: block; }

/* ---- Mass action bar ---- */
.mass-action-bar {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    background: #eff6ff; border: 1px solid #bfdbfe;
    border-radius: var(--radius); padding: 10px 14px;
    margin-bottom: 8px;
}
.mass-count { font-size: 13px; font-weight: 700; color: #1e40af; white-space: nowrap; padding-right: 6px; border-right: 1px solid #bfdbfe; }
.mass-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; }

/* Filter toggle button hidden on desktop (JS also hides it, belt+suspenders) */
.filter-toggle-btn { display: none; }

/* ---- Location bottom sheet (modal body) ---- */
.loc-sheet-label {
    display: flex; align-items: center; gap: 12px;
    padding: 13px 0; border-bottom: 1px solid var(--color-border);
    font-size: 16px; cursor: pointer;
    touch-action: manipulation;
}
.loc-sheet-label:last-child { border-bottom: none; }
.loc-sheet-label input[type=checkbox] { width: 22px; height: 22px; flex-shrink: 0; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--color-border); }

/* ---- Receipt preview button ---- */
.btn-receipt-preview {
    background: none; border: none; cursor: pointer;
    font-size: 15px; padding: 0 3px; line-height: 1;
    opacity: .75; transition: opacity .15s;
    touch-action: manipulation;
}
.btn-receipt-preview:hover { opacity: 1; }

/* ---- Receipt viewer modal ---- */
.modal-dialog-lg { min-width: min(800px, 95vw); width: min(800px, 95vw); }
.receipt-viewer-body {
    padding: 0; display: flex; flex-direction: column;
    height: min(75vh, 700px);
}
#receipt-viewer-frame {
    flex: 1; width: 100%; border: none; display: block;
    background: #f1f5f9;
}
.receipt-viewer-fallback {
    padding: 16px; text-align: center; font-size: 13px;
    color: var(--color-muted);
}

/* =============================================================================
   Mobile / iPhone Phase 1
   ============================================================================= */

/* touch-action on interactive elements */
button, a, label, .btn, .tx-checkbox, .loc-checkbox,
.nav-dropdown-btn, input[type=checkbox], input[type=radio] {
    touch-action: manipulation;
}

/* Hamburger — hidden on desktop */
.navbar-hamburger {
    display: none;
    flex-direction: column; justify-content: center; align-items: center;
    gap: 5px; width: 44px; height: 44px;
    background: none; border: none; cursor: pointer; padding: 0;
    margin-left: auto; flex-shrink: 0;
}
.navbar-hamburger span {
    display: block; width: 22px; height: 2px;
    background: #94a3b8; border-radius: 2px;
    transition: background .15s;
}
.navbar-hamburger:hover span { background: #fff; }

/* Mobile nav overlay */
.nav-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.5); z-index: 400;
    opacity: 0; transition: opacity .25s;
}
.nav-overlay.visible { opacity: 1; }

/* Mobile drawer */
.nav-drawer {
    position: fixed; top: 0; right: 0; bottom: 0;
    width: min(300px, 85vw);
    background: #0f172a; z-index: 401;
    display: flex; flex-direction: column;
    transform: translateX(110%);
    transition: transform .25s ease;
    overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.nav-drawer.open { transform: translateX(0); }
.nav-drawer-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px; border-bottom: 1px solid #1e293b;
    flex-shrink: 0;
}
.nav-drawer-close {
    background: none; border: none; color: #94a3b8;
    font-size: 28px; line-height: 1; cursor: pointer;
    width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
    touch-action: manipulation;
}
.nav-drawer-close:hover { color: #fff; }
.nav-drawer-user {
    padding: 14px 16px; border-bottom: 1px solid #1e293b;
    display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.nav-drawer-name { color: #e2e8f0; font-size: 14px; font-weight: 600; }
.nav-drawer-nav { flex: 1; padding: 8px 0; }
.nav-drawer-section {
    padding: 10px 16px 4px;
    color: #475569; font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .06em;
}
.nav-drawer-link {
    display: block; padding: 12px 16px;
    color: #94a3b8; text-decoration: none; font-size: 15px;
    transition: background .1s, color .1s;
    min-height: 44px; display: flex; align-items: center;
    touch-action: manipulation;
}
.nav-drawer-link:hover,
.nav-drawer-link:active { background: #1e293b; color: #fff; }
.nav-drawer-footer {
    padding: 16px; border-top: 1px solid #1e293b; flex-shrink: 0;
}

/* ---- Mobile breakpoint ---- */
@media (max-width: 767px) {

    /* Show hamburger, hide desktop nav */
    .navbar-hamburger { display: flex; }
    .navbar-menu { display: none; }
    .navbar-user { display: none; }
    .navbar { gap: 12px; padding: 0 16px; }

    /* Show overlay when active */
    .nav-overlay.visible { display: block; }

    /* Main content padding */
    .main-content { padding: 16px 12px 80px; }

    /* Page header stacks */
    .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }
    .page-header-right { width: 100%; }

    /* ---- Touch-friendly 44px tap targets ---- */
    .btn {
        min-height: 44px; padding: 10px 16px;
        font-size: 15px;
    }
    .btn-sm {
        min-height: 38px; padding: 8px 12px;
        font-size: 13px;
    }
    input[type=text], input[type=number], input[type=date],
    input[type=email], input[type=password], select, textarea {
        min-height: 44px; font-size: 16px !important; /* prevents iOS zoom */
        padding: 10px 12px;
    }
    .toolbar-input, .toolbar-select {
        min-height: 38px; font-size: 15px !important;
    }
    .tx-checkbox, .loc-checkbox, input[type=checkbox] {
        width: 20px; height: 20px; min-height: 20px;
    }

    /* ---- Table toolbar stacks ---- */
    .table-toolbar { flex-direction: column; align-items: stretch; gap: 8px; }
    .filter-group { flex-direction: column; align-items: flex-start; }
    .filter-amount-range { flex-wrap: wrap; }
    .toolbar-input { width: 100% !important; }
    .toolbar-select { width: 100% !important; }
    .filter-desc { min-width: unset; width: 100%; }

    /* ---- Mass action bar ---- */
    .mass-action-bar { flex-direction: column; align-items: stretch; }

    /* ---- Table: horizontal scroll ---- */
    .table-scroll { -webkit-overflow-scrolling: touch; }

    /* ---- Modals: bottom sheet on mobile ---- */
    .modal-dialog {
        position: fixed; top: auto; bottom: 0; left: 0; right: 0;
        transform: none;
        width: 100%; max-width: 100%; min-width: unset;
        border-radius: 18px 18px 0 0;
        max-height: 90vh; overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: calc(20px + env(safe-area-inset-bottom));
        margin: 0;
    }

    /* ---- Submit area ---- */
    .submit-area { flex-direction: column; align-items: stretch; }
    .submit-area .btn { width: 100%; text-align: center; }

    /* ---- Receipt list ---- */
    .receipt-item {
        flex-direction: column; align-items: flex-start; gap: 8px;
    }
    .receipt-item-actions { width: 100%; display: flex; gap: 8px; }
    .receipt-item-actions .btn { flex: 1; text-align: center; justify-content: center; }

    /* ---- Dashboard stat cards ---- */
    .dash-stats { grid-template-columns: 1fr 1fr; }

    /* ---- Alert ---- */
    .alert { font-size: 14px; }

    /* ================================================================
       Phase 3 — Dashboard mobile + location bottom sheet trigger
       ================================================================ */

    /* Current period badge stacks */
    .current-period-badge { flex-direction: column; align-items: flex-start; gap: 2px; font-size: 13px; }

    /* User status table → cards */
    .table-user-status thead { display: none; }
    .table-user-status,
    .table-user-status tbody { display: block; }
    .table-user-status tr {
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto auto auto;
        grid-template-areas:
            "user   status"
            "role   role  "
            "prog   prog  "
            "sub    action";
        gap: 4px 8px;
        padding: 12px;
        background: var(--color-surface);
        border-radius: 10px;
        border: 1px solid var(--color-border);
        margin-bottom: 8px;
        box-shadow: var(--shadow);
    }
    .table-user-status tr.status-row-overdue { border-left: 3px solid var(--color-danger); }
    .table-user-status td { display: block; padding: 0; border: none; text-align: left !important; }
    .table-user-status td[data-label="User"]      { grid-area: user; font-size: 15px; align-self: center; }
    .table-user-status td[data-label="Role"]      { grid-area: role; }
    .table-user-status td[data-label="Status"]    { grid-area: status; text-align: right !important; align-self: center; }
    .table-user-status td[data-label="Progress"]  { grid-area: prog; }
    .table-user-status td[data-label="Submitted"] { grid-area: sub; font-size: 12px; color: var(--color-muted); align-self: center; }
    .table-user-status td[data-label=""]          { grid-area: action; text-align: right !important; align-self: center; }

    /* Full year grid — tighter cells, horizontal scroll */
    .table-status th,
    .table-status td { padding: 6px 4px; font-size: 12px; }
    .table-status .status-cell { min-width: 28px; }

    /* Report cards grid on My Reports view */
    .reports-grid { grid-template-columns: 1fr; }

    /* ================================================================
       Phase 2 — Report page: card layout, filter collapse, sticky submit
       ================================================================ */

    /* -- Filter toggle button (mobile only) -- */
    .filter-toggle-btn { display: flex; align-items: center; gap: 6px; width: 100%; justify-content: center; }
    .toolbar-filters.filters-collapsed { display: none; }

    /* -- Transaction card layout -- */
    /* Hide table chrome */
    .table-report thead { display: none; }
    .table-report tfoot { display: none; }
    .table-report,
    .table-report tbody { display: block; }

    /* Each row becomes a card */
    .table-report tr.tx-row {
        display: grid;
        grid-template-columns: 24px 1fr auto;
        grid-template-rows: auto auto auto auto auto auto;
        grid-template-areas:
            "cb    date    amount"
            "cb    desc    type  "
            "det   det     det   "
            "loc   loc     loc   "
            "rec   rec     rec   "
            "act   act     act   ";
        gap: 4px 8px;
        padding: 12px;
        background: var(--color-surface);
        border-radius: 10px;
        border: 1px solid var(--color-border);
        margin-bottom: 8px;
        box-shadow: var(--shadow);
    }
    .table-report tr.row-complete   { border-left: 3px solid var(--color-success); }
    .table-report tr.row-incomplete { border-left: 3px solid var(--color-danger); background: #fff1f2; }
    .table-report tr.match-high  { border-left: 3px solid var(--match-high-border); }
    .table-report tr.match-medium { border-left: 3px solid var(--match-med-border); }

    /* Remove default td styles */
    .table-report td {
        display: block; padding: 0; border: none;
        text-align: left !important;
    }
    .table-report td.col-checkbox { grid-area: cb; display: flex; align-items: flex-start; padding-top: 2px; }
    .table-report td.col-date     { grid-area: date; font-size: 12px; color: var(--color-muted); align-self: center; }
    .table-report td.col-amount   { grid-area: amount; font-size: 15px; font-weight: 700; text-align: right !important; align-self: center; }
    .table-report td.col-desc     { grid-area: desc; font-size: 14px; font-weight: 600; padding-bottom: 2px; }
    .table-report td.col-type     { grid-area: type; text-align: right !important; align-self: center; }
    .table-report td.col-details  { grid-area: det; padding-top: 4px; }
    .table-report td.col-location { grid-area: loc; padding-top: 2px; }
    .table-report td.col-receipt  { grid-area: rec; padding-top: 4px; display: flex; align-items: center; gap: 8px; }
    .table-report td.col-actions  { grid-area: act; padding-top: 4px; display: flex; gap: 8px; }

    /* Full-width inputs inside cards */
    .table-report .details-input,
    .table-report .location-multiselect,
    .table-report .location-trigger { width: 100%; }

    /* Larger action buttons inside cards */
    .table-report .btn-xs { min-height: 36px; padding: 6px 12px; font-size: 13px; }

    /* -- Sticky submit bar -- */
    #report-actions {
        position: fixed; bottom: 0; left: 0; right: 0;
        background: var(--color-surface);
        border-top: 1px solid var(--color-border);
        padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
        display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
        z-index: 200;
        box-shadow: 0 -2px 8px rgba(0,0,0,.08);
    }
    #report-actions .submit-hint { font-size: 12px; color: var(--color-muted); flex: 1; }
    #report-actions .btn-lg { min-height: 44px; flex-shrink: 0; }
    #report-actions .submitted-notice { font-size: 13px; flex: 1; }

    /* Extra bottom padding so last card isn't hidden behind sticky bar */
    .main-content { padding-bottom: 120px; }

    /* Hide receipt viewer iframe bottom sheet since full iframe doesn't work well */
    .modal-dialog-lg { min-width: unset; width: 100%; }
    .receipt-viewer-body { height: 60vh; }
}
