:root {
    --ink: #172723;
    --muted: #6d7b77;
    --line: #e3e9e6;
    --paper: #ffffff;
    --canvas: #f4f6f3;
    --green: #1d6b5b;
    --green-dark: #183b35;
    --green-soft: #e7f2ed;
    --lime: #dcecae;
    --red: #b84d45;
    --red-soft: #faece9;
    --amber: #a87322;
    --shadow: 0 12px 35px rgba(23, 39, 35, .055);
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background: var(--canvas);
    font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; }
a { color: var(--green); text-decoration: none; }
a:hover { color: var(--green-dark); }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid rgba(29, 107, 91, .25); outline-offset: 3px; }
h1, h2, h3, h4, p { margin-top: 0; }
h1, h2, h3, h4 { letter-spacing: -.025em; }
h2 { margin-bottom: 8px; font-size: clamp(28px, 4vw, 38px); line-height: 1.12; }
h3 { margin-bottom: 0; font-size: 20px; }
h4 { margin-bottom: 7px; font-size: 16px; }
.muted { color: var(--muted); line-height: 1.6; }
.eyebrow { margin-bottom: 7px; color: var(--muted); font-size: 11px; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }

.app-shell { display: grid; grid-template-columns: 244px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; display: flex; flex-direction: column; height: 100vh; padding: 30px 20px 24px; color: #fff; background: var(--green-dark); }
.brand { display: flex; align-items: center; gap: 12px; color: inherit; }
.brand:hover { color: inherit; }
.brand-mark { display: grid; flex: 0 0 auto; place-items: center; width: 40px; height: 40px; border-radius: 13px; color: var(--green-dark); background: var(--lime); font-size: 13px; font-weight: 850; letter-spacing: -.03em; }
.brand strong { display: block; font-size: 16px; }
.brand small { display: block; max-width: 140px; margin-top: 4px; color: rgba(255,255,255,.55); font-size: 10px; line-height: 1.3; }
.main-nav { display: grid; gap: 7px; margin-top: 52px; }
.main-nav a { display: flex; align-items: center; gap: 12px; padding: 13px 14px; border-radius: 12px; color: rgba(255,255,255,.7); font-size: 14px; font-weight: 600; }
.main-nav a:hover { color: #fff; background: rgba(255,255,255,.06); }
.main-nav a.active { color: var(--green-dark); background: var(--lime); }
.nav-icon { display: grid; place-items: center; width: 22px; height: 22px; font-size: 15px; font-weight: 800; }
.sidebar-bottom { display: grid; gap: 12px; margin-top: auto; }
.settings-link, .logout-button { display: block; width: 100%; padding: 10px 14px; border: 0; border-radius: 10px; color: rgba(255,255,255,.62); background: transparent; text-align: left; font-size: 12px; cursor: pointer; }
.settings-link:hover, .settings-link.active, .logout-button:hover { color: #fff; background: rgba(255,255,255,.06); }

.main-wrap { display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 96px; padding: 22px clamp(24px, 4vw, 52px); border-bottom: 1px solid var(--line); background: rgba(255,255,255,.78); }
.topbar h1 { margin: 0; font-size: 18px; }
.topbar h1 span { color: var(--muted); font-weight: 500; }
.topbar .eyebrow { margin-bottom: 5px; }
.source-link { padding: 9px 0; font-size: 12px; font-weight: 650; }
.content { flex: 1; width: 100%; max-width: 1480px; margin: 0 auto; padding: 38px clamp(24px, 4vw, 52px) 56px; }
.footer { padding: 0 clamp(24px, 4vw, 52px) 26px; color: var(--muted); font-size: 11px; }
.sync-time { display: inline-flex; align-items: center; gap: 8px; }
.sync-icon { flex: 0 0 auto; width: 18px; height: 18px; color: var(--green); }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.page-heading p:last-child { margin-bottom: 0; }
.panel { border: 1px solid var(--line); border-radius: 20px; background: var(--paper); box-shadow: var(--shadow); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 25px 26px 20px; }
.panel-heading > a { flex: 0 0 auto; font-size: 12px; font-weight: 650; }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 11px 17px; border: 1px solid transparent; border-radius: 12px; font-size: 13px; font-weight: 700; line-height: 1.2; cursor: pointer; transition: transform .15s, background .15s; }
.button:hover { transform: translateY(-1px); }
.button.primary { color: #fff; background: var(--green); }
.button.primary:hover { color: #fff; background: #18594c; }
.button.secondary { border-color: var(--line); color: var(--ink); background: var(--paper); }
.button.secondary:hover { color: var(--green); background: var(--green-soft); }
.button:disabled { opacity: .55; cursor: wait; transform: none; }
.button.full { width: 100%; }

.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 22px; }
.stat-card { position: relative; overflow: hidden; min-height: 148px; padding: 23px 25px; border: 1px solid var(--line); border-radius: 18px; background: var(--paper); }
.stat-card > span { display: block; margin-bottom: 10px; color: var(--muted); font-size: 12px; font-weight: 650; }
.stat-card strong { display: block; margin-bottom: 5px; font-size: 35px; line-height: 1; letter-spacing: -.05em; }
.stat-card small { color: var(--muted); font-size: 11px; }
.stat-card.accent { border-color: var(--green-dark); color: #fff; background: var(--green-dark); }
.stat-card.accent > span, .stat-card.accent small { color: rgba(255,255,255,.65); }
.stat-card.accent::after { position: absolute; right: -25px; bottom: -55px; width: 150px; height: 150px; border-radius: 50%; background: var(--lime); opacity: .09; content: ""; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, 1fr); gap: 22px; }
.homework-list { padding: 0 26px 16px; }
.homework-item { position: relative; display: grid; grid-template-columns: 106px minmax(0, 1fr); gap: 20px; padding: 20px 34px 20px 0; border-top: 1px solid var(--line); }
.completion-form { margin: 0; }
.completion-toggle { position: relative; display: block; width: 24px; height: 24px; padding: 0; border: 2px solid #a8b8b2; border-radius: 50%; background: #fff; cursor: pointer; }
.completion-toggle:hover { border-color: var(--green); background: var(--green-soft); }
.completion-toggle::after { position: absolute; top: 4px; left: 7px; display: none; width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0; content: ""; transform: rotate(45deg); }
.completed .completion-toggle { border-color: var(--green); background: var(--green); }
.completed .completion-toggle::after { display: block; }
.completed .homework-body h4, .completed .homework-body p, .lesson-card.completed h4, .lesson-card.completed p { color: var(--muted); text-decoration: line-through; }
.homework-item .completion-form { position: absolute; top: 20px; right: 0; }
.date-badge strong, .date-badge small { display: block; }
.date-badge strong { margin-bottom: 4px; font-size: 12px; }
.date-badge small { color: var(--muted); font-size: 11px; }
.date-badge.today strong { color: var(--green); }
.homework-body p { margin: 0; color: #46534f; font-size: 13px; line-height: 1.55; white-space: pre-line; }
.recent-grades { padding: 0 26px 16px; }
.grade-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 15px 0; border-top: 1px solid var(--line); }
.grade-row strong { display: block; overflow: hidden; max-width: 200px; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.grade-row small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.grade { display: inline-grid; flex: 0 0 auto; place-items: center; min-width: 34px; height: 34px; padding: 0 8px; border-radius: 10px; font-size: 15px; font-weight: 800; }
.grade.excellent, .subject-average .excellent, .subject-card .excellent { color: #266d4e; background: #e3f3e9; }
.grade.good, .subject-average .good, .subject-card .good { color: #547027; background: #edf3dd; }
.grade.average, .subject-average .average, .subject-card .average { color: #97641d; background: #fcf0dc; }
.grade.low, .subject-average .low, .subject-card .low { color: var(--red); background: var(--red-soft); }
.grade.neutral { color: var(--muted); background: var(--canvas); }
.subjects-panel { margin-top: 22px; }
.subject-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; padding: 0 26px 26px; }
.subject-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 54px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); font-size: 12px; }
.subject-card:hover { border-color: #b9cbc4; background: #fafcfa; }
.subject-card strong { display: grid; flex: 0 0 auto; place-items: center; min-width: 35px; height: 30px; border-radius: 8px; font-size: 12px; }
.panel-empty { padding: 10px 26px 28px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.panel-empty strong { color: var(--ink); }
.panel-empty p { margin: 6px 0 0; }

.empty-state { padding: 60px 24px; border: 1px dashed #cbd6d1; border-radius: 22px; background: rgba(255,255,255,.55); text-align: center; }
.empty-state h3 { margin-bottom: 10px; font-size: 23px; }
.empty-state p { max-width: 520px; margin: 0 auto 22px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.empty-mark { display: grid; place-items: center; width: 54px; height: 54px; margin: 0 auto 20px; border-radius: 17px; color: var(--green-dark); background: var(--lime); font-size: 16px; font-weight: 850; }
.alert { margin-bottom: 18px; padding: 13px 16px; border: 1px solid transparent; border-radius: 12px; font-size: 13px; line-height: 1.5; }
.alert.error { border-color: #f0cdc8; color: #8f3b35; background: var(--red-soft); }
.alert.success { border-color: #c9e2d6; color: #235f48; background: var(--green-soft); }
.alert.info { border-color: #d6e1ed; color: #355e7a; background: #eef5fa; }

.compact-stat { min-width: 160px; padding: 15px 20px; border: 1px solid var(--line); border-radius: 15px; background: var(--paper); text-align: right; }
.compact-stat span { display: block; color: var(--muted); font-size: 10px; }
.compact-stat strong { display: block; margin-top: 4px; font-size: 25px; }
.subject-list { display: grid; gap: 16px; }
.subject-section { padding: 24px 26px; }
.subject-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.subject-heading h3 { margin-bottom: 5px; }
.subject-heading > div > span { color: var(--muted); font-size: 11px; }
.subject-average { display: flex; align-items: center; gap: 14px; }
.subject-average strong { display: grid; place-items: center; min-width: 48px; height: 38px; padding: 0 9px; border-radius: 10px; font-size: 15px; }
.grades-stream { display: flex; flex-wrap: wrap; gap: 9px; }
.grade-entry { display: flex; align-items: center; gap: 9px; padding: 5px 10px 5px 5px; border: 1px solid var(--line); border-radius: 12px; color: var(--muted); font-size: 11px; }
.grade-entry .grade { min-width: 30px; height: 30px; font-size: 13px; }

.week-switcher { display: flex; flex-wrap: wrap; gap: 8px; }
.days-list { display: grid; gap: 28px; }
.day-group { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 24px; }
.day-heading { padding-top: 19px; }
.day-heading span { color: var(--muted); font-size: 11px; }
.day-heading h3 { margin-top: 5px; font-size: 19px; }
.day-heading .today-label { display: inline-block; margin-top: 12px; padding: 5px 8px; border-radius: 7px; color: var(--green); background: var(--green-soft); font-size: 9px; font-weight: 750; text-transform: uppercase; }
.day-lessons { display: grid; gap: 10px; }
.lesson-card { position: relative; padding: 20px 22px 20px 58px; box-shadow: none; }
.lesson-card .completion-form { position: absolute; top: 22px; left: 21px; }
.lesson-meta { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; color: var(--muted); font-size: 10px; }
.lesson-meta .grade { min-width: 28px; height: 28px; font-size: 12px; }
.lesson-card p { margin: 0; color: #46534f; font-size: 14px; line-height: 1.65; white-space: pre-line; }
.attachments { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; }
.attachments a { display: inline-flex; gap: 6px; max-width: 100%; padding: 7px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--canvas); font-size: 10px; overflow-wrap: anywhere; }

.schedule-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.schedule-day { overflow: hidden; box-shadow: none; }
.schedule-day.current { border-color: #8fb9a9; box-shadow: 0 0 0 2px rgba(29,107,91,.08); }
.schedule-day-header { display: flex; align-items: center; justify-content: space-between; padding: 19px 22px; background: #fafbf9; }
.schedule-day-header span { color: var(--muted); font-size: 10px; }
.schedule-day-header h3 { margin-top: 4px; font-size: 18px; }
.schedule-day-header .today-label { display: inline-block; padding: 5px 8px; border-radius: 7px; color: var(--green); background: var(--green-soft); font-size: 9px; font-weight: 750; text-transform: uppercase; }
.lesson-count { display: grid; place-items: center; min-width: 27px; height: 27px; border-radius: 9px; background: var(--canvas); }
.schedule-lessons { padding: 0 22px; }
.schedule-lesson { display: grid; grid-template-columns: 25px minmax(0, 1fr) auto; align-items: center; gap: 12px; min-height: 70px; padding: 13px 0; border-top: 1px solid var(--line); }
.lesson-order { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 8px; color: var(--muted); background: var(--canvas); font-size: 11px; font-weight: 700; }
.schedule-subject strong, .schedule-subject small { display: block; }
.schedule-subject strong { font-size: 13px; line-height: 1.35; }
.schedule-subject small { margin-top: 5px; color: var(--muted); font-size: 10px; }
.schedule-lesson .grade { min-width: 30px; height: 30px; font-size: 12px; }
.absence-badge { display: grid; place-items: center; min-width: 30px; height: 30px; padding: 0 7px; border-radius: 9px; color: var(--red); background: var(--red-soft); font-size: 11px; font-weight: 750; }
.no-lessons { margin: 0; padding: 25px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; text-align: center; }

.settings-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 22px; }
.settings-card { padding: 26px; }
.settings-card > .eyebrow { margin-bottom: 8px; }
.settings-card > h3 { margin-bottom: 24px; }
.settings-card .panel-heading { padding: 0 0 20px; }
.details-list { margin: 0 0 24px; }
.details-list > div { display: grid; grid-template-columns: 160px 1fr; gap: 15px; padding: 14px 0; border-top: 1px solid var(--line); font-size: 12px; line-height: 1.5; }
.details-list dt { color: var(--muted); }
.details-list dd { margin: 0; font-weight: 600; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: #b6c0bc; }
.status-dot.success { background: #4b9c71; box-shadow: 0 0 0 5px #e8f3ec; }
.status-dot.error { background: var(--red); box-shadow: 0 0 0 5px var(--red-soft); }
.status-dot.running { background: var(--amber); box-shadow: 0 0 0 5px #fcf0dc; }
.security-list { display: grid; gap: 20px; margin: 0 0 26px; padding: 0; list-style: none; }
.security-list strong, .security-list span { display: block; }
.security-list strong { margin-bottom: 4px; font-size: 13px; }
.security-list span { color: var(--muted); font-size: 12px; line-height: 1.5; }
.appearance-card { grid-column: 1 / -1; }
.appearance-card > .muted { max-width: 680px; margin: -12px 0 24px; font-size: 13px; }
.theme-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 0 0 20px; padding: 0; border: 0; }
.theme-options legend { grid-column: 1 / -1; margin-bottom: 10px; padding: 0; color: var(--muted); font-size: 11px; font-weight: 650; }
.theme-option { display: flex; align-items: flex-start; gap: 12px; padding: 17px; border: 1px solid var(--line); border-radius: 13px; background: var(--paper); cursor: pointer; transition: border-color .15s, background .15s; }
.theme-option:hover { border-color: #b9cbc4; background: #fafcfa; }
.theme-option:has(input:checked) { border-color: var(--green); background: var(--green-soft); }
.theme-option input { flex: 0 0 auto; width: 17px; height: 17px; margin: 2px 0 0; accent-color: var(--green); }
.theme-copy strong, .theme-copy small { display: block; }
.theme-copy strong { margin-bottom: 5px; font-size: 13px; }
.theme-copy small { color: var(--muted); font-size: 11px; line-height: 1.5; }
.mobile-nav { display: none; }

.auth-page { display: grid; place-items: center; min-height: 100vh; padding: 24px; background: var(--green-dark); }
.auth-card { width: 100%; max-width: 440px; padding: 36px; border-radius: 24px; background: var(--paper); box-shadow: 0 24px 80px rgba(0,0,0,.2); }
.auth-brand { margin-bottom: 38px; color: var(--green-dark); }
.auth-card h1 { margin-bottom: 12px; font-size: 29px; }
.auth-card > .muted { margin-bottom: 25px; font-size: 13px; }
.auth-form { display: grid; gap: 11px; margin-top: 24px; }
.auth-form label { margin-top: 7px; font-size: 12px; font-weight: 700; }
.auth-form input { width: 100%; height: 47px; padding: 0 13px; border: 1px solid #ccd7d2; border-radius: 11px; color: var(--ink); background: #fff; }
.auth-form input:focus { border-color: var(--green); }
.auth-form small { margin-top: -5px; color: var(--muted); font-size: 10px; }
.auth-form .button { margin-top: 12px; }

@media (max-width: 1100px) {
    .app-shell { grid-template-columns: 210px minmax(0, 1fr); }
    .sidebar { padding-inline: 15px; }
    .brand small { display: none; }
    .dashboard-grid, .settings-grid { grid-template-columns: 1fr; }
    .subject-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
    .app-shell { display: block; }
    .sidebar { display: none; }
    .topbar { min-height: 78px; padding: 17px 18px; }
    .topbar h1 { font-size: 16px; }
    .source-link { display: none; }
    .content { padding: 25px 16px 100px; }
    .footer { display: none; }
    .page-heading { align-items: flex-start; margin-bottom: 22px; }
    .page-heading .button { display: none; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-card { min-height: 125px; padding: 18px; }
    .stat-card:first-child { grid-column: span 2; min-height: 115px; }
    .stat-card strong { font-size: 30px; }
    .dashboard-grid { gap: 16px; }
    .panel { border-radius: 16px; }
    .panel-heading { padding: 20px 18px 16px; }
    .homework-list, .recent-grades { padding: 0 18px 12px; }
    .homework-item { grid-template-columns: 1fr; gap: 10px; }
    .date-badge { display: flex; align-items: center; gap: 7px; }
    .date-badge strong { margin: 0; }
    .subject-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 0 18px 18px; }
    .subject-card { align-items: flex-start; flex-direction: column; }
    .compact-stat { min-width: 100px; padding: 12px; }
    .compact-stat span { max-width: 80px; }
    .subject-section { padding: 20px 18px; }
    .subject-heading { align-items: flex-start; }
    .subject-average { align-items: flex-end; flex-direction: column; gap: 6px; }
    .grades-stream { gap: 7px; }
    .grade-entry { padding-right: 9px; }
    .grade-entry > span:last-child { font-size: 10px; }
    .homework-heading, .schedule-heading { align-items: flex-start; flex-direction: column; }
    .week-switcher .button { display: inline-flex; }
    .day-group { grid-template-columns: 1fr; gap: 12px; }
    .day-heading { display: flex; align-items: center; justify-content: space-between; padding: 0 3px; }
    .day-heading > div { display: flex; align-items: baseline; gap: 8px; }
    .day-heading h3 { margin: 0; font-size: 17px; }
    .day-heading .today-label { margin: 0; }
    .schedule-grid { grid-template-columns: 1fr; gap: 12px; }
    .schedule-day-header { padding: 17px 18px; }
    .schedule-lessons { padding: 0 18px; }
    .details-list > div { grid-template-columns: 1fr; gap: 4px; }
    .settings-card { padding: 20px; }
    .theme-options { grid-template-columns: 1fr; }
    .theme-options legend { grid-column: auto; }
    .mobile-nav { position: fixed; z-index: 20; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); left: 12px; display: grid; grid-template-columns: repeat(5, 1fr); padding: 7px; border: 1px solid rgba(255,255,255,.12); border-radius: 17px; background: rgba(24,59,53,.97); box-shadow: 0 12px 30px rgba(23,39,35,.25); backdrop-filter: blur(16px); }
    .mobile-nav a { padding: 10px 2px; border-radius: 11px; color: rgba(255,255,255,.66); text-align: center; font-size: 9px; font-weight: 650; }
    .mobile-nav a.active { color: var(--green-dark); background: var(--lime); }
    .auth-card { padding: 28px 23px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}

.student-profile { display: flex; align-items: center; gap: 12px; }
.photo-card { grid-column: 1 / -1; }
.photo-preview { display: block; width: 76px; height: 76px; margin: 18px 0; border: 3px solid var(--paper); border-radius: 22px; object-fit: cover; box-shadow: var(--shadow); }
.photo-form { display: grid; gap: 11px; max-width: 520px; margin-top: 20px; }
.photo-form label { font-size: 12px; font-weight: 700; }
.photo-form input { max-width: 100%; padding: 10px; border: 1px dashed #b8c8c1; border-radius: 11px; background: var(--canvas); font-size: 12px; }
.photo-form small { color: var(--muted); font-size: 10px; }
.photo-form .button { justify-self: start; }

.browser-preview-link { margin-top: 10px; }
.login-preview-card { max-width: 900px; padding: 24px; }
.login-preview-image { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: 16px; background: #fff; }
.login-preview-card .muted { margin: 16px 0 0; font-size: 12px; }
