/* =========================================
   FACIAL RECOGNITION SYSTEM
   Professional Light Theme (Navy, White & Royal Blue)
========================================= */

:root {
    --navy: #0f1e45;
    --navy-mid: #172a5c;
    --blue: #2563eb;
    --blue-dark: #1d4ed8;
    --blue-light: #eff4ff;
    --indigo: #4f46e5;
    --indigo-light: #eef2ff;
    --teal: #0e7490;
    --teal-light: #ecfeff;
    --green: #15803d;
    --green-light: #dcfce7;
    --red: #be123c;
    --red-light: #ffe4e6;
    --amber: #b45309;
    --amber-light: #fef3c7;
    --text: #1e293b;
    --text-secondary: #475569;
    --muted: #64748b;
    --border: #e2e8f0;
    --background: #f3f6fb;
    --white: #ffffff;
    --shadow-sm: 0 2px 8px rgba(15, 30, 69, 0.04);
    --shadow: 0 10px 30px rgba(15, 30, 69, 0.06);
    --radius: 16px;
}

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

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--background);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

button, input, select {
    font-family: inherit;
}

button {
    cursor: pointer;
    border: none;
    background: none;
}

button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

[hidden] {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

/* =========================================
   LAYOUT & SIDEBAR
========================================= */

.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    min-width: 260px;
    background: var(--white);
    border-right: 1px solid var(--border);
    padding: 24px 16px 20px;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 40;
    transition: transform 0.25s ease;
}

.sidebar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 28px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 4px;
}

.brand-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--navy), var(--blue));
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--white);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.22);
    flex-shrink: 0;
}

.brand-text h2 {
    font-size: 15px;
    color: var(--navy);
    font-weight: 800;
    line-height: 1.2;
}

.brand-text span {
    display: block;
    color: var(--muted);
    font-size: 11px;
    margin-top: 2px;
}

.sidebar-close {
    display: none;
    color: var(--muted);
    padding: 6px;
    border-radius: 8px;
}

.nav-label {
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.4px;
    padding: 0 12px;
    margin-bottom: 10px;
}

.navigation {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 11px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    text-align: left;
    transition: all 0.18s ease;
}

.nav-link:hover {
    background: var(--blue-light);
    color: var(--blue);
}

.nav-link.active {
    background: var(--blue-light);
    color: var(--blue);
    box-shadow: inset 3px 0 0 var(--blue);
}

.nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
}

.sidebar-bottom {
    margin-top: auto;
    padding: 16px 10px 4px;
    border-top: 1px solid var(--border);
}

.system-status,
.topbar-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #16a34a;
    box-shadow: 0 0 0 4px #dcfce7;
    flex-shrink: 0;
}

.status-dot.warn {
    background: #d97706;
    box-shadow: 0 0 0 4px #fef3c7;
}

.status-dot.error {
    background: #dc2626;
    box-shadow: 0 0 0 4px #fee2e2;
}

.sidebar-bottom p {
    color: var(--muted);
    font-size: 11px;
    margin-top: 8px;
}

/* =========================================
   MAIN CONTENT & TOPBAR
========================================= */

.main-content {
    margin-left: 260px;
    width: calc(100% - 260px);
    min-height: 100vh;
    padding: 0 36px 28px;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: 76px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    margin-bottom: 26px;
    gap: 16px;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.menu-toggle {
    display: none;
    padding: 8px;
    border-radius: 10px;
    background: var(--white);
    border: 1px solid var(--border);
    color: var(--navy);
}

.topbar-caption {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1.5px;
    color: var(--muted);
}

#current-date {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.topbar-status {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 8px 15px;
    box-shadow: var(--shadow-sm);
}

/* =========================================
   TOAST NOTIFICATIONS & ALERTS
========================================= */

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 380px;
}

.toast {
    background: var(--white);
    border: 1px solid var(--border);
    border-left: 4px solid var(--blue);
    border-radius: 12px;
    padding: 13px 16px;
    box-shadow: 0 12px 28px rgba(15, 30, 69, 0.12);
    font-size: 13px;
    color: var(--text);
    animation: slideInToast 0.2s ease;
}

.toast.success { border-left-color: var(--green); }
.toast.error { border-left-color: var(--red); }

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

.inline-alert {
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 13px;
    margin-bottom: 16px;
    font-weight: 500;
}

.inline-alert.error {
    background: var(--red-light);
    color: var(--red);
    border: 1px solid #fecdd3;
}

.inline-alert.info {
    background: var(--blue-light);
    color: var(--blue-dark);
    border: 1px solid #bfdbfe;
}

/* =========================================
   PAGES & COMMON HEADINGS
========================================= */

.page {
    display: none;
    animation: pageAppear 0.25s ease;
}

.page.active {
    display: block;
}

@keyframes pageAppear {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.eyebrow {
    display: inline-block;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1.4px;
    color: var(--muted);
    text-transform: uppercase;
}

.blue-text { color: var(--blue); }
.teal-text { color: var(--teal); }
.green-text { color: var(--green); }
.red-text { color: var(--red); }
.light-eyebrow { color: #93c5fd; }

.page-intro,
.section-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.page-intro h2,
.section-heading h2 {
    color: var(--navy);
    font-size: 24px;
    font-weight: 800;
    margin-top: 4px;
}

.page-intro p,
.section-heading p {
    font-size: 13px;
    color: var(--muted);
    margin-top: 4px;
}

.page-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.page-tag {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--white);
    border: 1px solid var(--border);
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

/* =========================================
   BUTTONS
========================================= */

.primary-button,
.secondary-button,
.danger-button,
.danger-outline-button,
.ghost-light-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 18px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    transition: all 0.18s ease;
    text-decoration: none;
}

.primary-button {
    background: var(--blue);
    color: var(--white);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.22);
}

.primary-button:hover:not(:disabled) {
    background: var(--blue-dark);
    transform: translateY(-1px);
}

.secondary-button {
    background: var(--white);
    color: var(--navy);
    border: 1px solid var(--border);
}

.secondary-button:hover:not(:disabled) {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.danger-button {
    background: var(--red);
    color: var(--white);
}

.danger-button:hover:not(:disabled) {
    background: #9f1239;
}

.danger-outline-button {
    background: var(--white);
    color: var(--red);
    border: 1px solid #fecdd3;
}

.danger-outline-button:hover:not(:disabled) {
    background: var(--red-light);
}

.ghost-light-button {
    background: rgba(255, 255, 255, 0.14);
    color: var(--white);
    border: 1px solid rgba(255, 255, 255, 0.28);
}

.ghost-light-button:hover {
    background: rgba(255, 255, 255, 0.22);
}

.text-link-button {
    color: var(--blue);
    font-size: 12px;
    font-weight: 700;
}

.full-button {
    width: 100%;
    margin-top: 16px;
}

.btn-spinner {
    width: 15px;
    height: 15px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: var(--white);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

/* =========================================
   PANELS & CARDS
========================================= */

.panel {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.panel-heading,
.panel-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.panel-top-row h3 {
    font-size: 17px;
    color: var(--navy);
    font-weight: 800;
    margin-top: 3px;
}

.panel-top-row p {
    font-size: 12px;
    color: var(--muted);
    margin-top: 2px;
}

.helper-pill {
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    background: var(--background);
    padding: 4px 10px;
    border-radius: 999px;
}

/* =========================================
   DASHBOARD
========================================= */

.welcome-banner {
    background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 58%, #1e40af 100%);
    color: var(--white);
    border-radius: 20px;
    padding: 34px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 32px;
    margin-bottom: 30px;
    box-shadow: 0 16px 36px rgba(15, 30, 69, 0.16);
    overflow: hidden;
    position: relative;
}

.welcome-content {
    max-width: 600px;
    z-index: 2;
}

.welcome-content h1 {
    font-size: 32px;
    font-weight: 800;
    margin-top: 10px;
    line-height: 1.2;
}

.welcome-content p {
    margin-top: 12px;
    color: #dbeafe;
    font-size: 14px;
    line-height: 1.65;
}

.welcome-cta {
    display: flex;
    gap: 12px;
    margin-top: 22px;
    flex-wrap: wrap;
}

.welcome-visual {
    position: relative;
    width: 220px;
    height: 180px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.visual-circle {
    position: absolute;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.14);
}

.circle-one { width: 190px; height: 190px; }
.circle-two { width: 145px; height: 145px; }

.scan-card {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 16px;
    padding: 20px 24px;
    text-align: center;
    z-index: 2;
}

.scan-frame {
    color: #93c5fd;
    margin-bottom: 8px;
}

.scan-line {
    height: 2px;
    background: linear-gradient(90deg, transparent, #60a5fa, transparent);
    margin: 8px 0;
}

.scan-card strong {
    display: block;
    font-size: 12px;
    letter-spacing: 1px;
}

.scan-card small {
    font-size: 11px;
    color: #bfdbfe;
}

/* STATS CARDS */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-sm);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.blue-bg { background: var(--blue-light); color: var(--blue); }
.indigo-bg { background: var(--indigo-light); color: var(--indigo); }
.green-bg { background: var(--green-light); color: var(--green); }
.red-bg { background: var(--red-light); color: var(--red); }
.teal-bg { background: var(--teal-light); color: var(--teal); }
.navy-bg { background: #e2e8f0; color: var(--navy); }

.stat-meta span {
    display: block;
    font-size: 12px;
    color: var(--muted);
    font-weight: 600;
}

.stat-meta strong {
    display: block;
    font-size: 26px;
    font-weight: 800;
    color: var(--navy);
    margin-top: 2px;
}

/* QUICK ACTIONS */
.quick-actions-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 30px;
}

.quick-action-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    text-align: left;
    transition: all 0.18s ease;
    box-shadow: var(--shadow-sm);
}

.quick-action-card:hover {
    border-color: var(--blue);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.qa-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.quick-action-card strong {
    display: block;
    color: var(--navy);
    font-size: 14px;
    font-weight: 700;
}

.quick-action-card span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-top: 3px;
}

/* RECENT ACTIVITY */
.recent-activity-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.recent-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fafcff;
    transition: background 0.15s;
}

.recent-item:hover {
    background: var(--blue-light);
}

.recent-item-left {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.thumb-img {
    width: 52px;
    height: 52px;
    border-radius: 10px;
    object-fit: cover;
    border: 1px solid var(--border);
    background: #e2e8f0;
    flex-shrink: 0;
}

.recent-item-info strong {
    display: block;
    color: var(--navy);
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 280px;
}

.recent-item-info small {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-top: 2px;
}

.recent-item-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

/* =========================================
   PREDICT PAGE
========================================= */

.mode-switch {
    display: inline-flex;
    background: var(--white);
    border: 1px solid var(--border);
    padding: 5px;
    border-radius: 12px;
    gap: 6px;
    margin-bottom: 22px;
}

.mode-button {
    padding: 10px 20px;
    border-radius: 9px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
}

.mode-button.active {
    background: var(--navy);
    color: var(--white);
}

.predict-layout {
    display: grid;
    grid-template-columns: 1.08fr 0.92fr;
    gap: 24px;
    align-items: start;
}

.upload-area {
    border: 2px dashed #cbd5e1;
    border-radius: 14px;
    padding: 46px 24px;
    text-align: center;
    background: #f8fafc;
    cursor: pointer;
    transition: all 0.18s ease;
}

.upload-area:hover,
.upload-area.drag-over {
    border-color: var(--blue);
    background: var(--blue-light);
}

.upload-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: var(--blue-light);
    color: var(--blue);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
}

.upload-area h3 {
    font-size: 16px;
    color: var(--navy);
    font-weight: 700;
}

.upload-area p {
    color: var(--muted);
    font-size: 13px;
    margin-top: 4px;
}

.upload-area small {
    display: inline-block;
    margin-top: 10px;
    color: var(--muted);
    font-size: 11px;
}

.preview-stage {
    position: relative;
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    background: #0f172a;
    border: 1px solid var(--border);
}

.preview-stage img,
.webcam-screen video {
    display: block;
    width: 100%;
    max-height: 420px;
    object-fit: contain;
    margin: 0 auto;
}

.preview-stage canvas,
.webcam-screen canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    object-fit: contain;
}

.preview-file-meta {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--muted);
    margin-top: 10px;
    padding: 0 2px;
}

.preview-actions {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    flex-wrap: wrap;
}

/* WEBCAM */
.webcam-screen {
    position: relative;
    width: 100%;
    min-height: 300px;
    background: #0f172a;
    border-radius: 14px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.camera-placeholder {
    position: absolute;
    inset: 0;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    text-align: center;
}

.camera-placeholder h3 {
    color: var(--navy);
    font-size: 16px;
}

.camera-placeholder p {
    color: var(--muted);
    font-size: 13px;
    margin-top: 4px;
}

.webcam-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 16px;
}

.captured-preview-box {
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.webcam-note {
    margin-top: 14px;
    font-size: 12px;
    color: var(--muted);
}

.compact-select {
    padding: 7px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--white);
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
}

/* RESULT PANEL */
.result-badge {
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.6px;
    background: var(--background);
    color: var(--muted);
}

.result-badge.success { background: var(--green-light); color: var(--green); }
.result-badge.failure { background: var(--amber-light); color: var(--amber); }
.result-badge.error { background: var(--red-light); color: var(--red); }

.result-content {
    text-align: center;
    padding: 16px 8px;
}

.empty-result-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: var(--blue-light);
    color: var(--blue);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
    font-size: 24px;
    font-weight: 800;
}

.result-content h3 {
    color: var(--navy);
    font-size: 18px;
    font-weight: 800;
}

.result-content > p {
    color: var(--muted);
    font-size: 13px;
    margin-top: 6px;
}

.confidence-box {
    margin-top: 20px;
    text-align: left;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
}

.confidence-label {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    font-weight: 700;
    color: var(--navy);
    margin-bottom: 8px;
}

.confidence-track {
    height: 8px;
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
}

.confidence-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--blue), #16a34a);
    border-radius: 999px;
    transition: width 0.35s ease;
}

.detection-list {
    margin-top: 16px;
    text-align: left;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    background: var(--white);
}

.detection-list-title {
    font-size: 12px;
    font-weight: 800;
    color: var(--navy);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.detection-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-top: 1px solid var(--border);
    font-size: 13px;
}

.detection-row:first-of-type {
    border-top: none;
    padding-top: 0;
}

.result-meta-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 16px;
    text-align: left;
}

.result-meta-item {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
}

.result-meta-item span {
    display: block;
    font-size: 11px;
    color: var(--muted);
}

.result-meta-item strong {
    display: block;
    font-size: 12px;
    color: var(--navy);
    margin-top: 2px;
}

/* =========================================
   BADGES & TAGS
========================================= */

.source-tag,
.table-result {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    text-transform: capitalize;
}

.source-tag {
    background: var(--blue-light);
    color: var(--blue-dark);
}

.table-result.detected {
    background: var(--green-light);
    color: var(--green);
}

.table-result.not-detected {
    background: var(--amber-light);
    color: var(--amber);
}

.table-result.unanalysed {
    background: #e2e8f0;
    color: var(--text-secondary);
}

/* =========================================
   HISTORY & FILTERS
========================================= */

.history-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.mini-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
}

.mini-card span {
    font-size: 12px;
    color: var(--muted);
    font-weight: 600;
}

.mini-card strong {
    display: block;
    font-size: 26px;
    font-weight: 800;
    color: var(--navy);
    margin-top: 4px;
}

.filter-panel {
    margin-bottom: 20px;
    padding: 18px 20px;
}

.filter-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr 1fr 1fr auto;
    gap: 12px;
    align-items: end;
}

.filter-grid.gallery-filters {
    grid-template-columns: 1.6fr 1fr 1fr auto;
}

.filter-field label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-field input,
.filter-field select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 9px;
    font-size: 13px;
    color: var(--text);
    background: var(--white);
}

.filter-field input:focus,
.filter-field select:focus {
    outline: 2px solid #bfdbfe;
    border-color: var(--blue);
}

.table-panel {
    padding: 0;
    overflow: hidden;
}

.table-scroll {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 820px;
}

th {
    background: #f8fafc;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.6px;
    text-align: left;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 13px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    vertical-align: middle;
}

tbody tr:hover {
    background: #fafcff;
}

.empty-table {
    text-align: center;
    padding: 36px 16px;
    color: var(--muted);
}

.table-actions {
    display: flex;
    gap: 8px;
}

.icon-btn {
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    border: 1px solid var(--border);
    color: var(--navy);
    background: var(--white);
}

.icon-btn:hover {
    background: var(--blue-light);
    color: var(--blue);
    border-color: #bfdbfe;
}

.icon-btn.delete:hover {
    background: var(--red-light);
    color: var(--red);
    border-color: #fecdd3;
}

.pagination-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    background: #f8fafc;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 12px;
}

.pagination-info {
    font-size: 12px;
    color: var(--muted);
}

.pagination-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.page-btn {
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--white);
    font-size: 12px;
    font-weight: 700;
    color: var(--navy);
}

.page-btn.active {
    background: var(--blue);
    color: var(--white);
    border-color: var(--blue);
}

/* =========================================
   GALLERY PAGE
========================================= */

.gallery-page-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 18px;
}

.gallery-item-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.gallery-item-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.gallery-thumb-wrap {
    position: relative;
    height: 180px;
    background: #0f172a;
    overflow: hidden;
    cursor: pointer;
}

.gallery-thumb-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.gallery-card-body {
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.gallery-card-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--navy);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gallery-card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: var(--muted);
}

.gallery-card-actions {
    display: flex;
    gap: 8px;
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.gallery-card-actions button {
    flex: 1;
}

/* =========================================
   ANALYTICS
========================================= */

.period-switch {
    display: inline-flex;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 4px;
    gap: 4px;
}

.period-button {
    padding: 7px 14px;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
}

.period-button.active {
    background: var(--navy);
    color: var(--white);
}

.analytics-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.analytics-card {
    border-radius: var(--radius);
    padding: 22px;
    color: var(--white);
    box-shadow: var(--shadow);
}

.gradient-navy { background: linear-gradient(135deg, var(--navy), #1e3a8a); }
.gradient-green { background: linear-gradient(135deg, #15803d, #0f766e); }
.gradient-red { background: linear-gradient(135deg, #be123c, #9f1239); }
.gradient-blue { background: linear-gradient(135deg, #2563eb, #4f46e5); }

.analytics-card span {
    font-size: 12px;
    opacity: 0.9;
    font-weight: 600;
}

.analytics-card strong {
    display: block;
    font-size: 30px;
    font-weight: 800;
    margin: 6px 0 4px;
}

.analytics-card small {
    font-size: 11px;
    opacity: 0.85;
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.full-chart {
    grid-column: 1 / -1;
}

.chart-title h3 {
    font-size: 16px;
    color: var(--navy);
    font-weight: 800;
}

.chart-title p {
    font-size: 12px;
    color: var(--muted);
    margin-top: 2px;
    margin-bottom: 16px;
}

.chart-container {
    position: relative;
    height: 270px;
}

.chart-container.large-chart {
    height: 310px;
}

/* =========================================
   ABOUT PAGE
========================================= */

.about-hero-panel {
    margin-bottom: 20px;
}

.about-hero-panel h3,
.about-card h3 {
    font-size: 19px;
    color: var(--navy);
    font-weight: 800;
    margin: 6px 0 10px;
}

.about-hero-panel p,
.about-card p {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.7;
}

.about-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.about-steps,
.about-list {
    margin-top: 12px;
    padding-left: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    color: var(--text-secondary);
    font-size: 13px;
}

.about-card code {
    background: var(--blue-light);
    color: var(--blue-dark);
    padding: 2px 6px;
    border-radius: 5px;
    font-size: 12px;
}

.tech-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.tech-card {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
}

.tech-card strong {
    display: block;
    color: var(--navy);
    font-size: 14px;
    margin-bottom: 4px;
}

.tech-card span {
    font-size: 12px;
    color: var(--muted);
}

/* =========================================
   MODALS & EMPTY STATES & FOOTER
========================================= */

.empty-state {
    background: var(--white);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 36px 20px;
    text-align: center;
    color: var(--muted);
    grid-column: 1 / -1;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 30, 69, 0.55);
    backdrop-filter: blur(3px);
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
}

.modal-card {
    background: var(--white);
    border-radius: 18px;
    width: 100%;
    max-width: 680px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
    box-shadow: 0 24px 50px rgba(15, 30, 69, 0.25);
}

.confirm-card {
    max-width: 420px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
}

.modal-header h3 {
    font-size: 19px;
    color: var(--navy);
    font-weight: 800;
    margin-top: 2px;
}

.modal-close {
    padding: 6px;
    border-radius: 8px;
    color: var(--muted);
}

.modal-close:hover {
    background: var(--background);
    color: var(--navy);
}

.confirm-message {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 20px;
}

.confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.footer {
    margin-top: auto;
    padding-top: 32px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--muted);
    flex-wrap: wrap;
    gap: 8px;
}

/* =========================================
   RESPONSIVE BREAKPOINTS
========================================= */

@media (max-width: 1120px) {
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .quick-actions-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .analytics-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .filter-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .tech-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 960px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-close,
    .menu-toggle {
        display: inline-flex;
    }
    .mobile-overlay {
        position: fixed;
        inset: 0;
        background: rgba(15, 30, 69, 0.45);
        z-index: 35;
    }
    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 0 20px 24px;
    }
    .predict-layout,
    .charts-grid,
    .about-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .welcome-banner {
        flex-direction: column;
        padding: 24px;
        text-align: left;
    }
    .welcome-visual {
        display: none;
    }
    .welcome-content h1 {
        font-size: 25px;
    }
    .stats-grid,
    .quick-actions-grid,
    .history-summary,
    .analytics-summary,
    .filter-grid,
    .filter-grid.gallery-filters,
    .tech-grid,
    .webcam-controls {
        grid-template-columns: 1fr;
    }
    .recent-item {
        flex-direction: column;
        align-items: flex-start;
    }
    .recent-item-right {
        width: 100%;
        justify-content: space-between;
    }
}
