:root {
    color-scheme: light;
    --page: #f5f7fa;
    --line: #e3e7e5;
    --accent: #596a61;
    --muted: #5c6861;
    --ink: #242924;
    --debt: #a32835;
    --card: #fff;
    --shadow: 0 2px 8px rgb(34 48 38 / 8%);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--ink);
    background: var(--page);
}

* { box-sizing: border-box; }
body { margin: 0; padding: 16px; }
a { color: var(--accent); }
h1, h2, p, figure { margin: 0; }
h1, h2 { font-size: 1.22rem; line-height: 1.25; }
p { line-height: 1.55; }
button, input, select { font: inherit; }
button, summary { cursor: pointer; }
:focus-visible { outline: 3px solid #647f6e; outline-offset: 3px; }

.layout { width: min(100%, 1140px); margin-inline: auto; }
.site-header, .panel, .banner, .login-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow);
}
.site-header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 18px;
    margin-bottom: 12px;
}
.brand { color: var(--ink); font-size: 1.15rem; font-weight: 750; text-decoration: none; }
.identity { color: var(--muted); font-size: .86rem; overflow-wrap: anywhere; }
.menu summary, button {
    padding: 9px 14px;
    border: 1px solid var(--accent);
    border-radius: 8px;
    background: var(--card);
    color: var(--accent);
    font-weight: 650;
}
.menu summary { white-space: nowrap; }
.menu nav {
    position: absolute;
    z-index: 2;
    right: 12px;
    top: calc(100% + 5px);
    width: min(15rem, calc(100% - 24px));
    max-height: 70vh;
    overflow-y: auto;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--card);
    box-shadow: 0 6px 20px rgb(34 48 38 / 16%);
}
.menu a, .menu button {
    display: block;
    width: 100%;
    padding: 10px;
    border: 0;
    border-radius: 5px;
    text-align: left;
    text-decoration: none;
    color: var(--ink);
}
.menu a:hover, .menu a[aria-current], .menu button:hover { background: #ecf1ed; }
.menu form { margin-top: 4px; border-top: 1px solid var(--line); }
.banner-stack, .home-panels { display: grid; gap: 12px; }
.banner-stack { margin-bottom: 12px; }
.banner { min-width: 0; overflow: hidden; }
.image-banner img { display: block; width: 100%; height: auto; }
.html-banner { padding: 14px 18px; line-height: 1.5; overflow-wrap: anywhere; }
.html-banner > * + * { margin-top: .65em; }
.html-banner pre { white-space: pre-wrap; }
.home-panels { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: start; }
.panel { min-width: 0; padding: 16px 18px; }
.panel :is(h1, h2) { margin-bottom: 12px; }
.panel-heading { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; }
.debt-list { margin: 0; padding: 0; list-style: none; }
.debt-list li {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 10px;
    align-items: baseline;
    padding: 9px 0;
    border-bottom: 1px solid var(--line);
    overflow-wrap: anywhere;
}
.pair-index, .muted { color: var(--muted); }
.debt { color: var(--debt); font-variant-numeric: tabular-nums; }
.more-debts { margin-top: 10px; color: var(--accent); }
.entry-form { display: grid; gap: 10px; }
.entry-form label, .period-form label { display: grid; gap: 4px; min-width: 0; font-size: .9rem; font-weight: 600; }
.entry-form :is(input, select), .period-form input {
    width: 100%;
    min-height: 42px;
    min-width: 0;
    padding: 8px 10px;
    border: 1px solid #aeb9b1;
    border-radius: 8px;
    background: var(--card);
    color: var(--ink);
    font-size: 1rem;
}
.entry-form p { min-width: 0; }
.primary { min-height: 42px; background: var(--accent); color: #fff; }
.primary:hover { background: #46564e; }
button:disabled { opacity: .65; cursor: wait; }
.error, .errorlist, .success { padding: 8px 10px; border-radius: 6px; margin: 0 0 6px; }
.error, .errorlist { color: #90232e; background: #fff2f3; }
.errorlist { list-style: none; }
.success { color: #285438; background: #eef5ed; }
.period-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 12px; }
.table-wrap { overflow-x: auto; margin-top: 12px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
thead th { background: #f6f8f7; }
tbody th { font-weight: 550; }
.catalog-list { margin: 0; padding-inline-start: 24px; }
.catalog-list li { margin-bottom: 5px; overflow-wrap: anywhere; }
.category { margin-top: 14px; }
.catalog-form { margin-top: 16px; max-width: 26rem; }
.login-page { min-height: 100dvh; display: grid; place-items: center; }
.login-card { width: min(100%, 380px); padding: 20px; }
.login-card .entry-form { margin-top: 16px; }

@media (max-width: 620px) {
    body { padding: 10px; }
    .site-header, .panel, .html-banner { padding: 12px; }
    .home-panels { grid-template-columns: minmax(0, 1fr); }
    .debt-list li { gap: 8px; }
}
