/* Design system — Rank Edusign 2026 · Light
   Refined neutral light theme, restrained accent palette. */

:root {
    --bg: #fafafa;
    --bg-radial: radial-gradient(ellipse 90% 50% at top, rgba(124, 58, 237, 0.06), transparent 60%),
                 radial-gradient(ellipse 60% 40% at bottom right, rgba(217, 119, 6, 0.04), transparent 60%),
                 #fafafa;
    --surface-1: #ffffff;
    --surface-2: #f4f4f5;
    --surface-hover: #ececef;
    --border: rgba(0, 0, 0, 0.08);
    --border-strong: rgba(0, 0, 0, 0.16);

    --text: #18181b;
    --text-muted: #52525b;
    --text-dim: #a1a1aa;

    --accent: #7c3aed;
    --accent-hover: #6d28d9;
    --accent-soft: rgba(124, 58, 237, 0.1);
    --absence: #dc2626;
    --absence-soft: rgba(220, 38, 38, 0.08);
    --delay: #d97706;
    --delay-soft: rgba(217, 119, 6, 0.08);
    --attendance: #059669;
    --attendance-soft: rgba(5, 150, 105, 0.08);
    --danger: #dc2626;

    --radius: 14px;
    --radius-sm: 10px;
    --radius-pill: 999px;

    --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 8px rgba(16, 24, 40, 0.04);
    --shadow-card-hover: 0 1px 2px rgba(16, 24, 40, 0.06), 0 4px 16px rgba(16, 24, 40, 0.06);
    --transition: 200ms cubic-bezier(0.2, 0.8, 0.2, 1);

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', ui-monospace, monospace;
}

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

html, body {
    background: var(--bg-radial);
    color: var(--text);
    font-family: var(--font-sans);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    font-feature-settings: 'cv11', 'ss01';
}

body {
    padding: 32px 20px 80px;
    background-attachment: fixed;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font-family: inherit; }

.container { max-width: 1280px; margin: 0 auto; }
.container--wide { max-width: 1600px; }

/* Header */
.app-header { text-align: center; margin-bottom: 36px; }
.brand-mark {
    display: inline-flex; align-items: center; gap: 10px;
    font-size: 0.78em; letter-spacing: 0.18em; text-transform: uppercase;
    color: var(--text-muted); margin-bottom: 16px; font-weight: 500;
}
.brand-mark::before, .brand-mark::after {
    content: ''; height: 1px; width: 32px; background: var(--border);
}
.app-title {
    font-size: clamp(1.8em, 4vw, 2.6em);
    font-weight: 700;
    letter-spacing: -0.028em;
    line-height: 1.1;
    margin-bottom: 12px;
    color: var(--text);
}
.app-subtitle {
    font-size: 1.02em; color: var(--text-muted);
    max-width: 580px; margin: 0 auto; line-height: 1.5;
}

/* Tab nav */
.tab-nav-wrap { text-align: center; }
.tab-nav {
    display: inline-flex; gap: 4px;
    padding: 4px;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    margin: 24px 0 32px;
    box-shadow: var(--shadow-card);
}
.tab-link {
    padding: 9px 20px;
    color: var(--text-muted);
    font-size: 0.92em; font-weight: 500;
    border-radius: var(--radius-pill);
    transition: color var(--transition), background var(--transition);
}
.tab-link:hover { color: var(--text); text-decoration: none; }
.tab-link.active {
    color: var(--text);
    background: var(--surface-2);
}

/* Panel */
.panel {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-card);
}
.panel + .panel { margin-top: 20px; }
.panel-title {
    font-size: 0.74em; letter-spacing: 0.14em; text-transform: uppercase;
    color: var(--text-dim); margin-bottom: 16px;
    display: flex; align-items: center; gap: 10px; font-weight: 600;
}
.panel-title .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.panel-title.delay .dot { background: var(--delay); }
.panel-title.absence .dot { background: var(--absence); }

/* Controls (token + dates + filters) */
.controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px; align-items: end;
}
.controls .field--wide { grid-column: span 2; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
    font-size: 0.72em; letter-spacing: 0.1em; text-transform: uppercase;
    color: var(--text-dim); font-weight: 600;
}

.input, .select {
    width: 100%;
    background: var(--surface-1);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 12px;
    font-size: 0.95em;
    font-family: inherit;
    border-radius: var(--radius-sm);
    transition: border-color var(--transition), box-shadow var(--transition);
    appearance: none;
}
.input::placeholder { color: var(--text-dim); }
.input:focus, .select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 14px;
    padding-right: 32px;
}
input[type="date"].input { color-scheme: light; }

.btn {
    background: var(--accent);
    color: #ffffff;
    border: none;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.92em;
    font-weight: 600;
    cursor: pointer;
    transition: transform var(--transition), background var(--transition), box-shadow var(--transition);
    white-space: nowrap;
    box-shadow: 0 1px 2px rgba(124, 58, 237, 0.2);
}
.btn:hover { transform: translateY(-1px); background: var(--accent-hover); box-shadow: 0 4px 12px rgba(124, 58, 237, 0.22); }
.btn:active { transform: translateY(0); }
.btn--ghost {
    background: var(--surface-1); color: var(--text-muted);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-card);
}
.btn--ghost:hover { background: var(--surface-2); color: var(--text); box-shadow: var(--shadow-card-hover); }
.btn--danger {
    background: var(--surface-1);
    color: var(--danger);
    border: 1px solid rgba(220, 38, 38, 0.25);
    box-shadow: none;
    padding: 7px 14px;
    font-size: 0.85em;
}
.btn--danger:hover { background: var(--absence-soft); border-color: var(--danger); box-shadow: none; }
.btn--small { padding: 7px 14px; font-size: 0.85em; }

.help-text {
    font-size: 0.82em;
    color: var(--text-dim);
    text-align: center;
    margin-top: 14px;
}

/* School strip */
.school-strip {
    display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
    padding: 12px 16px;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-top: 20px;
    box-shadow: var(--shadow-card);
}
.school-strip-label {
    font-size: 0.72em; letter-spacing: 0.12em; text-transform: uppercase;
    color: var(--text-dim); margin-right: 4px; font-weight: 600;
}
.school-chip {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 6px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    font-size: 0.85em;
    color: var(--text);
    font-weight: 500;
}
.school-chip img {
    width: 18px; height: 18px; border-radius: 50%; object-fit: cover; background: var(--border);
}

/* Stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-top: 20px;
}
.stat-card {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    position: relative;
    overflow: hidden;
    transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
    box-shadow: var(--shadow-card);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-card-hover); }
.stat-card::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
    background: var(--accent);
}
.stat-card.absence::before { background: var(--absence); }
.stat-card.delay::before { background: var(--delay); }
.stat-card.attendance::before { background: var(--attendance); }

.stat-label {
    font-size: 0.72em; letter-spacing: 0.12em; text-transform: uppercase;
    color: var(--text-dim); margin-bottom: 14px;
    display: flex; align-items: center; gap: 8px; font-weight: 600;
}
.stat-value {
    font-size: 2.2em; font-weight: 600;
    letter-spacing: -0.028em;
    font-variant-numeric: tabular-nums;
    color: var(--text);
    line-height: 1.1;
}
.stat-value .unit { font-size: 0.5em; color: var(--text-dim); font-weight: 500; margin-left: 2px; }
.stat-card.absence .stat-value { color: var(--absence); }
.stat-card.delay .stat-value { color: var(--delay); }
.stat-card.attendance .stat-value { color: var(--attendance); }
.stat-sub {
    font-size: 0.82em; color: var(--text-muted); margin-top: 8px;
    font-variant-numeric: tabular-nums;
}

/* Chart */
.chart-panel { margin-top: 20px; }
.chart-canvas-wrap { position: relative; min-height: 320px; }

/* Detail lists */
.details-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 16px; margin-top: 20px;
}
.event-list { display: flex; flex-direction: column; gap: 10px; }
.event-item {
    padding: 14px;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--absence);
    transition: background var(--transition), border-color var(--transition);
}
.event-item.is-delay { border-left-color: var(--delay); }
.event-item:hover { background: var(--surface-2); border-color: var(--border-strong); }
.event-head {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
    margin-bottom: 6px;
}
.event-name { font-weight: 600; color: var(--text); font-size: 0.95em; line-height: 1.4; }
.event-meta {
    font-size: 0.82em; color: var(--text-muted); line-height: 1.6;
    font-variant-numeric: tabular-nums;
}
.event-pill {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    padding: 2px 10px;
    font-size: 0.72em;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
    font-weight: 500;
}
.event-pill.justified { color: var(--attendance); border-color: rgba(5, 150, 105, 0.3); background: var(--attendance-soft); }

.empty {
    text-align: center; color: var(--text-dim); padding: 32px 16px;
    font-size: 0.92em;
}

/* Person row (compare) */
.person-list { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.person-row {
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    padding: 14px;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: background var(--transition), border-color var(--transition);
}
.person-row:hover { background: var(--surface-2); border-color: var(--border-strong); }
.person-info { display: flex; align-items: center; gap: 14px; min-width: 0; }
.person-photo {
    width: 44px; height: 44px; border-radius: 50%;
    object-fit: cover; background: var(--accent-soft);
    border: 1px solid var(--border);
    flex-shrink: 0;
}
.person-details { min-width: 0; }
.person-name { font-weight: 600; color: var(--text); font-size: 0.98em; }
.person-email { font-size: 0.84em; color: var(--text-muted); margin-top: 1px; }
.person-school-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.tag-mini {
    font-size: 0.72em; padding: 2px 8px;
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: var(--radius-pill); color: var(--text-muted);
    font-weight: 500;
}

/* Compare cards */
.comparison-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px; margin-top: 20px;
}
.person-card {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-card);
}
.person-card-header {
    display: flex; align-items: center; gap: 14px;
    padding-bottom: 16px; margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.person-card-header img {
    width: 56px; height: 56px; border-radius: 50%;
    object-fit: cover; background: var(--accent-soft);
    border: 1px solid var(--border);
}
.person-card-header h3 { font-size: 1.1em; font-weight: 600; letter-spacing: -0.015em; color: var(--text); }
.stat-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 11px 0; border-bottom: 1px solid var(--border);
}
.stat-row:last-child { border-bottom: none; }
.stat-row .label { color: var(--text-muted); font-size: 0.9em; }
.stat-row .value { font-weight: 600; font-variant-numeric: tabular-nums; font-size: 1em; color: var(--text); }
.stat-row .value.absence { color: var(--absence); }
.stat-row .value.delay { color: var(--delay); }
.stat-row .value.attendance { color: var(--attendance); }

/* Loading & errors */
.loading {
    text-align: center; color: var(--text-muted); padding: 48px 20px;
    font-size: 0.95em;
}
.loading::before {
    content: ''; display: inline-block;
    width: 14px; height: 14px; margin-right: 10px;
    border: 2px solid var(--border-strong); border-top-color: var(--accent);
    border-radius: 50%; vertical-align: -2px;
    animation: spin 800ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error {
    background: var(--absence-soft);
    border: 1px solid rgba(220, 38, 38, 0.3);
    color: var(--absence);
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    margin: 20px 0;
    font-size: 0.92em;
    font-weight: 500;
}

.empty-state {
    text-align: center;
    padding: 64px 20px;
    background: var(--surface-1);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}
.empty-state h2 { font-size: 1.2em; font-weight: 600; margin-bottom: 8px; color: var(--text); }
.empty-state p { color: var(--text-muted); font-size: 0.95em; }

/* Responsive */
@media (max-width: 768px) {
    body { padding: 20px 14px 60px; }
    .panel { padding: 20px; }
    .controls { grid-template-columns: 1fr; }
    .controls .field--wide { grid-column: span 1; }
    .comparison-grid { grid-template-columns: 1fr; }
    .details-grid { grid-template-columns: 1fr; }
    .person-row { flex-direction: column; align-items: stretch; }
    .person-row .btn--danger { align-self: flex-end; }
}
