/* ============================================
   SFC - Sistem Forensik Citra
   Custom CSS Framework (Flat Design)
   ============================================ */

:root {
    --primary: #1a56db;
    --primary-dark: #1342a8;
    --primary-light: #e8effc;
    --success: #059669;
    --success-light: #d1fae5;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --critical: #7c2d12;
    --critical-light: #fde2e2;
    --info: #0891b2;
    --info-light: #e0f7fa;

    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    --bg: #f0f2f5;
    --bg-card: #ffffff;
    --text: #1f2937;
    --text-muted: #6b7280;
    --border: #e5e7eb;

    --sidebar-w: 260px;
    --sidebar-w-collapsed: 64px;
    --topbar-h: 56px;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
    --transition: 0.2s ease;
}

/* Dark mode */
[data-theme="dark"] {
    --bg: #111827;
    --bg-card: #1f2937;
    --text: #f3f4f6;
    --text-muted: #9ca3af;
    --border: #374151;
    --primary-light: #1e3a5f;
    --success-light: #064e3b;
    --warning-light: #78350f;
    --danger-light: #7f1d1d;
    --info-light: #164e63;
    --gray-50: #1a2332;
    --gray-100: #1f2937;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-font-smoothing: antialiased; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }

/* Layout */
.app-layout { display: flex; min-height: 100vh; }
html, body { overflow-x: hidden; max-width: 100vw; }

/* Sidebar */
.sidebar {
    width: var(--sidebar-w);
    background: var(--gray-900);
    color: #fff;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: width var(--transition);
    overflow-x: hidden;
}
.sidebar-brand {
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    padding: 0 20px;
    font-size: 1.2rem;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    white-space: nowrap;
}
.sidebar-brand span { color: var(--primary); margin-right: 4px; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 0; }
.sidebar-nav .nav-section {
    padding: 8px 20px 4px;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--gray-400);
    white-space: nowrap;
}
.sidebar-nav .nav-item {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    color: var(--gray-300);
    transition: all var(--transition);
    white-space: nowrap;
    gap: 12px;
    cursor: pointer;
}
.sidebar-nav .nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; text-decoration: none; }
.sidebar-nav .nav-item.active { background: var(--primary); color: #fff; }
.sidebar-nav .nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

/* Sidebar collapsed (desktop) */
.sidebar.collapsed { width: var(--sidebar-w-collapsed); }
.sidebar.collapsed .sidebar-brand { padding: 0; justify-content: center; font-size: 0; }
.sidebar.collapsed .sidebar-brand #sidebarLogo { font-size: 1.2rem; }
.sidebar.collapsed .nav-section { padding: 4px; font-size: 0; height: 1px; opacity: 0.3; background: rgba(255,255,255,0.1); margin: 8px 12px; }
.sidebar.collapsed .nav-item { padding: 12px 0; justify-content: center; font-size: 0; overflow: hidden; }
.sidebar.collapsed .nav-item svg { font-size: initial; width: 20px; height: 20px; }
.sidebar.collapsed + .main-content { margin-left: var(--sidebar-w-collapsed); }

/* Main content */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-width: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition);
    overflow-x: hidden;
}
.main-content > .page-content { flex: 1 0 auto; }

/* App footer (sticky-bottom via flex-grow on .page-content) */
.app-footer {
    flex-shrink: 0;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 12px 24px;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: auto;
}
.app-footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    max-width: 100%;
}
.app-footer-left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.app-footer-version {
    padding: 2px 8px;
    background: var(--gray-100, rgba(0,0,0,0.05));
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}
.app-footer-links { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.app-footer-links a { color: var(--text-muted); text-decoration: none; transition: color var(--transition); }
.app-footer-links a:hover { color: var(--primary); text-decoration: underline; }
.app-footer-sep { color: var(--gray-300, #d1d5db); }
@media (max-width: 640px) {
    .app-footer { padding: 10px 14px; text-align: center; }
    .app-footer-inner { justify-content: center; }
}

/* Topbar */
.topbar {
    height: var(--topbar-h);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.breadcrumb { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 0.9rem; }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb span.sep { color: var(--gray-300); }

.user-menu { display: flex; align-items: center; gap: 8px; cursor: pointer; position: relative; }
.user-menu .avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
}
.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    display: none;
    z-index: 200;
}
.user-dropdown.show { display: block; }
.user-dropdown a {
    display: block;
    padding: 10px 16px;
    color: var(--text);
    transition: background var(--transition);
}
.user-dropdown a:hover { background: var(--gray-100); text-decoration: none; }

/* Page content */
.page-content { padding: 24px; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.page-header h1 { font-size: 1.5rem; font-weight: 700; }

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-body { padding: 20px; }
.card-footer { padding: 12px 20px; border-top: 1px solid var(--border); }

/* Stats cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
}
.stat-card .stat-icon {
    width: 48px; height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
}
.stat-card .stat-icon.primary { background: var(--primary-light); color: var(--primary); }
.stat-card .stat-icon.success { background: var(--success-light); color: var(--success); }
.stat-card .stat-icon.warning { background: var(--warning-light); color: var(--warning); }
.stat-card .stat-icon.danger { background: var(--danger-light); color: var(--danger); }
.stat-card .stat-icon.info { background: var(--info-light); color: var(--info); }
.stat-card .stat-value { font-size: 1.5rem; font-weight: 700; }
.stat-card .stat-label { font-size: 0.8rem; color: var(--text-muted); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
}
.btn:hover { text-decoration: none; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { opacity: 0.9; color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.9; color: #fff; }
.btn-outline {
    background: transparent;
    border-color: var(--border);
    color: var(--text);
}
.btn-outline:hover { background: var(--gray-100); color: var(--text); }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }
.btn-block { display: flex; width: 100%; justify-content: center; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-label { display: block; margin-bottom: 4px; font-weight: 500; font-size: 0.9rem; }
.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    background: var(--bg-card);
    color: var(--text);
    transition: border-color var(--transition);
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,86,219,0.1); }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236b7280' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
input[type="number"].form-control { padding-right: 8px; }
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    opacity: 1;
    height: 28px;
    margin-left: 8px;
}
[data-theme="dark"] input[type="number"]::-webkit-inner-spin-button,
[data-theme="dark"] input[type="number"]::-webkit-outer-spin-button {
    filter: invert(1);
}
textarea.form-control { min-height: 80px; resize: vertical; }
.form-text { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 0.8rem; color: var(--danger); margin-top: 4px; }

/* Tables */
.table-responsive { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
table th, table td { padding: 10px 16px; text-align: left; border-bottom: 1px solid var(--border); }
table th { font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); background: var(--gray-50); }
[data-theme="dark"] table th { background: var(--gray-800); }
table tr:hover { background: var(--gray-50); }
[data-theme="dark"] table tr:hover { background: rgba(255,255,255,0.03); }

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-critical { background: #7c2d12; color: #fff; }
.badge-info { background: var(--info-light); color: var(--info); }
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-gray { background: var(--gray-200); color: var(--gray-600); }

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
}
.alert-success { background: var(--success-light); color: var(--success); border-left: 4px solid var(--success); }
.alert-error { background: var(--danger-light); color: var(--danger); border-left: 4px solid var(--danger); }
.alert-warning { background: var(--warning-light); color: var(--warning); border-left: 4px solid var(--warning); }
.alert-info { background: var(--info-light); color: var(--info); border-left: 4px solid var(--info); }

/* Score display */
.score-display {
    width: 120px; height: 120px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    font-size: 1.8rem;
    font-weight: 800;
    margin: 0 auto;
    position: relative;
}
.score-display.success { background: var(--success-light); color: var(--success); border: 4px solid var(--success); }
.score-display.warning { background: var(--warning-light); color: var(--warning); border: 4px solid var(--warning); }
.score-display.danger { background: var(--danger-light); color: var(--danger); border: 4px solid var(--danger); }
.score-display.critical { background: var(--critical-light); color: var(--critical); border: 4px solid var(--critical); }
.score-display .score-pct { font-size: 0.7rem; font-weight: 500; }

/* Score bar */
.score-bar { height: 8px; background: var(--gray-200); border-radius: 4px; overflow: hidden; }
.score-bar .fill { height: 100%; border-radius: 4px; transition: width 0.5s ease; }
.score-bar .fill.success { background: var(--success); }
.score-bar .fill.warning { background: var(--warning); }
.score-bar .fill.danger { background: var(--danger); }
.score-bar .fill.critical { background: var(--critical); }

/* Grid */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* Analysis result card */
.analyzer-card { border-left: 4px solid var(--border); }
.analyzer-card.success { border-left-color: var(--success); }
.analyzer-card.warning { border-left-color: var(--warning); }
.analyzer-card.danger { border-left-color: var(--danger); }
.analyzer-card.critical { border-left-color: var(--critical); }
.analyzer-card .card-header { font-size: 0.95rem; }
.analyzer-findings { font-size: 0.85rem; color: var(--text-muted); white-space: pre-line; line-height: 1.8; }

/* Visual output images */
.visual-output {
    max-width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: transform var(--transition);
}
.visual-output:hover { transform: scale(1.02); }

/* Upload dropzone */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--gray-50);
}
.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}
.upload-zone svg { width: 48px; height: 48px; color: var(--text-muted); margin-bottom: 12px; }
.upload-zone p { color: var(--text-muted); margin: 8px 0; }

/* Guide panel — hidden by default (displayed via floating button modal) */
.guide-panel {
    display: none;
}

/* Floating Guide FAB (bottom-right) */
.guide-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(26, 86, 219, 0.4), 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 900;
    transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.15s;
    animation: guideFabPulse 2.5s ease-in-out infinite;
}
.guide-fab:hover {
    background: var(--primary-dark);
    transform: scale(1.08);
    box-shadow: 0 12px 32px rgba(26, 86, 219, 0.5), 0 4px 12px rgba(0, 0, 0, 0.15);
}
.guide-fab:active { transform: scale(0.95); }
.guide-fab svg {
    width: 22px;
    height: 22px;
    color: #fff;
}
@keyframes guideFabPulse {
    0%, 100% { box-shadow: 0 8px 24px rgba(26, 86, 219, 0.4), 0 0 0 0 rgba(26, 86, 219, 0.4); }
    50%      { box-shadow: 0 8px 24px rgba(26, 86, 219, 0.4), 0 0 0 10px rgba(26, 86, 219, 0); }
}

/* Guide Sidebar (right panel) */
.guide-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    z-index: 1100;
    display: none;
}
.guide-modal-overlay.show { display: block; }

.guide-modal-card {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 380px;
    max-width: 90vw;
    background: var(--bg-card);
    display: flex;
    flex-direction: column;
    box-shadow: -8px 0 30px rgba(0, 0, 0, 0.3);
    border-left: 1px solid var(--border);
    z-index: 1101;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}
.guide-modal-overlay.show .guide-modal-card {
    transform: translateX(0);
}

.guide-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.guide-modal-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
}
.guide-modal-close {
    background: none;
    border: none;
    font-size: 1.6rem;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}
.guide-modal-close:hover {
    background: var(--gray-100);
    color: var(--danger);
}
[data-theme="dark"] .guide-modal-close:hover { background: rgba(255, 255, 255, 0.06); }

.guide-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    font-size: 0.88rem;
    line-height: 1.7;
    color: var(--text);
}
.guide-modal-body ul {
    margin: 10px 0;
    padding-left: 22px;
}
.guide-modal-body li { margin-bottom: 6px; }
.guide-modal-body strong { color: var(--primary); }
.guide-modal-body p { margin-bottom: 10px; }

/* Mobile adjustments */
@media (max-width: 768px) {
    .guide-fab { bottom: 16px; right: 16px; width: 48px; height: 48px; }
    .guide-fab svg { width: 20px; height: 20px; }
    .guide-modal-card { width: 100%; max-width: 100%; }
}

/* Modal/Lightbox */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    max-width: 90vw;
    max-height: 90vh;
    overflow: auto;
    position: relative;
}
.modal-content img { display: block; max-width: 100%; max-height: 85vh; }
.modal-close {
    position: absolute;
    top: 8px; right: 8px;
    background: rgba(0,0,0,0.5);
    color: #fff;
    border: none;
    width: 32px; height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Pagination */
.pagination { display: flex; gap: 4px; align-items: center; margin-top: 16px; }
.pagination a, .pagination span {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.85rem;
}
.pagination a:hover { background: var(--gray-100); text-decoration: none; }
.pagination .active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Tabs */
.tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 16px; gap: 0; }
.tab-item {
    padding: 10px 20px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    color: var(--text-muted);
    font-weight: 500;
    transition: all var(--transition);
}
.tab-item:hover { color: var(--text); }
.tab-item.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Dark mode toggle + topbar buttons */
.theme-toggle,
.topbar-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 36px; height: 36px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

/* Login page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--gray-900) 0%, #1e3a5f 100%);
}
.login-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}
.login-card h1 { text-align: center; margin-bottom: 8px; font-size: 1.5rem; }
.login-card .subtitle { text-align: center; color: var(--text-muted); margin-bottom: 32px; }

/* Responsive - Tablet */
@media (max-width: 1024px) {
    .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    table th, table td { padding: 8px 10px; font-size: 0.85rem; }
}

/* Responsive - Mobile */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 200;
    }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0 !important; }
    .sidebar.collapsed + .main-content { margin-left: 0 !important; }

    /* Grid layouts collapse to single column */
    .grid, .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr !important; gap: 12px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .stat-card { padding: 12px; min-width: 0; }
    .stat-card .stat-value { font-size: 1.2rem; }

    /* Page content - prevent horizontal overflow */
    .page-content { padding: 12px; max-width: 100vw; overflow-x: hidden; }
    .page-header { flex-direction: column; gap: 12px; align-items: flex-start; }
    .page-header h1 { font-size: 1.2rem; }
    .page-header .d-flex { flex-wrap: wrap; }

    /* Topbar mobile */
    .topbar { padding: 0 12px; }
    .topbar-left { flex: 1; min-width: 0; overflow: hidden; }
    .topbar-right { gap: 8px; }
    .breadcrumb { font-size: 0.8rem; overflow: hidden; white-space: nowrap; flex-wrap: nowrap; }
    .user-menu span { display: none; }
    .user-menu .avatar { width: 28px; height: 28px; font-size: 0.7rem; }

    /* Cards - allow full width, prevent forced expansion */
    .card { max-width: 100%; min-width: 0; }
    .card-body { padding: 12px; min-width: 0; overflow-wrap: break-word; word-break: break-word; }
    .card-header { padding: 12px 14px; flex-wrap: wrap; gap: 8px; }

    /* Tables: scroll horizontally inside container, keep proper column widths */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
        /* Visual hint for horizontal scroll */
        background:
            linear-gradient(to right, var(--bg-card), var(--bg-card)) left center,
            linear-gradient(to right, var(--bg-card), var(--bg-card)) right center,
            linear-gradient(to right, rgba(0,0,0,0.1), rgba(0,0,0,0)) left center,
            linear-gradient(to left, rgba(0,0,0,0.1), rgba(0,0,0,0)) right center;
        background-repeat: no-repeat;
        background-size: 20px 100%, 20px 100%, 10px 100%, 10px 100%;
        background-attachment: local, local, scroll, scroll;
    }
    .table-responsive table { min-width: 720px; width: 100%; }
    table th, table td {
        padding: 10px 12px;
        font-size: 0.8rem;
        white-space: nowrap;
    }
    /* Allow specific cells to wrap (filename, findings) */
    table td.truncate { white-space: nowrap; max-width: 200px; }
    table td.wrap { white-space: normal; }

    /* Form fields - fill container, don't overflow */
    .form-control, .form-select, input, textarea, select { max-width: 100%; min-width: 0; }
    .form-group { max-width: 100%; }

    /* Flex containers wrap on mobile */
    .d-flex.gap-2,
    .d-flex.gap-1 { flex-wrap: wrap; }
    .d-flex.gap-2 .form-control,
    .d-flex.gap-2 .form-select { max-width: 100% !important; width: 100%; }

    /* Override inline-style fixed widths in flex containers */
    .d-flex [style*="max-width:300px"],
    .d-flex [style*="max-width:200px"],
    .d-flex [style*="max-width:180px"],
    .d-flex [style*="max-width:160px"] {
        max-width: 100% !important;
        width: 100% !important;
    }

    /* Tabs */
    .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; padding-bottom: 1px; }
    .tab-item { padding: 8px 14px; font-size: 0.85rem; white-space: nowrap; }

    /* Buttons */
    .btn { padding: 6px 12px; font-size: 0.85rem; }
    .btn-lg { padding: 10px 20px; }

    /* Modals */
    .modal-content { max-width: calc(100vw - 16px); margin: 8px; }

    /* Upload zone */
    .upload-zone { padding: 24px 16px; }
    .upload-zone svg { width: 36px; height: 36px; }

    /* Pagination */
    .pagination { flex-wrap: wrap; }
    .pagination a, .pagination span { padding: 4px 8px; font-size: 0.8rem; }

    /* Filter form */
    .card .d-flex.gap-2.align-center { flex-direction: column; align-items: stretch; }
    .card .d-flex.gap-2.align-center input,
    .card .d-flex.gap-2.align-center select { max-width: 100% !important; width: 100%; }

    /* Logo preview boxes (settings page) */
    .logo-preview-box { max-width: 100%; }
}

/* Responsive - Small phone */
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
    .stat-card { padding: 10px; }
    .page-content { padding: 10px; }
    .topbar { padding: 0 8px; gap: 4px; }
    .topbar-left { gap: 8px; }
    .card-body { padding: 12px; }
    .card-header { padding: 10px 12px; font-size: 0.95rem; }
    .d-flex.gap-1 { gap: 4px; }
    .table-responsive table { min-width: 640px; }
    table th, table td { padding: 8px 10px; font-size: 0.75rem; white-space: nowrap; }
    .btn-sm { padding: 3px 6px; font-size: 0.75rem; }
    .page-header h1 { font-size: 1.1rem; }

    /* Profile/avatar circles - shrink */
    [style*="width:80px"][style*="height:80px"] {
        width: 60px !important;
        height: 60px !important;
        font-size: 1.4rem !important;
    }

    /* Modal padding */
    .modal-content { padding: 12px !important; }

    /* Filter selects fit nicely */
    .form-control, .form-select { font-size: 0.85rem; padding: 7px 10px; }
}

/* Misc */
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-sm { font-size: 0.85rem; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.w-full { width: 100%; }
.hidden { display: none; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Sidebar toggle button */
.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
}

/* Chart container */
.chart-container { position: relative; height: 300px; }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}
.empty-state svg { width: 64px; height: 64px; margin-bottom: 16px; opacity: 0.5; }
.empty-state p { margin: 8px 0; }

/* Toast notifications */
.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.toast {
    padding: 12px 20px;
    border-radius: var(--radius);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    transform: translateX(120%);
    transition: transform 0.3s ease, opacity 0.3s ease;
    pointer-events: auto;
    max-width: 400px;
}
.toast.toast-show { transform: translateX(0); }
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-warning { background: var(--warning); }
.toast-info { background: var(--primary); }

/* SPA loading transition */
#pageContent {
    transition: opacity 0.15s ease;
}

/* Dark mode specific overrides */
[data-theme="dark"] .guide-panel { background: #0c2d4a; border-color: #155e75; }
[data-theme="dark"] .guide-panel .guide-content { color: var(--text); }
[data-theme="dark"] .upload-zone { background: var(--bg-card); border-color: var(--border); }
[data-theme="dark"] .upload-zone:hover,
[data-theme="dark"] .upload-zone.dragover { border-color: var(--primary); background: var(--primary-light); }
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select { background: var(--gray-800); color: var(--text); border-color: var(--border); }
[data-theme="dark"] .form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,86,219,0.2); }
[data-theme="dark"] .login-page { background: linear-gradient(135deg, #0a0f1a 0%, #111827 100%); }
[data-theme="dark"] .login-card { background: var(--bg-card); }
[data-theme="dark"] .stat-card { background: var(--bg-card); }
[data-theme="dark"] .preset-card.preset-active { background: #0c2d4a; }
[data-theme="dark"] .badge-success { background: #064e3b; color: #6ee7b7; }
[data-theme="dark"] .badge-warning { background: #78350f; color: #fcd34d; }
[data-theme="dark"] .badge-danger { background: #7f1d1d; color: #fca5a5; }
[data-theme="dark"] .badge-info { background: #164e63; color: #67e8f9; }
[data-theme="dark"] .badge-primary { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .badge-gray { background: var(--gray-700); color: var(--gray-300); }
[data-theme="dark"] .badge-critical { background: #7c2d12; color: #fed7aa; }
[data-theme="dark"] .alert-success { background: #064e3b; color: #6ee7b7; border-left-color: #10b981; }
[data-theme="dark"] .alert-error { background: #7f1d1d; color: #fca5a5; border-left-color: #ef4444; }
[data-theme="dark"] .alert-warning { background: #78350f; color: #fcd34d; border-left-color: #f59e0b; }
[data-theme="dark"] .alert-info { background: #164e63; color: #67e8f9; border-left-color: #06b6d4; }
[data-theme="dark"] .score-display.success { background: #064e3b; color: #6ee7b7; border-color: #10b981; }
[data-theme="dark"] .score-display.warning { background: #78350f; color: #fcd34d; border-color: #f59e0b; }
[data-theme="dark"] .score-display.danger { background: #7f1d1d; color: #fca5a5; border-color: #ef4444; }

/* Trash section */
.trash-toggle { display: flex; align-items: center; gap: 8px; }
.trash-badge { background: var(--danger); color: #fff; border-radius: 50%; width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; font-size: 0.7rem; font-weight: 700; }
.trash-section { display: none; }
.trash-section.show { display: block; }
.trash-row { opacity: 0.7; }
.trash-row td:first-child { border-left: 3px solid var(--danger); }

/* Sortable table headers */
th.sortable a {
    color: var(--text-muted);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}
th.sortable a:hover { color: var(--primary); text-decoration: none; }
.sort-icon { font-size: 0.7rem; opacity: 0.4; line-height: 1; }
.sort-icon.active { opacity: 1; color: var(--primary); }

/* Progress bar / Loading overlay */
.progress-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}
.progress-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 32px 40px;
    text-align: center;
    min-width: 320px;
    max-width: 90vw;
    box-shadow: var(--shadow-lg);
}
.progress-bar-container {
    width: 100%;
    height: 8px;
    background: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
    margin: 16px 0;
}
.progress-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width 0.3s ease;
    animation: progress-indeterminate 1.5s ease-in-out infinite;
    width: 30%;
}
.progress-bar-fill.determinate {
    animation: none;
}
@keyframes progress-indeterminate {
    0% { margin-left: 0; width: 30%; }
    50% { margin-left: 40%; width: 40%; }
    100% { margin-left: 100%; width: 0%; }
}
.progress-text {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 12px;
}
.progress-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* Mobile sidebar overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
}
.sidebar.open ~ .sidebar-overlay,
.sidebar-overlay.show { display: block; }

/* Print styles */
@media print {
    .sidebar, .topbar, .btn, .guide-panel { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .card { break-inside: avoid; box-shadow: none; border: 1px solid #ddd; }
}
