:root {
    color-scheme: light;
    --bg: #c8aae4;
    --bg-2: #b79ad6;
    --surface: #f7f2fb;
    --surface-2: #efe6f6;
    --header: #5d4574;
    --text: #24182e;
    --muted: #5e4d6c;
    --accent: #c400c4;
    --accent-2: #7a2ea0;
    --line: #d8c6e6;
    --danger: #9d1740;
    --ok: #0d7a46;
    --shadow: 0 16px 40px rgba(70, 24, 96, 0.16);
    --radius: 16px;
    --focus: 0 0 0 3px rgba(196, 0, 196, 0.35);
}

html[data-theme="dark"] {
    color-scheme: dark;
    --bg: #1a1222;
    --bg-2: #2a1a38;
    --surface: #2c2338;
    --surface-2: #382a46;
    --header: #120d18;
    --text: #f7f1fb;
    --muted: #d2c0e2;
    --accent: #ff4dff;
    --accent-2: #c084fc;
    --line: #4d3d60;
    --danger: #ff8eaa;
    --ok: #8ee0b2;
    --shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html {
    background: var(--bg);
    color: var(--text);
}

body {
    margin: 0;
    min-height: 100vh;
    font: 16px/1.5 "Segoe UI", system-ui, sans-serif;
    background:
        radial-gradient(1200px 500px at 10% -10%, var(--bg-2), transparent 60%),
        var(--bg);
    color: var(--text);
}

body, .card, .topbar, .btn, input, select, textarea {
    transition: background-color 0.35s ease, color 0.35s ease, border-color 0.35s ease;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 18px;
    padding: 14px 22px;
    background: color-mix(in srgb, var(--header) 92%, transparent);
    color: #fff;
    box-shadow: var(--shadow);
}

.brand {
    color: #fff;
    font-weight: 750;
    letter-spacing: 0.02em;
    text-decoration: none;
    font-size: 1.15rem;
}

.nav, .subnav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.nav a, .subnav a {
    color: #fff;
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 999px;
}

.nav a:hover, .subnav a:hover, .subnav a.is-active {
    background: rgba(255, 255, 255, 0.16);
}

.who {
    margin: 0;
    color: #f3d7f8;
    font-size: 0.92rem;
}

.topbar .btn {
    margin-left: auto;
    color: #fff;
    border-color: rgba(255, 255, 255, 0.35);
}

.wrap {
    width: min(1120px, calc(100% - 28px));
    margin: 28px auto 48px;
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 12px; }
h1 { font-size: clamp(1.6rem, 2vw, 2.1rem); }
h2 { font-size: 1.25rem; }

.lead { color: var(--muted); margin-top: 0; }

.card, .panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
    margin: 0 0 16px;
    animation: rise 0.35s ease both;
}

.card-head, .row-actions, .inline-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
}

.grid-2, .grid-3 {
    display: grid;
    gap: 12px;
}

.grid-2 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.92rem;
    color: var(--muted);
}

input[type="checkbox"] { width: auto; align-self: flex-start; }

input, select, textarea {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
}

textarea { min-height: 110px; resize: vertical; }

input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible {
    outline: none;
    box-shadow: var(--focus);
}

.btn {
    appearance: none;
    border: 1px solid transparent;
    background: linear-gradient(180deg, var(--accent), var(--accent-2));
    color: #fff;
    border-radius: 999px;
    padding: 10px 16px;
    font: inherit;
    font-weight: 650;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn:hover { transform: translateY(-1px); }

.btn-ghost {
    background: transparent;
    color: var(--text);
    border-color: var(--line);
}

.topbar .btn-ghost { color: #fff; }

.btn-danger {
    background: transparent;
    color: var(--danger);
    border-color: var(--danger);
}

.banner {
    padding: 12px 14px;
    border-radius: 12px;
    margin: 0 0 16px;
}

.banner-ok { background: color-mix(in srgb, var(--ok) 18%, var(--surface)); color: var(--text); }
.banner-error, .error-list { background: color-mix(in srgb, var(--danger) 14%, var(--surface)); color: var(--text); }

.error-list { padding: 12px 16px 12px 32px; border-radius: 12px; }

.check-list {
    max-height: 240px;
    overflow: auto;
    display: grid;
    gap: 8px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-2);
}

.check-list label { flex-direction: row; align-items: flex-start; color: var(--text); }

.param-panel {
    margin: 0 0 10px 28px;
    display: grid;
    gap: 8px;
}
.check-list input { width: auto; margin-top: 3px; }

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 650; }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 0.8rem;
}

.badge-off { color: var(--danger); }

.legal-box {
    white-space: pre-wrap;
    background: var(--surface-2);
    border-radius: 12px;
    padding: 12px;
    margin: 8px 0;
}

.hint { color: var(--muted); font-size: 0.9rem; }

.hidden { display: none !important; }

.auth-card { width: min(460px, 100%); margin: 8vh auto; }

.series {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    align-items: end;
    margin-bottom: 12px;
}

@media (max-width: 720px) {
    .topbar { padding: 12px; }
    .topbar .btn { margin-left: 0; }
    .wrap { width: min(100% - 20px, 1120px); }
    .card-head, .row-actions { align-items: stretch; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation: none !important;
        transition: none !important;
    }
}

@keyframes rise {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}
