/* ---------------------------------------------------------------
   Duty Roster
   The palette is taken from the board it replaces: ballpoint blue
   for assignments, red marker for stars and Sundays, green for
   ad-hoc claim windows, on whiteboard laminate.
   No webfonts: this runs on an internal host and must render the
   same with no outbound network.
   --------------------------------------------------------------- */

:root {
    --board: #f7f7f4;
    --panel: #ffffff;
    --ink: #16386b;
    --ink-soft: #4a6591;
    --marker: #b3242b;
    --override: #1b6e52;
    --graphite: #23262b;
    --muted: #6b6f76;
    --rule: #d5d6d1;
    --rule-soft: #e8e8e4;
    --shade: #f0f0ec;
    --warn-bg: #fdf6e3;
    --warn-edge: #d8b34a;
    --block-bg: #fbeceb;

    --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
    --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;

    --gap: 1.25rem;
    --radius: 3px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--board);
    color: var(--graphite);
    font-family: var(--sans);
    font-size: 15px;
    line-height: 1.5;
}

a { color: var(--ink); }

/* ------------------------------ chrome ------------------------------ */

.masthead {
    display: flex;
    align-items: baseline;
    gap: 1.5rem;
    flex-wrap: wrap;
    padding: 1rem 1.5rem;
    background: var(--panel);
    border-bottom: 1px solid var(--rule);
}

.masthead .wordmark {
    font-family: var(--serif);
    font-size: 1.15rem;
    letter-spacing: 0.01em;
    color: var(--ink);
    text-decoration: none;
    font-weight: 700;
}

.masthead nav {
    display: flex;
    gap: 1.25rem;
    margin-left: auto;
    align-items: baseline;
}

.masthead nav a,
.masthead nav button {
    font-size: 0.85rem;
    color: var(--muted);
    text-decoration: none;
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
    font-family: inherit;
}

.masthead nav a:hover,
.masthead nav button:hover { color: var(--ink); }

.masthead nav a[aria-current="page"] {
    color: var(--graphite);
    border-bottom: 2px solid var(--ink);
    padding-bottom: 2px;
}

.shell {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--gap);
}

/* ------------------------------ headings ------------------------------ */

.month-head {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.month-title {
    font-family: var(--serif);
    font-size: 1.9rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin: 0;
    color: var(--graphite);
}

.status-chip {
    font-family: var(--mono);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    padding: 0.2rem 0.5rem;
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    color: var(--muted);
    background: var(--shade);
}

.status-chip.is-published { color: var(--override); border-color: var(--override); background: #eef6f2; }
.status-chip.is-locked { color: var(--marker); border-color: var(--marker); background: var(--block-bg); }

.month-head .spacer { margin-left: auto; }

.section-title {
    font-family: var(--mono);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.11em;
    color: var(--muted);
    margin: 0 0 0.6rem;
    font-weight: 600;
}

/* ------------------------------ buttons ------------------------------ */

.btn {
    font-family: var(--sans);
    font-size: 0.82rem;
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--rule);
    background: var(--panel);
    color: var(--graphite);
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    line-height: 1.4;
}

.btn:hover { border-color: var(--ink-soft); color: var(--ink); }
.btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.btn-primary {
    background: var(--ink);
    border-color: var(--ink);
    color: #fff;
}
.btn-primary:hover { background: #102c56; color: #fff; }

.btn-danger { color: var(--marker); border-color: #e3c3c1; }
.btn-danger:hover { border-color: var(--marker); color: var(--marker); }

.btn-group { display: flex; gap: 0.4rem; flex-wrap: wrap; }

/* ------------------------------ layout ------------------------------ */

.board-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: var(--gap);
    align-items: start;
}

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

/* ------------------------------ calendar ------------------------------ */

.calendar {
    background: var(--panel);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    overflow: hidden;
}

.weekday-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: var(--shade);
    border-bottom: 1px solid var(--rule);
}

.weekday-row span {
    padding: 0.5rem 0.6rem;
    font-family: var(--mono);
    font-size: 0.68rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
}

.weekday-row span.sunday { color: var(--marker); }

.week {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}

.cell {
    position: relative;
    min-height: 108px;
    padding: 0.4rem;
    border-right: 1px solid var(--rule-soft);
    border-bottom: 1px solid var(--rule-soft);
    background: var(--panel);
    text-align: left;
    font-family: inherit;
    cursor: pointer;
    display: block;
    width: 100%;
}

.cell:nth-child(7n) { border-right: 0; }
.cell:hover { background: #fbfbf9; }
.cell:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; z-index: 2; }

.cell.is-outside { background: var(--shade); cursor: default; }
.cell.is-outside .daynum { color: #b9bcc0; }
.cell.is-today { box-shadow: inset 0 0 0 2px var(--ink); }
.cell.has-block { background: var(--block-bg); }

.cell .daynum {
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--muted);
    display: block;
}

.cell.is-sunday .daynum { color: var(--marker); }

/* --- the signature: the slash pair, as written on the wall --- */

.pair {
    position: relative;
    height: 62px;
    margin-top: 2px;
}

.pair .slash {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 1px;
    height: 46px;
    background: var(--ink);
    transform: translate(-50%, -50%) rotate(45deg);
    opacity: 0.55;
}

.pair .rank {
    position: absolute;
    font-family: var(--serif);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--ink);
    line-height: 1;
}

.pair .rank-1 { left: 12%; top: 6%; }
.pair .rank-2 { right: 12%; bottom: 6%; }

.pair .rank .star {
    font-size: 0.7rem;
    color: var(--marker);
    vertical-align: super;
    margin-left: 1px;
}

.pair .rank.is-custom { color: var(--override); }

.pair.is-empty::after {
    content: "—";
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    color: #c9ccd0;
    font-size: 1.1rem;
}

.cell .note-dot {
    position: absolute;
    right: 6px;
    bottom: 6px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--override);
}

.cell .cell-issue {
    position: absolute;
    left: 6px;
    bottom: 5px;
    font-size: 0.62rem;
    color: var(--marker);
    font-family: var(--mono);
}

/* mobile: the grid becomes a list, one day per row */
@media (max-width: 720px) {
    .week { grid-template-columns: 1fr; }
    .weekday-row { display: none; }
    .cell {
        min-height: 0;
        display: grid;
        grid-template-columns: 3.5rem 1fr;
        align-items: center;
        gap: 0.75rem;
        border-right: 0;
        padding: 0.6rem 0.75rem;
    }
    .cell.is-outside { display: none; }
    .pair { height: 44px; margin: 0; }
    .pair .rank { font-size: 1.15rem; }
    .pair .slash { height: 34px; }
}

/* ------------------------------ tally ------------------------------ */

.side { display: grid; gap: var(--gap); }

.card {
    background: var(--panel);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    padding: 0.9rem;
}

.tally {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--mono);
    font-size: 0.8rem;
}

.tally th {
    text-align: right;
    font-weight: 600;
    color: var(--muted);
    font-size: 0.66rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 0 0.35rem 0.4rem;
    border-bottom: 1px solid var(--rule);
}

.tally th:first-child { text-align: left; }

.tally td {
    padding: 0.35rem;
    text-align: right;
    border-bottom: 1px solid var(--rule-soft);
    font-variant-numeric: tabular-nums;
}

.tally td:first-child {
    text-align: left;
    font-family: var(--serif);
    font-size: 1rem;
    font-weight: 700;
    color: var(--ink);
}

.tally tr.is-inactive td { opacity: 0.45; }
.tally td.is-off { color: var(--marker); font-weight: 600; }

.tally tfoot td {
    border-bottom: 0;
    border-top: 1px solid var(--rule);
    color: var(--muted);
    font-size: 0.7rem;
    padding-top: 0.45rem;
}

.stat-line {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    font-size: 0.8rem;
    padding: 0.25rem 0;
    border-bottom: 1px solid var(--rule-soft);
}

.stat-line:last-child { border-bottom: 0; }
.stat-line dt { color: var(--muted); margin: 0; }
.stat-line dd { margin: 0; font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ------------------------------ messages ------------------------------ */

.banner {
    padding: 0.6rem 0.8rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    margin-bottom: 1rem;
    border: 1px solid;
}

.banner-info { background: #eef2f8; border-color: #c3d2e8; color: var(--ink); }
.banner-warn { background: var(--warn-bg); border-color: var(--warn-edge); color: #6d5410; }
.banner-block { background: var(--block-bg); border-color: #e0b3b0; color: #7d1f1f; }

.finding-list {
    margin: 0;
    padding-left: 1.1rem;
    font-size: 0.8rem;
    line-height: 1.6;
}

.finding-list li { margin-bottom: 0.15rem; }

/* ------------------------------ editor ------------------------------ */

.editor {
    position: fixed;
    inset: 0 0 0 auto;
    width: min(420px, 100%);
    background: var(--panel);
    border-left: 1px solid var(--rule);
    box-shadow: -12px 0 32px rgba(20, 30, 50, 0.09);
    padding: 1.25rem;
    overflow-y: auto;
    z-index: 40;
}

.editor-head {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--rule);
}

.editor-head h2 {
    font-family: var(--serif);
    font-size: 1.3rem;
    margin: 0;
}

.editor-head .close { margin-left: auto; }

.rank-block {
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    padding: 0.8rem;
    margin-bottom: 0.9rem;
}

.rank-block > .section-title { margin-bottom: 0.5rem; }

.field { margin-bottom: 0.7rem; }

.field label {
    display: block;
    font-size: 0.75rem;
    color: var(--muted);
    margin-bottom: 0.2rem;
}

.field input[type="text"],
.field input[type="date"],
.field input[type="time"],
.field input[type="email"],
.field input[type="password"],
.field input[type="number"],
.field select,
.field textarea {
    width: 100%;
    padding: 0.4rem 0.5rem;
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.87rem;
    background: var(--panel);
    color: var(--graphite);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: 2px solid var(--ink);
    outline-offset: -1px;
    border-color: var(--ink);
}

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }

.checkline {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: var(--graphite);
}

.hint { font-size: 0.72rem; color: var(--muted); margin-top: 0.25rem; }
.hint strong { color: var(--ink); font-family: var(--mono); }

.error-text { color: var(--marker); font-size: 0.78rem; margin-top: 0.2rem; }

.scrim {
    position: fixed;
    inset: 0;
    background: rgba(25, 32, 45, 0.18);
    z-index: 30;
    border: 0;
    cursor: pointer;
}

/* ------------------------------ team page ------------------------------ */

.stack { display: grid; gap: var(--gap); }

.two-col {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: var(--gap);
    align-items: start;
}

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

.data-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }

.data-table th {
    text-align: left;
    font-family: var(--mono);
    font-size: 0.66rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 0 0.4rem 0.4rem;
    border-bottom: 1px solid var(--rule);
}

.data-table td {
    padding: 0.45rem 0.4rem;
    border-bottom: 1px solid var(--rule-soft);
    vertical-align: middle;
}

.data-table .code {
    font-family: var(--serif);
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--ink);
}

.data-table .actions { text-align: right; white-space: nowrap; }

.tag {
    font-family: var(--mono);
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.1rem 0.35rem;
    border-radius: var(--radius);
    background: var(--shade);
    color: var(--muted);
    border: 1px solid var(--rule);
}

.tag.is-on { color: var(--override); border-color: #b7d9c9; background: #eef6f2; }
.tag.is-off { color: var(--marker); border-color: #e3c3c1; background: var(--block-bg); }

.empty-state {
    padding: 1.5rem 1rem;
    text-align: center;
    color: var(--muted);
    font-size: 0.85rem;
}

/* ------------------------------ login ------------------------------ */

.login-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
}

.login-card {
    width: min(360px, 100%);
    background: var(--panel);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.login-card h1 {
    font-family: var(--serif);
    font-size: 1.4rem;
    margin: 0 0 0.25rem;
    color: var(--ink);
}

.login-card p.sub { margin: 0 0 1.25rem; color: var(--muted); font-size: 0.85rem; }

/* ------------------------------ motion ------------------------------ */

@media (prefers-reduced-motion: no-preference) {
    .cell, .btn { transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease; }
}

/* ------------------------------ print ------------------------------ */

@media print {
    @page { size: A4 landscape; margin: 10mm; }

    body { background: #fff; font-size: 11px; }

    .masthead, .editor, .scrim, .no-print, .btn { display: none !important; }

    .shell { max-width: none; padding: 0; }

    .board-layout { grid-template-columns: minmax(0, 1fr) 210px; gap: 8mm; }

    .calendar, .card { border-color: #999; break-inside: avoid; }

    .cell { min-height: 80px; border-color: #ccc; }

    .pair .rank { font-size: 1.2rem; color: #000; }
    .pair .slash { background: #000; }
    .pair .rank.is-custom { color: #000; }

    .cell.has-block { background: #fff; }
}
