/* ── Base ── */
:root {
    --bg: #f8f9fa;
    --surface: #ffffff;
    --border: #e2e5e9;
    --text: #212529;
    --text-muted: #6c757d;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff4ff;
    --success: #16a34a;
    --success-hover: #15803d;
    --danger: #dc2626;
    --accent: #0f172a;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.1);
    --sidebar-width: 240px;
}

* {
    border-radius: 0 !important;
}

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    font-size: 14px;
    margin: 0;
    min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background-color: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform 0.2s ease;
}

.sidebar-header {
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.sidebar-brand {
    font-size: 18px;
    font-weight: 800;
    color: var(--accent);
    text-decoration: none;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.sidebar-brand:hover {
    color: var(--accent);
    text-decoration: none;
}

.sidebar-subtitle {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.3px;
    border-left: 3px solid transparent;
    transition: all 0.12s ease;
}

.sidebar-link i {
    font-size: 16px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-link:hover {
    color: var(--text);
    background-color: var(--bg);
    text-decoration: none;
}

.sidebar-link.active {
    color: var(--primary);
    background-color: var(--primary-light);
    border-left-color: var(--primary);
    font-weight: 600;
}

.sidebar-link.active i {
    color: var(--primary);
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 1px;
    color: var(--text-muted);
}

.sidebar-user i {
    font-size: 18px;
}

.sidebar-logout {
    margin-left: auto;
    color: var(--text-muted);
    font-size: 16px;
    padding: 4px;
    transition: color 0.15s ease;
    text-decoration: none;
}

.sidebar-logout:hover {
    color: var(--danger);
}

/* ── Table Row Selection ── */
tr.row-selected {
    background-color: #dbeafe !important;
}

.row-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary);
}

th.col-check,
td.col-check {
    width: 36px;
    text-align: center;
    padding-left: 10px !important;
    padding-right: 4px !important;
}

/* ── Progress section with copy button ── */
.progress-section .btn + .btn {
    margin-left: 8px;
}

/* ── Result table fills viewport ── */
.table-wrapper-scroll {
    max-height: calc(100vh - 140px);
    overflow-y: auto;
}

.result-page {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 56px);
}

.result-page .table-wrapper-scroll {
    flex: 1;
    max-height: none;
    overflow-y: auto;
}

.result-page .progress-section {
    flex-shrink: 0;
}

/* ── Form Pages ── */
.form-page {
    max-width: 680px;
}

/* ── Mobile topbar ── */
.sidebar-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 52px;
    background-color: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 1030;
}

.sidebar-topbar .sidebar-brand {
    font-size: 16px;
}

.sidebar-toggle {
    background: none;
    border: 1px solid var(--border);
    padding: 6px 10px;
    font-size: 20px;
    color: var(--text);
    cursor: pointer;
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.4);
    z-index: 1035;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

/* Mobile: sidebar off-screen by default */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    body.sidebar-open .sidebar-overlay {
        opacity: 1;
        pointer-events: auto;
    }

    .main-content {
        margin-left: 0 !important;
        padding-top: 52px;
    }
}

/* ── Main Content ── */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.content-inner {
    padding: 28px 32px;
    max-width: 1400px;
}

/* ── Buttons ── */
.btn {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 10px 24px;
    border: none;
    transition: all 0.15s ease;
}

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

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

.btn-success {
    background-color: var(--success);
    color: #fff;
}

.btn-success:hover {
    background-color: var(--success-hover);
}

.btn-secondary {
    background-color: var(--accent);
    color: #fff;
}

.btn-secondary:hover {
    background-color: #1e293b;
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-outline:hover {
    background-color: var(--bg);
}

/* ── Forms ── */
.form-control,
.form-select {
    border: 1px solid var(--border);
    background-color: var(--surface);
    color: var(--text);
    padding: 10px 12px;
    font-size: 14px;
    transition: border-color 0.15s ease;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
    outline: none;
}

textarea.form-control {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.6;
    resize: vertical;
}

.form-check-input {
    border: 1px solid var(--border) !important;
}

.form-check-input:checked {
    background-color: var(--primary) !important;
    border-color: var(--primary) !important;
}

.form-label,
label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

/* ── Cards ── */
.card {
    background-color: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.card-header {
    background-color: var(--bg);
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding: 12px 16px;
}

.card-body {
    padding: 20px;
}

/* ── Tables ── */
.table {
    border: 1px solid var(--border);
    margin-bottom: 0;
    font-size: 13px;
}

.table thead th {
    background-color: var(--accent);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 10px 14px;
    border: none;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
}

.table tbody td {
    padding: 10px 14px;
    border-color: var(--border);
    vertical-align: middle;
}

.table-striped tbody tr:nth-child(odd) {
    background-color: #fafbfc;
}

.table-striped tbody tr:nth-child(even) {
    background-color: var(--surface);
}

.table tbody tr:hover {
    background-color: #eef2ff;
}

.table caption {
    caption-side: top;
    color: var(--text);
    font-weight: 600;
    font-size: 14px;
    padding: 8px 0;
}

/* ── Table Wrapper ── */
.table-wrapper {
    border: 1px solid var(--border);
    overflow: auto;
    box-shadow: var(--shadow);
    background-color: var(--surface);
}

.table-wrapper .table {
    border: none;
    margin: 0;
}

.table-wrapper-scroll {
    max-height: 500px;
    overflow-y: auto;
}

/* Sticky first column — only for stat tables */
.table-wrapper-sticky .table th:first-child,
.table-wrapper-sticky .table td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    background-color: inherit;
}

/* ── Alerts ── */
.alert {
    border: 1px solid;
    font-size: 13px;
    padding: 12px 16px;
}

.alert-danger {
    background-color: #fef2f2;
    border-color: #fecaca;
    color: var(--danger);
}

/* ── Code Block ── */
.code-output {
    background-color: #f1f5f9;
    border: 1px solid var(--border);
    padding: 16px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text);
    max-height: 400px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

/* ── Progress ── */
.progress-section {
    text-align: center;
    padding: 24px 0;
}

.progress-section h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* ── Stat page ── */
.stat-header {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 20px 0;
}

.stat-header img {
    width: 80px;
}

.stat-month {
    font-size: 32px;
    font-weight: 700;
    color: var(--accent);
}

.stat-total {
    font-size: 20px;
    font-weight: 600;
}

.stat-total strong {
    font-size: 28px;
    color: var(--primary);
}

.td-success {
    background-color: #dcfce7 !important;
    color: var(--success);
    font-weight: 600;
}

/* ── Login ── */
.login-wrapper {
    max-width: 380px;
    margin: 80px auto;
}

.login-wrapper h1 {
    font-size: 20px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 32px;
    color: var(--accent);
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}
