/* ============================================
   Design tokens
   ============================================ */
:root {
    --brand: #4f46e5;
    --brand-dark: #4338ca;
    --brand-light: #eef2ff;

    --ink: #111827;
    --ink-soft: #4b5563;
    --ink-faint: #9ca3af;

    --border: #e5e7eb;
    --surface: #ffffff;
    --bg: #f3f4f6;

    --success-bg: #ecfdf5;
    --success-ink: #047857;
    --danger: #dc2626;
    --danger-dark: #b91c1c;
    --warning: #d97706;
    --info: #0284c7;

    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
    --shadow-md: 0 4px 10px rgba(16, 24, 40, 0.08);
}

* { box-sizing: border-box; }

html, body {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    margin: 0;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ============================================
   Top navigation
   ============================================ */
.topnav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topnav-inner {
    max-width: 1000px;
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    font-weight: 700;
    font-size: 15px;
    color: var(--ink);
}

.brand-mark {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--brand);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.nav-links {
    display: flex;
    gap: 4px;
}

.nav-link {
    text-decoration: none;
    color: var(--ink-soft);
    font-size: 14px;
    font-weight: 600;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
}

.nav-link:hover { background: var(--bg); color: var(--ink); }
.nav-link.active { background: var(--brand-light); color: var(--brand-dark); }

/* ============================================
   Page shell
   ============================================ */
.page {
    max-width: 1000px;
    margin: 0 auto;
    padding: 36px 24px 64px;
}

.page-narrow {
    max-width: 620px;
    margin: 0 auto;
    padding: 36px 24px 64px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 32px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
}

.page-header h1 {
    margin: 0 0 4px;
    font-size: 22px;
    letter-spacing: -0.01em;
}

.page-header p {
    margin: 0;
    color: var(--ink-soft);
    font-size: 14px;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    line-height: 1.2;
}

.btn svg { width: 15px; height: 15px; flex-shrink: 0; }

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

.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); }

.btn-small { padding: 7px 12px; font-size: 13px; }

/* Icon-only action buttons used in the admin table */
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--ink-soft);
    text-decoration: none;
    cursor: pointer;
}

.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { background: var(--bg); color: var(--ink); }
.icon-btn.view:hover { color: var(--info); border-color: var(--info); }
.icon-btn.edit:hover { color: var(--warning); border-color: var(--warning); }
.icon-btn.delete:hover { color: var(--danger); border-color: var(--danger); }

.actions-group {
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
}

/* ============================================
   Landing page
   ============================================ */
.hero {
    text-align: center;
    padding: 48px 0 8px;
}

.hero .eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--brand-light);
    color: var(--brand-dark);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 5px 12px;
    border-radius: 999px;
    margin-bottom: 18px;
}

.hero h1 {
    font-size: 30px;
    margin: 0 0 10px;
    letter-spacing: -0.02em;
}

.hero .subtitle {
    color: var(--ink-soft);
    max-width: 460px;
    margin: 0 auto 36px;
    font-size: 15px;
}

.landing-links {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.landing-card {
    display: block;
    text-decoration: none;
    color: inherit;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 26px;
    width: 260px;
    text-align: left;
    transition: box-shadow 0.15s, transform 0.15s;
}

.landing-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-3px);
}

.landing-card .icon-tile {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--brand-light);
    color: var(--brand);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
}

.landing-card h2 {
    margin: 0 0 6px;
    font-size: 16px;
}

.landing-card p {
    margin: 0;
    font-size: 13px;
    color: var(--ink-soft);
    line-height: 1.5;
}

/* ============================================
   Stats strip (admin)
   ============================================ */
.stats-row {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.stat-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    min-width: 140px;
    box-shadow: var(--shadow);
}

.stat-box .num {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.stat-box .label {
    font-size: 12px;
    color: var(--ink-soft);
    margin-top: 2px;
}

/* ============================================
   Table (admin)
   ============================================ */
.table-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.table-wrap { overflow-x: auto; }

.cert-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

.cert-table th, .cert-table td {
    text-align: left;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    white-space: nowrap;
}

.cert-table th {
    background: #fafafa;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--ink-soft);
}

.cert-table tbody tr:last-child td { border-bottom: none; }
.cert-table tbody tr:hover { background: #fafafa; }

.person-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    background: var(--brand-light);
    color: var(--brand-dark);
    font-weight: 700;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.person-cell .meta { line-height: 1.3; }
.person-cell .email { color: var(--ink-soft); font-size: 12px; }

.badge {
    display: inline-block;
    background: var(--bg);
    color: var(--ink-soft);
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 999px;
}

.file-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--brand);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
}

.file-link:hover { text-decoration: underline; }
.file-link svg { width: 14px; height: 14px; }

/* ============================================
   Empty state
   ============================================ */
.empty-state {
    text-align: center;
    color: var(--ink-soft);
    padding: 64px 24px;
}

.empty-state .icon-tile {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: var(--brand-light);
    color: var(--brand);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

.empty-state h3 {
    margin: 0 0 4px;
    color: var(--ink);
    font-size: 15px;
}

.empty-state p { margin: 0; font-size: 13px; }

/* ============================================
   Alerts
   ============================================ */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 13px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 14px;
}

.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }

.alert-success { background: var(--success-bg); color: var(--success-ink); }
.alert-error { background: #fef2f2; color: var(--danger-dark); }
.alert-error ul { margin: 4px 0 0; padding-left: 18px; }

/* ============================================
   Forms
   ============================================ */
.cert-form {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-row + .form-row { margin-top: 16px; }

.cert-form label {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    display: block;
}

.cert-form input[type="text"],
.cert-form input[type="email"] {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--surface);
    color: var(--ink);
}

.cert-form input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-light);
}

.hint {
    font-size: 12px;
    color: var(--ink-faint);
    margin-top: 6px;
}

.current-file-note {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 13px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Custom file drop zone */
.file-drop {
    position: relative;
    border: 1.5px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 22px 16px;
    text-align: center;
    background: #fafafa;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.file-drop:hover, .file-drop.is-dragover {
    border-color: var(--brand);
    background: var(--brand-light);
}

.file-drop input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.file-drop .icon-tile {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--brand-light);
    color: var(--brand);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 10px;
}

.file-drop .drop-text { font-size: 13px; font-weight: 600; }
.file-drop .drop-hint { font-size: 12px; color: var(--ink-faint); margin-top: 2px; }
.file-drop .file-chosen { font-size: 13px; font-weight: 600; color: var(--brand-dark); }

.form-actions {
    margin-top: 26px;
    display: flex;
    gap: 10px;
}

/* Two-column layout for first/last name */
.form-row-split {
    display: flex;
    gap: 12px;
}

.form-row-split .form-row { flex: 1; margin-top: 0; }

/* Course multiselect, shown as toggleable chips */
.course-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}

.course-chip {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    background: var(--surface);
    color: var(--ink-soft);
    user-select: none;
    transition: background 0.1s, border-color 0.1s, color 0.1s;
}

.course-chip input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.course-chip .check {
    width: 15px;
    height: 15px;
    border-radius: 4px;
    border: 1.5px solid var(--border);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--surface);
}

.course-chip .check svg {
    width: 10px;
    height: 10px;
    opacity: 0;
    stroke: #fff;
}

.course-chip.checked {
    background: var(--brand-light);
    border-color: var(--brand);
    color: var(--brand-dark);
}

.course-chip.checked .check {
    background: var(--brand);
    border-color: var(--brand);
}

.course-chip.checked .check svg { opacity: 1; }

/* Course badges shown in the admin table */
.course-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    max-width: 220px;
    white-space: normal;
}

.course-badge {
    display: inline-block;
    background: var(--brand-light);
    color: var(--brand-dark);
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 999px;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 560px) {
    .page, .page-narrow { padding: 20px 14px 48px; }
    .card { padding: 20px; }
    .topnav-inner { padding: 12px 16px; }
    .landing-card { width: 100%; }
    .stat-box { flex: 1; min-width: 120px; }
}
