:root {
    --bg: #f4f6f9;
    --surface: #ffffff;
    --surface-muted: #f9fafb;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --accent: #0ea5a3;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #e5e7eb;
    --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Sora', 'Segoe UI', sans-serif;
    background: radial-gradient(1200px 600px at 15% 10%, #eef2ff 0%, rgba(238, 242, 255, 0) 60%),
        radial-gradient(900px 500px at 90% 5%, #ecfeff 0%, rgba(236, 254, 255, 0) 55%),
        var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

a {
    color: var(--primary);
}

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

.sidebar {
    width: 260px;
    background: linear-gradient(160deg, #ffffff 0%, #f1f5f9 100%);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    padding: 24px 18px;
    overflow-y: auto;
    transition: width 0.2s ease;
    z-index: 1030;
}

.sidebar .brand {
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 24px;
    color: var(--text);
}

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

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
}

.sidebar-nav a.active,
.sidebar-nav a:hover {
    background: #e0e7ff;
    color: #1e3a8a;
}

.sidebar .subtext {
    color: var(--muted);
    font-size: 0.8rem;
}

.app-content {
    margin-left: 260px;
    flex: 1;
    min-width: 0;
    padding: 24px 28px 40px;
    transition: margin-left 0.2s ease;
}

.topbar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 16px 20px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.topbar h1 {
    font-size: 1.25rem;
    margin: 0;
}

.topbar-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.card {
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
}

.table thead th {
    position: sticky;
    top: 0;
    background: #f8fafc;
    z-index: 1;
}

.badge-status {
    border-radius: 999px;
    padding: 4px 10px;
    font-weight: 600;
    font-size: 0.75rem;
}

.badge-status.done {
    background: #dcfce7;
    color: #166534;
}

.badge-status.pending {
    background: #fef3c7;
    color: #92400e;
}

.form-control,
.form-select {
    border-radius: 12px;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.page-enter {
    animation: fadeUp 0.4s ease;
}

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

.sidebar-collapsed .sidebar {
    width: 84px;
}

.sidebar-collapsed .app-content {
    margin-left: 84px;
}

.sidebar-collapsed .sidebar-nav span {
    display: none;
}

.image-thumb {
    width: 54px;
    height: 54px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.table-responsive {
    max-height: 60vh;
    max-width: 100%;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable;
}

.table-responsive > .table {
    width: max-content;
    min-width: 100%;
}

.qc-table thead th {
    position: sticky;
    top: 0;
    background: #f8fafc;
    z-index: 2;
}

.qc-table thead tr:first-child th {
    top: 0;
    z-index: 3;
}

.qc-table thead tr:nth-child(2) th {
    top: var(--qc-header-offset, 38px);
    z-index: 2;
}

.qc-measure.qc-in-range {
    background: #dcfce7;
    border-color: #86efac;
    color: #166534;
}

.qc-measure.qc-out-range {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #991b1b;
}

@media (max-width: 992px) {
    .app-shell {
        flex-direction: column;
    }
    .sidebar {
        position: static;
        width: 100%;
        height: auto;
        border-right: 0;
    }
    .sidebar-collapsed .sidebar {
        display: none;
    }
    .app-content {
        margin-left: 0;
        padding: 16px;
    }
    .sidebar-collapsed .app-content {
        margin-left: 0;
    }
    .topbar {
        flex-direction: column;
        align-items: flex-start;
    }
    .topbar-actions {
        width: 100%;
    }
    .topbar-actions .btn {
        flex: 1 1 160px;
    }
}

@media (max-width: 768px) {
    .topbar {
        padding: 12px 14px;
    }
    .card {
        border-radius: 14px;
    }
    .table-responsive {
        max-height: none;
    }
    .sidebar-nav a {
        padding: 8px 10px;
    }
}

@media (max-width: 576px) {
    .app-content {
        padding: 12px;
    }
    .topbar h1 {
        font-size: 1.1rem;
    }
    .image-thumb {
        width: 44px;
        height: 44px;
    }
}
