/* Tutors Ink Student Records
   Palette: warm paper background, deep ink-navy text, a wine-red accent
   used sparingly for warnings/flags — a nod to pen-on-paper marking. */

:root {
    --paper: #F7F4EE;
    --paper-raised: #FFFFFF;
    --ink: #1E2A3A;
    --ink-soft: #48566A;
    --ink-faint: #8B94A3;
    --rule: #DDD6C7;
    --accent-wine: #7C2D3B;
    --accent-wine-soft: #F3E4E6;
    --accent-gold: #A9792C;
    --accent-gold-soft: #F3E9D4;
    --ok-green: #2F6B4F;
    --ok-green-soft: #E4EFE8;
    --radius: 6px;
    --shadow: 0 1px 2px rgba(30, 42, 58, 0.06), 0 4px 12px rgba(30, 42, 58, 0.06);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Source Sans Pro", "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--paper);
    color: var(--ink);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .brand {
    font-family: "Iowan Old Style", "Palatino Linotype", Georgia, "Times New Roman", serif;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--ink);
}

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

/* ---------------------------------------------------------------- topbar */

.topbar {
    background: var(--ink);
    border-bottom: 3px solid var(--accent-wine);
}

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

.brand {
    color: #FFFFFF;
    font-size: 1.25rem;
    font-weight: 700;
}
.brand span {
    display: block;
    font-family: "Source Sans Pro", sans-serif;
    font-size: 0.68rem;
    font-weight: 400;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #C7B79A;
    margin-top: 1px;
}

nav { display: flex; align-items: center; gap: 22px; }
nav a {
    color: #D8DEE8;
    font-size: 0.92rem;
    font-weight: 500;
    padding-bottom: 3px;
    border-bottom: 2px solid transparent;
}
nav a:hover { color: #fff; text-decoration: none; }
nav a.active { color: #fff; border-bottom-color: var(--accent-gold); }

.btn-add {
    background: var(--accent-wine);
    color: #fff !important;
    padding: 7px 14px;
    border-radius: var(--radius);
    border: none;
}
.btn-add:hover { background: #6a2732; }

/* -------------------------------------------------------------- layout */

.container { max-width: 1180px; margin: 0 auto; padding: 28px 24px 60px; }

.footer {
    text-align: center;
    color: var(--ink-faint);
    font-size: 0.8rem;
    padding: 24px;
}

/* -------------------------------------------------------------- flashes */

.flash {
    padding: 10px 16px;
    border-radius: var(--radius);
    margin-bottom: 18px;
    font-size: 0.92rem;
}
.flash-success { background: var(--ok-green-soft); color: var(--ok-green); }
.flash-error { background: var(--accent-wine-soft); color: var(--accent-wine); }

/* ------------------------------------------------------------- dashboard */

.page-title {
    font-size: 1.6rem;
    margin: 0 0 4px;
}
.page-subtitle {
    color: var(--ink-soft);
    margin: 0 0 28px;
    font-size: 0.95rem;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}
.stat-card {
    background: var(--paper-raised);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
}
.stat-card .n {
    font-family: "Iowan Old Style", Georgia, serif;
    font-size: 2.1rem;
    font-weight: 600;
    line-height: 1;
}
.stat-card .label {
    color: var(--ink-soft);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 6px;
}
.stat-card.wine .n { color: var(--accent-wine); }
.stat-card.gold .n { color: var(--accent-gold); }
.stat-card.green .n { color: var(--ok-green); }

.panel-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

.panel {
    background: var(--paper-raised);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
}
.panel h2 {
    font-size: 1.02rem;
    margin: 0 0 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--rule);
}

.bar-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    font-size: 0.88rem;
}
.bar-row .bar-label { width: 150px; flex-shrink: 0; color: var(--ink-soft); }
.bar-row .bar-track {
    flex: 1;
    background: var(--paper);
    border-radius: 3px;
    height: 10px;
    overflow: hidden;
}
.bar-row .bar-fill {
    height: 100%;
    background: var(--accent-gold);
    border-radius: 3px;
}
.bar-row .bar-n { width: 34px; text-align: right; color: var(--ink-faint); font-size: 0.82rem; }

.review-list { list-style: none; margin: 0; padding: 0; }
.review-list li {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--rule);
    font-size: 0.9rem;
}
.review-list li:last-child { border-bottom: none; }
.review-list .grade-tag {
    background: var(--accent-wine-soft);
    color: var(--accent-wine);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.78rem;
    font-weight: 600;
}
.empty-note { color: var(--ink-faint); font-size: 0.88rem; font-style: italic; }

/* ------------------------------------------------------------- filters */

.filter-bar {
    background: var(--paper-raised);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    padding: 14px 18px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
    align-items: flex-end;
}
.filter-field { display: flex; flex-direction: column; gap: 4px; }
.filter-field label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink-soft);
}
.filter-bar input, .filter-bar select {
    padding: 7px 10px;
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    font-size: 0.9rem;
    background: #fff;
    color: var(--ink);
    min-width: 150px;
}
.filter-bar button, .btn {
    padding: 8px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--accent-wine);
    background: var(--accent-wine);
    color: #fff;
    font-size: 0.9rem;
    cursor: pointer;
}
.filter-bar button:hover, .btn:hover { background: #6a2732; }
.btn-secondary {
    background: #fff;
    color: var(--ink);
    border: 1px solid var(--rule);
}
.btn-secondary:hover { background: var(--paper); color: var(--ink); }
.btn-danger {
    background: #fff;
    color: var(--accent-wine);
    border: 1px solid var(--accent-wine);
}
.btn-danger:hover { background: var(--accent-wine-soft); }

.result-count { color: var(--ink-soft); font-size: 0.88rem; margin-bottom: 10px; }

/* --------------------------------------------------------------- table */

table.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--paper-raised);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}
table.data-table th {
    text-align: left;
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ink-soft);
    background: var(--paper);
    padding: 10px 14px;
    border-bottom: 1px solid var(--rule);
}
table.data-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--rule);
    font-size: 0.9rem;
    vertical-align: top;
}
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tr:hover { background: var(--paper); }

.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 10px;
    font-size: 0.76rem;
    font-weight: 600;
}
.badge-current { background: var(--ok-green-soft); color: var(--ok-green); }
.badge-resigned { background: #EEECE4; color: var(--ink-soft); }
.badge-redflag { background: var(--accent-wine-soft); color: var(--accent-wine); }
.badge-once-off { background: var(--accent-gold-soft); color: var(--accent-gold); }
.badge-blank { background: #EEECE4; color: var(--ink-faint); }

.subject-chip {
    display: inline-block;
    background: var(--paper);
    border: 1px solid var(--rule);
    color: var(--ink-soft);
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 0.76rem;
    margin: 0 4px 4px 0;
}

/* ---------------------------------------------------------------- forms */

.form-panel {
    background: var(--paper-raised);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    padding: 24px 28px;
    box-shadow: var(--shadow);
    max-width: 820px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px 20px;
}
.form-field { display: flex; flex-direction: column; gap: 5px; }
.form-field.full { grid-column: 1 / -1; }
.form-field label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--ink-soft);
}
.form-field input[type=text],
.form-field input[type=email],
.form-field input[type=date],
.form-field select,
.form-field textarea {
    padding: 8px 10px;
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    font-size: 0.92rem;
    font-family: inherit;
    background: #fff;
    color: var(--ink);
}
.form-field textarea { resize: vertical; min-height: 70px; }
.form-field .hint { font-size: 0.76rem; color: var(--ink-faint); }

.checkbox-field { display: flex; align-items: center; gap: 8px; flex-direction: row; }
.checkbox-field input { width: 16px; height: 16px; }

.subject-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px 16px;
}
.subject-checkbox { display: flex; align-items: center; gap: 7px; font-size: 0.88rem; }
.subject-checkbox input { width: 15px; height: 15px; }

fieldset {
    border: none;
    padding: 0;
    margin: 0 0 20px;
}
fieldset legend {
    font-size: 0.95rem;
    font-weight: 600;
    padding: 0 0 10px;
    border-bottom: 1px solid var(--rule);
    width: 100%;
    margin-bottom: 14px;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--rule);
}

/* --------------------------------------------------------- detail view */

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 22px;
}
.detail-header h1 { margin: 0 0 6px; }
.detail-actions { display: flex; gap: 10px; }

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}
.detail-field {
    padding: 12px 0;
    border-bottom: 1px solid var(--rule);
}
.detail-field .k {
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink-faint);
    margin-bottom: 3px;
}
.detail-field .v { font-size: 0.95rem; }
.detail-field .v.empty { color: var(--ink-faint); font-style: italic; }

.flag-banner {
    background: var(--accent-wine-soft);
    color: var(--accent-wine);
    padding: 10px 16px;
    border-radius: var(--radius);
    font-size: 0.88rem;
    margin-bottom: 18px;
}

/* ------------------------------------------------------------- auth ui */

.nav-user {
    color: #D8DEE8;
    font-size: 0.85rem;
    margin-left: 4px;
    padding-left: 18px;
    border-left: 1px solid rgba(255,255,255,0.15);
}
.role-tag {
    background: rgba(255,255,255,0.12);
    color: #C7B79A;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 1px 7px;
    border-radius: 8px;
    margin-left: 4px;
}
.link-btn {
    background: none;
    border: none;
    color: #D8DEE8;
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
}
.link-btn:hover { color: #fff; }

.auth-wrap {
    max-width: 380px;
    margin: 60px auto;
    background: var(--paper-raised);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    padding: 32px 30px;
    box-shadow: var(--shadow);
}
.auth-wrap h1 { font-size: 1.35rem; margin: 0 0 4px; text-align: center; }
.auth-wrap .page-subtitle { text-align: center; margin-bottom: 22px; }
.auth-wrap .form-field { margin-bottom: 14px; }
.auth-wrap button[type=submit] { width: 100%; margin-top: 6px; padding: 10px; }

.role-badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 10px;
    font-size: 0.76rem;
    font-weight: 600;
}
.role-badge.admin { background: var(--accent-wine-soft); color: var(--accent-wine); }
.role-badge.viewer { background: #EEECE4; color: var(--ink-soft); }

.inline-form { display: inline-flex; gap: 6px; align-items: center; }
.inline-form input[type=text], .inline-form input[type=password] {
    padding: 5px 8px;
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    font-size: 0.85rem;
    width: 130px;
}

@media (max-width: 720px) {
    .stat-grid, .panel-grid, .form-grid, .detail-grid, .subject-grid { grid-template-columns: 1fr; }
    .topbar-inner { flex-direction: column; gap: 12px; align-items: flex-start; }
}
