:root {
    --bg: #f3f0e8;
    --paper: #fffdf8;
    --ink: #1d1c19;
    --muted: #5e5a53;
    --line: #e2dcd0;
    --me: #1e6b45;
    --other: #2c5278;
    --warn: #8a3d2f;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 16px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}

:focus-visible {
    outline: 2px solid var(--me);
    outline-offset: 2px;
}

.top {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
    align-items: center;
    justify-content: space-between;
    padding: 0.8rem 1rem;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
}

.brand {
    color: inherit;
    font-weight: 700;
    text-decoration: none;
}

nav { display: flex; flex-wrap: wrap; gap: 0.35rem; }

nav a {
    color: inherit;
    text-decoration: none;
    padding: 0.45rem 0.75rem;
    border-radius: 999px;
}

nav a.active { background: var(--ink); color: white; }

.wrap {
    max-width: 980px;
    margin: 0 auto;
    padding: 1rem 1rem 3rem;
}

.stack { display: flex; flex-direction: column; gap: 1rem; }

h1 { font-size: 1.6rem; line-height: 1.2; margin: 0; }
h2 { font-size: 1.15rem; margin: 0 0 0.7rem; }
h3 { font-size: 1rem; margin: 0 0 0.4rem; }

.lead, .hint { color: var(--muted); }
.lead { margin: 0.35rem 0 0; }
.hint { font-size: 0.9rem; margin: 0.4rem 0 0; }

.card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 1rem;
}

.summary { margin: 0.2rem 0 0.7rem; }

a { color: var(--other); }

.split {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.8fr);
    gap: 1rem;
    align-items: start;
}

.monthnav {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 0.6rem;
}

.monthnav strong { flex: 1; text-align: center; }

.iconbtn {
    color: inherit;
    text-decoration: none;
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.cal {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
}

.dow {
    text-align: center;
    font-size: 0.75rem;
    color: var(--muted);
}

a.day {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-height: 3.4rem;
    padding: 0.2rem;
    border-radius: 8px;
    background: #fff;
    color: inherit;
    text-decoration: none;
}

.day.empty { background: transparent; }
.day.weekend { background: #f6f3ec; }
.day.future .num { color: var(--muted); }
.day.today .num { color: var(--me); font-weight: 700; }
.day.sel { box-shadow: inset 0 0 0 2px var(--ink); }
.day .num { font-size: 0.8rem; }

.pills { display: flex; flex-wrap: wrap; gap: 2px; }

.pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.15rem;
    height: 1.15rem;
    padding: 0 0.2rem;
    border-radius: 99px;
    font-size: 0.65rem;
    font-weight: 700;
    color: white;
}

.pill.ich, .swatch.ich { background: var(--me); }
.pill.anderer, .swatch.anderer { background: var(--other); }

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    align-items: center;
    margin: 0.7rem 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.swatch {
    display: inline-block;
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 99px;
    margin-right: 0.25rem;
}

.jump, .range, .actions, .inline, .filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.inline input[type="text"] { flex: 1; min-width: 0; width: auto; }
.field.inline-label { display: flex; align-items: center; gap: 0.45rem; margin: 0; }
.field.inline-label span { margin: 0; }

.jump { margin-top: 0.8rem; }

label.field { display: block; margin: 0 0 0.8rem; }
label.field span, .field-label { display: block; margin-bottom: 0.25rem; }

input[type="text"], input[type="password"], input[type="date"], textarea {
    width: 100%;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: white;
    font: inherit;
    color: inherit;
}

.jump input[type="date"], .range input[type="date"] { width: auto; }

textarea { resize: vertical; }

button, .btn {
    font: inherit;
    color: inherit;
    cursor: pointer;
    min-height: 44px;
    padding: 0.55rem 1rem;
    border-radius: 10px;
}

button.primary {
    background: var(--ink);
    color: white;
    border: 0;
}

button.ghost, a.btn {
    background: white;
    border: 1px solid var(--line);
    color: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

button.danger {
    background: transparent;
    color: var(--warn);
    border: 1px solid var(--warn);
}

.quick {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.quick button {
    width: 100%;
    border: 0;
    color: white;
    font-weight: 600;
}

.quick button.me { background: var(--me); }
.quick button.other { background: var(--other); }
.quick button:hover { filter: brightness(0.95); }

.choices { display: flex; flex-direction: column; gap: 0.15rem; margin-bottom: 0.5rem; }
.choices label { display: flex; gap: 0.5rem; align-items: center; min-height: 40px; }

.child-block, .child-row { border-top: 1px solid var(--line); padding: 0.8rem 0; }
.child-block:first-of-type { border-top: 0; padding-top: 0; }

.auth { max-width: 28rem; width: 100%; margin: 1rem auto; }

.flash { padding: 0.7rem 0.9rem; border-radius: 10px; margin: 0; }
.flash.ok { background: #e5f2ea; color: #143d28; }
.flash.err { background: #f8e6e2; color: #6d2a22; }

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }
th, td {
    text-align: left;
    padding: 0.45rem 0.5rem;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}
th { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.numc { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.meter {
    position: relative;
    height: 12px;
    border-radius: 99px;
    background: var(--other);
    overflow: hidden;
    margin-top: 0.35rem;
}
.meter-fill { display: block; height: 100%; background: var(--me); }
.meter-half {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    margin-left: -1px;
    background: white;
    box-shadow: 0 0 0 1px var(--ink);
}
.meter-labels {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 0.25rem;
}

.filters { margin-bottom: 0.8rem; }
.filters a {
    text-decoration: none;
    color: inherit;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.4rem 0.75rem;
    background: white;
}
.filters a.active { background: var(--ink); color: white; border-color: var(--ink); }

.child-block + .child-block { margin-top: 0.2rem; }
.person + .person { margin-top: 1.1rem; padding-top: 0.3rem; }

.fine { color: var(--muted); font-size: 0.85rem; margin: 0; }

.print-only { display: none; }

@media (max-width: 860px) {
    .split { grid-template-columns: 1fr; }
    .wrap { padding: 0.75rem 0.6rem 2.5rem; }
}

@media print {
    .noprint, .top, .flash { display: none !important; }
    body { background: white; }
    .wrap { max-width: none; padding: 0; }
    .card { border: 0; padding: 0; }
    a { color: inherit; text-decoration: none; }
    .print-only { display: block; }
}
