:root {
    color-scheme: light;
    --bg: #f0f4f8;
    --surface: #ffffff;
    --surface-soft: #f7f9fc;
    --surface-strong: #e8eef7;
    --text: #0f172a;
    --text-muted: #667085;
    --text-light: #98a2b3;
    --border: #d8e2f1;
    --primary: #5366ff;
    --primary-light: #6b7fff;
    --primary-dark: #3d4dd9;
    --success: #10b981;
    --success-light: #6ee7b7;
    --danger: #ef4444;
    --danger-light: #f87171;
    --warning: #f59e0b;
    --warning-light: #fbbf24;
    --info: #3b82f6;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.08);
    --shadow-xl: 0 20px 50px rgba(0, 0, 0, 0.1);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
        'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
        sans-serif;
    background: linear-gradient(135deg, #f0f4f8 0%, #e8eef7 100%);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

img,
svg {
    display: block;
    max-width: 100%;
}

.container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(135deg, rgba(83, 102, 255, 0.1) 0%, rgba(16, 185, 129, 0.1) 100%);
}

.container .card {
    width: 100%;
    max-width: 520px;
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    padding: 40px;
    animation: slideInUp 0.4s ease;
}

.logo {
    text-align: center;
    margin-bottom: 32px;
}

.logo .logo-icon {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--primary-dark), var(--primary-light));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    color: white;
    margin-bottom: 18px;
    box-shadow: 0 8px 20px rgba(83, 102, 255, 0.25);
}

.logo h2 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}

.logo p {
    color: var(--text-muted);
    font-size: 15px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #334155;
    font-weight: 600;
    font-size: 14px;
    letter-spacing: 0.3px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    min-height: 48px;
    padding: 12px 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    background: #f8fafc;
    color: var(--text);
    font-size: 14px;
    transition: all 0.3s ease;
}

.form-group textarea {
    min-height: 120px;
    resize: vertical;
}

.form-group input:hover,
.form-group select:hover,
.form-group textarea:hover {
    border-color: #cbd5e1;
    background: #ffffff;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(83, 102, 255, 0.1), inset 0 0 0 1px var(--primary);
}

.form-group input:invalid:not(:placeholder-shown),
.form-group select:invalid {
    border-color: var(--danger);
}

.form-group input:invalid:not(:placeholder-shown):focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1), inset 0 0 0 1px var(--danger);
}

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

.btn-primary {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(83, 102, 255, 0.3);
    letter-spacing: 0.3px;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(83, 102, 255, 0.4);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.text-center {
    text-align: center;
    margin-top: 20px;
}

.text-center a {
    color: var(--primary-dark);
    text-decoration: none;
}

/* ============ ADMIN PANEL LAYOUT ============ */
.admin-wrapper {
    display: flex;
    min-height: 100vh;
    background: var(--bg);
}

.sidebar {
    width: 280px;
    background: linear-gradient(180deg, #1a2847 0%, #232e48 100%);
    color: #f8fafc;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    padding-bottom: 24px;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 2px 0 10px rgba(15, 23, 42, 0.1);
}

.sidebar-header {
    padding: 32px 26px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 6px;
}

.sidebar-header p {
    font-size: 13px;
    color: rgba(248, 250, 252, 0.6);
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin-top: 24px;
    flex: 1;
}

.sidebar-menu li {
    margin-bottom: 4px;
}

.sidebar-menu li a {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 22px;
    color: rgba(226, 232, 240, 0.85);
    border-radius: var(--radius-lg);
    transition: all 0.25s ease;
    font-size: 14px;
    font-weight: 500;
    position: relative;
    margin: 0 12px;
}

.sidebar-menu li a::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--primary);
    border-radius: 0 4px 4px 0;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.sidebar-menu li a:hover {
    background: rgba(99, 102, 241, 0.15);
    color: #ffffff;
}

.sidebar-menu li a.active {
    background: rgba(99, 102, 241, 0.2);
    color: #ffffff;
}

.sidebar-menu li a.active::before {
    opacity: 1;
}

.main-content {
    flex: 1;
    margin-left: 280px;
    padding: 36px 40px;
    min-width: 0;
    width: calc(100% - 280px);
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 32px;
    padding: 26px 32px;
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
}

.top-bar h1 {
    font-size: 32px;
    font-weight: 700;
    color: var(--text);
}

.admin-info {
    display: flex;
    align-items: center;
}

.admin-name {
    display: inline-flex;
    align-items: center;
    padding: 12px 18px;
    border-radius: 999px;
    background: rgba(99,102,241,0.12);
    color: var(--primary-dark);
    font-weight: 700;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius-xl);
    padding: 28px;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 18px;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    font-size: 44px;
    flex-shrink: 0;
}

.stat-info {
    flex: 1;
}

.stat-info h3 {
    margin-bottom: 8px;
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-info p {
    font-size: 36px;
    font-weight: 700;
    color: var(--text);
}

.stat-card.safe .stat-info p {
    color: var(--success);
}

.stat-card.missing .stat-info p {
    color: var(--danger);
}

.stat-card.unaccounted .stat-info p {
    color: var(--warning);
}

.card {
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    margin-bottom: 32px;
    border: 1px solid #e2e8f0;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    padding: 28px 32px;
    border-bottom: 1px solid #e2e8f0;
    flex-wrap: wrap;
}

.card-header h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
}

.btn-refresh {
    padding: 12px 24px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.25s ease;
    box-shadow: 0 4px 12px rgba(83, 102, 255, 0.3);
}

.btn-refresh:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(83, 102, 255, 0.4);
}

.table-responsive {
    overflow-x: auto;
    padding: 20px;
    width: 100%;
}

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

thead {
    background: linear-gradient(180deg, #f8fafc 0%, #f0f4f8 100%);
}

th,
td {
    padding: 16px 18px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

th {
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text-muted);
}

td {
    color: #475569;
    font-size: 14px;
}

tbody tr {
    transition: background 0.2s ease;
}

tbody tr:hover {
    background: rgba(83, 102, 255, 0.04);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.status-safe {
    background: #d1fae5;
    color: var(--success);
}

.status-missing {
    background: #fee2e2;
    color: var(--danger);
}

.status-unaccounted {
    background: #fef3c7;
    color: var(--warning);
}

.status-active {
    background: #dbeafe;
    color: var(--info);
}

.status-resolved {
    background: #d1fae5;
    color: var(--success);
}

.last-updated {
    text-align: center;
    padding: 16px 20px;
    font-size: 13px;
    color: var(--text-muted);
    background: var(--surface-soft);
    border-radius: var(--radius-lg);
    margin-top: 16px;
    border: 1px solid #e2e8f0;
}

/* Animations */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    max-width: 500px;
    width: 90%;
    animation: slideInUp 0.3s ease;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 28px 32px;
    border-bottom: 1px solid #e2e8f0;
}

.modal-header h3 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}

.close {
    font-size: 28px;
    font-weight: 300;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.25s ease;
    line-height: 1;
}

.close:hover {
    color: var(--text);
}

.modal-body {
    padding: 28px 32px;
}

/* Filters Bar */
.filters-bar {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
    align-items: center;
}

.search-box {
    flex: 1;
    min-width: 250px;
}

.search-box input {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    font-size: 14px;
    background: var(--surface);
    transition: all 0.25s ease;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(83, 102, 255, 0.1);
}

.filter-group {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.filter-group select {
    padding: 12px 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    font-size: 14px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    transition: all 0.25s ease;
    min-width: 180px;
}

.filter-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(83, 102, 255, 0.1);
}

/* Media Queries */
@media (max-width: 1280px) {
    .main-content {
        padding: 24px 28px;
    }
    
    .stats-grid {
        gap: 20px;
    }
    
    .stat-card {
        padding: 20px;
    }
    
    .stat-info p {
        font-size: 28px;
    }
}

@media (max-width: 1024px) {
    .sidebar {
        width: 72px;
    }

    .main-content {
        margin-left: 72px;
        padding: 20px;
        width: calc(100% - 72px);
    }

    .sidebar-header h2,
    .sidebar-header p,
    .sidebar-menu li a span {
        display: none;
    }
    
    .sidebar-menu li a {
        justify-content: center;
        padding: 16px;
    }

    .top-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
        padding: 20px;
    }
    
    .top-bar h1 {
        font-size: 28px;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        padding: 20px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
}

@media (max-width: 768px) {
    .main-content {
        padding: 16px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .stat-card {
        padding: 18px;
    }
    
    .stat-icon {
        font-size: 32px;
    }
    
    .stat-info p {
        font-size: 24px;
    }
    
    .table-responsive {
        padding: 12px;
    }
    
    th,
    td {
        padding: 12px 10px;
    }
    
    th {
        font-size: 11px;
    }
    
    td {
        font-size: 13px;
    }
    
    .card-header h2 {
        font-size: 18px;
    }
    
    .btn-refresh {
        width: 100%;
    }
}

@media (max-width: 640px) {
    body {
        font-size: 14px;
    }
    
    .top-bar {
        padding: 16px;
    }
    
    .top-bar h1 {
        font-size: 24px;
    }
    
    .admin-name {
        font-size: 13px;
        padding: 8px 14px;
    }
    
    .card {
        border-radius: 20px;
    }
    
    .card-header {
        padding: 16px;
    }
    
    .card-header h2 {
        font-size: 16px;
    }
    
    .table-responsive {
        padding: 8px;
    }
    
    th, td {
        padding: 10px 8px;
        font-size: 12px;
    }
    
    .status-badge {
        padding: 4px 10px;
        font-size: 11px;
    }
    
    .last-updated {
        font-size: 11px;
        padding: 12px;
    }
}