/* Choose when a report runs. Self-contained: published by the site build through
 * its existing css project, so there is no import to wire.
 *
 * The design tokens are the application's own, copied from
 * projects/ores.web/packages/web/src/styles.css, so the screen reads in the
 * colours the real one uses. The prototype's own chrome -- the banner and the
 * variant bar -- is deliberately unlike the design on trial. */

:root {
    --bg: #121214;
    --panel: #1a1a1e;
    --panel-2: #26262b;
    --line: #30363d;
    --line-soft: #21262d;
    --line-strong: #4a5568;
    --ink: #e3e3e6;
    --ink-dim: #a1a1aa;
    --ink-faint: #71717a;
    --accent: #58a6ff;
    --accent-bright: #8ab4f8;
    --accent-dim: #21262d;
    --ok: #3fb950;
    --warn: #d29922;
    --bad: #f85149;
    --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    --radius: 0.5rem;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 14px/1.5 var(--sans);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-bright); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { margin: 0; text-wrap: balance; letter-spacing: -0.01em; font-weight: 600; }
p { margin: 0; }

.mono { font-family: var(--mono); }
.dim { color: var(--ink-dim); }
.faint { color: var(--ink-faint); }
.hint { color: var(--ink-faint); font-size: 12px; }

/* -------------------------------------------------------------- chrome */
/* The prototype's own chrome, deliberately unlike the design on trial. */

.proto-note {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 60;
    padding: 6px 14px;
    background: repeating-linear-gradient(45deg, #2a2113, #2a2113 10px, #241d11 10px, #241d11 20px);
    border-bottom: 1px solid #4a3a17;
    color: var(--warn);
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.proto-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    background: #0b0e13;
    border-top: 1px solid var(--line);
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.55);
    font-size: 12px;
    max-height: 75vh;
    display: flex;
    flex-direction: column;
}

.proto-bar .bar-line {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    flex-wrap: wrap;
    justify-content: center;
}

.proto-bar button {
    background: none;
    border: 1px solid transparent;
    color: var(--ink-dim);
    font-size: 12px;
    line-height: 1;
    padding: 6px 10px;
    cursor: pointer;
    border-radius: 999px;
}

.proto-bar button:hover { background: var(--panel-2); color: var(--ink); }
.proto-bar button.on { background: var(--accent-dim); color: var(--ink); border-color: var(--line); }
.proto-bar .label { padding: 0 6px; color: var(--ink-dim); white-space: nowrap; }
.proto-bar .label b { color: var(--accent); }
.proto-bar .sep { color: var(--line); padding: 0 2px; }
.proto-bar .tag-prototype {
    border: 1px solid #4a3a17;
    color: var(--warn);
    background: #2a2113;
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.proto-bar .gist {
    flex: 1 1 220px;
    min-width: 0;
    color: var(--ink-dim);
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 6px;
}
.proto-bar .state-panel {
    border-top: 1px solid var(--line-soft);
    overflow-y: auto;
    max-height: 45vh;
    padding: 10px 14px 14px;
}
.proto-bar .state-panel .state-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
    gap: 2px 24px;
    font-size: 12px;
    color: var(--ink-dim);
}
.proto-bar .state-panel .state-grid b { color: var(--ink); font-family: var(--mono); font-weight: 400; }
.proto-bar .state-panel .state-note { color: var(--ink-faint); margin-top: 6px; font-size: 12px; }
.proto-bar .state-panel ol {
    margin: 6px 0 0;
    padding: 0;
    list-style: none;
    font-family: var(--mono);
    font-size: 12px;
    color: var(--ink-dim);
}

/* --------------------------------------------------------------- shell */

.shell { padding-top: 28px; padding-bottom: 8rem; min-height: 100vh; display: flex; flex-direction: column; }

.appheader { border-bottom: 1px solid var(--line); background: var(--bg); }
.appheader-inner {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    max-width: 1200px;
    margin: 0 auto;
    min-width: 0;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.brand .mark {
    width: 26px;
    height: 26px;
    border-radius: 7px;
    background: linear-gradient(140deg, var(--accent), #2f6fbf);
    display: grid;
    place-items: center;
    font-size: 13px;
    font-weight: 700;
    color: #06121f;
}
.brand .name { font-size: 13px; font-weight: 600; letter-spacing: -0.01em; }
.appnav { display: flex; align-items: center; gap: 2px; margin-left: 8px; min-width: 0; overflow-x: auto; }
.appnav a {
    color: var(--ink-dim);
    font-size: 13px;
    padding: 6px 10px;
    border-radius: var(--radius);
    white-space: nowrap;
}
.appnav a:hover { background: var(--panel-2); color: var(--ink); }
.appnav a.here { background: var(--panel-2); color: var(--ink); }
.modechip {
    margin-left: auto;
    font-size: 11px;
    letter-spacing: 0.04em;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 3px 10px;
    color: var(--ink-dim);
    white-space: nowrap;
}

main { flex: 1; max-width: 1200px; width: 100%; margin: 0 auto; padding: 22px 20px 0; display: grid; gap: 18px; align-content: start; }

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

.pagehead { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 16px; }
.pagehead h1 { font-size: 22px; }
.pagehead .lede { color: var(--ink-dim); margin-top: 4px; max-width: 76ch; font-size: 14px; }
.pagehead .actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pagehead .updated { color: var(--ink-faint); font-size: 12px; }

.crumbs { font-size: 12px; color: var(--ink-faint); display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 22px; }

.sectionhead { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.sectionhead h2 { font-size: 17px; }
.sectionhead .meta { display: flex; align-items: center; gap: 8px; color: var(--ink-faint); font-size: 12px; flex-wrap: wrap; }

.notice {
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 13px;
    background: var(--bg);
    color: var(--ink-dim);
}
.notice.warn { border-color: #6b4e12; background: #2a2008; color: #f2cc60; }
.notice.err { border-color: #7a2a28; background: #2a1414; color: #ffb4ad; }
.notice b { color: inherit; }

.tag {
    display: inline-block;
    border-radius: 999px;
    border: 1px solid var(--line);
    color: var(--ink-dim);
    padding: 1px 8px;
    font-size: 11px;
    line-height: 1.5;
    white-space: nowrap;
}
.tag.accent { border-color: rgba(88, 166, 255, 0.5); background: rgba(88, 166, 255, 0.1); color: var(--accent-bright); }
.tag.warn { border-color: rgba(210, 153, 34, 0.5); background: rgba(210, 153, 34, 0.1); color: var(--warn); }
.tag.muted { border-color: var(--line-soft); color: var(--ink-faint); }
.tag.ok { border-color: rgba(63, 185, 80, 0.5); background: rgba(63, 185, 80, 0.1); color: var(--ok); }

.btn {
    border: 1px solid var(--line);
    background: var(--panel-2);
    color: var(--ink);
    border-radius: 6px;
    padding: 6px 12px;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}
.btn:hover { border-color: var(--line-strong); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #06121f; font-weight: 600; }
.btn.ghost { background: none; border-color: transparent; color: var(--ink-dim); }
.btn.ghost:hover { color: var(--ink); background: var(--panel-2); }
.btn.small { font-size: 12px; padding: 4px 9px; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn.linklike { background: none; border-color: var(--line); text-decoration: none; display: inline-block; }

/* -------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
    text-align: left;
    font-weight: 500;
    color: var(--ink-faint);
    font-size: 12px;
    padding: 6px 12px 6px 0;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
td {
    padding: 9px 12px 9px 0;
    border-bottom: 1px solid var(--line-soft);
    vertical-align: top;
}
td:last-child, th:last-child { padding-right: 0; }
td.code { font-family: var(--mono); font-size: 12px; }
td.wrap { white-space: normal; }
td.num { text-align: right; font-family: var(--mono); }
tr.editorrow td { padding: 0 0 14px; background: var(--bg); }
tr.unreachable td { color: var(--ink-faint); }
.cellgroup { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rowfoot { color: var(--ink-faint); font-size: 12px; margin-top: 12px; }
.reportname { color: var(--ink); font-weight: 500; }
.reportid { display: block; color: var(--ink-faint); font-size: 11px; font-family: var(--mono); }

/* --------------------------------------------------------------- grid */

.statgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 12px 32px; }
.statgrid .lbl { display: block; color: var(--ink-faint); font-size: 12px; margin-bottom: 4px; }
.statgrid .val { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 14px; }

.gaps dl { margin: 0; display: grid; gap: 14px; font-size: 13px; }
.gaps dt { color: var(--ink); font-weight: 600; margin-bottom: 2px; }
.gaps dd { margin: 0; color: var(--ink-dim); max-width: 92ch; }

.kv { width: 100%; border-collapse: collapse; font-size: 13px; }
.kv td { padding: 7px 0; border-bottom: 1px solid var(--line-soft); }
.kv tr:last-child td { border-bottom: none; }
.kv td:first-child { color: var(--ink-faint); width: 42%; }

/* ------------------------------------------------- the schedule editor */
/* One editor, three hosts: a report row in A, a schedule row in B, and the
 * panel under the grid in C. The fields and the preview are the same. */

.sched-edit { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); padding: 14px 16px; display: grid; gap: 12px; }
.sched-edit .fields { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-end; }
.field label { display: block; color: var(--ink-faint); font-size: 12px; margin-bottom: 4px; }
.field select, .field input[type="time"] {
    background: var(--panel-2);
    border: 1px solid var(--line);
    color: var(--ink);
    border-radius: 6px;
    padding: 6px 8px;
    font: inherit;
    font-size: 13px;
    min-width: 9rem;
}
.field input[type="time"]:disabled, .field select:disabled { opacity: 0.5; }
.sched-edit .exprline { font-size: 12px; color: var(--ink-dim); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.sched-edit .exprline .mono { color: var(--ink); background: var(--bg); border: 1px solid var(--line-soft); border-radius: 4px; padding: 2px 7px; }
.nextlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; font-family: var(--mono); font-size: 12px; color: var(--ink-dim); }
.nextlist li { display: flex; gap: 8px; align-items: baseline; }
.nextlist li .bullet { color: var(--ink-faint); }
.sched-edit .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.sched-edit .previewhead { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }

.nextfires { display: grid; gap: 4px; }

/* ---------------------------------------------------------- A: on report */

.schedcell .expr { font-family: var(--mono); font-size: 12px; color: var(--ink-dim); }
.schedcell .next { margin-top: 4px; font-family: var(--mono); font-size: 11px; color: var(--ink-faint); }

/* ------------------------------------------------- B: schedule list rows */

.schedrow { display: grid; grid-template-columns: 10.5rem minmax(0, 1fr) auto; gap: 16px; align-items: start; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.schedrow:first-of-type { border-top: 1px solid var(--line-soft); }
.schedrow .when { font-family: var(--mono); font-size: 13px; color: var(--ink); }
.schedrow .when .rel { display: block; color: var(--ink-faint); font-size: 11px; font-family: var(--sans); }
.schedrow .which .name { color: var(--ink); font-weight: 500; }
.schedrow .which .detail { color: var(--ink-faint); font-size: 12px; margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.schedrow .rowacts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.schedrow .host { grid-column: 1 / -1; }
.nexthead { display: flex; gap: 10px; flex-wrap: wrap; align-items: baseline; font-size: 13px; color: var(--ink-dim); padding: 2px 0 10px; border-bottom: 1px solid var(--line-soft); }
.nexthead b { color: var(--ink); font-weight: 600; }

.tray { display: grid; gap: 0; }
.tray-item { border-bottom: 1px solid var(--line-soft); padding: 2px 0 10px; }
.tray-item:last-child { border-bottom: none; }
.tray-editor { margin-top: 10px; }
.trayrow { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 9px 0; }
.trayrow .name { color: var(--ink); font-weight: 500; }
.trayrow .detail { color: var(--ink-faint); font-size: 12px; }

/* ---------------------------------------------------------- C: calendar */

.cal { display: grid; gap: 0; font-size: 12px; }
.cal-head, .cal-row { display: grid; grid-template-columns: 3.4rem repeat(7, minmax(0, 1fr)); gap: 1px; }
.cal-head { margin-bottom: 1px; }
.cal-head span { color: var(--ink-faint); font-size: 11px; padding: 0 0 4px 6px; letter-spacing: 0.03em; }
.cal-head span .dom { color: var(--ink-dim); }
.cal-row .cal-h { color: var(--ink-faint); font-family: var(--mono); font-size: 10px; padding: 2px 6px 0 0; text-align: right; }
.cal-row .cell { min-height: 20px; border-top: 1px solid var(--line-soft); border-left: 1px solid var(--line-soft); padding: 2px 4px; display: flex; gap: 3px; flex-wrap: wrap; align-items: flex-start; min-width: 0; }
.cal-row .cell.we { background: rgba(255, 255, 255, 0.018); }
.cal-row:last-child .cell { border-bottom: 1px solid var(--line-soft); }
.chip {
    display: inline-block;
    border: 1px solid rgba(88, 166, 255, 0.45);
    background: rgba(88, 166, 255, 0.12);
    color: var(--accent-bright);
    border-radius: 4px;
    padding: 0 5px;
    font-size: 10px;
    line-height: 15px;
    font-family: var(--mono);
    letter-spacing: 0.02em;
    cursor: pointer;
    white-space: nowrap;
}
.chip:hover { background: rgba(88, 166, 255, 0.24); }
.chip.week { border-color: rgba(210, 153, 34, 0.5); background: rgba(210, 153, 34, 0.12); color: #f2cc60; }
.chip.intra { border-color: var(--line); background: var(--panel-2); color: var(--ink-dim); }
.cal-note { display: flex; gap: 10px; flex-wrap: wrap; align-items: baseline; font-size: 12px; color: var(--ink-dim); margin-bottom: 10px; }
.cal-note.legend { font-size: 11px; color: var(--ink-faint); margin-bottom: 12px; gap: 4px 16px; }
.cal-note.legend .item { display: inline-flex; gap: 5px; align-items: center; }
.cal-note.legend .chip { cursor: default; }
.cal-foot { margin-top: 10px; display: flex; gap: 10px; flex-wrap: wrap; align-items: baseline; color: var(--ink-faint); font-size: 12px; }

.key { display: grid; grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr)); gap: 10px 28px; margin-top: 4px; }
.keyrow { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 10px; align-items: baseline; font-size: 12px; padding: 6px 0; border-bottom: 1px solid var(--line-soft); }
.keyrow .kcode { font-family: var(--mono); font-size: 11px; color: var(--accent-bright); }
.keyrow .kname { color: var(--ink); }
.keyrow .kdetail { color: var(--ink-faint); font-size: 11px; display: block; }
.keyrow .keyacts { grid-column: 2; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-start; }

/* ------------------------------------------------------------- reach */

.reach { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.reach h3 { font-size: 13px; color: var(--ink); margin-bottom: 6px; }
.reach ul { margin: 0; padding-left: 18px; font-size: 13px; color: var(--ink-dim); display: grid; gap: 4px; }
.reach .does h3 { color: var(--ok); }
.reach .not h3 { color: var(--ink-faint); }

/* ------------------------------------------------------------ dialog */

.backdrop {
    position: fixed;
    inset: 0;
    z-index: 70;
    background: rgba(4, 6, 10, 0.72);
    display: grid;
    place-items: center;
    padding: 24px;
}
.dialog { background: var(--panel); border: 1px solid var(--line-strong); border-radius: 10px; padding: 20px 22px; width: min(46rem, 100%); box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6); display: grid; gap: 14px; }
.dialog h2 { font-size: 16px; }
.dialog .confirmline { font-size: 13px; color: var(--ink-dim); }
.dialog .confirmline b { color: var(--ink); font-weight: 500; }
.dialog .actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.dialog dl { margin: 0; display: grid; gap: 8px; font-size: 13px; }
.dialog dt { color: var(--ink-faint); font-size: 12px; }
.dialog dd { margin: 0; color: var(--ink); }

@media (max-width: 900px) {
    .reach { grid-template-columns: 1fr; }
    .schedrow { grid-template-columns: 1fr; }
    .schedrow .rowacts { justify-content: flex-start; }
}

@media (max-width: 820px) {
    .appheader-inner { padding: 12px 14px; }
    .appnav { display: none; }
}
