:root {
    color-scheme: light;
    --paper: #f5f2ec;
    --surface: #fffdfa;
    --ink: #292a24;
    --text: #403c34;
    --muted: #655f54;
    --line: #e2d9cc;
    --edge: #b6a894;
    --rail: #262a26;
    --rail-text: #e5dfd3;
    --accent: #735640;
    --accent-dark: #543c2e;
    --warm: #eee5d8;
    --radius: 12px;
    font-family: "Segoe UI", "Helvetica Neue", system-ui, sans-serif;
    background: var(--paper);
    color: var(--text);
    font-synthesis: none;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; font-size: 15px; line-height: 1.55; }
button, select, input, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }
button, select, summary { cursor: pointer; }
:focus-visible { outline: 3px solid #a4774e; outline-offset: 3px; }
h1, h2, p, ul, dl { margin: 0; }
h1, h2 { font-family: Georgia, "Times New Roman", serif; font-weight: 400; color: var(--ink); line-height: 1.14; }
h1 { font-size: clamp(32px, 4.3vw, 55px); letter-spacing: -.05em; }
h2 { font-size: clamp(21px, 2.2vw, 26px); letter-spacing: -.025em; }
.hint { color: var(--muted); font-size: 13px; margin: 7px 0 14px; }
.skip { position: fixed; top: 10px; left: 10px; z-index: 20; padding: 9px 13px; color: white; background: var(--rail); transform: translateY(-200%); }
.skip:focus { transform: none; }

.shell { display: grid; min-height: 100vh; grid-template-columns: 220px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; padding: 27px 17px 19px; background: var(--rail); color: var(--rail-text); overflow: auto; }
.brand { display: flex; gap: 13px; align-items: center; padding: 0 11px; color: #fffaf1; font-family: Georgia, serif; font-size: 25px; line-height: 1; letter-spacing: -.03em; }
.brand-mark { width: 30px; height: 32px; border: 1px solid #c6a889; border-radius: 2px 2px 15px 15px; flex: none; position: relative; }
.brand-mark::after { content: ""; position: absolute; width: 9px; height: 13px; border-radius: 8px 8px 3px 3px; background: #d3b597; left: 9px; top: 8px; }
.navigation { display: grid; gap: 5px; margin: 42px 0 20px; }
.navigation a { display: flex; align-items: center; gap: 10px; min-height: 43px; padding: 8px 10px; border-radius: 6px; font-size: 13px; font-weight: 650; }
.navigation a::before { content: ""; width: 5px; height: 5px; border-radius: 50%; border: 1px solid #c3a78a; flex: none; }
.navigation a:hover, .navigation a[aria-current="page"] { color: #fffaf1; background: #383d35; }
.navigation a[aria-current="page"]::before { background: #d3b597; }
.sidebar-end { margin-top: auto; display: grid; gap: 6px; border-top: 1px solid #4d5046; padding: 15px 11px 0; font-size: 12px; }
.sidebar-end a { color: #fffaf1; text-decoration: underline; text-underline-offset: 3px; }
.workspace { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 3; min-height: 64px; display: flex; justify-content: space-between; align-items: center; gap: 15px; padding: 10px clamp(17px, 3.2vw, 43px); border-bottom: 1px solid var(--line); background: var(--surface); }
.desktop-label { font-weight: 650; color: var(--ink); font-size: 13px; }
.demo-label { display: inline-flex; gap: 7px; align-items: center; color: var(--accent-dark); font-size: 12px; }
.demo-label i { width: 6px; height: 6px; flex: none; border-radius: 50%; background: #9c7658; }
.topbar .menu-button { display: none; }
.screen { flex: 1; width: 100%; max-width: 1530px; min-width: 0; margin: 0 auto; padding: 27px clamp(17px, 3.2vw, 43px) 25px; outline: none; }
.footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 9px; padding: 10px clamp(17px, 3.2vw, 43px) 20px; color: var(--muted); font-size: 11px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 4px 0 20px; }
.page-head p, .hero p, .family-head p { color: var(--muted); margin-top: 6px; }
.hero { background: linear-gradient(110deg, #f3eadc, #eae0d1); border: 1px solid #e6d9c6; border-radius: var(--radius); padding: 24px clamp(16px, 3vw, 34px); display: flex; align-items: flex-end; justify-content: space-between; gap: 17px; }
.hero .hero-date, .reference { display: block; color: var(--accent); font-weight: 675; font-size: 11px; letter-spacing: .045em; }
.hero h1 { margin-top: 5px; }
.actions { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 41px; padding: 8px 13px; border: 1px solid transparent; border-radius: 7px; font-size: 13px; font-weight: 670; line-height: 1.28; text-align: center; }
.button.primary { color: #fffaf2; background: var(--accent); border-color: var(--accent); }
.button.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.button.secondary { color: var(--ink); background: var(--surface); border-color: var(--edge); }
.button.secondary:hover, .button.quiet:hover { background: var(--warm); }
.button.quiet { color: var(--accent-dark); background: transparent; }
.button.small { min-height: 34px; padding: 6px 9px; font-size: 12px; }
.button:disabled { opacity: .6; cursor: wait; }
.external { color: var(--accent-dark); text-decoration: underline; text-underline-offset: 3px; font-weight: 650; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 13px 0; }
.metric { min-width: 0; border: 1px solid var(--line); border-radius: 9px; padding: 13px 15px; background: var(--surface); }
.metric > span, .metric small { display: block; font-size: 12px; color: var(--muted); }
.metric > span { font-weight: 650; }
.metric strong { display: block; color: var(--ink); font-family: Georgia, serif; font-size: clamp(22px, 3vw, 34px); line-height: 1.03; font-weight: 400; margin-top: 5px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; align-items: start; }
.summary { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); margin-top: 15px; }
.card, .record-tile { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 16px 18px; margin-bottom: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 7px; margin-bottom: 11px; }
.section-head { padding: 3px 1px; }
.card p + .actions, .statusline + .actions { margin-top: 9px; }
.tile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(258px, 100%), 1fr)); gap: 11px; margin-top: 12px; }
.tile-grid .record-tile { margin: 0; }
.record-tile h2 { margin: 4px 0 3px; }
.record-tile h2 a:hover { color: var(--accent-dark); text-decoration: underline; }
.record-tile p, .tile-foot, .task-list small, .count { color: var(--muted); font-size: 12px; }
.tile-top, .tile-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.tile-foot { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 6px; }
.task-list, .document-list, .sources { padding: 0; list-style: none; }
.task-list li, .document, .sources li { border-bottom: 1px solid var(--line); padding: 9px 0; min-width: 0; }
.task-list li:last-child, .document:last-child, .sources li:last-child { border-bottom: 0; }
.task-list a:not(.button) { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.task-list a:hover strong { text-decoration: underline; }
.task-list strong { font-weight: 650; color: var(--ink); font-size: 13px; }
.task-list small { display: block; }
.task-list i { font-style: normal; color: var(--accent); }
.sources li > p { color: var(--muted); font-size: 13px; margin-top: 3px; }
.empty { padding: 10px 12px; border-radius: 7px; background: var(--paper); color: var(--muted); font-size: 13px; }
.notice { margin: 0 0 13px; padding: 10px 12px; border-left: 3px solid #aa8763; border-radius: 5px; background: var(--warm); color: var(--accent-dark); font-size: 13px; }

.tabs { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; padding: 5px; margin-bottom: 13px; border: 1px solid var(--line); border-radius: 8px; background: var(--warm); }
.tabs a { padding: 8px 10px; border-radius: 6px; color: var(--accent-dark); font-size: 12px; font-weight: 700; }
.tabs a[aria-current="page"], .tabs a:hover { background: var(--surface); color: var(--ink); }
.statusline { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.pill { display: inline-block; font-size: 11px; font-weight: 675; border-radius: 18px; padding: 3px 8px; white-space: normal; line-height: 1.35; }
.pill.muted { color: #595347; background: #eee9df; }
.pill.green { color: #365341; background: #e7eee5; }
.pill.amber { color: #704b26; background: #f5e8d2; }
.pill.blue { color: #3c5161; background: #e7edf1; }
.pill.red { color: #793f32; background: #f3e5e0; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(175px, 100%), 1fr)); gap: 8px 11px; margin: 5px 0 12px; }
.pair { min-width: 0; border-top: 1px solid var(--line); padding-top: 7px; }
.pair dt { color: var(--muted); font-size: 12px; }
.pair dd { margin: 3px 0 0; font-size: 14px; font-weight: 650; overflow-wrap: anywhere; }
.plain-note { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; margin-bottom: 10px; }
.table-wrap { min-width: 0; max-width: 100%; overflow-x: auto; scrollbar-color: #b8a78d transparent; }
table { width: 100%; text-align: left; border-collapse: collapse; font-size: 13px; }
th { padding: 8px 9px; background: var(--warm); color: var(--accent-dark); font-weight: 680; white-space: nowrap; font-size: 11px; }
td { padding: 9px; border-bottom: 1px solid var(--line); }
td strong, td small { display: block; }
td small { color: var(--muted); margin-top: 2px; }
tr:last-child td { border-bottom: 0; }
.document { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.document-text { min-width: 0; overflow-wrap: anywhere; }
.document-text small { display: block; color: var(--muted); font-size: 12px; }
.document-text .external { font-size: 11px; }
.simple-list { padding-left: 20px; color: var(--muted); font-size: 14px; }
.simple-list li + li { margin-top: 5px; }
.family-head { border-radius: var(--radius); background: var(--warm); border: 1px solid var(--line); padding: 19px 22px; margin-bottom: 12px; }
.family-head h2 { margin-top: 4px; font-size: clamp(25px, 3.4vw, 38px); }
.family-head .reference { margin: 0; }

.form { display: grid; gap: 11px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr)); gap: 9px 12px; align-items: end; }
.field { display: grid; gap: 4px; min-width: 0; color: var(--ink); font-size: 12px; font-weight: 670; }
.field :is(input, select, textarea) { width: 100%; min-width: 0; min-height: 41px; padding: 7px 9px; background: #fff; color: var(--text); border: 1px solid var(--edge); border-radius: 7px; font-size: 13px; font-weight: 450; }
.field textarea { resize: vertical; }
.check { display: flex; align-items: flex-start; gap: 7px; color: var(--muted); font-size: 13px; }
.check input { accent-color: var(--accent); margin: 4px 0 0; }
.form-error { background: #f7e8e4; color: #753b2d; border-radius: 7px; padding: 8px 10px; font-size: 13px; }
.dialog { width: min(675px, calc(100vw - 22px)); max-height: 90dvh; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; background: var(--surface); color: var(--text); }
.dialog::backdrop { background: #201e1b99; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 9px; margin-bottom: 10px; }
.toast { position: fixed; right: 16px; bottom: 16px; z-index: 16; max-width: min(400px, calc(100% - 32px)); padding: 9px 13px; background: var(--rail); color: white; border-radius: 7px; font-size: 13px; }
.toast.error { background: #783e30; }

@media (max-width: 1050px) {
    .hero, .page-head { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 860px) {
    .shell { grid-template-columns: 175px minmax(0, 1fr); }
    .sidebar { padding-inline: 8px; }
    .summary, .split { grid-template-columns: minmax(0, 1fr); gap: 7px; }
    .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 650px) {
    .shell { display: block; }
    .sidebar { display: none; position: fixed; top: 49px; left: 8px; width: min(253px, calc(100vw - 26px)); height: auto; max-height: calc(100dvh - 60px); z-index: 10; padding: 12px; border-radius: 9px; box-shadow: 0 6px 34px #201e1b60; }
    .menu-open .sidebar, .topbar .menu-button { display: flex; }
    .navigation { margin: 17px 0; }
    .topbar { min-height: 52px; padding: 6px 9px; }
    .topbar .menu-button { min-height: 36px; }
    .desktop-label { display: none; }
    .screen { padding: 13px 9px 17px; }
    .hero { padding: 16px 12px; gap: 10px; }
    .hero p, .page-head p { font-size: 13px; }
    .metrics { gap: 6px; margin: 9px 0; }
    .metric { padding: 9px 8px; }
    .card, .record-tile { padding: 12px 10px; }
    .document { align-items: flex-start; flex-direction: column; gap: 5px; }
    .footer { padding: 5px 9px 14px; }
}
@media print {
    .sidebar, .topbar, .footer, #feedback, .tabs, .page-head, .button { display: none !important; }
    .shell { display: block; }
    .screen { padding: 0; }
    .card { break-inside: avoid; }
}
