:root {
    --ink: #172033;
    --muted: #667085;
    --panel: #ffffff;
    --surface: #f6f8fb;
    --surface-strong: #edf2f7;
    --line: #d9e1ea;
    --line-soft: #edf1f5;
    --teal: #04706e;
    --gold: #b7791f;
    --coral: #c2412f;
    --blue: #2458d3;
    --nav: #111827;
    --shadow: 0 12px 30px rgba(16, 24, 40, 0.08);
    --shadow-soft: 0 1px 2px rgba(16, 24, 40, 0.06);
    --radius-lg: 8px;
    --radius-md: 8px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    font-family: "Plus Jakarta Sans", sans-serif;
    background: var(--surface);
    -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.auth-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    padding: 28px;
    gap: 20px;
}

.auth-panel,
.panel,
.hero-strip,
.stat-card,
.course-card,
.finance-card,
.profile-card {
    backdrop-filter: none;
}

.auth-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 30px;
    box-shadow: var(--shadow-soft);
}

.intro-panel {
    background: linear-gradient(145deg, #111827, #1f2937);
    color: #f8fafc;
}

.intro-panel .eyebrow,
.intro-panel .lead {
    color: rgba(246, 240, 230, 0.76);
}

.auth-panel h1,
.auth-panel h2,
.brand-card h2,
.topbar h2,
.hero-strip h3,
.panel h3,
.panel h4 {
    margin: 0;
    font-family: "Outfit", sans-serif;
}

.lead {
    max-width: 620px;
    font-size: 1.05rem;
    line-height: 1.65;
}

.credential-list,
.tag-list,
.card-list,
.stack-list,
.stats-grid,
.panel-grid,
.finance-grid {
    display: grid;
    gap: 16px;
}

.credential-card,
.tag-chip,
.stack-item,
.course-card,
.finance-card,
.profile-card {
    border-radius: var(--radius-md);
    border: 1px solid var(--line);
    background: var(--panel);
}

.credential-card {
    padding: 16px;
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.14);
}

.credential-card span {
    display: block;
    margin-top: 6px;
    font-size: 0.95rem;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.73rem;
    font-weight: 800;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    align-items: start;
}

.form-grid.single,
.form-grid .wide {
    grid-column: 1 / -1;
}

.actions-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 700;
    min-width: 0;
}

input,
select,
textarea {
    width: 100%;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #ffffff;
    padding: 11px 12px;
    outline: none;
    color: var(--ink);
    transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: rgba(36, 88, 211, 0.58);
    box-shadow: 0 0 0 3px rgba(36, 88, 211, 0.1);
}

.primary-button,
.ghost-button,
.mini-button {
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 10px 14px;
    font-weight: 700;
    min-height: 40px;
    transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease, border-color 120ms ease;
}

.primary-button { background: #04706e; color: white; box-shadow: var(--shadow-soft); }
.primary-button:hover { background: #065f5d; }
.ghost-button, .mini-button { background: #ffffff; color: var(--ink); border-color: var(--line); }
.ghost-button:hover, .mini-button:hover { background: #f8fafc; border-color: #c8d3df; }
.mini-button.danger { background: #fff7f5; border-color: #f3c9c1; color: var(--coral); }

.error-text {
    min-height: 24px;
    color: var(--coral);
}

.form-drawer {
    margin-top: 16px;
    padding: 16px;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: #f8fafc;
}

.toggle-form-button {
    width: 100%;
    max-width: 220px;
    margin-bottom: 2px;
}

.custom-fields,
.custom-builder {
    padding: 14px;
    border-radius: 8px;
    background: #f8fafc;
    border: 1px solid var(--line-soft);
}

.option-group {
    padding: 14px;
    border-radius: 8px;
    background: #ffffff;
    border: 1px dashed #cdd6e1;
    margin-top: 12px;
}

.option-group-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.option-control {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
}

.option-control input {
    flex: 1;
}

.option-chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.option-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 999px;
    background: #eaf7f6;
    border: 1px solid #bce2df;
    font-weight: 700;
}

.option-chip button {
    border: none;
    background: transparent;
    color: var(--coral);
    font-weight: 700;
    padding: 0;
}

.custom-fields h4,
.custom-builder h4 {
    margin: 0 0 10px;
    font-family: "Outfit", sans-serif;
}

.backup-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.file-input-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    min-height: 46px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #ffffff;
    color: var(--ink);
    font-weight: 700;
    cursor: pointer;
}

.file-input-button input {
    display: none;
}

.report-preview {
    min-height: 420px;
}

.report-shell {
    display: grid;
    gap: 16px;
}

.report-header,
.report-block {
    padding: 16px;
    border-radius: 8px;
    background: #ffffff;
    border: 1px solid var(--line-soft);
}

.report-student {
    display: flex;
    gap: 16px;
    align-items: center;
}

.inline-summary {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    align-items: center;
    font-weight: 600;
}

.report-photo {
    width: 88px;
    height: 88px;
    border-radius: 8px;
    object-fit: cover;
    background: var(--surface-strong);
}

.attendance-sheet-grid {
    display: grid;
    gap: 12px;
}

.attendance-row {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) 160px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    padding: 12px;
    border-radius: 8px;
    background: #ffffff;
    border: 1px solid var(--line-soft);
}

.attendance-row strong,
.attendance-row span {
    display: block;
}

.attendance-row span {
    color: var(--muted);
    font-size: 0.92rem;
}

.action-menu {
    display: flex;
    gap: 8px;
    align-items: center;
    min-width: 0;
    flex-wrap: wrap;
}

.action-menu select {
    min-width: 0;
    width: 100%;
    background: #ffffff;
    color: var(--ink);
    border: 1px solid var(--line);
    appearance: auto;
    flex: 1 1 140px;
}

.action-row {
    min-width: 0;
}

.action-menu .mini-button {
    flex-shrink: 0;
}

.custom-field-list {
    display: grid;
    gap: 10px;
    margin-bottom: 14px;
}

.builder-note {
    margin: 0 0 10px;
    color: var(--muted);
    font-size: 0.94rem;
}

.custom-field-card {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    padding: 12px 14px;
    border-radius: 8px;
    background: #ffffff;
    border: 1px solid var(--line-soft);
    cursor: grab;
}

.custom-field-card.dragging {
    opacity: 0.55;
}

.custom-field-card strong,
.custom-field-card span {
    display: block;
}

.custom-field-card span {
    color: var(--muted);
    font-size: 0.88rem;
}

.app-shell {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    height: 100vh;
    overflow: hidden;
    width: 100%;
    max-width: 100vw;
}

.workspace-shell {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    min-height: 0;
    min-width: 0;
    overflow: hidden;
}

.sidebar {
    padding: 16px 12px 22px;
    background: var(--nav);
    color: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.16) transparent;
}

.sidebar::-webkit-scrollbar,
.main-panel::-webkit-scrollbar {
    width: 8px;
}

.sidebar::-webkit-scrollbar-thumb,
.main-panel::-webkit-scrollbar-thumb {
    background: rgba(31, 36, 48, 0.18);
    border-radius: 999px;
}

.brand-mark {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    font: 800 1.4rem "Outfit", sans-serif;
    color: white;
    background: linear-gradient(145deg, #04706e, #2458d3);
}

.school-logo {
    position: relative;
    width: 54px;
    height: 54px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    color: #ffffff;
    background:
        linear-gradient(145deg, rgba(4, 112, 110, 0.96), rgba(36, 88, 211, 0.94));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 10px 22px rgba(17, 24, 39, 0.18);
    overflow: hidden;
}

.school-logo::before {
    content: "";
    position: absolute;
    inset: 8px;
    border: 2px solid rgba(255, 255, 255, 0.58);
    border-radius: 9px 9px 14px 14px;
}

.school-logo::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 10px;
    width: 2px;
    height: 16px;
    background: rgba(255, 255, 255, 0.62);
    transform: translateX(-50%);
}

.school-logo strong {
    position: relative;
    z-index: 1;
    margin-top: 14px;
    font: 800 0.85rem "Outfit", sans-serif;
    letter-spacing: 0.04em;
}

.logo-book {
    position: absolute;
    top: 12px;
    left: 16px;
    width: 22px;
    height: 10px;
    border: 2px solid rgba(255, 255, 255, 0.72);
    border-top: 0;
    border-radius: 0 0 8px 8px;
}

.school-logo-large {
    width: 88px;
    height: 88px;
    margin-bottom: 22px;
    border-radius: 18px;
}

.school-logo-large::before {
    inset: 13px;
    border-radius: 13px 13px 20px 20px;
}

.school-logo-large::after {
    top: 18px;
    height: 26px;
}

.school-logo-large .logo-book {
    top: 22px;
    left: 27px;
    width: 34px;
    height: 16px;
}

.school-logo-large strong {
    margin-top: 22px;
    font-size: 1.18rem;
}

.topbar-logo {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    flex: 0 0 40px;
}

.topbar-logo::before {
    inset: 6px;
    border-radius: 7px 7px 10px 10px;
}

.topbar-logo::after {
    top: 8px;
    height: 12px;
}

.topbar-logo .logo-book {
    top: 10px;
    left: 12px;
    width: 16px;
    height: 8px;
}

.topbar-logo strong {
    margin-top: 11px;
    font-size: 0.62rem;
}

.profile-card {
    padding: 14px;
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.08);
    display: grid;
    gap: 5px;
}

.profile-card span,
.profile-card strong {
    display: block;
}

.profile-card span { color: rgba(244, 240, 232, 0.8); }
.profile-card strong { margin: 2px 0 2px; color: white; text-transform: capitalize; }
.profile-card .ghost-button { width: 100%; background: rgba(255, 255, 255, 0.1); color: white; padding: 9px 12px; border-radius: 8px; font-size: 0.88rem; border-color: rgba(255, 255, 255, 0.12); }
.profile-meta {
    display: block;
    margin-top: 0;
    color: rgba(244, 240, 232, 0.8);
    font-size: 12px;
    line-height: 1.5;
}
.profile-identity {
    display: flex;
    gap: 12px;
    align-items: center;
}
.profile-avatar {
    width: 46px;
    height: 46px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    font: 700 0.95rem "Outfit", sans-serif;
    color: white;
    background: linear-gradient(145deg, #04706e, #2458d3);
    border: 1px solid rgba(255, 255, 255, 0.15);
    overflow: hidden;
}
.profile-avatar.has-photo {
    background: rgba(255, 255, 255, 0.18);
}
.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.nav-menu { display: grid; gap: 8px; flex: 1; align-content: start; }
.profile-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 6px;
}

.profile-actions .ghost-button {
    min-height: 40px;
    white-space: nowrap;
}

.nav-item {
    border: 1px solid transparent;
    background: transparent;
    color: #cbd5e1;
    border-radius: 8px;
    text-align: left;
    padding: 11px 12px;
    font-weight: 750;
}

.nav-item.active,
.nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    transform: none;
}

.main-panel {
    padding: 20px 24px 28px;
    background: var(--surface);
    overflow-y: auto;
    min-height: 0;
    min-width: 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(31, 36, 48, 0.16) transparent;
}

.topbar,
.hero-strip {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
}

.topbar {
    margin-bottom: 0;
    padding: 12px 22px;
    background: #ffffff;
    border: none;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    box-shadow: none;
    position: sticky;
    top: 0;
    z-index: 30;
    min-width: 0;
}

.feedback {
    margin-bottom: 18px;
    padding: 14px 16px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #ffffff;
    box-shadow: var(--shadow-soft);
}

.feedback.success {
    color: var(--teal);
    background: #eaf7f6;
    border-color: #bce2df;
}

.feedback.error {
    color: var(--coral);
    background: #fff7f5;
    border-color: #f3c9c1;
}

.topbar-brand-group,
.topbar-actions,
.section-heading {
    display: flex;
    align-items: center;
}

.topbar-brand-group {
    gap: 12px;
    min-width: fit-content;
}

.topbar-mark {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    font-size: 1rem;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.topbar-brand-copy h2 {
    font-size: 1.02rem;
    color: var(--ink);
    letter-spacing: 0.02em;
}

.topbar-actions {
    gap: 10px;
    flex: 0 0 auto;
    justify-content: flex-end;
    flex-wrap: nowrap;
    min-width: 0;
}

.search-field {
    display: grid;
    gap: 6px;
    color: var(--muted);
}

.search-field-large {
    flex: 1 1 420px;
    max-width: 560px;
    min-width: 240px;
    position: relative;
}

.search-field-large span {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.search-field-large::before {
    content: "";
    position: absolute;
    left: 18px;
    top: 50%;
    width: 18px;
    height: 18px;
    transform: translateY(-50%);
    border: 2px solid #98a2b3;
    border-radius: 50%;
}

.search-field-large::after {
    content: "";
    position: absolute;
    left: 32px;
    top: calc(50% + 6px);
    width: 9px;
    height: 2px;
    background: #98a2b3;
    transform: rotate(45deg);
    transform-origin: left center;
}

.search-field input { min-width: 260px; }

.search-field-large input {
    min-width: 0;
    width: 100%;
    padding: 12px 18px 12px 48px;
    border-radius: 8px;
    background: #f8fafc;
    border-color: var(--line);
    color: var(--ink);
}

.search-field-large input::placeholder {
    color: #98a2b3;
}

.search-field-large input:focus {
    border-color: rgba(36, 88, 211, 0.5);
    box-shadow: 0 0 0 3px rgba(36, 88, 211, 0.1);
}

.header-profile-menu {
    position: relative;
}

.header-profile-menu summary {
    list-style: none;
}

.header-profile-menu summary::-webkit-details-marker {
    display: none;
}

.header-profile-trigger {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 5px 7px 5px 12px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #ffffff;
    box-shadow: none;
    cursor: pointer;
    user-select: none;
}

.header-profile-menu[open] .header-profile-trigger {
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.05);
}

.header-profile-meta {
    display: grid;
    gap: 2px;
    text-align: right;
}

.header-profile-meta strong {
    color: var(--ink);
}

.header-profile-label {
    color: var(--muted);
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
}

.header-profile-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 12px);
    width: min(360px, 92vw);
    display: grid;
    gap: 12px;
    padding: 18px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #ffffff;
    box-shadow: var(--shadow);
}

.header-profile-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.header-profile-panel .profile-meta {
    color: var(--muted);
    font-size: 0.88rem;
}

.header-profile-panel .profile-actions {
    margin-top: 2px;
}

.header-profile-panel .ghost-button {
    background: rgba(31, 36, 48, 0.08);
    color: var(--ink);
}

.section-heading {
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
}

.section-heading h3 {
    margin: 0;
    font: 750 1.45rem "Outfit", sans-serif;
}

.hero-strip {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-soft);
    margin-bottom: 18px;
}

.hero-strip h3 {
    max-width: 760px;
    font-size: 1.45rem;
    line-height: 1.2;
}

.hero-copy {
    margin: 8px 0 0;
    max-width: 680px;
    color: var(--muted);
    line-height: 1.6;
}

.hero-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(100px, 1fr));
    gap: 12px;
    width: min(100%, 400px);
}

.hero-metrics div,
.finance-card {
    padding: 14px;
    border-radius: 8px;
    background: #f8fafc;
    border: 1px solid var(--line-soft);
}

.hero-metrics span,
.finance-card span,
.stat-card span {
    display: block;
    color: var(--muted);
}

.stat-card span,
.stat-card strong {
    color: #ffffff;
}

.hero-metrics strong,
.finance-card strong,
.stat-card strong {
    display: block;
    margin-top: 6px;
    font: 750 1.55rem "Outfit", sans-serif;
}

.content-section { display: none; }
.content-section.active { display: block; }

.stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 18px; }
.two-up { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 18px; }
.dual-layout { grid-template-columns: 1.2fr 0.95fr; }

.panel {
    padding: 18px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    min-width: 0;
    overflow: hidden;
}

.panel-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: start;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.panel-head-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
    margin-left: auto;
}

.panel-head-actions .toggle-form-button {
    width: auto;
    max-width: none;
    margin: 0;
    white-space: nowrap;
}

.stat-card {
    padding: 18px;
    border-radius: 8px;
    color: white;
    box-shadow: var(--shadow-soft);
    min-height: 112px;
    display: grid;
    align-content: space-between;
}

.stat-card.teal { background: #04706e; }
.stat-card.gold { background: #b7791f; }
.stat-card.coral { background: #c2412f; }
.stat-card.blue { background: #2458d3; }

.tag-list { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.tag-chip { padding: 14px; background: #f8fafc; }
.tag-chip strong, .stack-item h4 { display: block; margin-bottom: 4px; }

.timeline-list { margin: 0; padding-left: 20px; display: grid; gap: 10px; }
.timeline-list li, .stack-item p, .course-card p { color: var(--muted); line-height: 1.6; }

.stack-item,
.course-card {
    padding: 14px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: start;
}

.stack-item-meta,
.course-meta,
.action-row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.course-card { flex-direction: column; }
.course-card-head { display: flex; justify-content: space-between; gap: 12px; align-items: start; }

.badge,
.pill {
    display: inline-flex;
    align-items: center;
    padding: 7px 10px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 700;
}

.badge { background: #eef4ff; color: var(--blue); border: 1px solid #d6e4ff; }
.pill { background: #f2f4f7; color: var(--ink); border: 1px solid #e4e7ec; }
.pill.paid, .pill.present, .pill.active { background: #eaf7f6; color: var(--teal); border-color: #bce2df; }
.pill.partial, .pill.late, .pill.on-leave, .pill.probation { background: #fff7e6; color: #99620d; border-color: #f6dda5; }
.pill.due, .pill.absent { background: #fff7f5; color: var(--coral); border-color: #f3c9c1; }

.table-wrap {
    overflow-x: auto;
    max-width: 100%;
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: #f8fafc;
}

th, td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--line-soft);
    text-align: left;
    vertical-align: top;
}

tbody tr:hover {
    background: #f8fafc;
}

th {
    color: var(--muted);
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

td strong { display: block; margin-bottom: 4px; }
td span { color: var(--muted); font-size: 0.9rem; }
td .badge { margin-top: 0; }
.table-cell-stack {
    display: grid;
    gap: 4px;
    min-width: 160px;
}

.table-text {
    display: inline-block;
    line-height: 1.5;
}

.finance-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 16px; }

.record-filter-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin: 14px 0;
    padding: 12px;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: #f8fafc;
}

.record-filter-bar label {
    min-width: 0;
}

.results-summary-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.result-metric {
    border-radius: 8px;
    border: 1px solid var(--line-soft);
    background: #ffffff;
    padding: 16px;
    position: relative;
    overflow: hidden;
}

.result-metric::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, #04706e, #2458d3, #b7791f);
}

.result-metric span {
    display: block;
    color: var(--muted);
    font-size: 0.82rem;
}

.result-metric strong {
    display: block;
    margin-top: 8px;
    font: 700 1.05rem "Outfit", sans-serif;
    color: var(--ink);
}

#results-form-wrap {
    margin-top: 16px;
    padding: 18px;
    border-radius: 8px;
    border: 1px solid var(--line-soft);
    background: #f8fafc;
}

#results-board {
    display: grid;
    gap: 18px;
}

.results-insight-grid {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: 16px;
}

.results-spotlight,
.results-band-card,
.results-table-card {
    padding: 18px;
    border-radius: 8px;
    border: 1px solid var(--line-soft);
    background: #ffffff;
}

.results-card-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: start;
    margin-bottom: 14px;
}

.results-card-head h4 {
    margin: 0;
}

.results-card-head p {
    margin: 6px 0 0;
    color: var(--muted);
    line-height: 1.5;
}

.results-rank-list,
.results-band-list,
.subject-list {
    display: grid;
    gap: 10px;
}

.results-rank-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.results-rank-item,
.results-band-item {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    padding: 12px 14px;
    border-radius: 8px;
    background: #f8fafc;
}

.results-rank-copy strong,
.results-rank-copy span {
    display: block;
}

.results-rank-copy span,
.subject-pill small {
    color: var(--muted);
}

.results-rank-badge {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    color: white;
    font-weight: 700;
    background: linear-gradient(135deg, #04706e, #2458d3);
}

.results-card-footer {
    margin-top: 14px;
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.6;
}

.results-band-item strong,
.results-band-item span {
    display: block;
}

.results-band-item strong {
    font-size: 1.2rem;
    font-family: "Outfit", sans-serif;
}

.results-band-item.distinction strong {
    color: var(--teal);
}

.results-band-item.credit strong {
    color: #99620d;
}

.results-band-item.support strong {
    color: var(--coral);
}

.results-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}

.subject-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border-radius: 999px;
    background: #eef4ff;
    color: var(--blue);
    font-weight: 700;
}

.results-table-card .table-wrap {
    margin-top: 12px;
}

.panel-grid,
.content-section,
.report-preview,
.report-shell,
.custom-fields,
.custom-builder,
.results-table-card {
    min-width: 0;
}

.panel-grid > *,
.form-grid > * {
    min-width: 0;
}

.results-cell-stack {
    display: grid;
    gap: 4px;
    min-width: 130px;
}

.results-cell-stack strong,
.results-cell-stack span {
    display: block;
}

.score-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.score-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border-radius: 999px;
    background: #f2f4f7;
    color: var(--ink);
    font-size: 0.82rem;
    font-weight: 700;
}

.score-chip.total {
    background: #eaf7f6;
    color: var(--teal);
}

.subject-pill {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    background: #f8fafc;
}

.subject-pill strong,
.subject-pill small {
    display: block;
}

.ai-output {
    min-height: 520px;
}

.ai-document {
    display: grid;
    gap: 14px;
    line-height: 1.65;
}

.ai-document h3,
.ai-document h4,
.ai-document p,
.ai-document ul,
.ai-document ol {
    margin: 0;
}

.ai-document h3 {
    font: 750 1.35rem "Outfit", sans-serif;
}

.ai-document h4 {
    margin-top: 4px;
    font: 750 1rem "Outfit", sans-serif;
}

.ai-document ul,
.ai-document ol {
    padding-left: 20px;
}

.ai-document li + li {
    margin-top: 6px;
}

.ai-meta-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.ai-meta-grid span {
    padding: 10px;
    border-radius: 8px;
    background: #f8fafc;
    border: 1px solid var(--line-soft);
}

.account-identity {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid var(--line-soft);
    background: #ffffff;
}

.account-avatar {
    width: 68px;
    height: 68px;
    border-radius: 8px;
    object-fit: cover;
    display: grid;
    place-items: center;
    font: 700 1.1rem "Outfit", sans-serif;
    color: white;
    background: linear-gradient(145deg, #04706e, #2458d3);
}

.empty-state,
.permission-note {
    padding: 20px;
    border-radius: var(--radius-md);
    background: #f8fafc;
    border: 1px dashed #cdd6e1;
    color: var(--muted);
}

.permission-note {
    margin: 0 0 14px;
    padding: 14px 16px;
}

@media (max-width: 1180px) {
    .auth-shell,
    .workspace-shell { grid-template-columns: 1fr; }
    .stats-grid, .two-up, .dual-layout, .finance-grid, .hero-metrics, .results-insight-grid, .record-filter-bar, .ai-meta-grid { grid-template-columns: 1fr; }
    .topbar, .hero-strip { flex-direction: column; align-items: stretch; }
    .topbar {
        gap: 12px;
    }
    .search-field-large {
        flex-basis: auto;
        max-width: none;
        min-width: 0;
        width: 100%;
    }
    .search-field input { min-width: 0; }
    .nav-menu {
        grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    }
    .topbar-brand-group,
    .topbar-actions {
        justify-content: space-between;
    }
    .profile-actions {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    .app-shell {
        height: auto;
        min-height: 100vh;
        overflow-x: hidden;
        overflow-y: visible;
    }
    .workspace-shell {
        display: block;
        width: 100%;
        max-width: 100vw;
        overflow: visible;
    }
    .sidebar {
        position: sticky;
        top: 0;
        z-index: 8;
        padding: 10px 12px;
        width: 100%;
        max-width: 100vw;
        overflow-x: auto;
        overflow-y: hidden;
        border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    }
    .nav-menu {
        display: flex;
        gap: 8px;
        min-width: max-content;
    }
    .nav-item {
        flex: 0 0 auto;
        min-height: 42px;
        padding: 10px 12px;
        border-radius: 8px;
        white-space: nowrap;
        text-align: center;
    }
    .nav-item.active,
    .nav-item:hover {
        transform: none;
    }
    .main-panel {
        padding: 14px;
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
        overflow-y: visible;
    }
    .hero-strip {
        align-items: stretch;
    }
    .hero-metrics {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
    .panel {
        padding: 16px;
        border-radius: 8px;
    }
    .table-wrap {
        border-radius: 8px;
    }
    table {
        min-width: 720px;
    }
    th, td {
        padding: 12px 10px;
    }
}

@media (max-width: 1420px) {
    .dual-layout {
        grid-template-columns: 1fr;
    }
    .entry-layout > .panel:first-child {
        order: 2;
    }
    .entry-layout > .panel:last-child {
        order: 1;
    }
    .report-preview {
        min-height: 300px;
    }
}

@media (max-width: 720px) {
    body {
        overflow-x: hidden;
    }
    .auth-shell,
    .main-panel { padding: 12px; }
    .sidebar { padding: 8px 10px; }
    .form-grid { grid-template-columns: 1fr; }
    .nav-menu { grid-template-columns: none; }
    .stack-item, .course-card-head, .section-heading, .results-rank-item, .results-band-item, .subject-pill {
        flex-direction: column;
        align-items: stretch;
    }
    .topbar {
        padding: 10px 14px;
        gap: 10px;
        width: 100%;
        max-width: 100vw;
    }
    .topbar-brand-group {
        flex-direction: row;
        justify-content: flex-start;
        min-width: 0;
        width: 100%;
    }
    .topbar-mark {
        width: 38px;
        height: 38px;
        border-radius: 8px;
        flex: 0 0 38px;
    }
    .topbar-brand-copy h2 {
        font-size: 0.98rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .topbar-actions,
    .header-profile-menu,
    .header-profile-trigger {
        width: 100%;
    }
    .header-profile-trigger,
    .header-profile-meta {
        text-align: left;
    }
    .header-profile-trigger {
        justify-content: space-between;
        padding: 8px 10px 8px 12px;
        border-radius: 8px;
    }
    .header-profile-panel {
        left: 0;
        right: 0;
        width: 100%;
    }
    .toggle-form-button {
        max-width: none;
    }
    .panel-head-actions {
        width: 100%;
        justify-content: flex-start;
        margin-left: 0;
    }
    .form-drawer {
        padding: 14px;
    }
    .stats-grid,
    .hero-metrics,
    .results-summary-strip {
        grid-template-columns: 1fr;
    }
    .record-filter-bar {
        padding: 10px;
        gap: 10px;
    }
    .badge,
    .pill,
    button,
    input,
    select,
    textarea {
        max-width: 100%;
    }
    .primary-button,
    .ghost-button,
    .mini-button,
    .file-input-button {
        width: 100%;
        justify-content: center;
    }
    .header-profile-panel {
        position: fixed;
        left: 12px;
        right: 12px;
        top: 86px;
        width: auto;
    }
    .panel-head {
        gap: 10px;
        margin-bottom: 12px;
    }
}
