﻿/* ============================================================
   TechSpire MIS — Professional Application Stylesheet v2.0
   Dark theme with glassmorphism, micro-animations, responsive
   ============================================================ */

/* ----- RESET & BASE ----- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    /* Brand Palette */
    --bg-deep:       #020617;
    --bg-dark:       #0f172a;
    --bg-card:       rgba(15, 23, 42, 0.88);
    --bg-card-hover: rgba(20, 30, 52, 0.92);
    --bg-sidebar:    rgba(8, 15, 30, 0.97);
    --bg-input:      rgba(15, 23, 42, 0.6);
    --accent-blue:   #38bdf8;
    --accent-indigo: #818cf8;
    --accent-teal:   #2dd4bf;
    --accent-yellow: #fde047;
    --text-main:     #f1f5f9;
    --text-muted:    #94a3b8;
    --text-faint:    #64748b;
    --border-glow:   rgba(56, 189, 248, 0.18);
    --border-subtle: rgba(148, 163, 184, 0.12);
    --success:       #22c55e;
    --error:         #ef4444;
    --warning:       #f59e0b;
    --info:          #38bdf8;
    --sidebar-width: 250px;

    /* Shadows */
    --shadow-sm:  0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md:  0 4px 12px rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.2);
    --shadow-lg:  0 8px 30px rgba(0,0,0,0.35), 0 4px 8px rgba(0,0,0,0.2);
    --shadow-xl:  0 16px 50px rgba(0,0,0,0.4);
    --shadow-glow: 0 0 20px rgba(56, 189, 248, 0.12);

    /* Transitions */
    --ease-out: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ============================================================
   LIGHT THEME — default for employees
   Applied via [data-theme="light"] on <html>
   ============================================================ */
[data-theme="light"] {
    --bg-deep:       #f1f5f9;
    --bg-dark:       #ffffff;
    --bg-card:       rgba(255, 255, 255, 0.95);
    --bg-card-hover: rgba(248, 250, 252, 1);
    --bg-sidebar:    rgba(255, 255, 255, 0.98);
    --bg-input:      rgba(241, 245, 249, 0.8);
    --accent-blue:   #0284c7;
    --accent-indigo: #6366f1;
    --accent-teal:   #0d9488;
    --accent-yellow: #ca8a04;
    --text-main:     #0f172a;
    --text-muted:    #475569;
    --text-faint:    #94a3b8;
    --border-glow:   rgba(2, 132, 199, 0.15);
    --border-subtle: rgba(148, 163, 184, 0.2);
    --success:       #16a34a;
    --error:         #dc2626;
    --warning:       #d97706;
    --info:          #0284c7;
    --shadow-sm:  0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md:  0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg:  0 8px 30px rgba(0,0,0,0.1), 0 4px 8px rgba(0,0,0,0.05);
    --shadow-xl:  0 16px 50px rgba(0,0,0,0.12);
    --shadow-glow: 0 0 20px rgba(2, 132, 199, 0.08);
}

[data-theme="light"] body {
    background: linear-gradient(160deg, #f1f5f9 0%, #e2e8f0 50%, #f8fafc 100%);
}

[data-theme="light"] .sidebar {
    background: rgba(255, 255, 255, 0.98);
    border-right-color: rgba(148, 163, 184, 0.2);
}

[data-theme="light"] .sidebar-brand h2 {
    background: linear-gradient(135deg, #0284c7, #6366f1);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}

[data-theme="light"] .top-bar {
    background: rgba(255, 255, 255, 0.85);
    border-bottom-color: rgba(148, 163, 184, 0.15);
}

[data-theme="light"] thead { background: rgba(241, 245, 249, 0.98); }

[data-theme="light"] select option { background: #fff; color: #0f172a; }

[data-theme="light"] .stat-card .stat-value {
    background: linear-gradient(135deg, #0284c7, #6366f1);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}

[data-theme="light"] .btn-primary {
    background: linear-gradient(135deg, #0284c7, #6366f1);
    box-shadow: 0 3px 12px rgba(2, 132, 199, 0.2);
}

[data-theme="light"] .modal-box,
[data-theme="light"] .confirm-box { background: #fff; }

[data-theme="light"] .toast { background: rgba(255,255,255,0.97) !important; }

[data-theme="light"] .tip-text,
[data-theme="light"] .btn-tip { background: #fff; color: #0f172a; border-color: rgba(148,163,184,0.2); }
[data-theme="light"] .tip-text::after { border-top-color: #fff; }
[data-theme="light"] .btn-tip::before { border-bottom-color: #fff; }

[data-theme="light"] .notif-dropdown { background: #fff; }

[data-theme="light"] .rte-toolbar { background: rgba(241,245,249,0.95); }
[data-theme="light"] .rte-editor { background: #fff; }

[data-theme="light"] .lightbox-overlay { background: rgba(255,255,255,0.95); }
[data-theme="light"] .lightbox-btn,
[data-theme="light"] .lightbox-close,
[data-theme="light"] .lightbox-nav { background: rgba(15,23,42,0.8); }

[data-theme="light"] .guest-card .brand-header h1 {
    background: linear-gradient(135deg, #0284c7, #6366f1);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}

/* Light theme: form input improvements */
[data-theme="light"] input,
[data-theme="light"] select,
[data-theme="light"] textarea {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(148, 163, 184, 0.35);
}

[data-theme="light"] input:focus,
[data-theme="light"] select:focus,
[data-theme="light"] textarea:focus {
    background: #fff;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.1);
}

[data-theme="light"] input::placeholder,
[data-theme="light"] textarea::placeholder {
    color: rgba(100, 116, 139, 0.6);
}

/* Light theme: table contrast */
[data-theme="light"] th {
    color: #334155;
    border-bottom-color: rgba(148, 163, 184, 0.25);
}

[data-theme="light"] td {
    border-bottom-color: rgba(148, 163, 184, 0.15);
}

[data-theme="light"] tr[data-href]:hover {
    background: rgba(2, 132, 199, 0.06);
}

/* Light theme: filter bar */
[data-theme="light"] .filter-bar {
    background: rgba(241, 245, 249, 0.7);
    border-color: rgba(148, 163, 184, 0.25);
}

/* Light theme: overlays */
[data-theme="light"] .modal-overlay {
    background: rgba(15, 23, 42, 0.45);
}

[data-theme="light"] .confirm-overlay {
    background: rgba(15, 23, 42, 0.45);
}

[data-theme="light"] .loading-overlay {
    background: rgba(241, 245, 249, 0.92);
}

[data-theme="light"] .loading-overlay p {
    color: #334155;
}

/* Light theme: toast backgrounds */
[data-theme="light"] .toast-success,
[data-theme="light"] .toast-error,
[data-theme="light"] .toast-warning,
[data-theme="light"] .toast-info {
    background: rgba(255, 255, 255, 0.97) !important;
}

/* Light theme: sidebar nav contrast */
[data-theme="light"] .sidebar-nav li a {
    color: #475569;
}

[data-theme="light"] .sidebar-nav li a:hover,
[data-theme="light"] .sidebar-nav li a.active {
    color: #0f172a;
    background: rgba(2, 132, 199, 0.08);
    border-left-color: #0284c7;
}

[data-theme="light"] .sidebar-section-title {
    color: #64748b;
}

[data-theme="light"] .sidebar-brand small {
    color: #64748b;
}

/* Light theme: card hover */
[data-theme="light"] .card:hover {
    border-color: rgba(2, 132, 199, 0.2);
}

/* Light theme: col toggler */
[data-theme="light"] .col-toggler-dropdown {
    background: #fff;
    border-color: rgba(148, 163, 184, 0.25);
}

/* Light theme: receipt preview */
[data-theme="light"] .receipt-preview {
    background: rgba(241, 245, 249, 0.5);
}

/* Light theme: upload zone */
[data-theme="light"] .upload-zone {
    background: rgba(2, 132, 199, 0.02);
    border-color: rgba(2, 132, 199, 0.2);
}

[data-theme="light"] .upload-zone:hover,
[data-theme="light"] .upload-zone.drag-over {
    background: rgba(2, 132, 199, 0.05);
    border-color: #0284c7;
}

/* Light theme: file preview */
[data-theme="light"] .file-preview {
    background: rgba(241, 245, 249, 0.5);
}

/* Light theme: clock widget */
[data-theme="light"] .clock-widget {
    background: rgba(2, 132, 199, 0.04);
    border-color: rgba(2, 132, 199, 0.15);
}

/* Light theme: pagination */
[data-theme="light"] .pagination a {
    background: rgba(2, 132, 199, 0.05);
    border-color: rgba(2, 132, 199, 0.12);
    color: #475569;
}

[data-theme="light"] .pagination a:hover {
    background: rgba(2, 132, 199, 0.1);
    color: #0f172a;
}

/* Light theme: logout button contrast */
[data-theme="light"] .logout-btn {
    background: rgba(220, 38, 38, 0.08);
    border-color: rgba(220, 38, 38, 0.2);
}

[data-theme="light"] .logout-btn:hover {
    background: rgba(220, 38, 38, 0.15);
}

/* Light theme: filter presets */
[data-theme="light"] .filter-preset {
    background: rgba(2, 132, 199, 0.06);
    border-color: rgba(2, 132, 199, 0.15);
    color: #475569;
}

[data-theme="light"] .filter-preset:hover {
    background: rgba(2, 132, 199, 0.12);
    color: #0f172a;
}

/* Light theme: flash messages readability */
[data-theme="light"] .flash-success { background: rgba(22, 163, 74, 0.08); border-color: rgba(22, 163, 74, 0.2); }
[data-theme="light"] .flash-error   { background: rgba(220, 38, 38, 0.08); border-color: rgba(220, 38, 38, 0.2); }
[data-theme="light"] .flash-warning { background: rgba(217, 119, 6, 0.08); border-color: rgba(217, 119, 6, 0.2); }
[data-theme="light"] .flash-info    { background: rgba(2, 132, 199, 0.08); border-color: rgba(2, 132, 199, 0.2); }

/* Theme transition for smooth toggle */
html { transition: background 0.3s, color 0.3s; }
body, .sidebar, .top-bar, .card, .stat-card, input, select, textarea, .toast, .modal-box, thead {
    transition: background 0.3s, border-color 0.3s, color 0.3s, box-shadow 0.3s;
}

html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(160deg, var(--bg-deep) 0%, var(--bg-dark) 50%, #0c1631 100%);
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.6;
    font-size: clamp(0.875rem, 0.85rem + 0.1vw, 1rem);
}

a { color: var(--accent-blue); text-decoration: none; transition: color 0.2s var(--ease-out); }
a:hover { color: var(--accent-indigo); }

/* Focus ring for accessibility */
*:focus-visible {
    outline: 2px solid var(--accent-blue);
    outline-offset: 2px;
    border-radius: 4px;
}

::selection { background: rgba(56, 189, 248, 0.3); color: #fff; }

/* ----- PAGE FADE-IN ANIMATION ----- */
@keyframes pageIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.page-content { animation: pageIn 0.3s var(--ease-out); }

/* ----- APP LAYOUT ----- */
.app-layout { display: flex; min-height: 100vh; }

/* ----- SIDEBAR ----- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-glow);
    padding: 1.25rem 0;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    overflow-y: auto;
    z-index: 100;
    backdrop-filter: blur(16px);
    transition: transform 0.3s var(--ease-out);
}

.sidebar-brand {
    padding: 0 1.25rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 0.75rem;
}
.sidebar-brand h2 {
    font-size: 1.1rem; font-weight: 700;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-indigo));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
    margin: 0;
}
.sidebar-brand small { color: var(--text-faint); font-size: 0.68rem; display: block; margin-top: 0.2rem; }

/* Sidebar logo image */
.sidebar-logo {
    display: block;
    max-height: 72px;
    max-width: 200px;
    width: auto;
    height: auto;
    object-fit: contain;
    object-position: left center;
    margin-bottom: 0.3rem;
    opacity: 0.93;
    transition: opacity 0.2s;
}
.sidebar-logo:hover { opacity: 1; }

/* ── Mobile top-bar logo ──────────────────────────────────────── */
/* Hidden on desktop (sidebar is visible); shown on mobile only   */
.mob-logo-wrap {
    display: none;
    align-items: center;
    flex-shrink: 0;
    margin-right: 0.1rem;
    text-decoration: none;
}
.mob-logo-wrap img {
    height: 24px;
    width: auto;
    max-width: 110px;
    object-fit: contain;
    opacity: 0.88;
    display: block;
    transition: opacity 0.2s;
}
.mob-logo-wrap img:hover { opacity: 1; }
/* On mobile: sidebar slides off, show compact logo in header  */
@media (max-width: 768px) {
    .mob-logo-wrap { display: flex; }
    /* Slightly larger on tablet-sized mobile */
    .mob-logo-wrap img { height: 26px; }
}
/* Tiny phones: keep it even tighter */
@media (max-width: 380px) {
    .mob-logo-wrap img { height: 22px; max-width: 90px; }
}

/* ── Guest / login page logo ─────────────────────────────────── */
.guest-logo-wrap {
    text-align: center;
    margin-bottom: 1.1rem;
}
.guest-logo {
    display: inline-block;
    max-height: 52px;
    max-width: 200px;
    width: auto;
    height: auto;
    object-fit: contain;
}
@media (max-width: 480px) {
    .guest-logo { max-height: 42px; max-width: 160px; }
}

/* ── Light theme: top-bar background reference for logo tint ── */
/* The top bar in light mode is near-white — no filter needed if  */
/* logo-sidebar.png is a coloured logo on transparent background. */
[data-theme="light"] .mob-logo-wrap img {
    opacity: 0.85;
}
[data-theme="light"] .sidebar-logo {
    /* Sidebar bg stays dark in light theme — logo-sidebar.png    */
    /* (white/light version) is ideal; same opacity rule applies. */
    opacity: 0.9;
}

.sidebar-nav { list-style: none; }
.sidebar-nav li a {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.55rem 1.25rem; color: var(--text-muted);
    font-size: 0.84rem; font-weight: 500;
    transition: all 0.2s var(--ease-out);
    border-left: 3px solid transparent;
    position: relative;
}
.sidebar-nav li a:hover,
.sidebar-nav li a.active {
    color: var(--text-main);
    background: rgba(56, 189, 248, 0.06);
    border-left-color: var(--accent-blue);
}
.sidebar-nav li a.active::after {
    content: ''; position: absolute; right: 0; top: 50%; transform: translateY(-50%);
    width: 3px; height: 60%; background: var(--accent-blue); border-radius: 3px 0 0 3px;
}
.sidebar-nav li a .nav-icon { width: 20px; text-align: center; font-size: 0.95rem; flex-shrink: 0; }

.sidebar-section-title {
    padding: 0.85rem 1.25rem 0.35rem; font-size: 0.65rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-faint);
}
.sidebar-badge {
    background: var(--error); color: #fff; font-size: 0.58rem; font-weight: 700;
    padding: 1px 6px; border-radius: 10px; margin-left: auto; animation: badgePulse 2s infinite;
}
@keyframes badgePulse { 0%,100% { opacity: 1; } 50% { opacity: 0.7; } }

/* ----- MOBILE SIDEBAR ----- */
.sidebar-overlay {
    display: none; position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.55);
    z-index: 199; /* just below sidebar z-index 200, above everything else */
    opacity: 0; transition: opacity 0.25s ease;
    -webkit-tap-highlight-color: transparent;
}
.sidebar-overlay.visible { display: block; opacity: 1; }

.main-content { flex: 1; margin-left: var(--sidebar-width); min-height: 100vh; }

/* ----- TOP HEADER BAR ----- */
.top-bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.75rem 2rem;
    border-bottom: 1px solid var(--border-subtle);
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(12px);
    position: sticky; top: 0; z-index: 50;
}
.top-bar h1 { font-size: clamp(1.1rem, 1rem + 0.3vw, 1.35rem); font-weight: 600; }

.top-bar-user { display: flex; align-items: center; gap: 0.75rem; font-size: 0.85rem; }
.top-bar-user .user-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-indigo));
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.8rem; color: #fff;
    transition: transform 0.2s, box-shadow 0.2s;
}
.top-bar-user .user-avatar:hover { transform: scale(1.1); box-shadow: var(--shadow-glow); }
.top-bar-user .user-name { font-weight: 500; color: var(--text-main); }
.top-bar-user .user-role { color: var(--text-faint); font-size: 0.7rem; }

.logout-btn {
    padding: 0.4rem 0.85rem; background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.25); color: var(--error);
    border-radius: 8px; font-size: 0.78rem; font-weight: 500; cursor: pointer;
    transition: all 0.2s var(--ease-out);
}
.logout-btn:hover { background: rgba(239, 68, 68, 0.2); transform: translateY(-1px); color: var(--error); }

.page-content { padding: 1.5rem 2rem; max-width: 1400px; }

/* ----- GLASS CARD ----- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-glow);
    border-radius: 14px;
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow-md);
    transition: transform 0.25s var(--ease-out), box-shadow 0.25s var(--ease-out), border-color 0.25s;
    animation: cardIn 0.4s var(--ease-out) both;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

.card:hover { border-color: rgba(56, 189, 248, 0.25); }

.card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1rem; padding-bottom: 0.7rem;
    border-bottom: 1px solid var(--border-subtle);
}
.card-header h3 { font-size: 1rem; font-weight: 600; }

/* ----- STAT CARDS ----- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 1rem; margin-bottom: 1.25rem;
}
.stat-card {
    background: var(--bg-card); border: 1px solid var(--border-glow);
    border-radius: 12px; padding: 1.15rem;
    backdrop-filter: blur(8px);
    transition: transform 0.3s var(--ease-spring), box-shadow 0.3s;
    cursor: default;
}
.stat-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg), var(--shadow-glow); }

/* Linked stat cards (dashboard navigation) */
a.stat-card, .stat-card-link {
    display: block;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}
a.stat-card:hover, .stat-card-link:hover { color: inherit; }
.stat-card .stat-label {
    font-size: 0.72rem; color: var(--text-faint); text-transform: uppercase;
    letter-spacing: 0.06em; margin-bottom: 0.4rem; display: flex; align-items: center; gap: 0.3rem;
}
.stat-card .stat-value {
    font-size: clamp(1.5rem, 1.3rem + 0.5vw, 1.8rem); font-weight: 700;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-indigo));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.stat-card .stat-sub { font-size: 0.7rem; color: var(--text-faint); margin-top: 0.15rem; }

/* ----- FORM ELEMENTS ----- */
.form-group { margin-bottom: 0.9rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }

label {
    display: flex; align-items: center; gap: 0.3rem;
    font-size: 0.82rem; font-weight: 500; color: var(--text-muted); margin-bottom: 0.3rem;
}
label .required { color: var(--error); }

input, select, textarea {
    width: 100%; padding: 0.6rem 0.85rem;
    background: var(--bg-input); border: 1px solid var(--border-subtle);
    border-radius: 8px; color: var(--text-main); font-family: inherit; font-size: 0.88rem;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
    outline: none;
}
input:hover, select:hover, textarea:hover { border-color: rgba(148, 163, 184, 0.3); }
input:focus, select:focus, textarea:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.12);
    background: rgba(15, 23, 42, 0.8);
}
input::placeholder, textarea::placeholder { color: rgba(148, 163, 184, 0.4); }
input.error, select.error, textarea.error { border-color: var(--error); box-shadow: 0 0 0 3px rgba(239,68,68,0.12); }
input.success { border-color: var(--success); box-shadow: 0 0 0 3px rgba(34,197,94,0.12); }
select { cursor: pointer; }
select option { background: var(--bg-dark); color: var(--text-main); }
textarea { resize: vertical; min-height: 70px; }
input[type="checkbox"] { width: auto; margin-right: 0.5rem; accent-color: var(--accent-blue); cursor: pointer; }

/* ----- PASSWORD TOGGLE ----- */
.password-input-wrap {
    position: relative;
}

.password-input-wrap input {
    padding-right: 2.6rem;
}

.password-toggle-btn {
    position: absolute;
    right: 0.6rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-faint);
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
    line-height: 1;
    z-index: 2;
}

.password-toggle-btn:hover {
    color: var(--text-main);
}

.password-toggle-btn:focus-visible {
    outline: 2px solid var(--accent-blue);
    outline-offset: 2px;
    border-radius: 4px;
}

.password-toggle-btn svg {
    width: 18px;
    height: 18px;
    pointer-events: none;
}

/* ----- TOOLTIP SYSTEM ----- */
.tooltip-wrap { position: relative; display: inline-flex; align-items: center; }
.tip {
    width: 16px; height: 16px; border-radius: 50%;
    background: rgba(56, 189, 248, 0.15); color: var(--accent-blue);
    font-size: 0.6rem; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
    cursor: help; flex-shrink: 0; border: 1px solid rgba(56, 189, 248, 0.25);
    margin-left: 0.3rem; transition: all 0.2s; user-select: none;
}
.tip:hover { background: rgba(56, 189, 248, 0.35); transform: scale(1.15); }
.tip-text {
    visibility: hidden; opacity: 0; position: absolute;
    bottom: calc(100% + 10px); left: 50%; transform: translateX(-50%);
    background: #1e293b; color: var(--text-main);
    font-size: 0.76rem; font-weight: 400; padding: 0.55rem 0.85rem;
    border-radius: 10px; max-width: 280px; min-width: 160px; white-space: normal;
    z-index: 200; border: 1px solid var(--border-glow);
    box-shadow: var(--shadow-lg); transition: opacity 0.2s, visibility 0.2s;
    line-height: 1.45; pointer-events: none;
}
.tip-text::after {
    content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
    border: 6px solid transparent; border-top-color: #1e293b;
}
.tip-text.tip-right { left: 0; transform: translateX(0); }
.tip-text.tip-right::after { left: 12px; transform: none; }
.tip-text.tip-left { left: auto; right: 0; transform: translateX(0); }
.tip-text.tip-left::after { left: auto; right: 12px; transform: none; }
.tooltip-wrap:hover .tip-text { visibility: visible; opacity: 1; }

.section-help {
    width: 20px; height: 20px; border-radius: 50%;
    background: linear-gradient(135deg, rgba(56,189,248,0.12), rgba(129,140,248,0.12));
    color: var(--accent-blue); font-size: 0.7rem; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
    cursor: help; border: 1px solid rgba(56,189,248,0.2); margin-left: 0.5rem; transition: all 0.2s;
}
.section-help:hover { background: rgba(56,189,248,0.25); transform: scale(1.15); box-shadow: var(--shadow-glow); }

.btn-tooltip-wrap { position: relative; display: inline-flex; }
.btn-tip {
    visibility: hidden; opacity: 0; position: absolute; top: calc(100% + 8px); left: 50%;
    transform: translateX(-50%); background: #1e293b; color: var(--text-main);
    font-size: 0.74rem; padding: 0.4rem 0.7rem; border-radius: 8px; white-space: nowrap;
    max-width: 240px; z-index: 200; border: 1px solid var(--border-glow);
    box-shadow: var(--shadow-md); transition: opacity 0.2s, visibility 0.2s; pointer-events: none;
}
.btn-tip::before {
    content: ''; position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
    border: 5px solid transparent; border-bottom-color: #1e293b;
}
.btn-tooltip-wrap:hover .btn-tip { visibility: visible; opacity: 1; }

/* ----- BUTTONS ----- */
.btn {
    display: inline-flex; align-items: center; gap: 0.5rem;
    padding: 0.55rem 1.2rem; border: none; border-radius: 8px;
    font-family: inherit; font-size: 0.86rem; font-weight: 600; cursor: pointer;
    transition: all 0.2s var(--ease-out); text-decoration: none; white-space: nowrap;
    position: relative; overflow: hidden;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.98); }

.btn-primary {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-indigo));
    color: #fff; box-shadow: 0 3px 12px rgba(56, 189, 248, 0.25);
}
.btn-primary:hover { box-shadow: 0 6px 20px rgba(56, 189, 248, 0.35); color: #fff; }

.btn-success { background: linear-gradient(135deg, #22c55e, #16a34a); color: #fff; }
.btn-success:hover { box-shadow: 0 4px 14px rgba(34,197,94,0.3); color: #fff; }

.btn-danger {
    background: rgba(239, 68, 68, 0.12); border: 1px solid rgba(239, 68, 68, 0.25); color: var(--error);
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.22); }

.btn-secondary {
    background: rgba(148, 163, 184, 0.1); border: 1px solid var(--border-subtle); color: var(--text-muted);
}
.btn-secondary:hover { color: var(--text-main); border-color: rgba(148, 163, 184, 0.3); background: rgba(148, 163, 184, 0.15); }

.btn-warning { background: rgba(245, 158, 11, 0.12); border: 1px solid rgba(245, 158, 11, 0.25); color: var(--warning); }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.76rem; border-radius: 6px; }
.btn-full { width: 100%; justify-content: center; }
.btn.loading { pointer-events: none; opacity: 0.7; }

/* ----- TABLES ----- */
.table-wrap { overflow-x: auto; border-radius: 10px; border: 1px solid var(--border-glow); }
/*
 * .table-wrapper is the class used by SMA admin views (settings, testing,
 * diagnostics, dashboard, projects/show). It needs the same overflow-x
 * behavior as .table-wrap so wide tables scroll horizontally on mobile
 * instead of breaking the page layout.
 */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 10px;
}
.table-wrapper .data-table { min-width: 720px; }
@media (max-width: 480px) {
    .table-wrapper .data-table { font-size: .78rem; }
    .table-wrapper .data-table th,
    .table-wrapper .data-table td { padding: .5rem .6rem; white-space: nowrap; }
    .table-wrapper .data-table td.wrap-cell,
    .table-wrapper .data-table th.wrap-cell { white-space: normal; }
}
table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
thead { background: rgba(8, 15, 30, 0.95); position: sticky; top: 0; z-index: 5; }
th {
    padding: 0.7rem 1rem; text-align: left; font-weight: 600;
    color: var(--text-faint); font-size: 0.72rem; text-transform: uppercase;
    letter-spacing: 0.06em; border-bottom: 1px solid var(--border-glow); white-space: nowrap;
    user-select: none;
}
th[data-sortable] { cursor: pointer; }
th[data-sortable]:hover { color: var(--accent-blue); }
th[data-sort-dir="asc"]::after { content: ' \2191'; color: var(--accent-blue); }
th[data-sort-dir="desc"]::after { content: ' \2193'; color: var(--accent-blue); }

td {
    padding: 0.65rem 1rem; border-bottom: 1px solid rgba(148, 163, 184, 0.06);
    vertical-align: middle;
}

/* Clickable rows */
tr[data-href] { cursor: pointer; transition: background 0.15s, transform 0.15s; }
tr[data-href]:hover {
    background: rgba(56, 189, 248, 0.04);
    box-shadow: inset 3px 0 0 var(--accent-blue);
}
tr[data-href]:active { background: rgba(56, 189, 248, 0.08); }

/* Amount cells */
td.cell-amount { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }
td.cell-date { white-space: nowrap; font-variant-numeric: tabular-nums; }
td.cell-truncate { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ----- BADGES ----- */
.badge {
    display: inline-flex; align-items: center; gap: 0.25rem;
    padding: 0.2rem 0.65rem; border-radius: 20px;
    font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
    transition: transform 0.15s; white-space: nowrap;
}

.badge-draft       { background: rgba(148, 163, 184, 0.15); color: var(--text-muted); }
.badge-submitted   { background: rgba(56, 189, 248, 0.15);  color: var(--accent-blue); }
.badge-needs_review { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-approved    { background: rgba(34, 197, 94, 0.15);   color: var(--success); }
.badge-rejected    { background: rgba(239, 68, 68, 0.15);   color: var(--error); }
.badge-reimbursed  { background: rgba(129, 140, 248, 0.15); color: var(--accent-indigo); }
.badge-active      { background: rgba(34, 197, 94, 0.15);   color: var(--success); }
.badge-disabled    { background: rgba(239, 68, 68, 0.15);   color: var(--error); }
.badge-locked      { background: rgba(245, 158, 11, 0.15);  color: var(--warning); }
.badge-super_admin { background: rgba(253, 224, 71, 0.12);  color: var(--accent-yellow); }
.badge-admin       { background: rgba(129, 140, 248, 0.15); color: var(--accent-indigo); }
.badge-employee    { background: rgba(56, 189, 248, 0.15);  color: var(--accent-blue); }
.badge-clocked_in  { background: rgba(34, 197, 94, 0.15);   color: var(--success); }
.badge-clocked_out { background: rgba(148, 163, 184, 0.15); color: var(--text-muted); }
.badge-corrected   { background: rgba(245, 158, 11, 0.15);  color: var(--warning); }

/* ----- FLASH / TOAST ----- */
.flash-message {
    padding: 0.7rem 1rem; border-radius: 10px; margin-bottom: 0.75rem;
    font-size: 0.86rem; font-weight: 500; display: flex; align-items: center; gap: 0.5rem;
    animation: flashIn 0.3s var(--ease-out);
}
@keyframes flashIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
.flash-success { background: rgba(34, 197, 94, 0.1); border: 1px solid rgba(34, 197, 94, 0.25); color: var(--success); }
.flash-error   { background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.25); color: var(--error); }
.flash-warning { background: rgba(245, 158, 11, 0.1); border: 1px solid rgba(245, 158, 11, 0.25); color: var(--warning); }
.flash-info    { background: rgba(56, 189, 248, 0.1); border: 1px solid rgba(56, 189, 248, 0.25); color: var(--accent-blue); }
.flash-close { background: none; border: none; color: inherit; font-size: 1.2rem; cursor: pointer; opacity: 0.5; margin-left: auto; padding: 0; line-height: 1; transition: opacity 0.2s; }
.flash-close:hover { opacity: 1; }
.flash-icon { font-size: 1rem; flex-shrink: 0; }
.flash-text { flex: 1; }

/* ----- PAGINATION ----- */
.pagination {
    display: flex; align-items: center; gap: 0.3rem; margin-top: 1rem; justify-content: center; flex-wrap: wrap;
}
.pagination a, .pagination span {
    padding: 0.4rem 0.7rem; border-radius: 6px; font-size: 0.8rem; font-weight: 500; transition: all 0.2s;
    min-width: 34px; text-align: center;
}
.pagination a { background: rgba(56, 189, 248, 0.06); border: 1px solid rgba(56, 189, 248, 0.12); color: var(--text-muted); }
.pagination a:hover { background: rgba(56, 189, 248, 0.15); color: var(--text-main); transform: translateY(-1px); }
.pagination .active { background: linear-gradient(135deg, var(--accent-blue), var(--accent-indigo)); color: #fff; border: none; }
.pagination .disabled { opacity: 0.3; pointer-events: none; }

/* ----- UPLOAD ZONE ----- */
.upload-zone {
    border: 2px dashed var(--border-glow); border-radius: 12px;
    padding: 2rem 1.5rem; text-align: center; cursor: pointer;
    transition: all 0.3s var(--ease-out); position: relative;
    background: rgba(56, 189, 248, 0.02);
}
.upload-zone:hover, .upload-zone.drag-over {
    border-color: var(--accent-blue); background: rgba(56, 189, 248, 0.06);
    box-shadow: 0 0 25px rgba(56, 189, 248, 0.1); transform: scale(1.005);
}
.upload-zone .upload-icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.upload-zone p { color: var(--text-muted); font-size: 0.88rem; }
.upload-zone .formats { font-size: 0.75rem; color: var(--text-faint); margin-top: 0.4rem; }
.upload-zone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.file-preview {
    display: flex; align-items: center; gap: 0.75rem;
    margin-top: 0.6rem; padding: 0.65rem 0.85rem;
    background: rgba(56, 189, 248, 0.05); border: 1px solid var(--border-subtle);
    border-radius: 10px; transition: background 0.2s;
}
.file-preview:hover { background: rgba(56, 189, 248, 0.08); }
.file-preview img {
    width: 48px; height: 48px; object-fit: cover; border-radius: 8px;
    border: 1px solid var(--border-glow); cursor: pointer; transition: transform 0.2s;
}
.file-preview img:hover { transform: scale(1.1); }
.file-preview .file-info { flex: 1; min-width: 0; }
.file-preview .file-name { font-weight: 500; font-size: 0.84rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-preview .file-size { font-size: 0.72rem; color: var(--text-faint); }

/* ----- COLLAPSIBLE ----- */
.collapsible-toggle {
    display: flex; align-items: center; gap: 0.5rem; width: 100%;
    background: none; border: none; color: var(--accent-blue);
    font-family: inherit; font-size: 0.86rem; font-weight: 500;
    cursor: pointer; padding: 0.75rem 0 0.5rem; transition: color 0.2s;
}
.collapsible-toggle:hover { color: var(--accent-indigo); }
.collapsible-toggle .arrow { transition: transform 0.3s var(--ease-out); font-size: 0.7rem; }
.collapsible-toggle.open .arrow { transform: rotate(90deg); }
.collapsible-content { max-height: 0; overflow: hidden; transition: max-height 0.4s var(--ease-out); }
.collapsible-content.open { max-height: 1000px; overflow: visible; }

/* ----- FILTER BAR ----- */
.filter-bar {
    display: flex; flex-wrap: wrap; gap: 0.65rem; align-items: flex-end;
    padding: 0.85rem; background: rgba(8, 15, 30, 0.4);
    border-radius: 10px; border: 1px solid var(--border-subtle);
}
.filter-bar .form-group { margin-bottom: 0; min-width: 140px; flex: 1; }
.filter-bar label { font-size: 0.68rem; margin-bottom: 0.15rem; }
.filter-bar input, .filter-bar select { padding: 0.42rem 0.6rem; font-size: 0.8rem; }

/* Quick date presets */
.filter-presets { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.filter-preset {
    padding: 0.25rem 0.6rem; font-size: 0.7rem; border-radius: 5px;
    background: rgba(56,189,248,0.08); border: 1px solid rgba(56,189,248,0.15);
    color: var(--text-muted); cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.filter-preset:hover { background: rgba(56,189,248,0.15); color: var(--text-main); }
.filter-preset.active { background: var(--accent-blue); color: #fff; border-color: var(--accent-blue); }
.active-filter-count {
    padding: 0.15rem 0.5rem; border-radius: 10px; font-size: 0.65rem; font-weight: 700;
    background: var(--accent-blue); color: #fff; margin-left: 0.3rem;
}

/* ----- CLOCK WIDGET ----- */
.clock-widget {
    display: flex; align-items: center; gap: 1rem; padding: 1rem 1.15rem;
    background: rgba(56, 189, 248, 0.04); border: 1px solid rgba(56, 189, 248, 0.12);
    border-radius: 12px; transition: border-color 0.3s;
}
.clock-widget:hover { border-color: rgba(56, 189, 248, 0.25); }
.clock-status { font-size: 0.84rem; flex: 1; }
.clock-status strong { color: var(--accent-blue); }
.clock-time { font-size: 0.75rem; color: var(--text-faint); }

/* ----- RECEIPT DETAIL ----- */
.receipt-preview {
    max-width: 100%; max-height: 400px; border-radius: 10px;
    border: 1px solid var(--border-glow); object-fit: contain;
    background: rgba(0,0,0,0.3); cursor: zoom-in;
}
.detail-grid { display: grid; grid-template-columns: 140px 1fr; gap: 0.4rem 1rem; font-size: 0.86rem; }
.detail-grid dt { color: var(--text-faint); font-weight: 500; }
.detail-grid dd { color: var(--text-main); }

/* ----- GUEST LAYOUT ----- */
.guest-layout { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 2rem; }
.guest-card { width: 100%; max-width: 420px; }
.guest-card .brand-header { text-align: center; margin-bottom: 2rem; }
.guest-card .brand-header h1 {
    font-size: 1.75rem; font-weight: 700;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-indigo));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.guest-card .brand-header p { color: var(--text-muted); font-size: 0.88rem; margin-top: 0.3rem; }

/* ----- MODALS ----- */
.modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(2, 6, 23, 0.85); backdrop-filter: blur(8px);
    z-index: 1000; align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.25s;
}
.modal-overlay.visible { display: flex; opacity: 1; }
.modal-box {
    background: var(--bg-dark); border: 1px solid var(--border-glow); border-radius: 16px;
    padding: 2rem; max-width: 520px; width: 90%; max-height: 80vh; overflow-y: auto;
    box-shadow: var(--shadow-xl); transform: scale(0.95); transition: transform 0.25s var(--ease-spring);
}
.modal-overlay.visible .modal-box { transform: scale(1); }

/* ----- LIGHTBOX ----- */
.lightbox-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.92); z-index: 5000;
    align-items: center; justify-content: center; flex-direction: column;
    cursor: zoom-out; animation: lbFadeIn 0.25s;
}
.lightbox-overlay.visible { display: flex; }
@keyframes lbFadeIn { from { opacity: 0; } to { opacity: 1; } }

.lightbox-img {
    max-width: 90vw; max-height: 80vh; object-fit: contain;
    border-radius: 8px; box-shadow: 0 0 60px rgba(0,0,0,0.6);
    transition: transform 0.3s var(--ease-out); cursor: default;
}
.lightbox-controls {
    position: fixed; bottom: 2rem; left: 50%; transform: translateX(-50%);
    display: flex; gap: 0.5rem; z-index: 5001;
}
.lightbox-btn {
    padding: 0.5rem 1rem; border-radius: 8px; font-size: 0.85rem; font-weight: 600;
    cursor: pointer; border: 1px solid rgba(255,255,255,0.2);
    background: rgba(15,23,42,0.9); color: #fff; backdrop-filter: blur(8px);
    transition: all 0.2s;
}
.lightbox-btn:hover { background: rgba(56,189,248,0.3); border-color: var(--accent-blue); }
.lightbox-close {
    position: fixed; top: 1.5rem; right: 1.5rem;
    width: 40px; height: 40px; border-radius: 50%;
    background: rgba(15,23,42,0.8); color: #fff; border: 1px solid rgba(255,255,255,0.2);
    font-size: 1.3rem; cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all 0.2s; z-index: 5001;
}
.lightbox-close:hover { background: rgba(239,68,68,0.4); }
.lightbox-nav {
    position: fixed; top: 50%; transform: translateY(-50%);
    width: 44px; height: 44px; border-radius: 50%;
    background: rgba(15,23,42,0.8); color: #fff; border: 1px solid rgba(255,255,255,0.15);
    font-size: 1.2rem; cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all 0.2s; z-index: 5001;
}
.lightbox-nav:hover { background: rgba(56,189,248,0.3); }
.lightbox-prev { left: 1.5rem; }
.lightbox-next { right: 1.5rem; }

/* ----- ACTION BUTTONS ----- */
.action-btns { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.row-actions { display: flex; gap: 0.3rem; opacity: 0.7; transition: opacity 0.2s; }
tr:hover .row-actions { opacity: 1; }

/* ----- LOADING ----- */
.loading-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(2, 6, 23, 0.88); backdrop-filter: blur(8px);
    z-index: 2000; align-items: center; justify-content: center;
    flex-direction: column; gap: 1rem;
}
.loading-overlay.visible { display: flex; }
.loading-overlay p { color: var(--text-muted); font-size: 0.92rem; }
.loading-spinner {
    width: 44px; height: 44px; border: 3px solid rgba(56,189,248,0.15);
    border-top-color: var(--accent-blue); border-radius: 50%; animation: spin 0.7s linear infinite;
}
.spinner-inline {
    display: inline-block; width: 14px; height: 14px;
    border: 2px solid rgba(255,255,255,0.25); border-top-color: #fff;
    border-radius: 50%; animation: spin 0.6s linear infinite; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ----- TOAST SYSTEM ----- */
.toast-container {
    position: fixed; top: 1rem; right: 1rem; z-index: 3000;
    display: flex; flex-direction: column; gap: 0.5rem; max-width: 400px; width: 100%;
    pointer-events: none;
}
.toast {
    display: flex; align-items: flex-start; gap: 0.65rem;
    padding: 0.8rem 1rem; border-radius: 12px; backdrop-filter: blur(16px);
    box-shadow: var(--shadow-lg); pointer-events: all;
    transform: translateX(120%); transition: transform 0.3s var(--ease-out), opacity 0.3s;
    opacity: 0; position: relative; overflow: hidden;
}
.toast-visible { transform: translateX(0); opacity: 1; }
.toast-exit { transform: translateX(120%); opacity: 0; }
.toast-success { background: rgba(15,23,42,0.95); border: 1px solid rgba(34,197,94,0.35); }
.toast-error   { background: rgba(15,23,42,0.95); border: 1px solid rgba(239,68,68,0.35); }
.toast-warning { background: rgba(15,23,42,0.95); border: 1px solid rgba(245,158,11,0.35); }
.toast-info    { background: rgba(15,23,42,0.95); border: 1px solid rgba(56,189,248,0.35); }
.toast-success .toast-icon { color: var(--success); }
.toast-error .toast-icon   { color: var(--error); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info .toast-icon    { color: var(--accent-blue); }
.toast-icon { flex-shrink: 0; margin-top: 1px; }
.toast-body { flex: 1; min-width: 0; }
.toast-message { font-size: 0.86rem; color: var(--text-main); font-weight: 500; line-height: 1.4; }
.toast-close { background: none; border: none; color: var(--text-faint); cursor: pointer; font-size: 1.1rem; padding: 0; line-height: 1; opacity: 0.5; transition: opacity 0.2s; }
.toast-close:hover { opacity: 1; }
.toast-progress { height: 2px; background: rgba(255,255,255,0.08); border-radius: 2px; margin-top: 0.4rem; overflow: hidden; }
.toast-progress-bar { height: 100%; background: currentColor; opacity: 0.4; border-radius: 2px; animation: toast-shrink linear forwards; }
@keyframes toast-shrink { from { width: 100%; } to { width: 0%; } }
.upload-progress-bar-wrap { height: 5px; background: rgba(56,189,248,0.12); border-radius: 5px; margin-top: 0.4rem; overflow: hidden; }
.upload-progress-fill { height: 100%; background: var(--accent-blue); border-radius: 5px; transition: width 0.3s; }
.upload-progress-text { font-size: 0.68rem; color: var(--accent-blue); margin-top: 0.15rem; }

/* Confirm dialog */
.confirm-overlay {
    position: fixed; inset: 0; background: rgba(2,6,23,0.85); backdrop-filter: blur(8px);
    z-index: 3500; display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.2s;
}
.confirm-visible { opacity: 1; }
.confirm-box {
    background: var(--bg-dark); border: 1px solid var(--border-glow); border-radius: 16px;
    padding: 2rem; max-width: 400px; width: 90%; text-align: center; box-shadow: var(--shadow-xl);
}
.confirm-danger { border-color: rgba(239,68,68,0.35); }
.confirm-icon { margin-bottom: 0.75rem; color: var(--accent-blue); }
.confirm-danger .confirm-icon { color: var(--error); }
.confirm-title { font-size: 1.1rem; margin-bottom: 0.4rem; }
.confirm-message { font-size: 0.86rem; color: var(--text-muted); margin-bottom: 1.25rem; line-height: 1.5; }
.confirm-actions { display: flex; gap: 0.65rem; justify-content: center; }

/* ----- NOTIFICATION BELL ----- */
.notif-bell-wrap { position: relative; }
.notif-bell-btn {
    background: none; border: none; color: var(--text-muted); cursor: pointer;
    font-size: 1.25rem; padding: 0.3rem; position: relative; transition: color 0.2s;
}
.notif-bell-btn:hover { color: var(--accent-blue); transform: scale(1.1); }
.notif-badge {
    position: absolute; top: -4px; right: -6px; background: var(--error);
    color: #fff; font-size: 0.55rem; font-weight: 700; padding: 1px 5px;
    border-radius: 10px; min-width: 16px; text-align: center; line-height: 1.4;
    animation: badgePulse 2s infinite;
}
.notif-dropdown {
    position: absolute; top: calc(100% + 8px); right: -4rem; width: 320px;
    background: var(--bg-dark); border: 1px solid var(--border-glow); border-radius: 12px;
    box-shadow: var(--shadow-xl); display: none; z-index: 300; overflow: hidden;
}
.notif-dropdown-open { display: block; animation: dropIn 0.2s var(--ease-out); }
@keyframes dropIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
.notif-dropdown-header { padding: 0.7rem 1rem; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-subtle); font-size: 0.86rem; }
.notif-dropdown-body { max-height: 280px; overflow-y: auto; }
.notif-empty { padding: 2rem 1rem; text-align: center; color: var(--text-faint); font-size: 0.84rem; }
.notif-item {
    display: flex; align-items: flex-start; gap: 0.65rem; padding: 0.65rem 1rem;
    border-bottom: 1px solid rgba(148,163,184,0.05); text-decoration: none;
    color: var(--text-main); transition: background 0.15s;
}
.notif-item:hover { background: rgba(56,189,248,0.05); }
.notif-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent-blue); flex-shrink: 0; margin-top: 5px; }
.notif-item-content { flex: 1; min-width: 0; }
.notif-item-title { font-size: 0.8rem; font-weight: 500; }
.notif-item-time { font-size: 0.68rem; color: var(--text-faint); margin-top: 2px; }
.notif-dropdown-footer {
    display: block; padding: 0.6rem 1rem; text-align: center; font-size: 0.8rem;
    color: var(--accent-blue); border-top: 1px solid var(--border-subtle); text-decoration: none; transition: background 0.15s;
}
.notif-dropdown-footer:hover { background: rgba(56,189,248,0.05); }
.notification-unread { border-left: 3px solid var(--accent-blue); }

/* ----- RICH TEXT EDITOR ----- */
.rte-toolbar {
    display: flex; align-items: center; gap: 2px; padding: 0.35rem;
    flex-wrap: wrap; /* wrap toolbar buttons on narrow screens */
    background: rgba(8,15,30,0.8); border: 1px solid var(--border-subtle);
    border-bottom: none; border-radius: 8px 8px 0 0;
}
.rte-btn {
    background: none; border: none; color: var(--text-muted); cursor: pointer;
    padding: 0.3rem 0.5rem; border-radius: 4px; font-size: 0.8rem; font-family: inherit; transition: all 0.15s;
}
.rte-btn:hover { background: rgba(56,189,248,0.12); color: var(--text-main); }
.rte-sep { width: 1px; height: 18px; background: var(--border-subtle); margin: 0 3px; }
.rte-editor {
    min-height: 120px; padding: 0.75rem; background: var(--bg-input);
    border: 1px solid var(--border-subtle); border-radius: 0 0 8px 8px;
    color: var(--text-main); font-family: inherit; font-size: 0.88rem;
    line-height: 1.7; outline: none; overflow-y: auto; max-height: 400px;
}
.rte-editor:focus { border-color: var(--accent-blue); box-shadow: 0 0 0 3px rgba(56,189,248,0.12); }
.rte-editor:empty::before { content: attr(placeholder); color: rgba(148,163,184,0.35); white-space: pre-wrap; pointer-events: none; }

/* ----- COLUMN TOGGLER ----- */
.col-toggler-wrap { position: relative; display: inline-block; margin-bottom: 0.5rem; }
.col-toggler-dropdown {
    display: none; position: absolute; top: calc(100% + 4px); right: 0;
    background: var(--bg-dark); border: 1px solid var(--border-glow); border-radius: 10px;
    padding: 0.5rem; min-width: 180px; z-index: 200; box-shadow: var(--shadow-lg);
}
.col-toggler-open { display: block; }
.col-toggler-item {
    display: flex; align-items: center; gap: 0.5rem; padding: 0.3rem 0.5rem;
    font-size: 0.8rem; cursor: pointer; border-radius: 4px; transition: background 0.15s;
}
.col-toggler-item:hover { background: rgba(56,189,248,0.06); }

/* ----- ANNOUNCEMENT STYLES ----- */
.announcement-unread { border-left: 3px solid var(--accent-blue); }
.announcement-body h3, .announcement-body h4 { color: var(--accent-blue); margin: 1rem 0 0.5rem; }
.announcement-body p { margin-bottom: 0.5rem; }
.announcement-body ul, .announcement-body ol { padding-left: 1.5rem; margin-bottom: 0.75rem; }

/* ----- UTILITIES ----- */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--text-muted); }
.text-faint  { color: var(--text-faint); }
.text-success { color: var(--success); }
.text-error  { color: var(--error); }
.text-warning { color: var(--warning); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.d-flex { display: flex; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.hidden { display: none !important; }

/* ----- MOBILE: CARD-BASED TABLES ----- */
@media (max-width: 640px) {
    .table-wrap.responsive-cards table,
    .table-wrap.responsive-cards thead { display: none; }
    .table-wrap.responsive-cards { border: none; }

    .mobile-cards { display: flex; flex-direction: column; gap: 0.6rem; }
    .mobile-card {
        background: var(--bg-card); border: 1px solid var(--border-glow);
        border-radius: 10px; padding: 1rem; transition: border-color 0.2s;
    }
    .mobile-card:hover { border-color: rgba(56,189,248,0.3); }
    .mobile-card-row { display: flex; justify-content: space-between; padding: 0.2rem 0; font-size: 0.84rem; }
    .mobile-card-label { color: var(--text-faint); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; }
    .mobile-card-actions { display: flex; gap: 0.4rem; margin-top: 0.5rem; padding-top: 0.5rem; border-top: 1px solid var(--border-subtle); }
}

/* ----- RESPONSIVE BREAKPOINTS ----- */
@media (max-width: 1024px) {
    .page-content { padding: 1.25rem 1.5rem; }
    .stats-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); width: 280px; z-index: 200; }
    .sidebar.mobile-open { transform: translateX(0); box-shadow: var(--shadow-xl); }
    .main-content { margin-left: 0; }
    .page-content {
        padding: 0.85rem 0.9rem;
        padding-bottom: calc(0.85rem + env(safe-area-inset-bottom, 0px));
        width: 100%;
        max-width: 100%;
    }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .top-bar {
        padding: 0.65rem 1rem;
        padding-left: max(1rem, env(safe-area-inset-left, 0px));
        padding-right: max(1rem, env(safe-area-inset-right, 0px));
    }
    .top-bar h1 { font-size: 1.05rem; }
    .top-bar-user .user-name, .top-bar-user .user-role { display: none; }
    .form-row { grid-template-columns: 1fr; }
    .form-row-3 { grid-template-columns: 1fr; }
    .detail-grid { grid-template-columns: 110px 1fr; }

    /* Filter bar stacks on mobile */
    .filter-bar { flex-direction: column; }
    .filter-bar .form-group { min-width: 100%; }

    /* Period filter wraps on smaller tablets */
    .chart-period-btns { grid-template-columns: repeat(5, 1fr); }
}

@media (max-width: 520px) {
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .action-btns { flex-direction: column; }
    .action-btns .btn { width: 100%; justify-content: center; }
    .toast-container { right: 0.5rem; left: 0.5rem; max-width: none; }
    .notif-dropdown { right: -2rem; width: 90vw; max-width: 320px; }
}

@media (max-width: 400px) {
    .stats-grid { grid-template-columns: 1fr; }
    .chart-period-btns { grid-template-columns: repeat(3, 1fr); }
}

.mobile-menu-btn {
    display: none; background: none; border: none; color: var(--text-main);
    font-size: 1.4rem; cursor: pointer; padding: 0.4rem; transition: color 0.2s;
    min-width: 44px; min-height: 44px; align-items: center; justify-content: center;
}
.mobile-menu-btn:hover { color: var(--accent-blue); }
@media (max-width: 768px) { .mobile-menu-btn { display: flex; } }

/* Prevent horizontal overflow on mobile */
html, body { overflow-x: hidden; max-width: 100vw; }

/* iOS: prevent input zoom (must be 16px+) */
@media (max-width: 768px) {
    input, select, textarea { font-size: 16px !important; }
}

/* iOS safe-area for sidebar */
@supports (padding: env(safe-area-inset-left)) {
    .sidebar {
        padding-top: max(1.25rem, env(safe-area-inset-top));
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Better touch targets for nav links */
@media (max-width: 768px) {
    .sidebar-nav li a { padding: 0.75rem 1.25rem; min-height: 44px; }
    .btn { min-height: 44px; }
    .btn-sm { min-height: 36px; }
    .logout-btn { min-height: 40px; }
}

/* ============================================================
   EXPENSE TREND CHART — period filter buttons & container
   ============================================================ */
.chart-period-btns {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 0.35rem;
    margin-bottom: 0.9rem;
}

.period-btn {
    padding: 0.42rem 0.3rem;
    background: rgba(56, 189, 248, 0.06);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s var(--ease-out);
    text-align: center;
    white-space: nowrap;
    font-family: inherit;
    letter-spacing: 0.02em;
    line-height: 1.2;
}

.period-btn:hover {
    background: rgba(56, 189, 248, 0.14);
    color: var(--text-main);
    border-color: rgba(56, 189, 248, 0.3);
    transform: translateY(-1px);
}

.period-btn.active {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-indigo));
    border-color: transparent;
    color: #fff;
    box-shadow: 0 2px 10px rgba(56, 189, 248, 0.35);
}

[data-theme="light"] .period-btn { background: rgba(2,132,199,0.06); border-color: rgba(148,163,184,0.2); color: #475569; }
[data-theme="light"] .period-btn:hover { background: rgba(2,132,199,0.12); color: #0f172a; }
[data-theme="light"] .period-btn.active { background: linear-gradient(135deg, #0284c7, #6366f1); color: #fff; }

.chart-custom-range {
    display: none;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: flex-end;
    margin-bottom: 0.75rem;
}
.chart-custom-range.visible { display: flex; }

.chart-container {
    position: relative;
    width: 100%;
    min-height: 200px;
}

#expenseChart { width: 100%; }

.chart-empty {
    display: flex; align-items: center; justify-content: center;
    height: 200px; color: var(--text-faint); font-size: 0.86rem;
    flex-direction: column; gap: 0.5rem;
}

.chart-total-label {
    font-size: 0.72rem; color: var(--text-faint); font-weight: 500;
    padding: 0.2rem 0.65rem; border-radius: 20px;
    background: rgba(56, 189, 248, 0.1); border: 1px solid rgba(56, 189, 248, 0.15);
}

/* ----- PRINT STYLESHEET ----- */
@media print {
    body { background: #fff; color: #000; }
    .sidebar, .top-bar, .filter-bar, .action-btns, .btn, .pagination,
    .toast-container, .loading-overlay, .mobile-menu-btn, .notif-bell-wrap { display: none !important; }
    .main-content { margin-left: 0; }
    .card { background: #fff; border: 1px solid #ddd; box-shadow: none; backdrop-filter: none; break-inside: avoid; }
    table { font-size: 10pt; }
    th { background: #f0f0f0; color: #333; }
    .badge { border: 1px solid #999; color: #333; background: #eee; }
    a { color: #000; text-decoration: none; }
}
/* ----- MOBILE FAB (Floating Action Button) ----- */
.mob-fab {
    display: none;
    position: fixed;
    bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
    right: 1.25rem;
    width: 58px; height: 58px;
    border-radius: 50%;
    background: linear-gradient(135deg, #38bdf8, #818cf8);
    color: #fff;
    font-size: 2rem;
    font-weight: 300;
    text-decoration: none;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(56,189,248,0.45);
    z-index: 900;
    transition: transform 0.15s, box-shadow 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.mob-fab:active { transform: scale(0.93); box-shadow: 0 2px 10px rgba(56,189,248,0.3); }
@media (max-width: 768px) {
    .mob-fab { display: flex; }
    /* don't show on the create page itself */
    body.page-expenses-create .mob-fab { display: none; }
}

/* ----- HOURS CHART (secondary chart) ----- */
#hoursChart { width: 100%; }

/* ============================================================
   CSS VARIABLE ALIASES & MISSING VARS (v4.0 additions)
   ============================================================ */
:root {
    /* --card-bg is used in some views; --bg-card is canonical */
    --card-bg: var(--bg-card);
    /* Adaptive values that flip correctly in light theme */
    --border-inset: rgba(255, 255, 255, 0.07);
    --bg-row-alt: rgba(255, 255, 255, 0.03);
    --progress-track-bg: rgba(255, 255, 255, 0.08);
    --border-divider: rgba(255, 255, 255, 0.06);
    --radius: 10px;
}
[data-theme="light"] {
    --card-bg: var(--bg-card);
    --border-inset: rgba(0, 0, 0, 0.07);
    --bg-row-alt: rgba(0, 0, 0, 0.02);
    --progress-track-bg: rgba(0, 0, 0, 0.07);
    --border-divider: rgba(148, 163, 184, 0.15);
}

/* ============================================================
   LIGHT THEME — Fixes for hardcoded inline rgba(255,255,255,X)
   ============================================================ */

/* Schedule calendar table header */
[data-theme="light"] .sched-table thead tr { background: rgba(241,245,249,0.98) !important; }
[data-theme="light"] .sched-table tfoot tr { background: rgba(241,245,249,0.98) !important; }

/* Schedule row hover */
[data-theme="light"] .sched-row:hover { background: rgba(2,132,199,0.03); }

/* Shift action buttons */
[data-theme="light"] .shift-actions .btn {
    background: rgba(0,0,0,0.06) !important;
    color: var(--text-muted) !important;
}
/* Empty cell add button */
[data-theme="light"] .add-cell-btn {
    border-color: rgba(0,0,0,0.12) !important;
    color: var(--text-faint);
}

/* My Schedule — empty day card */
[data-theme="light"] .day-card-empty {
    background: rgba(0,0,0,0.015) !important;
    border-color: rgba(0,0,0,0.07) !important;
}
/* My Schedule — notes separator inside shift block */
[data-theme="light"] .shift-note-sep { border-top-color: rgba(0,0,0,0.07) !important; }

/* Progress bar tracks (white glass → light gray in light theme) */
[data-theme="light"] .progress-track,
[data-theme="light"] .schedule-progress-track,
[data-theme="light"] .leave-progress-track,
[data-theme="light"] .project-progress-track { background: rgba(0,0,0,0.07) !important; }

/* Table row dividers */
[data-theme="light"] .card table tbody tr { border-bottom-color: rgba(148,163,184,0.12); }

/* Stats strip inner borders */
[data-theme="light"] .stats-strip-item + .stats-strip-item {
    border-left-color: rgba(148,163,184,0.2);
}

/* Schedule report adherence ring */
[data-theme="light"] .adherence-ring-bg { stroke: rgba(0,0,0,0.08) !important; }

/* Modal improvements in light */
[data-theme="light"] .modal-box {
    box-shadow: 0 8px 40px rgba(0,0,0,0.15), 0 2px 8px rgba(0,0,0,0.08);
}

/* Leave type colors in light */
[data-theme="light"] .leave-type-vacation { color: #0369a1; }
[data-theme="light"] .leave-type-sick     { color: #b91c1c; }
[data-theme="light"] .leave-type-personal { color: #7c3aed; }
[data-theme="light"] .leave-type-unpaid   { color: #475569; }

/* Card gradient headers */
[data-theme="light"] .card-gradient-header {
    background: linear-gradient(135deg, rgba(2,132,199,0.06) 0%, rgba(99,102,241,0.04) 100%) !important;
}

/* Payroll project breakdown rows */
[data-theme="light"] .payroll-breakdown-row {
    background: rgba(241,245,249,0.5) !important;
    border-top-color: rgba(148,163,184,0.1) !important;
}

/* Report stat card titles */
[data-theme="light"] .sched-table tbody tr:nth-child(even) {
    background: rgba(241,245,249,0.35);
}

/* ============================================================
   ANNOUNCEMENT STYLING (v4.0)
   ============================================================ */
.announcement-card {
    transition: transform 0.15s var(--ease-out), box-shadow 0.15s var(--ease-out);
    cursor: pointer;
}
.announcement-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}
.announcement-unread { border-left: 3px solid var(--accent-blue) !important; }
[data-theme="light"] .announcement-unread { background: rgba(2,132,199,0.025) !important; }
.announcement-priority-urgent   { border-left: 3px solid var(--error) !important; }
.announcement-priority-important { border-left: 3px solid var(--warning) !important; }

/* Announcement body typography */
.announcement-body { line-height: 1.8; }
.announcement-body img { max-width: 100%; border-radius: 6px; margin: 0.5rem 0; }
.announcement-body h1, .announcement-body h2, .announcement-body h3 {
    color: var(--text-main); margin: 0.75rem 0 0.25rem;
}
.announcement-body ul, .announcement-body ol { padding-left: 1.5rem; }
.announcement-body p { margin-bottom: 0.65rem; }
.announcement-body a { color: var(--accent-blue); text-decoration: underline; }

/* Read-by stats pill */
.ann-read-stat {
    display: inline-flex; align-items: center; gap: 0.3rem;
    font-size: 0.72rem; padding: 0.15rem 0.5rem; border-radius: 20px;
    background: rgba(34,197,94,0.12); color: var(--success);
    border: 1px solid rgba(34,197,94,0.2);
}
[data-theme="light"] .ann-read-stat {
    background: rgba(22,163,74,0.08); border-color: rgba(22,163,74,0.2);
}

/* ============================================================
   HORIZONTAL SCROLL CONTAINERS (schedule, payroll tables)
   ============================================================ */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 0 0 var(--radius) var(--radius);
}
.table-responsive::-webkit-scrollbar { height: 4px; }
.table-responsive::-webkit-scrollbar-track {
    background: var(--bg-row-alt); border-radius: 2px;
}
.table-responsive::-webkit-scrollbar-thumb {
    background: var(--accent-blue); border-radius: 2px; opacity: 0.6;
}

.scroll-hint {
    display: none; font-size: 0.7rem;
    color: var(--text-faint); text-align: right;
    padding: 0.15rem 0.5rem 0; margin-bottom: 0.35rem;
}
@media (max-width: 768px) { .scroll-hint { display: block; } }

/* ============================================================
   MOBILE — Schedule Calendar (sticky employee column)
   ============================================================ */
@media (max-width: 960px) {
    .sched-table th, .sched-table td {
        min-width: 76px; padding: 0.2rem !important; font-size: 0.7rem !important;
    }
    .sched-table th:first-child, .sched-table td:first-child {
        position: sticky; left: 0; z-index: 2;
        background: var(--bg-card); min-width: 100px;
    }
    [data-theme="light"] .sched-table td:first-child,
    [data-theme="light"] .sched-table th:first-child { background: #fff; }
    .shift-block { padding: 0.2rem 0.3rem !important; }
}

/* ============================================================
   MOBILE — My Schedule Day Cards
   ============================================================ */
@media (max-width: 480px) {
    .my-schedule-grid { grid-template-columns: repeat(2, 1fr) !important; }
}

/* ============================================================
   MOBILE — Schedule Report
   ============================================================ */
@media (max-width: 640px) {
    .sched-report-stats { grid-template-columns: repeat(2, 1fr) !important; }
    .sched-adherence-ring { display: none !important; }
    .sched-report-table th:nth-child(n+5),
    .sched-report-table td:nth-child(n+5) { display: none; }
}

/* ============================================================
   MOBILE — Leave & Payroll Tables
   ============================================================ */
@media (max-width: 768px) {
    .payroll-table { font-size: 0.8rem; }
    .payroll-table th:nth-child(n+5),
    .payroll-table td:nth-child(n+5) { min-width: 85px; }
    .leave-admin-table th:nth-child(n+6),
    .leave-admin-table td:nth-child(n+6) { display: none; }
}

/* ============================================================
   MOBILE — Landscape & Orientation
   ============================================================ */
@media (max-width: 844px) and (orientation: landscape) {
    .sidebar { width: 200px; }
    .main-content { margin-left: 200px; }
    .page-content { padding: 0.75rem; }
}

/* ============================================================
   WEB VIEW / PWA / BROWSER COMPATIBILITY
   ============================================================ */

/* Prevent text resize on iOS orientation change */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

/* Smooth scrolling */
html { scroll-behavior: smooth; }

/* Remove tap highlight on all interactive elements */
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }

/* Prevent long-press callout on iOS */
img { -webkit-touch-callout: none; user-select: none; }

/* Safe-area bottom padding for notch phones */
.page-content { padding-bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px)); }

/* Improved focus rings (keyboard navigation accessibility) */
:focus-visible { outline: 2px solid var(--accent-blue); outline-offset: 2px; }
button:focus:not(:focus-visible),
a:focus:not(:focus-visible) { outline: none; }

/* Text selection highlight */
::selection { background: rgba(56,189,248,0.25); color: var(--text-main); }
[data-theme="light"] ::selection { background: rgba(2,132,199,0.18); }

/* Responsive font scaling for small phones */
@media (max-width: 380px) {
    body { font-size: 0.88rem; }
    .card-header h3 { font-size: 0.92rem; }
    .stat-value { font-size: 1.35rem !important; }
    .btn { padding: 0.45rem 0.85rem; font-size: 0.82rem; }
}

/* ============================================================
   UTILITY CLASSES (v4.0 new modules)
   ============================================================ */

/* Module stats grid (schedule report, payroll, leave admin) */
.module-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
    gap: 0.75rem; margin-bottom: 1.25rem;
}
@media (max-width: 480px) { .module-stats-grid { grid-template-columns: repeat(2, 1fr); } }

/* Stat mini card */
.stat-mini {
    background: var(--bg-card); border: 1px solid var(--border-subtle);
    border-radius: 8px; padding: 0.75rem 1rem; text-align: center;
}
.stat-mini-value {
    font-size: 1.5rem; font-weight: 700; color: var(--accent-blue); line-height: 1.1;
}
.stat-mini-label {
    font-size: 0.67rem; text-transform: uppercase;
    letter-spacing: 0.05em; color: var(--text-faint); margin-top: 0.2rem;
}

/* Status indicator dot */
.status-dot {
    display: inline-block; width: 8px; height: 8px;
    border-radius: 50%; flex-shrink: 0; vertical-align: middle; margin-right: 0.25rem;
}
.status-dot-green  { background: var(--success); }
.status-dot-red    { background: var(--error); }
.status-dot-yellow { background: var(--warning); }
.status-dot-blue   { background: var(--accent-blue); }
.status-dot-gray   { background: var(--text-faint); }

/* Outline badge variant */
.badge-outline { background: transparent; border: 1px solid currentColor; }

/* Section label (form section headings) */
.form-section-label {
    font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--text-faint); font-weight: 600;
    margin: 1.25rem 0 0.65rem; padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--border-divider);
}

/* Gap utility */
.gap-half { gap: 0.5rem; }
.gap-05   { gap: 0.35rem; }
.gap-1    { gap: 1rem; }
.gap-2    { gap: 2rem; }
.flex-wrap { flex-wrap: wrap; }

/* ==========================================================
   v4.2 — GLOBAL SEARCH
   ========================================================== */
.global-search { position: relative; display: flex; align-items: center; }
.global-search-toggle {
    background: none; border: none; cursor: pointer; font-size: 1.1rem;
    color: var(--text-muted); padding: 0.3rem; transition: color 0.2s;
}
.global-search-toggle:hover { color: var(--text-main); }

.global-search-box {
    display: none; position: fixed; top: 0; left: 0; right: 0;
    z-index: 9000; background: var(--bg-card); box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    padding: 0.6rem 1rem; border-bottom: 1px solid var(--border-subtle);
}
.global-search-box.open { display: flex; align-items: center; gap: 0.5rem; }

.global-search-box input {
    flex: 1; background: transparent; border: none; outline: none;
    font-size: 1rem; color: var(--text-main); padding: 0.5rem 0;
    font-family: inherit;
}
.global-search-box input::placeholder { color: var(--text-faint); }

.global-search-close {
    background: none; border: none; cursor: pointer; font-size: 1.2rem;
    color: var(--text-faint); padding: 0.3rem; flex-shrink: 0;
}
.global-search-close:hover { color: var(--text-main); }

.search-results {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    background: var(--bg-card); border: 1px solid var(--border-subtle);
    border-top: none; border-radius: 0 0 8px 8px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.25); max-height: 70vh; overflow-y: auto;
    z-index: 9001;
}

.search-group-label {
    padding: 0.5rem 1rem 0.25rem; font-size: 0.68rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-faint);
    border-top: 1px solid var(--border-divider);
}
.search-group-label:first-child { border-top: none; }

.search-result-item {
    display: block; padding: 0.55rem 1rem; text-decoration: none;
    color: var(--text-main); transition: background 0.1s; cursor: pointer;
}
.search-result-item:hover, .search-result-item.active { background: var(--bg-row-alt); }
.search-result-title { font-weight: 600; font-size: 0.88rem; }
.search-result-title mark { background: rgba(56,189,248,0.25); color: inherit; border-radius: 2px; padding: 0 2px; }
.search-result-sub { font-size: 0.75rem; color: var(--text-faint); margin-top: 0.1rem; }

.search-empty {
    padding: 1.5rem 1rem; text-align: center; color: var(--text-faint); font-size: 0.88rem;
}

/* Desktop: inline search box next to other header items */
@media (min-width: 769px) {
    .global-search-box {
        position: absolute; top: calc(100% + 6px); right: 0; left: auto;
        width: 420px; border-radius: 8px; border: 1px solid var(--border-subtle);
        padding: 0.5rem 0.75rem;
    }
    .search-results { border-radius: 0 0 8px 8px; }
}

/* Mobile: full-width top overlay */
@media (max-width: 768px) {
    .global-search-box { padding: 0.5rem 0.75rem; }
    .global-search-box input { font-size: 0.92rem; }
    .search-results { max-height: 60vh; }
}

/* ==========================================================
   v4.2 — LEAVE CALENDAR
   ========================================================== */
.leave-cal-card { border-radius: 8px; }

.leave-cal-header {
    display: grid; grid-template-columns: repeat(7, 1fr);
    background: var(--bg-row-alt); border-bottom: 1px solid var(--border-divider);
}
.leave-cal-day-name {
    text-align: center; padding: 0.5rem 0.25rem; font-size: 0.72rem;
    font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--text-faint);
}

.leave-cal-grid {
    display: grid; grid-template-columns: repeat(7, 1fr);
}

.leave-cal-cell {
    min-height: 80px; padding: 0.3rem; border-right: 1px solid var(--border-divider);
    border-bottom: 1px solid var(--border-divider); position: relative;
    overflow: hidden;
}
.leave-cal-cell:nth-child(7n) { border-right: none; }
.leave-cal-cell-empty { background: var(--bg-row-alt); opacity: 0.5; }
.leave-cal-weekend { background: rgba(148,163,184,0.04); }
.leave-cal-today { background: rgba(56,189,248,0.06); }

.leave-cal-date {
    font-size: 0.75rem; font-weight: 600; color: var(--text-faint);
    padding: 0.15rem 0.25rem; line-height: 1;
}
.leave-cal-date.today {
    background: var(--accent-blue); color: #fff; border-radius: 50%;
    width: 22px; height: 22px; display: flex; align-items: center; justify-content: center;
    font-size: 0.7rem;
}

.leave-cal-block {
    padding: 0.15rem 0.3rem; border-radius: 3px; margin-top: 0.15rem;
    font-size: 0.65rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    cursor: default;
}

.leave-cal-name { font-weight: 600; color: var(--text-main); }

/* Mobile: tighter calendar cells */
@media (max-width: 768px) {
    .leave-cal-cell { min-height: 52px; padding: 0.2rem; }
    .leave-cal-block { font-size: 0.58rem; padding: 0.1rem 0.2rem; }
    .leave-cal-name { display: none; }
    .leave-cal-block::after {
        content: ''; display: inline-block; width: 6px; height: 6px;
        border-radius: 50%; vertical-align: middle;
    }
    .leave-cal-date { font-size: 0.65rem; }
}
@media (max-width: 480px) {
    .leave-cal-cell { min-height: 38px; }
    .leave-cal-day-name { font-size: 0.6rem; padding: 0.35rem 0; }
}

/* ==========================================================
   v4.2 — BULK EXPENSE ACTION BAR
   ========================================================== */
.bulk-action-bar {
    position: fixed; bottom: -80px; left: 50%; transform: translateX(-50%);
    z-index: 6000; transition: bottom 0.3s ease;
    width: calc(100% - 2rem); max-width: 640px;
}
.bulk-action-bar.visible { bottom: 1.5rem; }

.bulk-action-inner {
    background: var(--bg-card); border: 1px solid var(--border-subtle);
    border-radius: 12px; padding: 0.75rem 1rem;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
}

.bulk-count {
    font-weight: 700; font-size: 0.88rem; color: var(--accent-blue);
    white-space: nowrap;
}

.bulk-status-select {
    padding: 0.35rem 0.5rem; font-size: 0.82rem; border-radius: 6px;
    border: 1px solid var(--border-subtle); background: var(--bg-body);
    color: var(--text-main); cursor: pointer; min-width: 140px;
}

@media (max-width: 768px) {
    .bulk-action-bar { width: calc(100% - 1rem); max-width: none; }
    .bulk-action-inner { padding: 0.6rem 0.75rem; gap: 0.5rem; }
    .bulk-count { font-size: 0.78rem; }
    .bulk-status-select { min-width: 120px; font-size: 0.78rem; }
}

/* Light theme adjustments */
[data-theme="light"] .bulk-action-inner {
    box-shadow: 0 4px 20px rgba(0,0,0,0.12);
}
[data-theme="light"] .global-search-box {
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
}
[data-theme="light"] .search-results {
    box-shadow: 0 12px 40px rgba(0,0,0,0.1);
}
[data-theme="light"] .search-result-title mark {
    background: rgba(2,132,199,0.18);
}
[data-theme="light"] .leave-cal-today {
    background: rgba(2,132,199,0.06);
}
[data-theme="light"] .leave-cal-weekend {
    background: rgba(100,116,139,0.04);
}

/* ==========================================================
   v4.2 — CHART VIEW TOGGLE (Day / Month / Year)
   ========================================================== */
.chart-view-toggle {
    display: flex; gap: 0; margin: 0 1rem 0.5rem;
    border: 1px solid var(--border-subtle); border-radius: 6px; overflow: hidden;
    width: fit-content;
}
.chart-view-toggle .view-btn {
    padding: 0.3rem 0.85rem; font-size: 0.75rem; font-weight: 600;
    border: none; background: transparent; color: var(--text-faint);
    cursor: pointer; transition: all 0.2s; text-transform: uppercase;
    letter-spacing: 0.04em;
}
.chart-view-toggle .view-btn.active {
    background: var(--accent-blue); color: #fff;
}
.chart-view-toggle .view-btn:not(.active):hover {
    background: var(--bg-row-alt);
}
.chart-change-badge {
    font-size: 0.78rem; font-weight: 700; letter-spacing: 0.01em;
}
@media (max-width: 480px) {
    .chart-view-toggle { margin: 0 0.5rem 0.4rem; }
    .chart-view-toggle .view-btn { padding: 0.25rem 0.6rem; font-size: 0.68rem; }
}

/* ==========================================================
   v4.2 — DUPLICATE EXPENSE FLAG
   ========================================================== */
.dup-flag {
    display: inline-flex; align-items: center; justify-content: center;
    color: #f59e0b; font-size: 0.92rem; text-decoration: none;
    margin-left: 0.3rem; vertical-align: middle;
    transition: transform 0.15s;
}
.dup-flag:hover { transform: scale(1.2); color: #d97706; }

/* Duplicate banner on expense detail page */
.dup-banner {
    display: flex; align-items: flex-start; gap: 0.6rem;
    background: rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.3);
    border-left: 4px solid #f59e0b; border-radius: 6px;
    padding: 0.75rem 1rem; margin-bottom: 0.75rem;
    color: var(--text-main); font-size: 0.88rem;
}
.dup-banner-icon { font-size: 1.4rem; flex-shrink: 0; line-height: 1; color: #f59e0b; }

/* Inline warning on create form */
.dup-inline-warn {
    background: rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.3);
    border-left: 4px solid #f59e0b; border-radius: 6px;
    padding: 0.6rem 0.85rem; margin: 0.5rem 0; font-size: 0.84rem;
    color: var(--text-main); display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap;
}

[data-theme="light"] .dup-banner {
    background: rgba(245,158,11,0.08); border-color: rgba(245,158,11,0.25);
}
[data-theme="light"] .dup-inline-warn {
    background: rgba(245,158,11,0.08); border-color: rgba(245,158,11,0.25);
}

/* ==========================================================
   v4.3 — PDF PREVIEW
   ========================================================== */
.pdf-preview-stack { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 1rem; }
.pdf-preview-wrap {
    border: 1px solid var(--border-subtle); border-radius: 8px; overflow: hidden;
    background: var(--bg-card);
}
.pdf-preview-toolbar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.5rem 0.75rem; background: var(--bg-row-alt);
    border-bottom: 1px solid var(--border-divider); gap: 0.5rem; flex-wrap: wrap;
}
.pdf-preview-name {
    font-size: 0.82rem; font-weight: 500; color: var(--text-main);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    flex: 1; min-width: 120px;
}
.pdf-preview-frame {
    width: 100%; height: 520px; border: 0; display: block;
    background: #fff;
}
@media (max-width: 768px) {
    .pdf-preview-frame { height: 360px; }
}

/* ==========================================================
   v4.4 — INLINE IMAGE PREVIEW (mirrors PDF preview style)
   ========================================================== */
.img-preview-stack { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 1rem; }
.img-preview-wrap {
    border: 1px solid var(--border-subtle); border-radius: 8px; overflow: hidden;
    background: var(--bg-card);
}
.img-preview-toolbar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.5rem 0.75rem; background: var(--bg-row-alt);
    border-bottom: 1px solid var(--border-divider); gap: 0.5rem; flex-wrap: wrap;
}
.img-preview-name {
    font-size: 0.82rem; font-weight: 500; color: var(--text-main);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    flex: 1; min-width: 120px;
}
.img-preview-frame {
    width: 100%; max-height: 640px; object-fit: contain; display: block;
    background: #0f172a; cursor: zoom-in;
    transition: opacity 0.15s;
}
.img-preview-frame:hover { opacity: 0.95; }
[data-theme="light"] .img-preview-frame { background: #f1f5f9; }
@media (max-width: 768px) {
    .img-preview-frame { max-height: 460px; }
}

/* Fullscreen PDF modal */
.pdf-fs-modal {
    position: fixed; inset: 0; z-index: 9500; background: rgba(0,0,0,0.92);
    display: none; flex-direction: column;
}
.pdf-fs-bar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.6rem 1rem; background: var(--bg-card);
    border-bottom: 1px solid var(--border-subtle); flex-shrink: 0;
}
.pdf-fs-title { font-weight: 600; font-size: 0.92rem; }
.pdf-fs-frame { flex: 1; width: 100%; border: 0; background: #fff; }

/* ==========================================================
   v4.3 — EXPENSE PREV/NEXT NAV BAR
   ========================================================== */
.exp-nav-bar {
    display: flex; justify-content: space-between; align-items: center;
    gap: 0.5rem; padding: 0.55rem 0.85rem; margin-bottom: 0.75rem;
    background: var(--bg-card); border: 1px solid var(--border-subtle);
    border-radius: 8px; flex-wrap: wrap;
}
.exp-nav-btn {
    padding: 0.35rem 0.75rem; font-size: 0.82rem; font-weight: 600;
    color: var(--accent-blue); text-decoration: none; border-radius: 5px;
    transition: background 0.15s;
    display: inline-flex; align-items: center; gap: 0.3rem;
}
.exp-nav-btn:hover { background: var(--bg-row-alt); }
.exp-nav-btn.disabled { color: var(--text-faint); cursor: not-allowed; opacity: 0.5; }
.exp-nav-center {
    display: flex; align-items: center; gap: 0.6rem; flex: 1;
    justify-content: center; font-size: 0.8rem; color: var(--text-muted);
}
.exp-nav-position strong { color: var(--text-main); font-size: 0.92rem; }
.exp-nav-filter-hint {
    background: rgba(56,189,248,0.12); color: var(--accent-blue);
    padding: 0.15rem 0.5rem; border-radius: 12px; font-size: 0.7rem; font-weight: 600;
}
@media (max-width: 520px) {
    .exp-nav-bar { padding: 0.45rem 0.6rem; }
    .exp-nav-btn { padding: 0.3rem 0.55rem; font-size: 0.75rem; }
    .exp-nav-center { font-size: 0.72rem; }
}

/* ==========================================================
   v4.3 — NEEDS REVIEW BANNER
   ========================================================== */
.review-banner {
    background: rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.35);
    border-left: 4px solid #f59e0b; border-radius: 8px;
    margin-bottom: 1rem; overflow: hidden;
}
.review-banner-header {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.75rem 1rem; background: rgba(245,158,11,0.05);
    border-bottom: 1px solid rgba(245,158,11,0.2);
    flex-wrap: wrap;
}
.review-banner-icon {
    font-size: 1.6rem; color: #f59e0b; line-height: 1; flex-shrink: 0;
}
.review-confidence-pill {
    display: inline-block; margin-left: 0.6rem;
    background: rgba(245,158,11,0.2); color: #f59e0b;
    font-size: 0.7rem; font-weight: 700;
    padding: 0.15rem 0.55rem; border-radius: 20px;
    text-transform: uppercase; letter-spacing: 0.04em;
}
.review-banner-body {
    padding: 0.75rem 1rem; display: grid;
    grid-template-columns: 1fr 1fr; gap: 1.25rem;
}
@media (max-width: 720px) {
    .review-banner-body { grid-template-columns: 1fr; gap: 0.75rem; }
}
.review-section-label {
    font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em;
    color: #f59e0b; font-weight: 700; margin-bottom: 0.4rem;
}
.review-list {
    margin: 0; padding-left: 1.2rem; font-size: 0.85rem;
    color: var(--text-main); line-height: 1.55;
}
.review-list li { margin-bottom: 0.35rem; }
.review-list li strong { color: var(--text-main); }

[data-theme="light"] .review-banner {
    background: rgba(245,158,11,0.08); border-color: rgba(245,158,11,0.3);
}
[data-theme="light"] .review-banner-header {
    background: rgba(245,158,11,0.04); border-color: rgba(245,158,11,0.18);
}

/* ==========================================================
   EXPENSE LIST — MOBILE-FIRST REDESIGN
   ========================================================== */

/* ── Filter card ── */
.exp-filter-card { padding: 0; overflow: hidden; }
.exp-filter-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.75rem 1rem; cursor: pointer; user-select: none;
}
.exp-filter-header:hover { background: var(--bg-row-alt); }

.exp-filter-body {
    /* Hidden by default on mobile — toggled open by JS */
    display: none; flex-direction: column; gap: 0.5rem;
    padding: 0 1rem 1rem; border-top: 1px solid var(--border-subtle);
}
.exp-filter-body.is-open { display: flex; }

/* On desktop always show the filter in a wrapping row */
@media (min-width: 769px) {
    .exp-filter-card { padding: 1rem 1rem 0.75rem; }
    .exp-filter-header { display: none; } /* header toggle hidden on desktop */
    .exp-filter-body {
        display: flex !important; flex-direction: row; flex-wrap: wrap;
        padding: 0; border-top: none;
    }
}

/* ── Action bar ── */
.exp-action-bar {
    display: flex; flex-direction: column; gap: 0.55rem; margin-bottom: 0.75rem;
}
.exp-new-btn { width: 100%; text-align: center; font-size: 1rem; padding: 0.65rem; }

.exp-secondary-actions {
    display: flex; gap: 0.4rem; overflow-x: auto; -webkit-overflow-scrolling: touch;
    padding-bottom: 2px; /* show scrollbar when needed */
    scrollbar-width: thin;
}
.exp-secondary-actions::-webkit-scrollbar { height: 3px; }
.exp-secondary-actions::-webkit-scrollbar-thumb { background: var(--border-divider); border-radius: 2px; }

.exp-action-pill {
    white-space: nowrap; flex-shrink: 0;
    padding: 0.35rem 0.75rem; font-size: 0.82rem;
}
.exp-ocr-badge {
    display: inline-block; background: var(--accent-blue); color: #fff;
    border-radius: 10px; font-size: 0.65rem; font-weight: 700;
    padding: 0.05rem 0.4rem; margin-left: 0.2rem; vertical-align: middle;
}
.exp-count-line { font-size: 0.8rem; color: var(--text-faint); }

/* On desktop: action bar reverts to horizontal row */
@media (min-width: 769px) {
    .exp-action-bar {
        flex-direction: row; align-items: center; justify-content: space-between;
    }
    .exp-new-btn { width: auto; font-size: 0.88rem; padding: 0.35rem 0.85rem; }
    .exp-secondary-actions { overflow-x: visible; }
    .exp-count-line { order: -1; /* push count left */ }
}

/* ── Table column visibility on mobile ── */
@media (max-width: 768px) {
    /* Hide non-essential columns on portrait mobile */
    th[data-col="created"],
    td:has(> *[class*="cell-date"]:last-child),
    th[data-col="category"],
    th[data-col="receipts"] {
        display: none;
    }
    /* Target the "Created" 2nd date column specifically */
    .exp-col-created { display: none !important; }

    /* Tighten table on mobile */
    .table-wrap table th,
    .table-wrap table td { padding: 0.45rem 0.5rem; font-size: 0.82rem; }

    /* Make amount + status stand out on small screens */
    .cell-amount { font-weight: 700; }
}

@media (max-width: 480px) {
    /* Extreme narrow: also hide employee column */
    th[data-col="employee"],
    .exp-col-employee { display: none !important; }
}

/* ── Filter submit button group ── */
.exp-filter-submit-group {
    display: flex; gap: 0.4rem; align-items: flex-end; flex-wrap: wrap;
}
@media (max-width: 768px) {
    .exp-filter-submit-group { flex-direction: row; width: 100%; }
    .exp-filter-submit-group .btn { flex: 1; text-align: center; padding: 0.6rem; }
}

/* ==========================================================
   TAX SUMMARY WIDGET
   ========================================================== */
.tax-summary-card { overflow: hidden; }

.tax-summary-period-label {
    font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.07em; color: var(--text-faint);
    margin-bottom: 0.6rem;
}
.tax-period-range { font-weight: 400; text-transform: none; letter-spacing: 0; }

.tax-grid {
    display: grid;
    grid-template-columns: 1.8fr repeat(3, 1fr);
    gap: 0.5rem;
    margin-bottom: 0.85rem;
}
@media (max-width: 600px) { .tax-grid { grid-template-columns: 1fr 1fr; } }

.tax-item {
    background: var(--bg-row-alt); border-radius: 8px;
    padding: 0.65rem 0.85rem;
}
.tax-item-label {
    font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--text-faint); margin-bottom: 0.2rem;
}
.tax-item-value {
    font-size: 1.15rem; font-weight: 700; color: var(--text-main);
    font-variant-numeric: tabular-nums;
}
.tax-item-sub { font-size: 0.68rem; color: var(--text-faint); margin-top: 0.15rem; }

.tax-total-highlight {
    background: rgba(56,189,248,0.1);
    border-left: 3px solid var(--accent-blue);
}
.tax-total-highlight .tax-item-value {
    font-size: 1.45rem; color: var(--accent-blue);
}

.tax-bar-wrap {
    padding: 0.6rem 0; border-top: 1px solid var(--border-divider);
    border-bottom: 1px solid var(--border-divider); margin-bottom: 0.75rem;
}

.tax-last30-panel {
    background: var(--bg-row-alt); border-radius: 8px;
    padding: 0.65rem 0.85rem; margin-bottom: 0.5rem;
}

.tax-item-mini {
    display: flex; flex-direction: column; gap: 0.1rem;
}
.tax-mini-label {
    font-size: 0.66rem; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--text-faint);
}
.tax-mini-value {
    font-size: 0.95rem; font-weight: 700; color: var(--text-main);
    font-variant-numeric: tabular-nums;
}

[data-theme="light"] .tax-total-highlight { background: rgba(2,132,199,0.08); }
[data-theme="light"] .tax-last30-panel    { background: rgba(100,116,139,0.06); }

/* ==========================================================
   EXPENSE SHOW PAGE — MOBILE UX OVERHAUL
   ========================================================== */

/* ── Two-column → single column on mobile ── */
.exp-show-columns {
    display: flex; flex-direction: row; flex-wrap: wrap; gap: 1.25rem;
}
.exp-show-columns > .card { flex: 1; min-width: 280px; }

@media (max-width: 768px) {
    .exp-show-columns {
        flex-direction: column; gap: 0.75rem;
    }
    .exp-show-columns > .card {
        min-width: unset; width: 100%;
        /* Receipt card first on mobile */
    }
}

/* ── Prev/Next nav bar — bigger touch targets ── */
.exp-nav-bar { padding: 0.65rem 0.85rem; }
.exp-nav-btn { padding: 0.5rem 1rem; font-size: 0.88rem; min-height: 40px; }

@media (max-width: 480px) {
    .exp-nav-center { font-size: 0.78rem; }
}

/* ── Action bar — mobile-first rows ── */
.exp-show-action-bar {
    display: flex; flex-direction: column; gap: 0.5rem;
    margin-bottom: 0.75rem;
}
.exp-show-primary-row {
    display: flex; gap: 0.4rem; align-items: center;
}
.exp-show-btn-back  { flex: 0 0 auto; min-height: 40px; padding: 0.4rem 0.8rem; }
.exp-show-btn-edit  { flex: 1; text-align: center; min-height: 40px; font-size: 0.95rem; }
.exp-show-btn-del   { flex: 0 0 40px; height: 40px; padding: 0; font-size: 1.1rem;
                       display: flex; align-items: center; justify-content: center; }

.exp-show-ocr-row {
    display: flex; gap: 0.4rem;
}
.exp-show-ocr-row form { flex: 1; }
.exp-show-ocr-row .btn { width: 100%; justify-content: center; display: flex; align-items: center; min-height: 38px; }

.exp-show-status-row {
    display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap;
}
.exp-show-status-select {
    flex: 1; min-width: 130px; padding: 0.4rem 0.5rem;
    font-size: 0.85rem; min-height: 38px;
}
.exp-show-status-row .btn { min-height: 38px; white-space: nowrap; }

/* On desktop: action bar reverts to original horizontal layout */
@media (min-width: 769px) {
    .exp-show-action-bar { flex-direction: row; align-items: flex-start; justify-content: space-between; gap: 0.75rem; }
    .exp-show-primary-row { flex: 0 0 auto; }
    .exp-show-btn-edit { flex: 0 0 auto; font-size: 0.88rem; }
    .exp-show-ocr-row { flex: 0 0 auto; }
    .exp-show-status-row { flex: 0 0 auto; }
}

/* ── Tax breakdown grid — responsive ── */
.tax-breakdown-grid {
    display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; font-size: 0.84rem;
}
.tax-breakdown-item { white-space: nowrap; }

/* ── Inline PDF / Image preview — tighter on mobile ── */
@media (max-width: 768px) {
    .pdf-preview-frame { height: 55vw; max-height: 380px; }
    .img-preview-frame  { max-height: 55vw; }
    .pdf-preview-toolbar { padding: 0.4rem 0.55rem; }
    .pdf-preview-name { font-size: 0.75rem; }
}

/* ── OCR raw text always collapsed ── */
.collapsible-toggle { width: 100%; text-align: left; }

/* ── Needs review / dup banners — compact on mobile ── */
@media (max-width: 600px) {
    .review-banner-body { padding: 0.55rem 0.75rem; }
    .review-list { font-size: 0.8rem; }
    .dup-banner { padding: 0.5rem 0.75rem; font-size: 0.82rem; }
}

/* ── Inline edit form ── */
@media (max-width: 768px) {
    #inlineEditForm .form-row { flex-direction: column; gap: 0.5rem; }
}

/* ── Expense list: clean 4-col mobile view (Date, Vendor, Amount, Status) ── */
@media (max-width: 768px) {
    /* Hide non-essential columns */
    .exp-mob-hide { display: none !important; }

    /* The 4 visible columns: Date | Vendor | Amount | Status */
    /* Remove min-width constraint so table fits viewport */
    .table-wrap table { min-width: 0 !important; width: 100% !important; }

    /* Column widths that work on 390px */
    th[data-col="date"]   { width: 90px; }
    th[data-col="vendor"] { width: auto; }  /* takes remaining space */
    th[data-col="amount"] { width: 75px; text-align: right; }
    th[data-col="status"] { width: 80px; text-align: center; }

    /* Cell styling */
    td.cell-date { font-size: 0.8rem; white-space: nowrap; color: var(--text-faint); }
    td.cell-amount { font-size: 0.88rem; font-weight: 700; text-align: right; white-space: nowrap; }
    .exp-vendor-cell { font-size: 0.88rem; font-weight: 500; }
    td:has(.badge) { text-align: center; }

    /* Row: taller for touch, cursor pointer */
    table tbody tr { min-height: 52px; cursor: pointer; }
    table tbody td { padding: 0.7rem 0.6rem; vertical-align: middle; }

    /* Status badge: full text visible, compact */
    table tbody .badge {
        font-size: 0.65rem;
        padding: 0.2rem 0.4rem;
        white-space: nowrap;
    }

    /* Header */
    table thead th {
        font-size: 0.65rem;
        padding: 0.5rem 0.6rem;
        text-transform: uppercase;
        letter-spacing: 0.04em;
    }
    th[data-col="amount"] { text-align: right; }

    /* Table container: no min-width scroll needed with 4 cols */
    .table-wrap { overflow-x: hidden; }
}

/* ── Clockout modal + any modal with action rows — mobile ── */
@media (max-width: 600px) {
    /* RTE toolbar: wrap onto 2 lines */
    .rte-toolbar {
        flex-wrap: wrap;
        gap: 0.25rem;
    }
    .rte-btn { min-height: 36px; min-width: 36px; }

    /* Bottom action row: stack char count above buttons */
    #clockoutModal .d-flex.justify-between {
        flex-direction: column;
        gap: 0.75rem;
    }
    #clockoutModal .action-btns {
        flex-direction: column;
        width: 100%;
        gap: 0.5rem;
    }
    #clockoutModal .action-btns .btn {
        width: 100%;
        justify-content: center;
        min-height: 48px;
        font-size: 1rem;
    }

    /* RTE editor: taller on mobile for easier typing */
    .rte-editor { min-height: 140px; font-size: 16px; }

    /* Generic fix: any modal action row that has overflow issues */
    .modal-box .d-flex.justify-between {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    .modal-box .action-btns { flex-wrap: wrap; }
}

/* ==========================================================
   COMPREHENSIVE MOBILE OVERHAUL — iPhone 17 Pro (390px)
   Covers all views: dashboard, expenses, hours, schedule,
   leave, payroll, profile, forms, modals, navigation.
   ========================================================== */

/* ── 1. Sidebar: smooth open/close animation ── */
.sidebar {
    transition: transform 0.25s cubic-bezier(0.4,0,0.2,1),
                box-shadow 0.25s ease;
    will-change: transform;
}
/* Narrow to 85vw max so a sliver of content is always visible */
@media (max-width: 480px) {
    .sidebar { width: min(280px, 88vw); }
}

/* ── 2. CRITICAL: prevent iOS zoom on ALL inputs ── */
@media (max-width: 768px) {
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
    select,
    textarea,
    .filter-bar input,
    .filter-bar select,
    .form-group input,
    .form-group select,
    .form-group textarea,
    .global-search-box input {
        font-size: 16px !important;
    }
}

/* ── 3. Period buttons: wrap into 4+4 on phone ── */
@media (max-width: 768px) {
    .chart-period-btns {
        grid-template-columns: repeat(4, 1fr) !important;
    }
    .period-btn { min-height: 36px; font-size: 0.78rem; }
    .chart-view-toggle .view-btn { padding: 0.3rem 0.55rem; font-size: 0.72rem; }
}
@media (max-width: 480px) {
    .chart-period-btns {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 0.25rem;
    }
}

/* ── 4. All table wrappers: horizontal scroll, no layout break ── */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 6px;
}
@media (max-width: 768px) {
    .table-wrap table { min-width: 480px; }
    /* Schedule needs more space */
    .table-wrap.sched-wrap table { min-width: 620px; }

    /* Show a subtle scroll hint on first load */
    .table-wrap::after {
        content: '';
        display: block;
        height: 0;
    }

    /* Table text: keep readable */
    table th { font-size: 0.73rem; letter-spacing: 0; text-transform: uppercase; }
    table td { font-size: 0.84rem; padding: 0.55rem 0.65rem; }

    /* Row actions: compact */
    .row-actions { flex-wrap: nowrap; gap: 0.2rem; }
    .row-actions .btn-sm { padding: 0.25rem 0.45rem; font-size: 0.72rem; min-height: 32px; }
}

/* ── 5. Stats grid: 2-col on all phones ── */
@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 0.65rem;
    }
    .stat-card { padding: 0.85rem 0.9rem; }
    .stat-value { font-size: 1.5rem; }
    .stat-label { font-size: 0.68rem; }
}
/* Single column only on very tiny phones */
@media (max-width: 340px) {
    .stats-grid { grid-template-columns: 1fr !important; }
}

/* ── 6. Dashboard cards: full width, compact on mobile ── */
@media (max-width: 768px) {
    /* Expense trend chart */
    #expenseChartCard .card-header { flex-wrap: wrap; gap: 0.4rem; }
    .chart-total-label { font-size: 0.75rem; }
    .chart-change-badge { font-size: 0.72rem; }
    #chartTaxBadge { font-size: 0.72rem; padding: 0.12rem 0.5rem; }

    /* Leave balance widget */
    #tab-details dl.profile-detail-grid { grid-template-columns: 100px 1fr; }

    /* Week schedule grid */
    #myScheduleWeek { grid-template-columns: repeat(7, 1fr); gap: 0.2rem; }
}

/* ── 7. Forms: all form-rows stack on mobile ── */
@media (max-width: 640px) {
    .form-row { flex-direction: column !important; gap: 0.5rem; }
    .form-row .form-group { min-width: 100%; }
    .form-row-3 { grid-template-columns: 1fr !important; }
    .form-group label { font-size: 0.82rem; margin-bottom: 0.25rem; }
    .form-group input,
    .form-group select,
    .form-group textarea { padding: 0.6rem 0.75rem; }
}

/* ── 8. Filter bar: collapsed + 2-col grid inside ── */
@media (max-width: 768px) {
    /* Filter form inside: 2-column grid instead of stacked list */
    .exp-filter-body .filter-bar {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }
    .exp-filter-body .filter-bar .form-group { min-width: 0; }
    .exp-filter-submit-group { grid-column: 1 / -1; }
}
@media (max-width: 420px) {
    .exp-filter-body .filter-bar { grid-template-columns: 1fr; }
}

/* ── 9. Modals: full-screen friendly ── */
@media (max-width: 600px) {
    .modal-overlay { align-items: flex-end; }
    .modal-box {
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 20px 20px 0 0 !important;
        padding: 1.5rem 1.25rem 2rem !important;
        max-height: 92vh;
        overflow-y: auto;
    }
    /* Prevent nested large modals */
    .ocr-modal-box { border-radius: 20px 20px 0 0 !important; }
    .pdf-fs-modal { align-items: flex-end; }
    .pdf-fs-frame { border-radius: 0; }
}

/* ── 10. Action buttons: better on mobile ── */
@media (max-width: 600px) {
    .exp-action-bar { gap: 0.4rem; }
    .exp-new-btn { font-size: 0.95rem; min-height: 46px; }
    .exp-secondary-actions { gap: 0.35rem; }
    .exp-action-pill { min-height: 38px; font-size: 0.78rem; }
}

/* ── 11. Expense show: action bar touch-friendly ── */
@media (max-width: 600px) {
    .exp-show-primary-row .btn { min-height: 46px; }
    .exp-show-status-select { min-height: 46px; font-size: 16px !important; }
    .exp-show-status-row .btn { min-height: 46px; }
    .exp-show-ocr-row .btn { min-height: 42px; }
}

/* ── 12. Nav: breadcrumbs, pagination compact ── */
@media (max-width: 600px) {
    .exp-nav-bar { padding: 0.55rem 0.7rem; }
    .exp-nav-btn { padding: 0.5rem 0.85rem; font-size: 0.82rem; min-height: 44px; }
    .exp-nav-center { font-size: 0.78rem; }

    /* Pagination */
    .pagination { flex-wrap: wrap; justify-content: center; gap: 0.25rem; }
    .pagination a, .pagination span { min-width: 36px; min-height: 36px; font-size: 0.82rem; }
}

/* ── 13. Profile view: tab bar scrollable ── */
@media (max-width: 600px) {
    .profile-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; }
    .profile-tab { white-space: nowrap; min-height: 44px; }
    .profile-hero { flex-direction: column; text-align: center; gap: 0.75rem; }
    .profile-hero-actions { justify-content: center; }
}

/* ── 14. Schedule table: horizontal scroll ── */
@media (max-width: 960px) {
    .sched-table th, .sched-table td { font-size: 0.78rem !important; padding: 0.4rem 0.35rem !important; }
}
@media (max-width: 768px) {
    .sched-table th, .sched-table td { font-size: 0.72rem !important; }
}

/* ── 15. Card header: wrap on small screens ── */
/* Title + actions sit on one row by default. On narrower viewports the
 * title gets squeezed and action buttons (Batch Runs / New Run / etc.)
 * get clipped off the right edge. Wrap the row, allow the title to
 * shrink with min-width:0, and let the action group take the full
 * width below the title when there isn't room beside it.
 */
@media (max-width: 768px) {
    .card-header { flex-wrap: wrap; gap: 0.5rem 0.4rem; }
    .card-header h3,
    .card-header .card-title { min-width: 0; flex: 1 1 auto; }
    .card-header > div:last-child { flex-wrap: wrap; }
}
@media (max-width: 600px) {
    .card-header h3 { font-size: 0.92rem; }
    .card { padding: 0.9rem 0.85rem; }
}

/* ── 16. Bulk OCR modal: full height list ── */
@media (max-width: 600px) {
    .ocr-modal-box { max-height: 95vh; overflow-y: auto; }
    .ocr-log { max-height: 100px; }
    .ocr-stats { grid-template-columns: 1fr 1fr; }
}

/* ── 17. Birthday popup: bottom sheet ── */
@media (max-width: 600px) {
    #birthdayPopup .modal-box {
        border-radius: 20px 20px 0 0 !important;
    }
    .bday-row { padding: 0.4rem 0.5rem; }
}

/* ── 18. Tax stat cards: readable on 390px ── */
@media (max-width: 480px) {
    .stat-card .stat-value { font-size: 1.3rem; }
    .stat-card .stat-sub { font-size: 0.66rem; }
}

/* ── 19. No horizontal overflow anywhere ── */
* { box-sizing: border-box; }
img, video, iframe { max-width: 100%; }

/* Strict viewport containment — nothing can be wider than the screen */
html { overflow-x: hidden; }
body { overflow-x: hidden; max-width: 100vw; }
.app-layout { overflow-x: hidden; max-width: 100vw; }
.main-content { overflow-x: hidden; max-width: 100vw; min-width: 0; }

@media (max-width: 768px) {
    /* Force all grid/flex children to respect viewport */
    .page-content > * { max-width: 100%; }
    .stats-grid { width: 100%; max-width: 100%; overflow: hidden; }
    .card { max-width: 100%; }

    /* Prevent absolutely anything from causing horizontal scroll */
    .page-content { overflow-x: hidden; }
}

/* NOTE: do NOT globally set d-flex { flex-wrap: wrap } — breaks header layout.
   Wrap only where explicitly needed with flex-wrap class. */

/* ── MOBILE HEADER / HAMBURGER FIXES ─────────────────────── */
@media (max-width: 768px) {
    /* Top bar never wraps — stays single row */
    .top-bar { padding: 0 0.75rem; height: 54px; overflow: visible; }
    .top-bar > div:first-child { flex-shrink: 0; gap: 0.4rem; overflow: hidden; }
    .top-bar h1 {
        font-size: 0.95rem; white-space: nowrap;
        overflow: hidden; text-overflow: ellipsis;
        max-width: calc(100vw - 200px); /* Reserve space for right buttons */
    }

    /* Hamburger: big, always accessible, no event issues */
    .mobile-menu-btn {
        display: flex !important;
        min-width: 48px; min-height: 48px;
        padding: 0.5rem;
        font-size: 1.5rem;
        touch-action: manipulation; /* prevent 300ms delay on iOS */
        cursor: pointer;
        position: relative; z-index: 60; /* above everything */
        background: transparent; border: none;
        -webkit-tap-highlight-color: rgba(56,189,248,0.2);
    }

    /* Right side of top bar: hide verbose items on mobile */
    .top-bar-user {
        gap: 0.2rem;
        flex-shrink: 0;
    }
    .top-bar-user .user-name,
    .top-bar-user .user-role { display: none; }
    .logout-btn { display: none; } /* Access logout via sidebar profile section */

    /* Notification bell: bigger tap target */
    .notif-bell-btn { min-width: 44px; min-height: 44px; }

    /* Theme toggle: keep small */
    #themeToggleBtn { min-width: 40px; min-height: 40px; }

    /* Search toggle */
    .global-search-toggle { min-width: 40px; min-height: 40px; }

    /* User avatar: tappable link to profile */
    .top-bar-user .user-avatar {
        min-width: 38px; min-height: 38px;
        font-size: 0.85rem;
    }
}

/* ── 20. Toast notifications: safe area aware ── */
@media (max-width: 600px) {
    .toast-container {
        bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
        left: 0.75rem; right: 0.75rem; max-width: none;
    }
    .toast { border-radius: 12px; padding: 0.75rem 1rem; font-size: 0.88rem; }
}

/* ── 21. Loading overlay ── */
@media (max-width: 600px) {
    .loading-overlay p { font-size: 0.88rem; }
}

/* ── 22. Hours stats strip ── */
@media (max-width: 600px) {
    .module-stats-grid { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
}

/* ── 23. Announcement cards ── */
@media (max-width: 600px) {
    .ann-priority-banner { font-size: 0.82rem; padding: 0.5rem 0.75rem; }
}

/* ── 24. Directory: 2-col grid on mobile (was 3-col) ── */
@media (max-width: 600px) {
    .dir-grid { grid-template-columns: 1fr !important; }
}

/* ── 25. Auto-OCR banner: compact ── */
.auto-ocr-banner { padding: 0.65rem 0.85rem; }
@media (max-width: 480px) {
    .auto-ocr-banner { font-size: 0.82rem; }
    .auto-ocr-spinner { width: 16px; height: 16px; }
}

/* ── Sidebar mobile footer (profile + logout) ── */
.sidebar-mobile-footer {
    border-top: 1px solid var(--border-divider);
    padding: 0.75rem;
    display: flex; gap: 0.5rem;
    margin-top: auto;
    position: sticky; bottom: 0;
    background: var(--bg-sidebar);
}
.sidebar-footer-btn {
    flex: 1; display: flex; flex-direction: column; align-items: center;
    gap: 0.25rem; padding: 0.65rem 0.5rem;
    border-radius: 8px; text-decoration: none; color: var(--text-faint);
    font-size: 0.72rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.05em; min-height: 56px; justify-content: center;
    background: rgba(255,255,255,0.04); transition: background 0.15s, color 0.15s;
}
.sidebar-footer-btn:hover, .sidebar-footer-btn:active { background: rgba(255,255,255,0.08); color: var(--text-main); }
.sidebar-footer-logout { color: var(--error); }
.sidebar-footer-logout:hover { background: rgba(239,68,68,0.12); }

/* mob-only: only visible on mobile */
.mob-only { display: none; }
@media (max-width: 768px) { .mob-only { display: flex; } }

/* Sidebar needs to be full height flex column for sticky footer */
.sidebar { display: flex; flex-direction: column; }
.sidebar-nav { flex: 1; overflow-y: auto; }

/* ── Sidebar overlay: improved ── */
.sidebar-overlay {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

/* Prevent body scroll when sidebar is open (iOS safe method — no position:fixed) */
html.sidebar-open { overflow: hidden; }
/* On iOS, height:100% + overflow:hidden on html prevents scroll */
@media (max-width: 768px) {
    html.sidebar-open, html.sidebar-open body { height: 100%; overflow: hidden; }
}

/* ── Hamburger button: override anything that could block it ── */
.mobile-menu-btn {
    position: relative !important;
    z-index: 100 !important; /* above sidebar overlay */
    touch-action: manipulation !important;
    -webkit-tap-highlight-color: rgba(56,189,248,0.15);
    flex-shrink: 0 !important;
}