:root {
    --bg: #f1f5f9;
    --surface: #ffffff;
    --surface-alt: #f8fafc;
    --sidebar: #0f172a;
    --sidebar-hover: rgba(255, 255, 255, 0.08);
    --sidebar-active: rgba(59, 130, 246, 0.22);
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary: #059669;
    --warning: #d97706;
    --danger: #dc2626;
    --purple: #7c3aed;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 4px 12px rgba(15, 23, 42, 0.04);
}

* { box-sizing: border-box; }

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

.hidden { display: none !important; }

/* --- Auth & Public Screens --- */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: radial-gradient(circle at top left, #dbeafe 0%, #f1f5f9 45%, #ede9fe 100%);
}

.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 36px;
    width: 100%;
    max-width: 520px;
    box-shadow: 0 20px 45px rgba(15, 23, 42, 0.1);
}

.auth-card.wide { max-width: 720px; }

.brand-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #eff6ff;
    color: var(--primary);
    border: 1px solid #bfdbfe;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 12px;
}

.auth-card h1, .auth-card h2 { margin: 0 0 8px 0; font-size: 24px; font-weight: 700; }
.auth-card p.sub { margin: 0 0 24px 0; color: var(--text-muted); font-size: 14px; line-height: 1.5; }

/* --- App Shell --- */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    flex-shrink: 0;
    background: var(--sidebar);
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    padding: 20px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-logo {
    padding: 6px 12px 18px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 16px;
}
.sidebar-logo h2 { margin: 0; font-size: 18px; color: #fff; font-weight: 700; }
.sidebar-logo span { font-size: 12px; color: #94a3b8; display: block; margin-top: 2px; }

.nav-section-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #64748b;
    padding: 10px 12px 6px 12px;
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #cbd5e1;
    margin-bottom: 4px;
    transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: var(--sidebar-active); color: #93c5fd; font-weight: 600; }

.sidebar-footer {
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.main-area {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar-left { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.topbar-title { margin: 0; font-size: 19px; font-weight: 700; }

.session-picker {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    padding: 5px 10px;
    border-radius: 8px;
}
.session-picker select {
    border: none;
    background: transparent;
    font-weight: 600;
    font-size: 13px;
    color: var(--text);
    outline: none;
    cursor: pointer;
}

.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.content-body { padding: 24px; max-width: 1440px; width: 100%; margin: 0 auto; }

/* --- Cards, Grids, Forms, Buttons --- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.card-header h3 { margin: 0; font-size: 16px; font-weight: 700; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; }
.stat-value { font-size: 28px; font-weight: 700; margin-top: 6px; color: var(--text); }
.stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 14px;
}
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--text-muted); }

input[type="text"], input[type="password"], input[type="email"], input[type="number"], input[type="date"], input[type="time"], select, textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    background: #fff;
    outline: none;
    transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 15px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.15s, opacity 0.15s;
    text-decoration: none;
    white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: var(--secondary); color: #fff; }
.btn-secondary:hover:not(:disabled) { background: #047857; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-purple { background: var(--purple); color: #fff; }
.btn-outline { background: #fff; color: var(--text); border-color: var(--border); }
.btn-outline:hover:not(:disabled) { background: var(--surface-alt); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }

/* --- Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}
.badge-admin { background: #dbeafe; color: #1d4ed8; }
.badge-verifier { background: #fef3c7; color: #b45309; }
.badge-guide { background: #ede9fe; color: #6d28d9; }
.badge-green { background: #dcfce7; color: #15803d; }
.badge-amber { background: #fef3c7; color: #b45309; }
.badge-red { background: #fee2e2; color: #b91c1c; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-slate { background: #e2e8f0; color: #334155; }

/* --- Tables --- */
.table-wrap { overflow-x: auto; }
table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
table.data-table th {
    background: var(--surface-alt);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 12px;
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
table.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
table.data-table tr:hover td { background: #f8fafc; }

/* --- Alerts & Walkthrough --- */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 14px;
    border: 1px solid transparent;
}
.alert-info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.alert-warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert-success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.alert-danger { background: #fef2f2; border-color: #fecaca; color: #991b1b; }

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000;
}
.modal-box {
    background: var(--surface);
    border-radius: 14px;
    max-width: 780px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
}

.timeline { display: flex; flex-direction: column; gap: 10px; }
.timeline-step {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface-alt);
}
.timeline-dot {
    width: 24px; height: 24px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.timeline-dot.done { background: #16a34a; color: #fff; }
.timeline-dot.wait { background: #cbd5e1; color: #334155; }
.timeline-dot.warn { background: #dc2626; color: #fff; }

/* --- Print Styles (Preserving Official Format-1 Certificate + BPUT Markfoil + Attendance + Summary) --- */
#print-area { display: none; }

@media print {
    html, body {
        background: #fff !important;
        color: #000 !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    #appRoot, #publicRoot, #modalRoot, .modal-backdrop { display: none !important; }
    #print-area { display: block !important; }

    /* Format-1 Certificate */
    .certificate-page {
        width: 210mm;
        height: 297mm;
        box-sizing: border-box;
        page-break-after: always;
        break-after: page;
        position: relative;
        background: #fff;
        overflow: hidden;
    }
    .certificate-page:last-child { page-break-after: auto; break-after: auto; }
    .certificate-border {
        height: 100%;
        width: 100%;
        box-sizing: border-box;
        padding: 50px 60px;
        display: flex;
        flex-direction: column;
    }
    .cert-title {
        text-align: center;
        font-family: 'Times New Roman', serif;
        font-size: 24px;
        font-weight: bold;
        color: #224b8b;
        text-decoration: underline;
        margin-bottom: 36px;
        letter-spacing: 1px;
    }
    .cert-body {
        font-family: 'Times New Roman', serif;
        font-size: 18px;
        line-height: 1.8;
        text-align: justify;
        color: #000;
    }
    .cert-body p { margin-bottom: 22px; }
    .signature-area {
        margin-top: auto;
        display: flex;
        justify-content: space-between;
        align-items: flex-end;
        font-family: 'Times New Roman', serif;
        padding-top: 40px;
    }
    .sign-block { text-align: center; }

    /* Format-2 BPUT Markfoil (A4 Landscape) */
    .markfoil-page {
        width: auto;
        margin: 0;
        padding: 17mm 16mm 10mm 16mm;
        box-sizing: border-box;
        page-break-after: always;
        break-after: page;
        font-family: 'Arial Narrow', Arial, sans-serif;
        font-size: 9pt;
        color: #000;
    }
    .markfoil-page:last-child { page-break-after: auto; break-after: auto; }
    .header-title {
        text-align: center;
        font-weight: bold;
        font-size: 14pt;
        text-decoration: underline;
        margin: 0 0 12pt 0;
        text-transform: uppercase;
    }
    .info-table { width: 100%; border-collapse: collapse; margin-bottom: 18pt; font-size: 11pt; }
    .info-table td { width: 50%; padding: 1.5pt 2mm; vertical-align: top; border: none; line-height: 1.25; }
    .info-table span.val { font-weight: bold; text-transform: uppercase; margin-left: 4pt; }
    .mark-table { width: 100%; border-collapse: collapse; table-layout: auto; }
    .mark-table col.c-slno { width: 4.5%; }
    .mark-table col.c-regno { width: 9%; }
    .mark-table col.c-title { width: 16.5%; }
    .mark-table col.c-mark { width: 7%; }
    .mark-table th {
        border: 0.75pt solid #000; padding: 1.5pt 1pt; text-align: center; vertical-align: middle;
        font-size: 10.5pt; font-weight: normal; line-height: 1.12; height: 25mm;
    }
    .mark-table td {
        border: 0.75pt solid #000; padding: 2pt; text-align: center; vertical-align: middle;
        font-size: 11pt; height: 16mm; word-wrap: break-word;
    }
    .signatures {
        display: flex; justify-content: space-between; align-items: flex-start;
        padding: 0 9%; font-size: 11pt; margin-top: 34pt;
    }
    .sig-block { text-align: center; display: flex; flex-direction: column; align-items: center; min-width: 34mm; }
    .sig-line { display: block; width: 38mm; height: 34pt; }

    /* Attendance & Summary (A4 Portrait) */
    .attendance-page {
        width: auto; margin: 0; padding: 10mm; box-sizing: border-box;
        page-break-after: always; break-after: page;
        font-family: 'Times New Roman', serif; color: #000;
    }
    .attendance-page:last-child { page-break-after: auto; break-after: auto; }
}
