:root {
    --bg: #fbfaf9;
    --surface: #ffffff;
    --line: #e7e1da;
    --line-strong: #d8d0c7;
    --ink: #111111;
    --muted: #746f69;
    --soft: #f5f1eb;
    --accent: #111111;
    --green: #008f5f;
    --green-soft: #e9fff6;
    --blue: #1677e8;
    --blue-soft: #eef6ff;
    --warning: #b94a12;
    --warning-soft: #fff1e8;
    --danger: #c9352b;
    --danger-soft: #fff0ef;
    --shadow: 0 18px 54px rgba(28, 22, 16, 0.075);
}

* {
    box-sizing: border-box;
}

html {
    background: var(--bg);
}

body {
    background: var(--bg);
    color: var(--ink);
    font-family: "SF Pro Text", "Segoe UI", Arial, sans-serif;
    line-height: 1.5;
    margin: 0;
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

.page {
    display: grid;
    gap: 24px 28px;
    grid-template-columns: 232px minmax(0, 1fr);
    margin: 0 auto;
    max-width: 1440px;
    min-height: 100vh;
    padding: 34px;
}

.topbar,
.stats-grid,
.panel {
    grid-column: 2;
}

.app-nav {
    align-self: stretch;
    background: #fffdfa;
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: 7px;
    grid-column: 1;
    grid-row: 1 / span 8;
    margin: -34px 0 -34px -34px;
    padding: 28px 24px;
    position: sticky;
    top: 0;
}

.app-nav::before {
    align-items: center;
    color: var(--ink);
    content: "KidScreen";
    display: flex;
    font-size: 18px;
    font-weight: 850;
    margin-bottom: 27px;
}

.app-nav a {
    align-items: center;
    border-radius: 999px;
    color: #45413d;
    display: flex;
    font-size: 14px;
    font-weight: 750;
    gap: 10px;
    min-height: 42px;
    padding: 0 14px;
}

.app-nav a::before {
    background: var(--ink);
    border-radius: 999px;
    content: "";
    height: 9px;
    width: 9px;
}

.app-nav a:nth-of-type(2)::before {
    background: #8edfc8;
}

.app-nav a:nth-of-type(3)::before {
    background: #b9d6ff;
}

.app-nav a:nth-of-type(4)::before {
    background: #ffd0bb;
}

.app-nav a:nth-of-type(5)::before {
    background: #d2c5ff;
}

.app-nav a:hover {
    background: var(--soft);
}

.app-nav a.active {
    background: var(--ink);
    color: #ffffff;
}

.topbar {
    align-items: flex-start;
    display: flex;
    gap: 24px;
    justify-content: space-between;
    margin-bottom: 2px;
}

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

.topbar h1 {
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(42px, 4vw, 56px);
    font-weight: 500;
    letter-spacing: -0.02em;
    line-height: 0.98;
    margin: 0;
}

.muted {
    color: var(--muted);
    font-size: 14px;
}

.topbar .muted,
.login-card p {
    margin: 10px 0 0;
}

.panel,
.stat-card {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid var(--line);
    border-radius: 24px;
    box-shadow: var(--shadow);
}

.panel {
    display: grid;
    gap: 16px;
    padding: 22px;
}

.panel h2 {
    font-size: 20px;
    margin: 0;
}

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

.stat-card {
    min-height: 126px;
    padding: 20px;
}

.stat-label {
    color: var(--muted);
    display: block;
    font-size: 12px;
    font-weight: 850;
}

.stat-value {
    font-size: 34px;
    font-weight: 900;
    line-height: 1;
    margin-top: 18px;
}

.stat-card .muted {
    margin: 8px 0 0;
}

.form-row {
    align-items: end;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-row.four {
    grid-template-columns: 1.25fr 1fr 0.8fr auto;
}

.form-row label:only-of-type {
    max-width: 360px;
}

label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 850;
}

input,
select,
button,
.button-link {
    font: inherit;
}

input,
select {
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    color: var(--ink);
    display: block;
    margin-top: 7px;
    min-height: 42px;
    padding: 8px 14px;
    width: 100%;
}

input:focus,
select:focus {
    border-color: var(--ink);
    outline: 2px solid rgba(17, 17, 17, 0.08);
}

button,
.button-link {
    align-items: center;
    background: var(--ink);
    border: 1px solid var(--ink);
    border-radius: 999px;
    color: #ffffff;
    cursor: pointer;
    display: inline-flex;
    font-size: 13px;
    font-weight: 850;
    justify-content: center;
    min-height: 42px;
    padding: 0 18px;
}

button:hover,
.button-link:hover {
    background: #2a2a2a;
}

button.secondary,
.button-link.secondary {
    background: var(--surface);
    border-color: var(--line);
    color: var(--ink);
}

button.danger {
    background: var(--surface);
    border-color: #ffd0c9;
    color: var(--danger);
}

button.danger:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: #ffffff;
}

table {
    border-collapse: collapse;
    min-width: 700px;
    width: 100%;
}

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

th {
    color: var(--muted);
    font-size: 12px;
    font-weight: 850;
}

td {
    font-size: 14px;
}

tbody tr:last-child td {
    border-bottom: 0;
}

code,
.code-pill {
    background: var(--soft);
    border-radius: 999px;
    color: var(--ink);
    display: inline-block;
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 13px;
    font-weight: 850;
    padding: 6px 9px;
}

.badge {
    border-radius: 999px;
    display: inline-flex;
    font-size: 12px;
    font-weight: 900;
    padding: 7px 10px;
}

.badge.success {
    background: var(--green-soft);
    color: var(--green);
}

.badge.warning {
    background: var(--warning-soft);
    color: var(--warning);
}

.badge.danger {
    background: var(--danger-soft);
    color: var(--danger);
}

.badge.neutral {
    background: var(--soft);
    color: var(--ink);
}

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

.actions form {
    margin: 0;
}

.actions a {
    background: var(--soft);
    border-radius: 999px;
    color: var(--ink);
    font-size: 12px;
    font-weight: 900;
    padding: 8px 11px;
}

.actions button {
    min-width: 76px;
}

.empty-state,
.error {
    border-radius: 18px;
    padding: 14px 16px;
}

.empty-state {
    background: var(--soft);
    color: var(--muted);
}

.error {
    background: var(--danger-soft);
    border: 1px solid #ffd0c9;
    color: var(--danger);
}

.success {
    background: var(--green-soft);
    border: 1px solid #c5f7e3;
    border-radius: 18px;
    color: var(--green);
    padding: 14px 16px;
}

.login-page {
    background:
        linear-gradient(rgba(17, 17, 17, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(17, 17, 17, 0.035) 1px, transparent 1px),
        radial-gradient(circle at 50% 24%, rgba(243, 162, 15, 0.16), transparent 30%),
        #fffaf1;
    background-size: 32px 32px, 32px 32px, auto, auto;
    display: grid;
    grid-template-columns: 1fr;
    max-width: none;
    min-height: 100vh;
    padding: 24px;
    place-items: center;
    position: relative;
    overflow: hidden;
}

.login-page::after {
    background: #111111;
    content: "";
    opacity: 0.06;
    position: absolute;
    z-index: 0;
}

.login-page::after {
    bottom: 12%;
    height: 1px;
    left: 0;
    transform: rotate(-5deg);
    width: 100%;
}

.login-sun {
    --face-x: 0px;
    --face-y: 0px;
    --sun-rotate: 0deg;
    filter: drop-shadow(0 28px 24px rgba(92, 61, 17, 0.16));
    height: 220px;
    margin: 0 auto -76px;
    position: relative;
    transform: rotate(var(--sun-rotate));
    transform-origin: 50% 94%;
    transition: transform 180ms ease-out;
    width: 220px;
    z-index: 0;
}

.login-sun svg {
    display: block;
    height: 100%;
    overflow: visible;
    width: 100%;
}

.sun-rays {
    transform-origin: 50% 55%;
}

.sun-face {
    transform: translate(var(--face-x), var(--face-y));
    transform-box: fill-box;
    transition: transform 120ms ease-out;
}

.sun-eye-left-wink {
    opacity: 0;
}

.login-sun:hover .sun-eye-left-open,
.login-sun.is-winking .sun-eye-left-open {
    opacity: 0;
}

.login-sun:hover .sun-eye-left-wink,
.login-sun.is-winking .sun-eye-left-wink {
    opacity: 1;
}

.login-card {
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid var(--line);
    border-radius: 28px;
    box-shadow: 0 34px 80px rgba(32, 25, 13, 0.13);
    overflow: hidden;
    padding: 0;
    position: relative;
    width: min(520px, 100%);
    z-index: 1;
}

.login-card-header {
    align-items: center;
    background: #233508;
    display: flex;
    gap: 18px;
    justify-content: space-between;
    min-height: 74px;
    padding: 18px 26px;
}

.login-card-body {
    padding: 26px 30px 28px;
}

.login-brand {
    align-items: center;
    display: flex;
    gap: 12px;
    margin: 0;
    min-width: 0;
}

.brand-mark {
    align-items: center;
    background: var(--ink);
    border-radius: 999px;
    color: #ffffff;
    display: inline-flex;
    font-size: 17px;
    font-weight: 900;
    height: 44px;
    justify-content: center;
    width: 44px;
}

.login-card h1 {
    color: #ffffff;
    font-size: 17px;
    font-weight: 900;
    line-height: 1;
    margin: 0;
}

.auth-switch {
    background: rgba(0, 0, 0, 0.22);
    border: 0;
    border-radius: 999px;
    display: grid;
    gap: 4px;
    grid-template-columns: 1fr 1fr;
    margin: 0;
    padding: 3px;
    width: 176px;
}

.auth-switch-button {
    background: transparent;
    border: 0;
    color: rgba(255, 255, 255, 0.62);
    font-size: 10px;
    font-weight: 950;
    letter-spacing: 0.02em;
    min-height: 32px;
    padding: 0 10px;
    text-transform: uppercase;
}

.auth-switch-button:hover {
    color: #ffffff;
}

.login-card:not(.is-register) [data-auth-target="login"],
.login-card.is-register [data-auth-target="register"] {
    background: #fffaf1;
    color: #233508;
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.18);
}

.auth-panels {
    display: grid;
    min-height: 350px;
}

.login-form.auth-panel {
    align-content: start;
    grid-area: 1 / 1;
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}

.login-card:not(.is-register) .login-panel,
.login-card.is-register .register-panel {
    display: grid;
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
}

.login-form {
    display: grid;
    gap: 12px;
    height: 100%;
    transition: opacity 180ms ease, transform 180ms ease, visibility 180ms ease;
}

.login-panel {
    align-content: start;
    justify-self: center;
    max-width: 390px;
    padding-top: 44px;
    transform: translateY(0);
    width: 100%;
}

.register-panel {
    transform: translateY(0);
}

.auth-panel-title {
    border-bottom: 1px solid #edf0e7;
    margin-bottom: 2px;
    padding-bottom: 9px;
}

.auth-panel-title h2 {
    color: #1b2b0b;
    font-size: 21px;
    font-weight: 950;
    letter-spacing: 0;
    line-height: 1.1;
    margin: 0;
}

.auth-field {
    background: #f7f8f2;
    border: 1px solid #e5e8d9;
    border-radius: 16px;
    display: grid;
    gap: 5px;
    padding: 8px 13px 9px;
    transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.auth-field:focus-within {
    background: #ffffff;
    border-color: #8a9f55;
    box-shadow: 0 0 0 4px rgba(138, 159, 85, 0.14);
}

.auth-field span {
    color: #5d674b;
    font-size: 10px;
    font-weight: 950;
    letter-spacing: 0.05em;
    line-height: 1;
    text-transform: uppercase;
}

.login-form input {
    background: transparent;
    border: 0;
    color: #172033;
    display: block;
    font-size: 15px;
    font-weight: 800;
    height: 24px;
    line-height: 24px;
    margin-top: 0;
    min-height: 24px;
    padding: 0;
    width: 100%;
}

.login-form input:focus {
    outline: none;
}

.login-form input::placeholder {
    color: #a0a997;
    font-weight: 700;
}

.login-form button[type="submit"] {
    background: #263b08;
    border: 0;
    border-radius: 18px;
    box-shadow: 0 18px 30px rgba(38, 59, 8, 0.2);
    color: #ffffff;
    font-size: 14px;
    font-weight: 950;
    min-height: 54px;
    text-transform: uppercase;
    transition: background 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.login-form button[type="submit"]:hover {
    background: #5f7737;
    box-shadow: 0 18px 30px rgba(95, 119, 55, 0.24);
}

.login-form button[type="submit"]:active {
    transform: translateY(1px);
}

.login-form button {
    margin-top: 4px;
    width: 100%;
}

@media (prefers-reduced-motion: no-preference) {
    .login-sun {
        animation: sun-enter 520ms cubic-bezier(0.22, 1, 0.36, 1) both;
    }

    .login-card {
        animation: login-card-enter 520ms 90ms cubic-bezier(0.22, 1, 0.36, 1) both;
    }
}

@keyframes sun-enter {
    from {
        opacity: 0;
        transform: translateY(18px) rotate(-5deg) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translateY(0) rotate(var(--sun-rotate)) scale(1);
    }
}

@keyframes login-card-enter {
    from {
        opacity: 0;
        transform: translateY(14px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 1000px) {
    .page {
        display: block;
        padding: 22px;
    }

    .login-page {
        display: grid;
        padding: 22px;
    }

    .app-nav {
        flex-direction: row;
        flex-wrap: wrap;
        margin: -22px -22px 24px;
        min-height: 0;
        padding: 18px 22px;
        position: static;
    }

    .app-nav::before {
        flex-basis: 100%;
        margin-bottom: 8px;
    }

    .topbar {
        margin-bottom: 18px;
    }

    .stats-grid,
    .form-row,
    .form-row.four {
        grid-template-columns: 1fr;
    }

    .panel,
    .stats-grid {
        margin-top: 14px;
    }

    .panel {
        overflow-x: auto;
    }
}

@media (max-width: 640px) {
    .topbar {
        display: block;
    }

    .topbar form {
        margin-top: 14px;
    }

    .topbar h1 {
        font-size: 40px;
    }

    table,
    thead,
    tbody,
    tr,
    th,
    td {
        display: block;
        min-width: 0;
        width: 100%;
    }

    thead {
        display: none;
    }

    tbody {
        display: grid;
        gap: 10px;
    }

    tbody tr {
        border: 1px solid var(--line);
        border-radius: 18px;
        padding: 8px 0;
    }

    td {
        align-items: center;
        border-bottom: 0;
        display: flex;
        gap: 14px;
        justify-content: space-between;
        min-height: 42px;
        padding: 8px 12px;
    }

    td::before {
        color: var(--muted);
        content: attr(data-label);
        font-size: 12px;
        font-weight: 850;
    }

    td.actions {
        align-items: stretch;
        display: grid;
    }
}
