:root {
    color-scheme: light;
    font-family: "Inter", "Segoe UI", system-ui, sans-serif;
    color: #19322c;
    background: #f2f6f4;
    --text: #19322c;
    --muted: #50655e;
    --paper: #fff;
    --line: #d6e2dd;
    --green: #17624f;
    --dark: #123b33;
    --mint: #e3f2eb;
    --gold: #805021;
    --gold-bg: #fbf2e6;
    --error: #982e35;
    --gutter: clamp(1rem, 4vw, 2rem);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
h1, h2, h3, p { margin: 0; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
:focus-visible { outline: 3px solid #27856f; outline-offset: 3px; }

.shell {
    width: min(calc(100% - var(--gutter) - var(--gutter)), 72rem);
    margin-inline: auto;
}

.topbar { background: var(--dark); color: #f8fffb; }
.topbar-inner, .brand, .page-heading, .month-header, .dialog-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.topbar-inner { min-height: 4.25rem; }
.brand { justify-content: start; gap: .7rem; font-weight: 650; letter-spacing: -.015em; }
.brand-icon {
    position: relative;
    flex: 0 0 1.6rem;
    height: 1.5rem;
    border: 2px solid #a7d7c3;
    border-radius: .35rem;
}
.brand-icon::before, .brand-icon::after {
    content: "";
    position: absolute;
    background: #a7d7c3;
}
.brand-icon::before { top: .34rem; inset-inline: 0; height: 2px; }
.brand-icon::after { top: .67rem; left: .33rem; width: .28rem; height: .28rem; border-radius: 1px; }

.page-heading { margin-block: clamp(1.5rem, 4vw, 2.8rem) 1.5rem; align-items: end; }
h1 { font-size: clamp(2rem, 4.5vw, 3.2rem); line-height: 1.07; letter-spacing: -.055em; }
.page-heading p { color: var(--muted); margin-top: .6rem; line-height: 1.5; }
.sync-status {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    color: var(--muted);
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: .43rem .75rem;
    white-space: nowrap;
    font-size: .875rem;
}
.sync-dot { width: .52rem; height: .52rem; background: #788e84; border-radius: 50%; }
.sync-status[data-state="online"] { color: var(--green); }
.sync-status[data-state="online"] .sync-dot { background: #278367; }
.sync-status[data-state="offline"] .sync-dot { background: #b46e26; }
.notice { padding: 1rem; border: 1px solid #edc3c3; background: #fff5f4; border-radius: .8rem; color: var(--error); }

.planner {
    display: grid;
    grid-template-columns: minmax(0, 1.85fr) minmax(18rem, 1fr);
    align-items: start;
    gap: 1rem;
    padding-bottom: 2rem;
}
.planner[data-view="day"] { grid-template-columns: minmax(0, 46rem); justify-content: center; }
.card {
    min-width: 0;
    padding: clamp(.9rem, 3vw, 1.4rem);
    border: 1px solid var(--line);
    border-radius: 1rem;
    background: var(--paper);
    box-shadow: 0 4px 18px #183d3010;
}
h2 { font-size: 1.42rem; line-height: 1.2; letter-spacing: -.035em; }
h3 { font-size: 1rem; line-height: 1.3; font-weight: 700; }
#month-heading::first-letter, .weekday-label::first-letter { text-transform: uppercase; }
.month-header { margin-bottom: 1.1rem; flex-wrap: wrap; }

.view-tabs { display: inline-flex; gap: .2rem; padding: .2rem; border-radius: .7rem; background: #edf3f0; }
.view-tabs button {
    min-height: 2.15rem;
    border: 1px solid transparent;
    border-radius: .5rem;
    background: transparent;
    padding: .3rem .64rem;
    color: var(--muted);
    font-weight: 650;
    font-size: .875rem;
}
.view-tabs button[aria-pressed="true"] {
    border-color: var(--line);
    background: var(--paper);
    color: var(--green);
    box-shadow: 0 1px 2px #183d3010;
}

.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .38rem; }
.calendar-weekday {
    color: var(--muted);
    font-size: .85rem;
    font-weight: 650;
    padding: .15rem .25rem .4rem;
    text-align: center;
}
.calendar-day {
    min-width: 0;
    min-height: 5rem;
    display: flex;
    flex-direction: column;
    align-items: start;
    gap: .2rem;
    border: 1px solid var(--line);
    border-radius: .6rem;
    background: #fafcfb;
    padding: .43rem;
    color: var(--text);
    text-align: start;
}
.calendar-day:hover { border-color: #75a997; background: #f1f7f4; }
.calendar-day[aria-pressed="true"] { border-color: var(--green); box-shadow: inset 0 0 0 1px var(--green); background: var(--mint); }
.calendar-number { font-weight: 700; font-variant-numeric: tabular-nums; }
.calendar-holiday { background: var(--gold-bg); }
.calendar-event { color: var(--gold); font-size: .73rem; white-space: nowrap; letter-spacing: -.025em; }
.calendar-count {
    margin-top: auto;
    display: inline-flex;
    align-self: end;
    min-width: 1.45rem;
    padding: .1rem .3rem;
    justify-content: center;
    background: #d5ebe1;
    color: #135643;
    border-radius: .3rem;
    font-size: .8rem;
    font-weight: 750;
}
.calendar-legend { display: flex; align-items: center; gap: .45rem; margin-top: 1rem; color: var(--muted); font-size: .85rem; }
.legend-marker { width: .75rem; height: .75rem; border: 1px solid #bc8d57; border-radius: .21rem; background: var(--gold-bg); }

.day-picker { display: flex; gap: .55rem; align-items: stretch; }
.date-input { width: auto; max-width: 100%; }
.day-picker .day-nav { padding-inline: .75rem; }
.chevron { display: block; width: .55rem; height: .55rem; border-right: 2px solid; border-bottom: 2px solid; }
.chevron-right { transform: rotate(-45deg); }
.chevron-left { transform: rotate(135deg); }
.day-header { position: relative; padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
.weekday-label { margin-bottom: .3rem; color: var(--muted); font-size: .88rem; }
.day-header h2 { font-size: clamp(1.62rem, 3vw, 2rem); }
.day-header h2:focus { outline-offset: 4px; }
.holiday-tag {
    display: inline-block;
    margin-top: .55rem;
    padding: .24rem .55rem;
    font-size: .83rem;
    font-weight: 680;
    color: var(--gold);
    background: var(--gold-bg);
    border-radius: .35rem;
}
.day-body { display: grid; gap: 1rem; padding-top: 1rem; }
.coverage-list { list-style: none; margin: .55rem 0 0; padding: 0; }
.coverage-list li {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: .5rem;
    padding: .52rem 0;
    border-bottom: 1px solid var(--line);
    font-size: .9rem;
}
.coverage-count { flex-shrink: 0; color: var(--green); font-size: .85rem; }
.empty-state, .muted { margin-top: .45rem; color: var(--muted); font-size: .9rem; line-height: 1.45; }
.editor { min-width: 0; padding: .9rem; background: #f0f6f2; border: 1px solid var(--line); border-radius: .75rem; }
.editor h3 { margin-bottom: .65rem; }
.input-row { display: flex; gap: .5rem; align-items: stretch; }
form label, .manager-filter { display: block; font-size: .9rem; font-weight: 630; }
form > label { margin-bottom: .4rem; }
input:not([type="radio"]), select {
    min-width: 0;
    width: 100%;
    min-height: 2.52rem;
    border: 1px solid #aebfb6;
    border-radius: .5rem;
    padding: .45rem .6rem;
    color: var(--text);
    background: var(--paper);
}
input::placeholder { color: #64776e; }
input[type="date"] { width: min(11rem, 100%); }

.button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    min-height: 2.52rem;
    border: 1px solid transparent;
    border-radius: .5rem;
    padding: .42rem .78rem;
    font-size: .9rem;
    font-weight: 680;
}
.button-primary { background: var(--green); color: white; }
.button-primary:hover:not(:disabled) { background: #0e4d3d; }
.button-quiet { background: var(--paper); border-color: var(--line); color: var(--green); }
.button-quiet:hover:not(:disabled) { background: var(--mint); }
.topbar .button-quiet { color: #f8fffb; border-color: #5c8b7a; background: transparent; }
.topbar .button-quiet:hover { background: #245447; }
.topbar :focus-visible { outline-color: #a8dfc7; }
.text-button { background: transparent; color: var(--green); border: 0; padding: .2rem 0; font-size: .85rem; font-weight: 680; text-decoration: underline; text-underline-offset: .2em; }
.id-status { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .55rem; color: var(--muted); font-size: .85rem; }
fieldset { padding: 0; margin: 0; border: 0; min-width: 0; }
.mode-picker { display: grid; gap: .38rem; margin-bottom: .8rem; }
.mode-picker label { display: flex; align-items: center; gap: .5rem; min-height: 2.42rem; padding: .4rem .5rem; background: white; border: 1px solid var(--line); border-radius: .5rem; cursor: pointer; }
.mode-picker label:has(input:checked) { border-color: #77a897; color: var(--green); }
.mode-picker input { accent-color: var(--green); margin: 0; }
.time-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; margin-bottom: .75rem; }
.time-fields input { display: block; margin-top: .35rem; }
.time-fields p { grid-column: 1 / -1; margin-top: 0; }
.save-button { width: 100%; }
.remove-button { display: block; margin: .55rem auto 0; }
.form-message { margin-top: .65rem; font-size: .88rem; color: var(--green); line-height: 1.4; }
.form-message[data-tone="error"] { color: var(--error); }

.manager-dialog {
    width: min(calc(100% - 2rem), 42rem);
    max-height: 85dvh;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 1rem;
    padding: clamp(1rem, 4vw, 1.6rem);
    color: var(--text);
    background: var(--paper);
    box-shadow: 0 16px 40px #071c1660;
}
.manager-dialog::backdrop { background: #0d211c9e; }
.dialog-heading { margin-bottom: 1.1rem; align-items: start; }
.manager-filter select { width: auto; display: block; margin: .35rem 0 .8rem; }
.table-wrap { border: 1px solid var(--line); border-radius: .6rem; overflow: auto; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: .9rem; }
th, td { padding: .55rem .58rem; text-align: start; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
th { background: #eff5f1; }
th:last-child { width: 43%; }
tbody tr:last-child td { border-bottom: 0; }
.operator-code { font-family: ui-monospace, monospace; line-height: 1.4; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

@media (min-width: 620px) {
    .planner[data-view="day"] .day-body { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
}

@media (max-width: 820px) {
    .planner { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 540px) {
    .topbar-inner { min-height: 3.75rem; gap: .5rem; }
    .brand { font-size: .92rem; gap: .46rem; }
    .brand-icon { flex-basis: 1.35rem; height: 1.3rem; }
    .brand-icon::after { top: .63rem; left: .25rem; width: .24rem; height: .24rem; }
    .topbar .button { font-size: .82rem; padding-inline: .5rem; }
    .page-heading { flex-direction: column; align-items: start; gap: .65rem; margin-bottom: 1rem; }
    .page-heading p { margin-top: .45rem; }
    .calendar { gap: .25rem; }
    .calendar-day { min-height: 3.15rem; padding: .26rem; font-size: .9rem; }
    .calendar-weekday { font-size: .77rem; }
    .calendar-event { display: none; }
    .calendar-holiday .calendar-number { color: var(--gold); }
    .calendar-count { font-size: .72rem; min-width: 1.13rem; padding-inline: .22rem; }
    .dialog-heading h2 { font-size: 1.26rem; }
}
