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

:root {
    --primary: #3b82f6;
    --primary-light: #60a5fa;
    --primary-dark: #2563eb;
    --primary-bg: rgba(59,130,246,0.1);
    --primary-glow: rgba(59,130,246,0.25);
    --success: #10b981;
    --success-bg: rgba(16,185,129,0.1);
    --warning: #f59e0b;
    --warning-bg: rgba(245,158,11,0.1);
    --danger: #ef4444;
    --danger-bg: rgba(239,68,68,0.1);

    --sidebar-w: 260px;
    --topbar-h: 64px;
    --radius: 14px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --transition: 0.2s ease;
    --transition-slow: 0.35s ease;
}

/* ===== DARK THEME (DEFAULT) ===== */
[data-theme="dark"] {
    --bg-body: #0f1117;
    --bg-surface: #1a1d27;
    --bg-surface-hover: #22263a;
    --bg-card: #1e2233;
    --bg-input: #161926;
    --border: #2a2e3f;
    --border-hover: #3a3f55;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
    --overlay: rgba(0,0,0,0.6);
}

/* ===== LIGHT THEME ===== */
[data-theme="light"] {
    --bg-body: #f1f5f9;
    --bg-surface: #ffffff;
    --bg-surface-hover: #f8fafc;
    --bg-card: #ffffff;
    --bg-input: #f8fafc;
    --border: #e2e8f0;
    --border-hover: #cbd5e1;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
    --overlay: rgba(0,0,0,0.4);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.5;
    overflow-x: hidden;
    transition: background var(--transition-slow), color var(--transition-slow);
}

/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform var(--transition), background var(--transition-slow);
}

.sidebar-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); }

.logo { display: flex; align-items: center; gap: 0.75rem; }

.logo-icon {
    width: 38px; height: 38px;
    background: linear-gradient(135deg, var(--primary), #6366f1);
    color: white;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 10px var(--primary-glow);
}
.logo-icon svg { width: 20px; height: 20px; }

.logo-text-group { display: flex; flex-direction: column; }
.logo-text { font-size: 1.05rem; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
.logo-sub { font-size: 0.7rem; font-weight: 500; color: var(--primary-light); letter-spacing: 0.04em; }

.nav-menu { list-style: none; padding: 0.75rem; flex: 1; display: flex; flex-direction: column; gap: 2px; }

.nav-item {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.7rem 1rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition);
    user-select: none;
    position: relative;
}
.nav-item:hover { background: var(--bg-surface-hover); color: var(--text-primary); }
.nav-item.active {
    background: var(--primary-bg);
    color: var(--primary-light);
    box-shadow: inset 3px 0 0 var(--primary);
}

.nav-icon { width: 20px; height: 20px; flex-shrink: 0; }

.nav-badge {
    margin-left: auto;
    font-size: 0.7rem;
    font-weight: 600;
    background: var(--primary);
    color: white;
    padding: 0.1rem 0.45rem;
    border-radius: 100px;
    min-width: 20px;
    text-align: center;
}
.nav-badge-danger { background: var(--danger); }

/* Sidebar Footer */
.sidebar-footer { padding: 0.75rem; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 0.5rem; }

.btn-theme {
    width: 100%;
    display: flex; align-items: center; gap: 0.6rem;
    padding: 0.6rem 0.85rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}
.btn-theme:hover { border-color: var(--primary); color: var(--primary-light); }
.btn-theme svg { width: 16px; height: 16px; }

[data-theme="dark"] .icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

.sidebar-btn-group { display: flex; gap: 0.5rem; }

.btn-sidebar {
    flex: 1;
    display: flex; align-items: center; justify-content: center; gap: 0.4rem;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}
.btn-sidebar:hover { border-color: var(--border-hover); color: var(--text-primary); background: var(--bg-surface-hover); }
.btn-sidebar svg { width: 14px; height: 14px; }

/* ===== MAIN CONTENT ===== */
.main-content { margin-left: var(--sidebar-w); min-height: 100vh; transition: margin var(--transition); }

/* ===== TOPBAR ===== */
.topbar {
    position: sticky; top: 0;
    height: var(--topbar-h);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center;
    padding: 0 2rem; gap: 1rem; z-index: 50;
    backdrop-filter: blur(12px);
    transition: background var(--transition-slow);
}

.menu-toggle {
    display: none;
    background: none; border: none;
    cursor: pointer; color: var(--text-secondary);
    padding: 0.25rem;
}
.menu-toggle svg { width: 24px; height: 24px; }

.topbar h1 { font-size: 1.2rem; font-weight: 600; color: var(--text-primary); }
.topbar-actions { margin-left: auto; }

.search-global { position: relative; }
.search-icon { position: absolute; left: 0.75rem; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-muted); pointer-events: none; }
.search-global input {
    padding: 0.5rem 1rem 0.5rem 2.25rem;
    border: 1px solid var(--border);
    border-radius: 100px;
    font-size: 0.85rem;
    width: 280px;
    outline: none;
    transition: all var(--transition);
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: inherit;
}
.search-global input::placeholder { color: var(--text-muted); }
.search-global input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background: var(--bg-surface);
}

/* ===== PAGES ===== */
.page { display: none; padding: 1.5rem 2rem 2rem; }
.page.active { display: block; animation: fadeIn 0.3s ease; }

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

/* ===== STATS GRID ===== */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.5rem; }

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.25rem;
    border: 1px solid var(--border);
    display: flex; align-items: center; gap: 1rem;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    border-radius: var(--radius) var(--radius) 0 0;
    transition: height var(--transition);
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.stat-card:hover::before { height: 4px; }

.stat-total::before { background: linear-gradient(90deg, var(--primary), #6366f1); }
.stat-available::before { background: linear-gradient(90deg, var(--success), #34d399); }
.stat-loaned::before { background: linear-gradient(90deg, var(--warning), #fbbf24); }
.stat-calibration::before { background: linear-gradient(90deg, var(--danger), #f87171); }

.stat-icon {
    width: 48px; height: 48px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.stat-icon svg { width: 24px; height: 24px; }

.stat-total .stat-icon { background: var(--primary-bg); color: var(--primary-light); }
.stat-available .stat-icon { background: var(--success-bg); color: var(--success); }
.stat-loaned .stat-icon { background: var(--warning-bg); color: var(--warning); }
.stat-calibration .stat-icon { background: var(--danger-bg); color: var(--danger); }

.stat-number { font-size: 1.75rem; font-weight: 800; line-height: 1.2; }
.stat-label { font-size: 0.8rem; color: var(--text-secondary); font-weight: 500; }

.stat-total .stat-number { color: var(--primary-light); }
.stat-available .stat-number { color: var(--success); }
.stat-loaned .stat-number { color: var(--warning); }
.stat-calibration .stat-number { color: var(--danger); }

/* ===== DASHBOARD GRID ===== */
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ===== CARDS ===== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 1.25rem 1.5rem;
    transition: all var(--transition);
}
.card:hover { border-color: var(--border-hover); }

.card-animate {
    animation: cardSlideUp 0.4s ease backwards;
}
.card-animate:nth-child(1) { animation-delay: 0.05s; }
.card-animate:nth-child(2) { animation-delay: 0.1s; }
.card-animate:nth-child(3) { animation-delay: 0.15s; }
.card-animate:nth-child(4) { animation-delay: 0.2s; }

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

.card h3 {
    font-size: 0.9rem; font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 0.5rem;
}
.card h3 svg { color: var(--text-muted); }

/* ===== ALERT LIST ===== */
.alert-list { display: flex; flex-direction: column; gap: 0.5rem; max-height: 300px; overflow-y: auto; }

.alert-item {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.65rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    transition: transform var(--transition);
}
.alert-item:hover { transform: translateX(3px); }

.alert-item.alert-danger { background: var(--danger-bg); color: #fca5a5; }
.alert-item.alert-warning { background: var(--warning-bg); color: #fcd34d; }
.alert-item.alert-info { background: var(--primary-bg); color: var(--primary-light); }

[data-theme="light"] .alert-item.alert-danger { color: #dc2626; }
[data-theme="light"] .alert-item.alert-warning { color: #d97706; }
[data-theme="light"] .alert-item.alert-info { color: var(--primary-dark); }

.alert-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.alert-danger .alert-dot { background: var(--danger); }
.alert-warning .alert-dot { background: var(--warning); }
.alert-info .alert-dot { background: var(--primary); }

.alert-item-text { flex: 1; }
.alert-item-meta { font-size: 0.75rem; opacity: 0.8; white-space: nowrap; }

.empty-state { text-align: center; padding: 2rem 1rem; color: var(--text-muted); font-size: 0.9rem; }
.empty-state-icon { font-size: 2.5rem; margin-bottom: 0.5rem; opacity: 0.4; }

/* ===== BREAKDOWN ===== */
.breakdown-list { display: flex; flex-direction: column; gap: 0.6rem; }
.breakdown-item { display: flex; align-items: center; justify-content: space-between; font-size: 0.85rem; }
.breakdown-bar-container { flex: 1; margin: 0 1rem; height: 6px; background: var(--border); border-radius: 100px; overflow: hidden; }
.breakdown-bar { height: 100%; background: linear-gradient(90deg, var(--primary), #6366f1); border-radius: 100px; transition: width 0.6s ease; }
.breakdown-count { font-weight: 600; color: var(--text-primary); min-width: 24px; text-align: right; }
.breakdown-label { color: var(--text-secondary); min-width: 120px; }

/* ===== PAGE ACTIONS ===== */
.page-actions { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; gap: 1rem; flex-wrap: wrap; }
.filter-group { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.filter-group select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.85rem; font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-input);
    cursor: pointer; outline: none;
    transition: all var(--transition);
}
.filter-group select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }

/* ===== BUTTONS ===== */
.btn-primary {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.6rem 1.25rem;
    background: linear-gradient(135deg, var(--primary), #6366f1);
    color: white; border: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem; font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
    white-space: nowrap;
    box-shadow: 0 2px 8px var(--primary-glow);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 16px var(--primary-glow); }
.btn-primary:active { transform: translateY(0); }

.btn-glow { animation: btnPulse 2s ease infinite; }
@keyframes btnPulse {
    0%, 100% { box-shadow: 0 2px 8px var(--primary-glow); }
    50% { box-shadow: 0 2px 20px var(--primary-glow); }
}

.btn-secondary {
    padding: 0.55rem 1.25rem;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.85rem; font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}
.btn-secondary:hover { background: var(--bg-surface-hover); border-color: var(--border-hover); }

.btn-danger {
    padding: 0.55rem 1.25rem;
    background: var(--danger);
    color: white; border: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem; font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}
.btn-danger:hover { background: #dc2626; }

.btn-icon {
    padding: 0.35rem 0.5rem;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.85rem;
    transition: all var(--transition);
    line-height: 1;
}
.btn-icon:hover { background: var(--bg-surface-hover); color: var(--text-primary); border-color: var(--border-hover); }

.btn-icon.btn-return { color: var(--success); border-color: rgba(16,185,129,0.3); }
.btn-icon.btn-return:hover { background: var(--success-bg); }

/* ===== TABLES ===== */
.table-container {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    transition: background var(--transition-slow);
}
.data-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.data-table thead { background: var(--bg-input); border-bottom: 1px solid var(--border); }
.data-table th {
    padding: 0.75rem 1rem; text-align: left;
    font-weight: 600; color: var(--text-muted);
    font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em;
    white-space: nowrap;
}
.data-table td { padding: 0.7rem 1rem; border-bottom: 1px solid var(--border); color: var(--text-secondary); }
.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:hover { background: var(--bg-surface-hover); }
.data-table tbody tr:last-child td { border-bottom: none; }
.action-btns { display: flex; gap: 0.35rem; }

/* ===== LOAN CARDS ===== */
.loan-cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 1rem; }

.loan-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    transition: all var(--transition);
    animation: cardSlideUp 0.3s ease backwards;
}
.loan-card:hover { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary-glow), var(--shadow-md); transform: translateY(-2px); }

.loan-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 0.75rem; }
.loan-card-title { font-weight: 600; font-size: 1rem; color: var(--text-primary); }
.loan-card-id { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.15rem; }

.loan-card-overdue { border-left: 4px solid var(--danger); }
.loan-card-overdue .loan-overdue-tag { display: inline-block; }
.loan-overdue-tag { display: none; font-size: 0.7rem; background: var(--danger-bg); color: var(--danger); padding: 0.15rem 0.5rem; border-radius: 100px; font-weight: 600; }

.loan-card-details { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; margin-bottom: 0.75rem; }
.loan-detail-item { display: flex; flex-direction: column; }
.loan-detail-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; font-weight: 500; }
.loan-detail-value { font-size: 0.85rem; color: var(--text-primary); font-weight: 500; }

.loan-card-photo { margin: 0.75rem 0; }
.loan-card-photo img {
    width: 100%; max-height: 180px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all var(--transition);
}
.loan-card-photo img:hover { opacity: 0.85; transform: scale(1.01); }

.loan-card-notes { font-size: 0.82rem; color: var(--text-secondary); padding: 0.5rem 0.75rem; background: var(--bg-input); border-radius: var(--radius-sm); margin-bottom: 0.75rem; font-style: italic; }

.loan-card-footer { display: flex; justify-content: flex-end; }

/* ===== BADGES ===== */
.badge {
    display: inline-flex; align-items: center;
    padding: 0.2rem 0.65rem;
    border-radius: 100px;
    font-size: 0.75rem; font-weight: 600;
    white-space: nowrap;
}
.badge-available { background: var(--success-bg); color: var(--success); }
.badge-loaned { background: var(--warning-bg); color: var(--warning); }
.badge-missing { background: var(--danger-bg); color: var(--danger); }
.badge-overdue { background: var(--danger-bg); color: var(--danger); }
.badge-soon { background: var(--warning-bg); color: var(--warning); }
.badge-ok { background: var(--success-bg); color: var(--success); }
.badge-none { background: rgba(100,116,139,0.1); color: var(--text-muted); }

/* ===== TABS ===== */
.loan-tabs, .calibration-tabs {
    display: flex; gap: 0.25rem;
    background: var(--bg-input);
    padding: 0.25rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}
.tab-btn {
    padding: 0.45rem 1rem;
    border: none; border-radius: var(--radius-xs);
    background: transparent;
    font-size: 0.85rem; font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}
.tab-btn.active { background: var(--primary); color: white; box-shadow: 0 1px 4px var(--primary-glow); }
.tab-btn:hover:not(.active) { color: var(--text-primary); }

/* ===== MODALS ===== */
.modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: var(--overlay);
    backdrop-filter: blur(6px);
    z-index: 200;
    align-items: center; justify-content: center;
    padding: 1rem;
}
.modal-overlay.open { display: flex; }

.modal {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%; max-width: 640px; max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.25s ease;
}
.modal-sm { max-width: 440px; }

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.96) translateY(8px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 1.1rem; font-weight: 600; color: var(--text-primary); }
.modal-close {
    background: none; border: none;
    font-size: 1.5rem; color: var(--text-muted);
    cursor: pointer; padding: 0.25rem; line-height: 1;
    transition: color var(--transition);
}
.modal-close:hover { color: var(--text-primary); }

.modal-footer { display: flex; justify-content: flex-end; gap: 0.5rem; padding: 1rem 1.5rem; border-top: 1px solid var(--border); }

/* ===== FORMS ===== */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; padding: 1.5rem; }
.form-group { display: flex; flex-direction: column; gap: 0.35rem; }
.form-group.full-width { grid-column: 1 / -1; }
.form-group label { font-size: 0.8rem; font-weight: 500; color: var(--text-secondary); }

.form-group input,
.form-group select,
.form-group textarea {
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.85rem; font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-input);
    outline: none;
    transition: all var(--transition);
}
.form-group input::placeholder, .form-group textarea::placeholder { color: var(--text-muted); }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background: var(--bg-surface);
}
.form-group textarea { resize: vertical; }

/* ===== PHOTO UPLOAD ===== */
.photo-upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    color: var(--text-muted);
}
.photo-upload-area:hover { border-color: var(--primary); background: var(--primary-bg); color: var(--primary-light); }
.photo-upload-area p { margin-top: 0.5rem; font-size: 0.85rem; font-weight: 500; }
.photo-hint { font-size: 0.75rem; opacity: 0.7; }
.photo-upload-area.drag-over { border-color: var(--primary); background: var(--primary-bg); }

.photo-preview {
    position: relative;
    margin-top: 0.5rem;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
}
.photo-preview img { width: 100%; max-height: 200px; object-fit: cover; display: block; }
.photo-remove {
    position: absolute; top: 0.5rem; right: 0.5rem;
    width: 28px; height: 28px;
    background: rgba(0,0,0,0.7); color: white;
    border: none; border-radius: 50%;
    font-size: 1.1rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background var(--transition);
}
.photo-remove:hover { background: var(--danger); }

/* ===== LIGHTBOX ===== */
.lightbox {
    display: flex; align-items: center; justify-content: center;
    width: 100%; height: 100%;
    position: relative;
}
.lightbox img { max-width: 90%; max-height: 90vh; border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.lightbox-close { position: absolute; top: 1rem; right: 1rem; font-size: 2rem; color: white; z-index: 10; }

/* ===== DETAIL CONTENT ===== */
.detail-content { padding: 1.5rem; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.detail-field { display: flex; flex-direction: column; gap: 0.2rem; }
.detail-field.full-width { grid-column: 1 / -1; }
.detail-label { font-size: 0.75rem; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.detail-value { font-size: 0.9rem; color: var(--text-primary); font-weight: 500; }
.detail-section-title {
    grid-column: 1 / -1;
    font-size: 0.85rem; font-weight: 600;
    color: var(--text-primary);
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
    margin-top: 0.25rem;
}

/* Thumbnail in table */
.photo-thumb {
    width: 40px; height: 40px;
    object-fit: cover;
    border-radius: var(--radius-xs);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: transform var(--transition);
}
.photo-thumb:hover { transform: scale(1.15); }

/* ===== TOAST ===== */
.toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 300; display: flex; flex-direction: column; gap: 0.5rem; }
.toast {
    padding: 0.75rem 1.25rem;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
    max-width: 360px;
    display: flex; align-items: center; gap: 0.5rem;
}
.toast-success { border-left: 4px solid var(--success); }
.toast-error { border-left: 4px solid var(--danger); }
.toast-warning { border-left: 4px solid var(--warning); }

@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateY(-10px); } }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 100px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .dashboard-grid { grid-template-columns: 1fr; }
    .loan-cards-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
    .main-content { margin-left: 0; }
    .menu-toggle { display: block; }
    .topbar { padding: 0 1rem; }
    .page { padding: 1rem; }
    .search-global input { width: 160px; }
    .form-grid { grid-template-columns: 1fr; }
    .data-table { font-size: 0.8rem; }
    .data-table th, .data-table td { padding: 0.5rem 0.65rem; }
    .page-actions { flex-direction: column; align-items: stretch; }
    .filter-group { flex-direction: column; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
    .stat-card { padding: 0.85rem; flex-direction: column; align-items: flex-start; gap: 0.5rem; }
    .stat-icon { width: 36px; height: 36px; }
    .stat-icon svg { width: 18px; height: 18px; }
    .stat-number { font-size: 1.35rem; }
    .detail-grid { grid-template-columns: 1fr; }
}
