/* Window schedules: deliberately plain for the proof of concept. */
:root {
    --ink: #1d2329;
    --muted: #5d6873;
    --line: #d9dee3;
    --bg: #f4f6f8;
    --card: #fff;
    --brand: #1f4e79;
    --brand-dark: #173b5c;
    --ok-bg: #e7f4ea; --ok: #1e6b34;
    --err-bg: #fbeaea; --err: #9b1c1c;
    --warn: #8a5a00;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--brand); }
h1 { font-size: 1.5rem; margin: 0 0 .5rem; line-height: 1.25; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
code { font-size: .9em; background: #eef1f4; padding: .1em .3em; border-radius: 3px; }

.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 24px; padding-bottom: 48px; }

.bar { background: var(--brand); color: #fff; }
.bar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 56px; flex-wrap: wrap; }
.brand { color: #fff; text-decoration: none; font-weight: 700; }
.brand span { font-weight: 400; opacity: .8; margin-left: .35rem; }
.bar nav { display: flex; align-items: center; gap: 18px; }
.bar nav a, .bar nav .link { color: #fff; text-decoration: none; opacity: .85; font-size: .95rem; }
.bar nav a[aria-current], .bar nav a:hover, .bar nav .link:hover { opacity: 1; text-decoration: underline; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 24px; margin-bottom: 20px; }
.card.narrow { max-width: 420px; margin: 48px auto; }
.muted { color: var(--muted); font-weight: 400; }
h1 .muted { font-size: 1rem; }
.hint { color: var(--muted); font-size: .875rem; margin: .35rem 0 0; }
.hint.warn { color: var(--warn); margin-top: 1rem; }
.crumb { margin: 0 0 .5rem; font-size: .9rem; }
.summary { margin: .25rem 0 0; }

label { display: block; font-weight: 600; margin: 1.1rem 0 .35rem; }
input[type=text], input[type=password], textarea { width: 100%; font: inherit; padding: .55rem .7rem; border: 1px solid #b9c2cb; border-radius: 6px; background: #fff; }
input[type=file] { font: inherit; max-width: 100%; }
textarea.mono, .prompt-text { font: 13.5px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.prompt-text { white-space: pre-wrap; background: #f8f9fa; border: 1px solid var(--line); border-radius: 6px; padding: 16px; overflow-x: auto; }

.btn { display: inline-block; margin-top: 1.25rem; padding: .6rem 1.1rem; border: 1px solid var(--brand); border-radius: 6px; background: var(--brand); color: #fff; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--brand-dark); }
.btn.quiet { background: #fff; color: var(--brand); }
.btn.quiet:hover { background: #eef3f8; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--brand); cursor: pointer; text-decoration: underline; }
form.inline { display: inline; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.actions .btn { margin-top: 1rem; }

.flash { padding: .75rem 1rem; border-radius: 6px; margin: 0 0 20px; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.err { background: var(--err-bg); color: var(--err); }
.card .flash { margin: .75rem 0 0; }

.table-scroll { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.list th { text-align: left; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); padding: .5rem .6rem; white-space: nowrap; }
table.list td { border-bottom: 1px solid var(--line); padding: .55rem .6rem; vertical-align: top; }

.badge { display: inline-block; font-size: .8rem; font-weight: 600; padding: .1rem .5rem; border-radius: 999px; background: #eef1f4; color: var(--muted); white-space: nowrap; }
.badge.succeeded { background: var(--ok-bg); color: var(--ok); }
.badge.failed { background: var(--err-bg); color: var(--err); }
.badge.running, .badge.queued { background: #e8f0f8; color: var(--brand); }

.progress { display: flex; gap: 14px; align-items: flex-start; background: #eef3f8; border-radius: 6px; padding: 14px 16px; margin-top: .75rem; }
.progress p { margin: .2rem 0 0; }
.spinner { flex: none; width: 22px; height: 22px; margin-top: 2px; border: 3px solid #c6d5e4; border-top-color: var(--brand); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

iframe.pdf { display: block; width: 100%; height: 80vh; min-height: 480px; border: 1px solid var(--line); border-radius: 8px; background: #fff; margin-bottom: 20px; }

.details { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1.25rem; margin: 0; }
.details dt { color: var(--muted); }
.details dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 560px) {
    .details { grid-template-columns: 1fr; }
    .details dd { margin-bottom: .5rem; }
    .card { padding: 18px; }
}

/* ---------- The schedule page: laid out like the PDF ---------- */
main.wrap.wide { max-width: 1480px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.small { font-size: .8rem; }
.btn.small { margin-top: 0; padding: .3rem .75rem; font-size: .875rem; }
.link.small { font-size: .875rem; }
.link.danger { color: var(--err); }
.badge.edited { background: #fff4dc; color: var(--warn); }
input[type=number], select { font: inherit; padding: .5rem .6rem; border: 1px solid #b9c2cb; border-radius: 6px; background: #fff; width: 100%; }

.sheet { background: var(--card); border: 1px solid var(--line); border-radius: 8px; margin-bottom: 20px; }
.sheet-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px 24px; padding: 14px 24px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--card); z-index: 2; border-radius: 8px 8px 0 0; }
.sheet-bar .actions .btn { margin-top: 0; }
.sheet-status { margin: 0; }
.filter { display: inline-flex; align-items: center; gap: .4rem; font-weight: 400; margin: .25rem 0 0; font-size: .9rem; }

.doc { padding: 20px 24px 28px; font-family: "Liberation Sans", Arial, Helvetica, sans-serif; color: #000; font-size: 14px; line-height: 1.3; }
.doc-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.doc-title { font-size: 1.5rem; font-weight: 700; margin: 0; }
.doc-group { margin-top: 2.25rem; }
.doc-sub { margin: .2rem 0 .75rem; font-size: 15px; }
.doc-h3 { font-size: 1.1rem; margin: 1.25rem 0 .5rem; }
.doc-note { margin: .6rem 0 0; }
.doc-note.strong { font-weight: 700; margin-top: .25rem; }
.doc-after { margin: .5rem 0 0; font-size: 13px; }
.doc .table-scroll { margin-top: .4rem; position: relative; }   /* keeps the hidden button labels inside the scrolling table */

.doc-table { width: 100%; border-collapse: collapse; }
.doc-table th { background: #1f4e79; color: #fff; font-weight: 700; text-align: center; padding: .45rem .5rem; border: 1px solid #1f4e79; border-left-color: #fff; border-right-color: #fff; }
.doc-table th:first-child { border-left-color: #1f4e79; }
.doc-table th:last-child { border-right-color: #1f4e79; }
.doc-table td { border: 1px solid #8c8c8c; padding: .45rem .55rem; vertical-align: middle; }
.doc-table td.c { text-align: center; }
.doc-table.summary td { text-align: center; border: 0; padding-top: .6rem; }
.doc-table .w-item { width: 14%; }
.doc-table tr.system td:first-child { color: #333; }

.doc-table.schedule { min-width: 1080px; }
.doc-table.schedule th:nth-child(1) { width: 9%; }
.doc-table.schedule th:nth-child(2) { width: 4%; }
.doc-table.schedule th:nth-child(3) { width: 11%; }
.doc-table.schedule th:nth-child(4) { width: 20%; }
.doc-table.schedule th:nth-child(5) { width: 20%; }
.doc-table.schedule th:nth-child(7) { width: 7%; }
.doc-table.schedule th:nth-child(8) { width: 6%; }
.doc-table.schedule td { height: 112px; }
.doc-table.schedule td.sketch { text-align: center; padding: 4px; }
.doc-table.schedule td.sketch img { display: inline-block; vertical-align: middle; }
.tick { color: var(--ok); font-weight: 700; }
.tick::before { content: "✓ "; }
.only-unchecked tr.is-checked { display: none; }
tr.just-saved td { animation: saved 3s ease-out; }
@keyframes saved { from { background: #fff1b8; } to { background: transparent; } }
@media (prefers-reduced-motion: reduce) { tr.just-saved td { animation: none; background: #fff8d6; } }
.add-opening { margin-top: .6rem; }

.history { list-style: none; margin: 0; padding: 0; }
.history li { padding: .45rem 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.history li:last-child { border-bottom: 0; }
.history time { display: inline-block; min-width: 7.5rem; color: var(--muted); }
#history .doc-head h2 { margin: 0; }
#history .doc-head { margin-bottom: .5rem; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); max-width: min(720px, calc(100vw - 32px)); background: #1d2329; color: #fff; padding: .7rem 1rem; border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.25); z-index: 50; transition: opacity .5s; }
.toast.gone { opacity: 0; }

/* ---------- Edit pop-ups ---------- */
dialog.modal { width: min(1120px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; border: 0; border-radius: 10px; box-shadow: 0 18px 60px rgba(0,0,0,.35); color: var(--ink); }
dialog.modal.narrow { width: min(560px, calc(100vw - 32px)); }
dialog.modal::backdrop { background: rgba(16, 24, 32, .5); }
dialog.modal[open] > form { display: flex; flex-direction: column; max-height: calc(100vh - 32px); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; }
.modal-close { background: none; border: 0; font-size: 1.75rem; line-height: 1; cursor: pointer; color: var(--muted); padding: 0 .25rem; }
.modal-body { padding: 4px 20px 16px; overflow-y: auto; }
.modal-foot { padding: 12px 20px 16px; border-top: 1px solid var(--line); background: #fafbfc; border-radius: 0 0 10px 10px; }
.modal-foot .actions .btn { margin-top: .5rem; }
.modal label { margin: .8rem 0 .3rem; }
.modal-grid { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 24px; align-items: start; }
.row2 { display: grid; gap: 0 14px; grid-template-columns: 1fr 1fr; }
.row-ref { display: grid; gap: 0 14px; grid-template-columns: minmax(0, 1fr) 8rem; }
.row-type { display: flex; align-items: center; gap: 12px; margin-top: .9rem; }
.row-type label { margin: 0; }
.row-type select { width: auto; min-width: 9rem; }

/* The edit pop-up's tabs, one per printed column. Each shows what it holds now. */
dialog.modal.tabbed { width: min(980px, calc(100vw - 32px)); }
dialog.modal.tabbed[open] > form { height: min(740px, calc(100vh - 32px)); }   /* the same height on every tab */
dialog.modal.tabbed .modal-body { flex: 1; }
.modal-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 0 20px; border-bottom: 1px solid var(--line); background: #fafbfc; }
.modal-tab { appearance: none; min-width: 0; margin: 0 0 -1px; padding: .65rem .8rem .55rem; border: 0; border-bottom: 3px solid transparent; background: none; font: inherit; text-align: left; color: var(--ink); cursor: pointer; }
.modal-tab:hover { background: #eef3f8; }
.modal-tab:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.modal-tab[aria-selected="true"] { border-bottom-color: var(--brand); background: #fff; }
.tab-name { display: block; font-weight: 700; }
.modal-tab[aria-selected="true"] .tab-name { color: var(--brand); }
.tab-sum { display: block; font-size: .85rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tab-alert { display: inline-flex; align-items: center; justify-content: center; width: 1.1rem; height: 1.1rem; margin-left: .4rem; border-radius: 50%; background: var(--err); color: #fff; font-size: .75rem; vertical-align: .1em; }
.tab-alert[hidden] { display: none; }
.tab-panel { padding-top: .25rem; }
.tab-panel:focus-visible { outline: 2px solid var(--brand); outline-offset: 4px; }
.declare { display: flex; align-items: center; gap: .5rem; margin: 0; }
.declare input { width: 1.1rem; height: 1.1rem; }
.modal-error { background: var(--err-bg); color: var(--err); padding: .6rem .8rem; border-radius: 6px; margin: .6rem 0 0; }
.field-error { color: var(--err); font-size: .875rem; margin: .3rem 0 0; }
[aria-invalid="true"] { border-color: var(--err) !important; outline: 1px solid var(--err); }

.preview { position: sticky; top: 16px; margin-top: 16px; background: #f8f9fa; border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.preview-label { margin: 0 0 .5rem; font-weight: 700; }
.preview-sketch { display: flex; align-items: center; justify-content: center; min-height: 120px; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 8px; }
.preview-sketch img { transform: scale(1.6); transform-origin: center; margin: 24px 0; }
.preview-wording { list-style: none; margin: .75rem 0 0; padding: 0; font-family: "Liberation Sans", Arial, sans-serif; font-size: .95rem; }

.design-editor { display: flex; flex-wrap: wrap; gap: 12px; margin: .5rem 0 .75rem; }
.design-col { flex: 1 1 230px; border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; background: #fcfcfd; }
.design-col-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: .35rem; }
.design-pane { display: grid; grid-template-columns: 1fr; gap: 6px; padding: .5rem 0; border-top: 1px dashed var(--line); }
.design-pane .pane-label { margin: 0; font-weight: 600; font-size: .9rem; }
.design-pane .link { justify-self: start; }

.question-rows { display: grid; gap: 4px; }
.question-row { display: grid; grid-template-columns: 220px 1fr auto; gap: 0 14px; align-items: end; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.question-row .link { margin-bottom: .6rem; }

@media (max-width: 860px) {
    .modal-grid { grid-template-columns: 1fr; }
    .preview { position: static; }
    /* On a narrow screen the sketch sits under the fields, and only where it changes. */
    #opening-dialog:not([data-tab="size"]):not([data-tab="design"]) .preview { display: none; }
    .question-row { grid-template-columns: 1fr; }
    .sheet-bar { position: static; padding: 14px 16px; }
    .doc { padding: 16px; }
}
@media (max-width: 560px) {
    .modal-tabs { grid-template-columns: 1fr 1fr; padding: 0 8px; }
    .row-ref { grid-template-columns: minmax(0, 1fr) 6rem; }
    .preview-sketch img { transform: scale(1.25); margin: 12px 0; }
    dialog.modal, dialog.modal.tabbed { width: 100vw; max-width: 100vw; max-height: 100vh; max-height: 100dvh; border-radius: 0; }
    dialog.modal[open] > form { max-height: 100vh; max-height: 100dvh; }
    dialog.modal.tabbed[open] > form { height: 100vh; height: 100dvh; }   /* dvh keeps Save above the phone's browser bar */
}
