/* ==========================================================================
   VISTORIA CAUTELAR — Design System Mobile-First
   v1.0 — 2026
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. CSS VARIABLES
   -------------------------------------------------------------------------- */
:root {
    /* Brand — Client (matching PDF laudo/certificado palette) */
    --primary: #2c3e50;
    --primary-dark: #1a252f;
    --primary-gradient: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    --primary-shadow: rgba(44, 62, 80, 0.35);

    /* Brand — Admin */
    --admin-primary: #1a252f;
    --admin-gradient: linear-gradient(135deg, #1a252f 0%, #2c3e50 100%);

    /* Status */
    --success: #28a745;
    --success-bg: #d4edda;
    --success-text: #155724;
    --warning: #f39c12;
    --warning-bg: #fff3cd;
    --warning-text: #856404;
    --danger: #dc3545;
    --danger-bg: #f8d7da;
    --danger-text: #721c24;
    --info: #17a2b8;
    --info-bg: #d1ecf1;
    --info-text: #0c5460;

    /* Neutrals */
    --white: #ffffff;
    --gray-50: #fafbfc;
    --gray-100: #f5f7fa;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-400: #ced4da;
    --gray-500: #adb5bd;
    --gray-600: #6c757d;
    --gray-700: #495057;
    --gray-800: #333333;
    --gray-900: #212529;

    /* Spacing */
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 20px;
    --sp-6: 24px;
    --sp-7: 32px;
    --sp-8: 40px;

    /* Radius */
    --radius-sm: 5px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-pill: 50px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow: 0 2px 10px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 20px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.15);

    /* Font */
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'SF Mono', SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;

    /* Touch */
    --tap-target: 44px;
    --tap-target-lg: 48px;

    /* Z-index */
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-navbar: 500;
    --z-modal-bg: 900;
    --z-modal: 1000;
    --z-toast: 1100;
    --z-bottom-nav: 600;

    /* Layout */
    --container-max: 1200px;
    --bottom-nav-h: 64px;
    --top-nav-h: 60px;
}

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

html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--gray-800);
    background: var(--gray-100);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    padding-bottom: calc(var(--bottom-nav-h) + 16px);
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

input, select, textarea, button {
    font-family: inherit;
    font-size: 16px; /* Prevents iOS zoom */
}

/* --------------------------------------------------------------------------
   3. TYPOGRAPHY
   -------------------------------------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    color: var(--gray-900);
}

h1 { font-size: 24px; }
h2 { font-size: 20px; }
h3 { font-size: 18px; }
h4 { font-size: 16px; }
small, .text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.text-muted { color: var(--gray-600); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-white { color: var(--white); }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

/* --------------------------------------------------------------------------
   4. LAYOUT
   -------------------------------------------------------------------------- */
.container {
    width: 100%;
    max-width: var(--container-max);
    margin: 0 auto;
    padding: var(--sp-4);
}

.page-content {
    padding: var(--sp-4);
    padding-bottom: calc(var(--bottom-nav-h) + var(--sp-5));
}

/* Grid helpers */
.grid-2 { display: grid; grid-template-columns: 1fr; gap: var(--sp-4); }
.grid-3 { display: grid; grid-template-columns: 1fr; gap: var(--sp-4); }
.grid-4 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }

.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: var(--sp-1); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }

.hidden { display: none !important; }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-3 { margin-bottom: var(--sp-3); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-5 { margin-bottom: var(--sp-5); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.p-4 { padding: var(--sp-4); }
.p-5 { padding: var(--sp-5); }

/* --------------------------------------------------------------------------
   5. TOP NAVBAR — Hidden on mobile, visible on desktop
   -------------------------------------------------------------------------- */
.top-nav {
    display: none;
    background: var(--primary-gradient);
    color: var(--white);
    padding: 0 var(--sp-6);
    height: var(--top-nav-h);
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: var(--z-navbar);
}

.top-nav .nav-brand {
    font-size: 18px;
    font-weight: 700;
    color: var(--white);
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.top-nav .nav-brand:hover { text-decoration: none; }

.top-nav .nav-links {
    display: flex;
    align-items: center;
    gap: var(--sp-1);
    list-style: none;
}

.top-nav .nav-links a {
    color: rgba(255,255,255,0.85);
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.top-nav .nav-links a:hover {
    background: rgba(255,255,255,0.15);
    color: var(--white);
    text-decoration: none;
}

.top-nav .nav-links a.active {
    background: rgba(255,255,255,0.25);
    color: var(--white);
    font-weight: 600;
}

.top-nav .nav-user {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    color: rgba(255,255,255,0.9);
    font-size: 14px;
}

.top-nav .nav-user a {
    color: rgba(255,255,255,0.85);
    font-size: 13px;
}

/* --------------------------------------------------------------------------
   5b. MOBILE HEADER — Visible only on mobile
   -------------------------------------------------------------------------- */
.mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--primary-gradient);
    color: var(--white);
    padding: 0 var(--sp-4);
    height: 52px;
    position: sticky;
    top: 0;
    z-index: var(--z-navbar);
    box-shadow: var(--shadow);
}

.mobile-header-brand {
    font-size: 16px;
    font-weight: 700;
    color: var(--white);
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.mobile-header-brand:hover { text-decoration: none; color: var(--white); }

.mobile-header-action {
    color: rgba(255,255,255,0.85);
    font-size: 14px;
    font-weight: 500;
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--radius-sm);
}

.mobile-header-action:hover { background: rgba(255,255,255,0.15); color: var(--white); text-decoration: none; }

/* --------------------------------------------------------------------------
   5c. MORE MENU — Mobile slide-up menu for admin items
   -------------------------------------------------------------------------- */
.more-menu-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: calc(var(--z-bottom-nav) + 10);
    align-items: flex-end;
}

.more-menu-overlay.active {
    display: flex;
}

.more-menu {
    background: var(--white);
    width: 100%;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
    animation: slideUp 0.25s ease;
}

.more-menu-header {
    padding: var(--sp-4) var(--sp-5);
    font-weight: 700;
    font-size: 16px;
    border-bottom: 1px solid var(--gray-200);
    color: var(--gray-800);
}

.more-menu-item {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-4) var(--sp-5);
    color: var(--gray-800);
    font-size: 15px;
    font-weight: 500;
    border-bottom: 1px solid var(--gray-100);
    text-decoration: none;
    transition: background 0.15s;
}

.more-menu-item:hover {
    background: var(--gray-50);
    text-decoration: none;
}

.more-menu-item span:first-child {
    font-size: 20px;
    width: 28px;
    text-align: center;
}

/* --------------------------------------------------------------------------
   6. BOTTOM NAVBAR — Mobile navigation
   -------------------------------------------------------------------------- */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-h);
    background: var(--white);
    border-top: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: var(--z-bottom-nav);
    padding-bottom: env(safe-area-inset-bottom, 0);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.06);
}

.bottom-nav .nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: var(--sp-2) var(--sp-3);
    color: var(--gray-500);
    font-size: 11px;
    font-weight: 500;
    text-decoration: none;
    min-width: 56px;
    transition: color 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.bottom-nav .nav-item .nav-icon {
    font-size: 22px;
    line-height: 1;
}

.bottom-nav .nav-item.active {
    color: var(--primary);
    font-weight: 600;
}

.bottom-nav .nav-item:hover {
    color: var(--primary);
    text-decoration: none;
}

/* FAB — Central action button */
.bottom-nav .nav-fab {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--primary-gradient);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    margin-top: -20px;
    box-shadow: 0 4px 15px var(--primary-shadow);
    border: 3px solid var(--white);
    transition: transform 0.2s;
}

.bottom-nav .nav-fab:hover {
    transform: scale(1.08);
    text-decoration: none;
}

/* --------------------------------------------------------------------------
   7. CARDS
   -------------------------------------------------------------------------- */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: var(--sp-4);
    overflow: hidden;
}

.card-header {
    padding: var(--sp-4) var(--sp-5);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
}

.card-header h2,
.card-header h3 {
    font-size: 17px;
    font-weight: 600;
    margin: 0;
}

.card-body {
    padding: var(--sp-5);
}

.card-footer {
    padding: var(--sp-4) var(--sp-5);
    border-top: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--sp-3);
}

/* Stat Card */
.stat-card {
    background: var(--white);
    padding: var(--sp-5);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    text-align: center;
}

.stat-card .stat-icon {
    font-size: 32px;
    margin-bottom: var(--sp-2);
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1.2;
}

.stat-card .stat-label {
    color: var(--gray-600);
    font-size: 13px;
    margin-top: var(--sp-1);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--sp-3);
    margin-bottom: var(--sp-5);
}

/* --------------------------------------------------------------------------
   8. BUTTONS
   -------------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    padding: var(--sp-3) var(--sp-5);
    min-height: var(--tap-target);
    border: none;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    line-height: 1.4;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}

.btn:hover { text-decoration: none; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary {
    background: var(--primary-gradient);
    color: var(--white);
}
.btn-primary:hover {
    box-shadow: 0 4px 15px var(--primary-shadow);
    color: var(--white);
}

.btn-success {
    background: var(--success);
    color: var(--white);
}
.btn-success:hover { background: #219a3a; color: var(--white); }

.btn-danger {
    background: var(--danger);
    color: var(--white);
}
.btn-danger:hover { background: #c82333; color: var(--white); }

.btn-warning {
    background: var(--warning);
    color: var(--white);
}

.btn-secondary {
    background: var(--gray-600);
    color: var(--white);
}
.btn-secondary:hover { background: var(--gray-700); color: var(--white); }

.btn-outline {
    background: var(--white);
    color: var(--primary);
    border: 2px solid var(--primary);
}
.btn-outline:hover {
    background: var(--primary);
    color: var(--white);
}

.btn-outline-danger {
    background: var(--white);
    color: var(--danger);
    border: 2px solid var(--danger);
}
.btn-outline-danger:hover {
    background: var(--danger);
    color: var(--white);
}

.btn-ghost {
    background: transparent;
    color: var(--gray-600);
}
.btn-ghost:hover { background: var(--gray-200); }

.btn-sm {
    padding: var(--sp-2) var(--sp-3);
    min-height: 36px;
    font-size: 13px;
    border-radius: var(--radius-sm);
}

.btn-lg {
    padding: var(--sp-4) var(--sp-6);
    min-height: var(--tap-target-lg);
    font-size: 16px;
    font-weight: 600;
}

.btn-block {
    width: 100%;
    display: flex;
}

.btn-icon {
    width: var(--tap-target);
    height: var(--tap-target);
    padding: 0;
    border-radius: var(--radius);
}

.btn-group {
    display: flex;
    gap: var(--sp-2);
    flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   9. FORMS
   -------------------------------------------------------------------------- */
.form-group {
    margin-bottom: var(--sp-4);
}

.form-group label {
    display: block;
    margin-bottom: var(--sp-2);
    color: var(--gray-800);
    font-weight: 500;
    font-size: 14px;
}

.form-group label .required {
    color: var(--danger);
    margin-left: 2px;
}

.form-control {
    width: 100%;
    padding: var(--sp-3) var(--sp-4);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 16px; /* Prevents iOS zoom */
    line-height: 1.5;
    color: var(--gray-800);
    background: var(--white);
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(44, 62, 80, 0.15);
}

.form-control::placeholder {
    color: var(--gray-500);
}

.form-control:disabled,
.form-control[readonly] {
    background: var(--gray-100);
    color: var(--gray-600);
}

select.form-control {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236c757d' d='M6 8.825L.35 3.175 1.175 2.35 6 7.175 10.825 2.35l.825.825z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

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

.form-hint {
    font-size: 12px;
    color: var(--gray-600);
    margin-top: var(--sp-1);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--sp-4);
}

.form-actions {
    display: flex;
    gap: var(--sp-3);
    margin-top: var(--sp-5);
}

.form-actions .btn {
    flex: 1;
}

/* Toggle Switch */
.toggle {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
    flex-shrink: 0;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--gray-300);
    border-radius: 28px;
    transition: 0.3s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background: var(--white);
    border-radius: 50%;
    transition: 0.3s;
}

.toggle input:checked + .toggle-slider {
    background: var(--primary);
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(22px);
}

/* --------------------------------------------------------------------------
   10. TABLES — Cards on mobile, table on desktop
   -------------------------------------------------------------------------- */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: var(--sp-4);
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th,
table td {
    padding: var(--sp-3) var(--sp-4);
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
    font-size: 14px;
}

table th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-700);
    white-space: nowrap;
}

table tbody tr {
    transition: background 0.15s;
}

table tbody tr:hover {
    background: var(--gray-50);
}

/* Card-based table for mobile */
.table-cards thead { display: none; }

.table-cards tbody tr {
    display: block;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--sp-3);
    padding: var(--sp-3);
    border: 1px solid var(--gray-200);
}

.table-cards tbody tr:hover {
    background: var(--white);
    box-shadow: var(--shadow);
}

.table-cards td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--sp-2) var(--sp-3);
    border-bottom: 1px solid var(--gray-100);
    font-size: 14px;
}

.table-cards td:last-child {
    border-bottom: none;
}

.table-cards td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--gray-700);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    flex-shrink: 0;
    margin-right: var(--sp-3);
}

.table-cards td .btn-group {
    justify-content: flex-end;
    width: 100%;
}

/* Actions column in table-cards */
.table-cards td.td-actions {
    justify-content: flex-end;
    padding-top: var(--sp-3);
}

.table-cards td.td-actions::before {
    display: none;
}

/* --------------------------------------------------------------------------
   11. ALERTS & TOASTS
   -------------------------------------------------------------------------- */
.alert {
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--radius);
    margin-bottom: var(--sp-4);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    animation: slideDown 0.3s ease;
    position: relative;
}

.alert-success { background: var(--success-bg); color: var(--success-text); }
.alert-error { background: var(--danger-bg); color: var(--danger-text); }
.alert-warning { background: var(--warning-bg); color: var(--warning-text); }
.alert-info { background: var(--info-bg); color: var(--info-text); }

.alert-close {
    margin-left: auto;
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    opacity: 0.6;
    padding: var(--sp-1);
    line-height: 1;
    color: inherit;
}

.alert-close:hover { opacity: 1; }

/* Toast — fixed top */
.toast-container {
    position: fixed;
    top: var(--sp-4);
    right: var(--sp-4);
    left: var(--sp-4);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    pointer-events: none;
}

.toast {
    background: var(--gray-900);
    color: var(--white);
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--radius);
    font-size: 14px;
    box-shadow: var(--shadow-lg);
    animation: slideDown 0.3s ease;
    pointer-events: auto;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; transform: translateY(-10px); }
}

/* --------------------------------------------------------------------------
   12. BADGES & STATUS
   -------------------------------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-rascunho { background: var(--gray-200); color: var(--gray-700); }
.badge-em-andamento { background: var(--info-bg); color: var(--info-text); }
.badge-concluido { background: var(--success-bg); color: var(--success-text); }
.badge-enviado { background: #cce5ff; color: #004085; }
.badge-cancelado { background: var(--danger-bg); color: var(--danger-text); }

.badge-success { background: var(--success-bg); color: var(--success-text); }
.badge-warning { background: var(--warning-bg); color: var(--warning-text); }
.badge-danger { background: var(--danger-bg); color: var(--danger-text); }
.badge-info { background: var(--info-bg); color: var(--info-text); }

/* --------------------------------------------------------------------------
   13. MODALS — Bottom sheet on mobile, centered on desktop
   -------------------------------------------------------------------------- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: var(--z-modal-bg);
    align-items: flex-end;
    justify-content: center;
    padding: 0;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: var(--white);
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease;
}

.modal-handle {
    width: 40px;
    height: 4px;
    background: var(--gray-300);
    border-radius: 2px;
    margin: var(--sp-3) auto;
}

.modal-header {
    padding: var(--sp-4) var(--sp-5);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 18px;
    margin: 0;
}

.modal-body {
    padding: var(--sp-5);
}

.modal-footer {
    padding: var(--sp-4) var(--sp-5);
    border-top: 1px solid var(--gray-200);
    display: flex;
    gap: var(--sp-3);
}

.modal-footer .btn { flex: 1; }

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--gray-600);
    cursor: pointer;
    padding: var(--sp-1);
    line-height: 1;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

/* --------------------------------------------------------------------------
   14. PROGRESS BAR
   -------------------------------------------------------------------------- */
.progress {
    background: var(--gray-200);
    border-radius: var(--radius-pill);
    height: 24px;
    overflow: hidden;
    position: relative;
}

.progress-bar {
    background: var(--primary-gradient);
    height: 100%;
    border-radius: var(--radius-pill);
    transition: width 0.5s ease;
    min-width: 0;
}

.progress-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
    color: var(--gray-700);
    z-index: 1;
}

/* --------------------------------------------------------------------------
   15. UPLOAD AREA
   -------------------------------------------------------------------------- */
.upload-area {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius-lg);
    padding: var(--sp-7) var(--sp-5);
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--gray-50);
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary);
    background: rgba(44, 62, 80, 0.06);
}

.upload-area .upload-icon {
    font-size: 48px;
    opacity: 0.4;
    margin-bottom: var(--sp-3);
}

.upload-area .upload-text {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-800);
}

.upload-area .upload-subtext {
    font-size: 13px;
    color: var(--gray-600);
    margin-top: var(--sp-1);
}

/* --------------------------------------------------------------------------
   16. PHOTO GALLERY
   -------------------------------------------------------------------------- */
.photos-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--sp-3);
}

.photo-card {
    background: var(--white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s;
    border: 1px solid var(--gray-200);
}

.photo-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.photo-card .photo-image {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    cursor: pointer;
}

.photo-card .photo-info {
    padding: var(--sp-2) var(--sp-3);
}

.photo-card .photo-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-800);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.photo-card .photo-actions {
    display: flex;
    gap: var(--sp-1);
    padding: var(--sp-2) var(--sp-3);
    border-top: 1px solid var(--gray-100);
}

/* --------------------------------------------------------------------------
   17. PAGE HEADER
   -------------------------------------------------------------------------- */
.page-header {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    margin-bottom: var(--sp-5);
}

.page-header h1 {
    font-size: 22px;
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.page-header .page-subtitle {
    color: var(--gray-600);
    font-size: 14px;
}

/* --------------------------------------------------------------------------
   18. LOGIN PAGE
   -------------------------------------------------------------------------- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-gradient);
    padding: var(--sp-5);
}

.login-page body,
body.login-page {
    background: var(--primary-gradient);
    padding-bottom: 0;
}

.login-card {
    background: var(--white);
    border-radius: var(--radius-xl);
    padding: var(--sp-7) var(--sp-6);
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.login-logo {
    text-align: center;
    margin-bottom: var(--sp-7);
}

.login-logo h1 {
    font-size: 22px;
    color: var(--gray-800);
    margin-top: var(--sp-3);
}

.login-logo .logo-icon {
    font-size: 48px;
}

/* --------------------------------------------------------------------------
   19. EMPTY STATE
   -------------------------------------------------------------------------- */
.empty-state {
    text-align: center;
    padding: var(--sp-8) var(--sp-5);
    color: var(--gray-600);
}

.empty-state .empty-icon {
    font-size: 56px;
    opacity: 0.3;
    margin-bottom: var(--sp-4);
}

.empty-state h3 {
    color: var(--gray-700);
    margin-bottom: var(--sp-2);
}

.empty-state p {
    font-size: 14px;
    margin-bottom: var(--sp-5);
}

/* --------------------------------------------------------------------------
   20. LOADING / SPINNER
   -------------------------------------------------------------------------- */
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
}

/* --------------------------------------------------------------------------
   21. THEME: ADMIN
   -------------------------------------------------------------------------- */
body.theme-admin {
    --primary: #1a252f;
    --primary-dark: #111920;
    --primary-gradient: linear-gradient(135deg, #1a252f 0%, #2c3e50 100%);
    --primary-shadow: rgba(26, 37, 47, 0.3);
}

body.theme-admin .top-nav {
    background: var(--admin-gradient);
}

body.theme-admin .mobile-header {
    background: var(--admin-gradient);
}

body.theme-admin .bottom-nav .nav-item.active {
    color: var(--admin-primary);
}

body.theme-admin .bottom-nav .nav-fab {
    background: var(--admin-gradient);
    box-shadow: 0 4px 15px rgba(26, 37, 47, 0.3);
}

/* --------------------------------------------------------------------------
   22. SEARCH BAR
   -------------------------------------------------------------------------- */
.search-bar {
    position: relative;
    margin-bottom: var(--sp-4);
}

.search-bar input {
    width: 100%;
    padding: var(--sp-3) var(--sp-4) var(--sp-3) 40px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-pill);
    font-size: 15px;
    background: var(--white);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-bar input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(44, 62, 80, 0.15);
}

.search-bar .search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-500);
    font-size: 16px;
    pointer-events: none;
}

/* --------------------------------------------------------------------------
   23. TABS
   -------------------------------------------------------------------------- */
.tabs {
    display: flex;
    overflow-x: auto;
    gap: var(--sp-1);
    border-bottom: 2px solid var(--gray-200);
    margin-bottom: var(--sp-5);
    -webkit-overflow-scrolling: touch;
}

.tabs .tab {
    padding: var(--sp-3) var(--sp-4);
    color: var(--gray-600);
    font-weight: 500;
    font-size: 14px;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

.tabs .tab.active,
.tabs .tab:hover {
    color: var(--primary);
    border-bottom-color: var(--primary);
    text-decoration: none;
}

/* --------------------------------------------------------------------------
   24. DIVIDER
   -------------------------------------------------------------------------- */
.divider {
    height: 1px;
    background: var(--gray-200);
    margin: var(--sp-5) 0;
}

/* --------------------------------------------------------------------------
   25. LIST ITEMS
   -------------------------------------------------------------------------- */
.list-item {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-4);
    border-bottom: 1px solid var(--gray-100);
    transition: background 0.15s;
}

.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--gray-50); }

.list-item .item-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    background: var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.list-item .item-content { flex: 1; min-width: 0; }
.list-item .item-title { font-weight: 600; font-size: 15px; }
.list-item .item-subtitle { font-size: 13px; color: var(--gray-600); }
.list-item .item-action { flex-shrink: 0; }

/* --------------------------------------------------------------------------
   26. SIGNATURE AREA
   -------------------------------------------------------------------------- */
.signature-area {
    border: 2px solid var(--gray-300);
    border-radius: var(--radius);
    background: var(--white);
    touch-action: none;
}

/* --------------------------------------------------------------------------
   DESKTOP BREAKPOINT (min-width: 769px)
   -------------------------------------------------------------------------- */
@media (min-width: 769px) {
    body {
        padding-bottom: 0;
    }

    /* Show top nav, hide bottom nav and mobile header */
    .mobile-header {
        display: none;
    }

    .top-nav {
        display: flex;
    }

    .bottom-nav {
        display: none;
    }

    .more-menu-overlay {
        display: none !important;
    }

    /* Container */
    .container {
        padding: var(--sp-6);
    }

    .page-content {
        padding: var(--sp-6);
        padding-bottom: var(--sp-6);
        max-width: var(--container-max);
        margin: 0 auto;
    }

    /* Typography */
    h1 { font-size: 28px; }
    .page-header h1 { font-size: 26px; }

    /* Grids */
    .grid-2 { grid-template-columns: 1fr 1fr; }
    .grid-3 { grid-template-columns: repeat(3, 1fr); }
    .grid-4 { grid-template-columns: repeat(4, 1fr); }
    .stats-grid { grid-template-columns: repeat(4, 1fr); gap: var(--sp-5); }

    /* Forms */
    .form-row {
        grid-template-columns: 1fr 1fr;
    }

    .form-row.cols-3 {
        grid-template-columns: repeat(3, 1fr);
    }

    .form-actions {
        justify-content: flex-end;
    }

    .form-actions .btn {
        flex: none;
        min-width: 150px;
    }

    /* Tables — show normal on desktop */
    .table-cards thead { display: table-header-group; }

    .table-cards tbody tr {
        display: table-row;
        background: transparent;
        border-radius: 0;
        box-shadow: none;
        margin-bottom: 0;
        padding: 0;
        border: none;
    }

    .table-cards td {
        display: table-cell;
        border-bottom: 1px solid var(--gray-200);
    }

    .table-cards td::before {
        display: none;
    }

    /* Page Header */
    .page-header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    /* Cards */
    .card-body {
        padding: var(--sp-6);
    }

    /* Modals — centered on desktop */
    .modal-overlay {
        align-items: center;
        padding: var(--sp-5);
    }

    .modal-content {
        max-width: 600px;
        border-radius: var(--radius-xl);
        animation: fadeIn 0.2s ease;
    }

    .modal-handle {
        display: none;
    }

    @keyframes fadeIn {
        from { opacity: 0; transform: scale(0.95); }
        to { opacity: 1; transform: scale(1); }
    }

    /* Photo gallery */
    .photos-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }

    /* Buttons */
    .btn-block-mobile {
        width: auto;
    }

    /* Login */
    .login-card {
        padding: var(--sp-8) var(--sp-7);
    }
}

/* Mobile-only utilities */
@media (max-width: 768px) {
    .hide-mobile { display: none !important; }

    .btn-block-mobile {
        width: 100%;
        display: flex;
    }

    /* Sticky bottom action on mobile forms */
    .form-sticky-bottom {
        position: fixed;
        bottom: var(--bottom-nav-h);
        left: 0;
        right: 0;
        padding: var(--sp-3) var(--sp-4);
        background: var(--white);
        border-top: 1px solid var(--gray-200);
        box-shadow: 0 -2px 10px rgba(0,0,0,0.06);
        z-index: var(--z-sticky);
    }

    .form-sticky-bottom .btn { width: 100%; }
}

@media (min-width: 769px) {
    .hide-desktop { display: none !important; }
}

/* --------------------------------------------------------------------------
   PRINT
   -------------------------------------------------------------------------- */
@media print {
    .top-nav,
    .bottom-nav,
    .btn,
    .no-print {
        display: none !important;
    }

    body {
        padding: 0;
        background: white;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}
