:root {
    --bg: #f3f5f8;
    --surface: #ffffff;
    --surface-soft: #f7f8fa;
    --border: #e4e7ec;
    --text: #171a21;
    --text-secondary: #69707d;
    --text-muted: #9aa1ad;

    --primary: #3157d5;
    --primary-dark: #2446b8;
    --primary-soft: #edf1ff;

    --success: #159a69;
    --success-soft: #eaf8f2;

    --warning: #c98216;
    --warning-soft: #fff5df;

    --danger: #d94a4a;
    --danger-soft: #fff0f0;

    --shadow: 0 10px 35px rgba(20, 28, 45, 0.06);
    --shadow-hover: 0 14px 40px rgba(20, 28, 45, 0.1);

    --radius: 18px;
    --radius-small: 11px;

    --transition: 180ms ease;
}

html[data-theme="dark"] {
    --bg: #111318;
    --surface: #1a1d24;
    --surface-soft: #20242c;
    --border: #2c313b;
    --text: #f1f3f7;
    --text-secondary: #a9afba;
    --text-muted: #707784;

    --primary: #718cff;
    --primary-dark: #8fa2ff;
    --primary-soft: #202943;

    --success: #42c893;
    --success-soft: #17352a;

    --warning: #e4a74c;
    --warning-soft: #382c18;

    --danger: #ef7070;
    --danger-soft: #3a2020;

    --shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
    --shadow-hover: 0 15px 45px rgba(0, 0, 0, 0.3);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family:
        Inter,
        ui-sans-serif,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        Helvetica,
        Arial,
        sans-serif;
    transition:
        background var(--transition),
        color var(--transition);
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

button:focus-visible,
input:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--primary) 25%, transparent);
    outline-offset: 2px;
}

/* ------------------------------
   LOGIN
------------------------------ */

.login-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at 20% 10%, rgba(49, 87, 213, 0.08), transparent 30%),
        var(--bg);
}

.login-container {
    width: min(100%, 440px);
}

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

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    flex: 0 0 44px;
    border-radius: 13px;
    background: var(--primary);
    color: white;
    font-size: 22px;
    font-weight: 800;
}

.brand h1 {
    margin: 0;
    font-size: 20px;
    letter-spacing: -0.03em;
}

.brand p {
    margin: 2px 0 0;
    color: var(--text-secondary);
    font-size: 12px;
}

.login-heading {
    margin: 40px 0 28px;
}

.login-heading h2 {
    margin: 0 0 7px;
    font-size: 28px;
    letter-spacing: -0.04em;
}

.login-heading p {
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.5;
}

.team-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 0 0 22px;
    padding: 0;
    border: 0;
}

.team-selector legend {
    width: 100%;
    margin-bottom: 9px;
    color: var(--text);
    font-size: 13px;
    font-weight: 650;
}

.team-option {
    position: relative;
}

.team-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.team-option span {
    display: block;
    padding: 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    color: var(--text-secondary);
    text-align: center;
    font-size: 14px;
    font-weight: 650;
    transition: var(--transition);
}

.team-option:hover span {
    border-color: var(--primary);
}

.team-option input:checked + span {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary);
}

.form-field {
    display: grid;
    gap: 8px;
}

.form-field label {
    font-size: 13px;
    font-weight: 650;
}

.form-field input {
    width: 100%;
    padding: 14px 15px;
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    outline: none;
    background: var(--surface-soft);
    color: var(--text);
    transition: var(--transition);
}

.form-field input:focus {
    border-color: var(--primary);
    background: var(--surface);
}

.error-message {
    min-height: 20px;
    margin: 8px 0 2px;
    color: var(--danger);
    font-size: 13px;
}

.primary-button,
.secondary-button,
.logout-button {
    border: 0;
    transition: var(--transition);
}

.primary-button {
    background: var(--primary);
    color: white;
}

.primary-button:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(49, 87, 213, 0.2);
}

.login-button {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-radius: var(--radius-small);
    font-weight: 700;
}

.login-footer {
    margin: 28px 0 0;
    color: var(--text-muted);
    font-size: 11px;
    text-align: center;
}

/* ------------------------------
   APPLICATION LAYOUT
------------------------------ */

.app-shell {
    min-height: 100vh;
    padding: 20px;
}

.dashboard {
    display: grid;
    grid-template-columns: minmax(220px, 0.8fr) minmax(400px, 1.7fr) minmax(340px, 1.15fr);
    gap: 20px;
    max-width: 1700px;
    min-height: calc(100vh - 40px);
    margin: 0 auto;
}

.panel {
    min-width: 0;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* ------------------------------
   MOBILE HEADER
------------------------------ */

.mobile-header {
    display: none;
}

/* ------------------------------
   SETTINGS
------------------------------ */

.settings-panel {
    display: flex;
    min-height: 0;
    flex-direction: column;
    padding: 24px;
}

.panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 25px;
    border-bottom: 1px solid var(--border);
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--primary);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.13em;
    text-transform: uppercase;
}

.panel-header h2,
.schedule-header h2 {
    margin: 0;
    font-size: 18px;
    letter-spacing: -0.025em;
}

.team-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 9px;
    border-radius: 8px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 11px;
    font-weight: 750;
    white-space: nowrap;
}

.settings-section {
    padding: 24px 0;
    border-bottom: 1px solid var(--border);
}

.settings-section h3 {
    margin: 0 0 12px;
    font-size: 13px;
}

.theme-switcher {
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding: 4px;
    border-radius: 10px;
    background: var(--surface-soft);
}

.theme-button {
    padding: 9px 6px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 650;
    transition: var(--transition);
}

.theme-button span {
    margin-right: 4px;
}

.theme-button.active {
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
}

.section-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.section-title-row p {
    margin: 3px 0 0;
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.4;
}

.average-value {
    color: var(--primary);
    font-size: 22px;
    font-weight: 800;
}

.grades-list {
    display: grid;
    gap: 8px;
    margin: 17px 0 12px;
}

.grade-row {
    display: flex;
    gap: 7px;
}

.grade-input {
    width: 100%;
    min-width: 0;
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: none;
    background: var(--surface-soft);
    color: var(--text);
    font-size: 13px;
}

.grade-input:focus {
    border-color: var(--primary);
}

.remove-grade {
    width: 35px;
    flex: 0 0 35px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    transition: var(--transition);
}

.remove-grade:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: var(--danger-soft);
}

.secondary-button {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px;
    border: 1px dashed var(--border);
    border-radius: 9px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 650;
}

.secondary-button:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-soft);
}

.settings-bottom {
    display: flex;
    align-items: flex-end;
    flex: 1;
    padding-top: 24px;
}

.logout-button {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 650;
}

.logout-button:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: var(--danger-soft);
}

/* ------------------------------
   TIMER
------------------------------ */

.timer-panel {
    display: flex;
    min-height: 650px;
    flex-direction: column;
}

.timer-topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 28px 30px;
}

.date-label {
    margin: 0;
    color: var(--text-secondary);
    font-size: 12px;
}

.live-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--success);
    font-size: 11px;
    font-weight: 700;
}

.live-indicator span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--success);
}

.timer-content {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 25px;
    text-align: center;
}

.timer-status {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 7px 11px;
    border-radius: 8px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 11px;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.timer-status.break {
    background: var(--warning-soft);
    color: var(--warning);
}

.timer-status.after-school {
    background: var(--surface-soft);
    color: var(--text-secondary);
}

.next-lesson {
    min-height: 92px;
    margin: 20px 0 18px;
}

.context-label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.next-lesson h2 {
    max-width: 450px;
    margin: 0;
    font-size: clamp(21px, 2.5vw, 30px);
    letter-spacing: -0.04em;
}

.next-lesson p {
    margin: 5px 0 0;
    color: var(--text-secondary);
    font-size: 13px;
}

.countdown {
    font-variant-numeric: tabular-nums;
    font-size: clamp(58px, 7vw, 105px);
    font-weight: 750;
    line-height: 1;
    letter-spacing: -0.07em;
    white-space: nowrap;
}

.current-time {
    margin-top: 19px;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    font-size: 19px;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.timer-description {
    margin-top: 9px;
    color: var(--text-muted);
    font-size: 11px;
}

.timer-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    padding: 19px;
    border-top: 1px solid var(--border);
}

.footer-stat {
    display: flex;
    align-items: center;
    gap: 7px;
}

.footer-label {
    color: var(--text-muted);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.footer-stat strong {
    font-size: 12px;
}

.footer-divider {
    width: 1px;
    height: 18px;
    background: var(--border);
}

/* ------------------------------
   SCHEDULE
------------------------------ */

.schedule-panel {
    display: flex;
    min-height: 0;
    flex-direction: column;
}

.schedule-header {
    padding: 28px 24px 18px;
}

.day-selector {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 5px;
    margin: 0 20px;
    padding: 4px;
    border-radius: 10px;
    background: var(--surface-soft);
}

.day-selector button {
    padding: 9px 4px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 750;
    letter-spacing: 0.05em;
    transition: var(--transition);
}

.day-selector button:hover {
    color: var(--text);
}

.day-selector button.active {
    background: var(--surface);
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
}

.schedule-date {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 17px 24px 8px;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 650;
}

.schedule-date span:last-child {
    color: var(--text-muted);
    font-weight: 500;
}

.schedule-list {
    display: flex;
    min-height: 0;
    flex-direction: column;
    gap: 7px;
    overflow-y: auto;
    padding: 8px 20px 20px;
}

.schedule-list::-webkit-scrollbar {
    width: 5px;
}

.schedule-list::-webkit-scrollbar-thumb {
    border-radius: 10px;
    background: var(--border);
}

.schedule-item {
    position: relative;
    display: grid;
    grid-template-columns: 67px 1fr auto;
    gap: 11px;
    align-items: center;
    padding: 12px;
    border: 1px solid transparent;
    border-radius: 11px;
    transition: var(--transition);
}

.schedule-item.lesson:hover {
    background: var(--surface-soft);
}

.schedule-time {
    color: var(--text-muted);
    font-size: 10px;
    font-variant-numeric: tabular-nums;
    line-height: 1.4;
}

.schedule-main {
    min-width: 0;
}

.schedule-subject {
    overflow: hidden;
    color: var(--text);
    font-size: 12px;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.schedule-meta {
    margin-top: 3px;
    overflow: hidden;
    color: var(--text-secondary);
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.schedule-state {
    color: var(--text-muted);
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.schedule-item.finished {
    opacity: 0.45;
}

.schedule-item.current {
    border-color: color-mix(in srgb, var(--primary) 30%, var(--border));
    background: var(--primary-soft);
}

.schedule-item.current .schedule-time,
.schedule-item.current .schedule-subject {
    color: var(--primary);
}

.schedule-item.current .schedule-state {
    color: var(--primary);
}

.schedule-item.next {
    border-color: color-mix(in srgb, var(--success) 25%, var(--border));
    background: var(--success-soft);
}

.schedule-item.next .schedule-state {
    color: var(--success);
}

.schedule-item.break {
    display: grid;
    grid-template-columns: 67px 1fr;
    min-height: 42px;
    background: var(--surface-soft);
}

.break-label {
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 750;
    letter-spacing: 0.08em;
}

.break-time {
    color: var(--text-muted);
    font-size: 10px;
    font-variant-numeric: tabular-nums;
}

.empty-schedule {
    display: grid;
    min-height: 180px;
    place-items: center;
    padding: 30px;
    color: var(--text-muted);
    font-size: 12px;
    text-align: center;
}

/* ------------------------------
   RESPONSIVE
------------------------------ */

@media (max-width: 1150px) {
    .dashboard {
        grid-template-columns: 210px minmax(350px, 1fr);
    }

    .schedule-panel {
        grid-column: 1 / -1;
        min-height: 500px;
    }

    .schedule-list {
        max-height: 550px;
    }
}

@media (max-width: 800px) {
    .app-shell {
        padding: 12px;
    }

    .mobile-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 12px;
        padding: 5px 5px 12px;
    }

    .brand-small .brand-mark {
        width: 36px;
        height: 36px;
        flex-basis: 36px;
        border-radius: 10px;
        font-size: 17px;
    }

    .brand-small h1 {
        font-size: 16px;
    }

    .dashboard {
        display: flex;
        flex-direction: column;
        min-height: 0;
        gap: 12px;
    }

    .timer-panel {
        order: 1;
        min-height: 560px;
    }

    .schedule-panel {
        order: 2;
        min-height: 480px;
    }

    .settings-panel {
        order: 3;
        min-height: auto;
    }

    .settings-bottom {
        padding-top: 20px;
    }

    .settings-section {
        padding: 18px 0;
    }

    .timer-topbar {
        padding: 22px 20px;
    }

    .timer-content {
        padding: 25px 15px;
    }

    .countdown {
        font-size: clamp(48px, 13vw, 78px);
    }
}

@media (max-width: 480px) {
    .login-page {
        padding: 14px;
    }

    .login-card {
        padding: 28px 20px;
        border-radius: 18px;
    }

    .login-heading {
        margin: 30px 0 23px;
    }

    .login-heading h2 {
        font-size: 25px;
    }

    .timer-panel {
        min-height: 500px;
    }

    .timer-topbar {
        padding: 18px;
    }

    .timer-content {
        padding: 15px 10px;
    }

    .timer-status {
        font-size: 9px;
    }

    .next-lesson {
        min-height: 82px;
        margin: 15px 0;
    }

    .next-lesson h2 {
        font-size: 21px;
    }

    .countdown {
        font-size: clamp(42px, 13.5vw, 62px);
        letter-spacing: -0.075em;
    }

    .current-time {
        font-size: 17px;
    }

    .schedule-header {
        padding: 22px 18px 15px;
    }

    .day-selector {
        margin: 0 14px;
    }

    .schedule-date {
        margin-left: 18px;
        margin-right: 18px;
    }

    .schedule-list {
        padding-left: 14px;
        padding-right: 14px;
    }

    .schedule-item {
        grid-template-columns: 58px 1fr auto;
        gap: 8px;
        padding: 10px;
    }

    .schedule-item.break {
        grid-template-columns: 58px 1fr;
    }

    .schedule-time,
    .schedule-meta {
        font-size: 9px;
    }

    .schedule-subject {
        font-size: 11px;
    }

    .schedule-state {
        font-size: 8px;
    }
}
