:root, body[data-theme="sade"] {
    --bg: #eef1f4;
    --paper: #ffffff;
    --ink: #1c2430;
    --muted: #5c6b7a;
    --line: #d5dde6;
    --brass: #1f6feb;
    --brass-deep: #164ea8;
    --brass-soft: #e7f0fb;
    --side: #1c2430;
    --side-text: #f4f7fb;
    --side-muted: #b7c3d1;
    --side-active: #2c3a4d;
    --side-accent: #d6e6ff;
    --on-brass: #ffffff;
    --field: #ffffff;
    --good: #1d6b45;
    --good-soft: #e5f3eb;
    --debt: #9a4034;
    --debt-soft: #f8e8e4;
    --shadow: 0 16px 36px rgba(20, 32, 48, 0.08);
    --glow: rgba(80, 130, 200, 0.18);
    --serif: "Fraunces", Georgia, serif;
    --sans: "Outfit", "Segoe UI", sans-serif;
}
body[data-theme="gece"] {
    --bg: #12161c;
    --paper: #1c232d;
    --ink: #e8eef6;
    --muted: #a7b4c4;
    --line: #2e3846;
    --brass: #e0b15a;
    --brass-deep: #f3d7a2;
    --brass-soft: #2a3340;
    --side: #0d1116;
    --side-text: #f4f7fb;
    --side-muted: #9aa8b8;
    --side-active: #243041;
    --side-accent: #e0b15a;
    --on-brass: #1c1408;
    --field: #151b24;
    --good: #8fd0aa;
    --good-soft: #163028;
    --debt: #f0a8a0;
    --debt-soft: #3a2424;
    --shadow: 0 16px 36px rgba(0, 0, 0, 0.28);
    --glow: rgba(224, 177, 90, 0.12);
}
body[data-theme="lacivert"] {
    --bg: #e7eef6;
    --paper: #f8fbff;
    --ink: #142033;
    --muted: #5d6e86;
    --line: #d3dfed;
    --brass: #c4a15a;
    --brass-deep: #8d6b2e;
    --brass-soft: #f4ead2;
    --side: #14284a;
    --side-text: #f3f7fc;
    --side-muted: #b9c8dc;
    --side-active: #1e3d6e;
    --side-accent: #f0d48a;
    --on-brass: #1c1408;
    --field: #ffffff;
    --good: #1d6b45;
    --good-soft: #e5f3eb;
    --debt: #9a4034;
    --debt-soft: #f8e8e4;
    --shadow: 0 16px 36px rgba(20, 40, 74, 0.08);
    --glow: rgba(20, 40, 74, 0.12);
}
body[data-theme="zumrut"] {
    --bg: #e7f0ea;
    --paper: #f7fbf8;
    --ink: #163028;
    --muted: #5d7368;
    --line: #d3e4da;
    --brass: #1f7a4d;
    --brass-deep: #145c38;
    --brass-soft: #e3f3ea;
    --side: #12352a;
    --side-text: #f3faf6;
    --side-muted: #b7d0c4;
    --side-active: #1c4d3c;
    --side-accent: #d7f5e4;
    --on-brass: #ffffff;
    --field: #ffffff;
    --good: #1d6b45;
    --good-soft: #e5f3eb;
    --debt: #9a4034;
    --debt-soft: #f8e8e4;
    --shadow: 0 16px 36px rgba(18, 53, 42, 0.08);
    --glow: rgba(31, 122, 77, 0.16);
}
body[data-theme="kagit"] {
    --bg: #efe7dc;
    --paper: #fbf7f1;
    --ink: #241c16;
    --muted: #74685d;
    --line: #e5dacb;
    --brass: #9a6432;
    --brass-deep: #6f4522;
    --brass-soft: #f3e4d0;
    --side: #241c17;
    --side-text: #f6efe6;
    --side-muted: #cbbba8;
    --side-active: #3a2e25;
    --side-accent: #f3d7a6;
    --on-brass: #ffffff;
    --field: #ffffff;
    --good: #1d6b45;
    --good-soft: #e5f3eb;
    --debt: #9a4034;
    --debt-soft: #f8e8e4;
    --shadow: 0 18px 40px rgba(56, 36, 18, 0.08);
    --glow: rgba(217, 176, 122, 0.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--sans);
    color: var(--ink);
    background:
        radial-gradient(1200px 500px at 10% -10%, var(--glow), transparent 50%),
        var(--bg);
    font-size: 15.5px;
    line-height: 1.45;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--serif); font-weight: 560; letter-spacing: -0.03em; margin: 0; }
h1 { font-size: 2rem; line-height: 1.1; }
h2 { font-size: 1.35rem; }

.shell { display: flex; flex-direction: column; min-height: 100vh; }
.desk-top {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 14px;
    background: var(--side);
    color: var(--side-text);
}
.desk-top .brand { padding: 0; color: inherit; }
.desk-top .brand strong { font-size: 1.15rem; }
.desk-top .brand small { color: var(--side-muted); }
.desk-meta { color: var(--side-muted); font-size: 0.85rem; }
.desk-top .kur-pill { margin-left: auto; background: transparent; color: var(--side-text); border-color: transparent; }
.desk-top .kur-pill strong { color: var(--side-accent); }
.desk-out { color: var(--side-accent); text-decoration: none; font-size: 0.85rem; }
.desk-commands {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
    padding: 10px 12px;
    background: color-mix(in srgb, var(--side) 8%, var(--bg));
    border-bottom: 1px solid var(--line);
}
.desk-commands a {
    min-height: 62px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    text-decoration: none;
    background: var(--paper);
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px;
    font-size: 0.74rem;
    font-weight: 650;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    box-shadow: var(--shadow);
}
.desk-commands a[aria-current="page"], .desk-menu a[aria-current="page"] {
    background: var(--brass);
    color: var(--on-brass);
    border-color: var(--brass);
}
.desk-body { display: flex; flex: 1; min-height: 0; align-items: stretch; }
.desk-side {
    width: 196px;
    flex: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
}
.desk-menu { display: flex; flex-direction: column; gap: 8px; }
.desk-menu a {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 48px;
    text-decoration: none;
    background: var(--paper);
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px;
    font-size: 0.74rem;
    font-weight: 650;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.desk-side .theme-dots { margin-top: 8px; }
.desk-side .theme-dots button { color: var(--ink); }
.desk-side .theme-dots button.on { color: var(--brass-deep); border-color: var(--brass); }
.main { flex: 1; min-width: 0; padding: 12px 14px 28px; }
.top {
    display: flex;
    align-items: center;
    margin: 0;
    padding: 8px 14px;
    background: var(--side);
    color: var(--side-text);
    border-radius: 8px 8px 0 0;
}
.top h1 { font-family: var(--sans); font-size: 0.95rem; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; }
.content {
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-top: 0;
    border-radius: 0 0 8px 8px;
    padding: 12px;
}
.side {
    width: 232px;
    flex: none;
    background: var(--side);
    color: var(--side-text);
    padding: 22px 16px;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.brand {
    display: flex;
    gap: 10px;
    align-items: center;
    text-decoration: none;
    padding: 0 8px 18px;
}
.brand strong { display: block; font-family: var(--serif); font-size: 1.35rem; font-weight: 650; }
.brand small { display: block; color: var(--side-muted); font-size: 0.78rem; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
    text-decoration: none;
    padding: 9px 12px;
    border-radius: 10px;
    color: var(--side-text);
}
.nav a:hover { background: rgba(255, 255, 255, 0.05); }
.nav a[aria-current="page"] { background: var(--side-active); color: var(--side-accent); }
.side-foot {
    margin-top: 12px;
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 16px 8px 0;
    color: var(--side-muted);
    font-size: 0.92rem;
}
.side-foot a { color: var(--side-accent); }
.theme-dots { margin-top: auto; display: flex; flex-wrap: wrap; gap: 4px; padding: 10px 4px 0; }
.theme-dots button {
    border: 1px solid transparent;
    background: transparent;
    color: var(--side-muted);
    border-radius: 999px;
    padding: 3px 7px;
    font-size: 0.72rem;
    cursor: pointer;
}
.theme-dots button.on { color: var(--side-accent); border-color: var(--side-accent); }
.theme-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.theme-picker form { margin: 0; }
.swatch {
    width: 100%;
    border: 1px solid var(--line);
    background: var(--field);
    color: var(--ink);
    border-radius: 14px;
    padding: 18px 12px;
    cursor: pointer;
    text-align: left;
}
.swatch.on { outline: 2px solid var(--brass); }
.swatch[data-theme-preview="sade"] { background: #f4f7fb; color: #1c2430; }
.swatch[data-theme-preview="gece"] { background: #1c232d; color: #e8eef6; }
.swatch[data-theme-preview="lacivert"] { background: #14284a; color: #f3f7fc; }
.swatch[data-theme-preview="zumrut"] { background: #12352a; color: #f3faf6; }
.swatch[data-theme-preview="kagit"] { background: #fbf7f1; color: #241c16; }

.eyebrow { margin: 0 0 4px; color: var(--muted); font-size: 0.82rem; letter-spacing: 0.08em; text-transform: uppercase; }
.kur-pill {
    text-decoration: none;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 8px 14px;
    color: var(--muted);
    white-space: nowrap;
}
.kur-pill strong { color: var(--brass-deep); font-weight: 600; }

.flash { padding: 12px 14px; border-radius: 12px; margin-bottom: 14px; }
.flash.ok { background: var(--good-soft); color: var(--good); }
.flash.bad { background: var(--debt-soft); color: var(--debt); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.dash { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 12px; }
.tile {
    aspect-ratio: 1;
    text-align: left;
    padding: 14px;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.7);
    background: var(--paper);
    box-shadow: var(--shadow);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.tile span { color: var(--muted); font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; }
.tile strong {
    font-family: var(--serif);
    font-size: clamp(1.15rem, 1.7vw, 1.7rem);
    font-weight: 560;
    letter-spacing: -0.03em;
    line-height: 1.15;
}
.tile em { margin-top: auto; font-style: normal; color: var(--muted); font-size: 0.88rem; }
.tile.debt strong { color: var(--debt); }
.tile.good strong { color: var(--good); }
.tile.accent { background: var(--side); color: var(--side-text); }
.tile.accent span, .tile.accent em { color: var(--side-muted); }
.tile[aria-expanded="true"] { outline: 2px solid var(--brass); outline-offset: 2px; }
.dash-panel {
    background: var(--paper);
    border-radius: 18px;
    padding: 16px;
    box-shadow: var(--shadow);
}
.dash-menu { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.dash-menu a {
    display: flex;
    flex-direction: column;
    gap: 3px;
    text-decoration: none;
    background: var(--field);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px 14px;
}
.dash-menu a:hover { border-color: var(--brass); background: var(--brass-soft); }
.dash-menu strong { font-weight: 600; }
.dash-menu span { color: var(--muted); font-size: 0.86rem; }
.dash-panel .lede { margin-bottom: 12px; }
.dash-panel .stats { margin-top: 12px; }
.stat, .card, .hero-balance, .preview {
    background: var(--paper);
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 18px;
    box-shadow: var(--shadow);
}
.stat { padding: 16px 18px; }
.stat span { display: block; color: var(--muted); font-size: 0.88rem; }
.stat strong { display: block; margin-top: 6px; font-family: var(--serif); font-size: 1.55rem; font-weight: 560; letter-spacing: -0.03em; }
.stat em { font-style: normal; color: var(--muted); font-size: 0.85rem; }
.stat.debt strong { color: var(--debt); }
.stat.good strong { color: var(--good); }

.card { padding: 18px; }
.card-head, .filters, .split-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}
.card-head p, .lede { margin: 4px 0 0; color: var(--muted); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 560; font-size: 0.78rem; letter-spacing: 0.06em; text-transform: uppercase; }
tr:hover td { background: var(--brass-soft); }
tr.is-open td { background: var(--brass-soft); }
.name-link { font-weight: 600; text-decoration: none; }
.name-link:hover { text-decoration: underline; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.debt { color: var(--debt); }
.good { color: var(--good); }
.muted { color: var(--muted); }
.group-row td {
    background: var(--brass-soft);
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--brass-deep);
    font-weight: 600;
}

.tag {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 2px 8px;
    background: var(--brass-soft);
    color: var(--brass-deep);
    font-size: 0.78rem;
}
.tag.off { background: #eee; color: #777; }

.btn, button.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border-radius: 11px;
    border: 1px solid transparent;
    padding: 9px 14px;
    text-decoration: none;
    background: transparent;
    cursor: pointer;
}
.btn.primary { background: var(--brass); color: var(--on-brass); }
.btn.primary:hover { background: var(--brass-deep); }
.btn.ghost { border-color: var(--line); background: var(--field); color: var(--ink); }
.btn.danger { color: var(--debt); padding-inline: 8px; }
.btn.small { padding: 6px 10px; font-size: 0.88rem; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field span { font-size: 0.86rem; color: var(--muted); }
input[type="text"], input[type="password"], input[type="date"], input[type="search"], select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    background: var(--field);
    border-radius: 11px;
    padding: 10px 12px;
    outline: none;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--brass); box-shadow: 0 0 0 3px var(--brass-soft); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; margin: 4px 0 12px; }
.check input { width: auto; }

.filters { flex-wrap: wrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips a {
    text-decoration: none;
    border: 1px solid var(--line);
    background: var(--field);
    border-radius: 999px;
    padding: 6px 10px;
    color: var(--muted);
}
.chips a.on { background: var(--brass); color: var(--on-brass); border-color: var(--brass); }

.search { max-width: 280px; }

.hero-balance { padding: 18px 20px; display: flex; justify-content: space-between; gap: 16px; align-items: flex-end; }
.hero-balance strong { font-family: var(--serif); font-size: 1.8rem; font-weight: 560; }
.seg { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.seg-item input { position: absolute; opacity: 0; pointer-events: none; }
.seg-item span {
    display: inline-flex;
    border: 1px solid var(--line);
    background: var(--field);
    border-radius: 999px;
    padding: 8px 12px;
    cursor: pointer;
}
.seg-item input:checked + span { background: var(--brass); color: var(--on-brass); border-color: var(--brass); }
.seg-item input:focus-visible + span { box-shadow: 0 0 0 3px rgba(169, 112, 58, 0.25); }

.split { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 14px; align-items: start; }
.preview { padding: 16px; position: sticky; top: 16px; }
.preview p { margin: 8px 0 0; white-space: pre-line; font-variant-numeric: tabular-nums; }
.hint { color: var(--muted); font-size: 0.88rem; margin: 0 0 12px; }

.account-list { display: flex; flex-direction: column; }
.account-list a {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    text-decoration: none;
    padding: 12px 4px;
    border-bottom: 1px solid var(--line);
}
.account-list a:hover { background: var(--brass-soft); }
.empty { padding: 28px 8px; text-align: center; color: var(--muted); }
.is-hidden { display: none; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.inline { display: inline; }
.two { display: grid; grid-template-columns: 320px 1fr; gap: 14px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 12px; }

.gate-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}
.gate {
    width: min(440px, 100%);
    background: var(--paper);
    border-radius: 24px;
    padding: 28px;
    box-shadow: var(--shadow);
}
.gate h1 { font-size: 2.2rem; margin: 8px 0; }
.gate .mark { width: 36px; height: 36px; }

.fis-head { display: grid; grid-template-columns: 170px minmax(180px, 1fr) 110px 240px; gap: 10px; align-items: end; }
.fis-balance { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--field); }
.fis-balance div { padding: 6px 8px; }
.fis-balance span { display: block; font-size: 0.7rem; letter-spacing: 0.06em; color: var(--muted); text-transform: uppercase; }
.fis-balance strong { font-size: 1.05rem; }
.fis-codes .seg-item span { min-width: 78px; justify-content: center; flex-direction: column; gap: 1px; border-radius: 8px; padding: 6px 8px; }
.fis-codes b { font-size: 0.95rem; letter-spacing: 0.04em; }
.fis-codes small { font-size: 0.68rem; font-weight: 500; }
.fis-band { background: var(--brass-soft); border-radius: 8px; padding: 10px 12px; margin: 8px 0 12px; }
.fis-band .field { margin-bottom: 0; }
.fis-band > .split > div:first-child { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.fis-band [data-for] { flex: 1 1 320px; }

@media (max-width: 1100px) {
    .stats { grid-template-columns: 1fr 1fr; }
    .desk-commands { grid-template-columns: repeat(3, 1fr); }
    .two, .split, .fis-head { grid-template-columns: 1fr; }
    .preview { position: static; }
}
@media (max-width: 860px) {
    .shell { flex-direction: column; }
    .desk-body { flex-direction: column; }
    .desk-side { width: auto; }
    .desk-menu { flex-direction: row; overflow-x: auto; }
    .desk-menu a { white-space: nowrap; min-height: 40px; }
    .desk-side .theme-dots { margin-top: 8px; }
    .side { width: auto; height: auto; position: relative; }
    .nav { flex-direction: row; overflow-x: auto; }
    .nav a { white-space: nowrap; }
    .side-foot { margin-top: 12px; }
    .main { padding: 12px; }
    .form-row { grid-template-columns: 1fr; }
    .stats { grid-template-columns: 1fr; }
    .dash { grid-template-columns: 1fr 1fr; }
}
@media print {
    .side, .top, .filters, .btn, .flash, .composer, .side-foot { display: none !important; }
    body { background: white; }
    .shell { display: block; }
    .main { padding: 0; }
    .card, .stat { box-shadow: none; }
}
