:root {
  --background: #eef0f5; --ink: #172038; --muted: #4e596d; --surface: #fff; --sunken: #f6f7fa;
  --line: #d2d6e0; --line-strong: #858da2; --accent: #6240d9; --link: #5938c9; --teal: #137a6c;
  --selected: #ebe6fd; --selected-line: #b9abf1;
  --tone-over: #dc4c4c; --tone-soon: #e0a526; --tone-open: #3b82f6; --tone-done: #16ac8b;
  --radius: 10px;
  --step: 1rem;
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--background);
}
:root[data-theme="dark"] {
  --background: #080a16; --ink: #f0f2ff; --muted: #b3bbd2; --surface: #161a2e; --sunken: #11142a;
  --line: #323a5a; --line-strong: #717a9e; --accent: #7854ea; --link: #bca9ff; --teal: #6cdecb;
  --selected: #2a2352; --selected-line: #6a56c8;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--background); color: var(--ink); -webkit-font-smoothing: antialiased; }
a { color: var(--link); }
:where(button, a, input, select, textarea, summary, tr, [tabindex]):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { margin: 0 0 .5rem; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; margin-top: 1.25rem; }
.muted { color: var(--muted); }
.fineprint { color: var(--muted); font-size: .875rem; }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.loading, .empty { padding: 2rem var(--step); color: var(--muted); }
.empty { border: 1px dashed var(--line-strong); border-radius: var(--radius); text-align: center; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .6rem var(--step); background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: .9rem; }
.brand-name { font-weight: 700; font-size: 1.1rem; letter-spacing: -0.02em; }
.brand-mark { display: inline-grid; place-items: center; width: 1.9rem; height: 1.9rem; border-radius: 9px; background: linear-gradient(145deg, #b5eee1, #7860e5); color: #122b3b; font-weight: 700; }
.tenant { color: var(--muted); }
.who { display: flex; align-items: center; gap: .75rem; font-size: .9375rem; flex-wrap: wrap; }
.role { color: var(--muted); }

.freshness { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: .75rem; padding: .75rem var(--step); }
.freshness-empty { margin: 0; }
.fresh { padding: .65rem .9rem .7rem; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--line-strong); border-radius: var(--radius); }
.fresh-unit strong { font-size: 1.05rem; }
.fresh-unit span { color: var(--muted); }
.fresh-state { font-weight: 600; margin-top: .1rem; }
.fresh-detail { font-size: .875rem; color: var(--muted); }
.fresh-current { border-left-color: var(--tone-done); }
.fresh-overdue { border-left-color: var(--tone-soon); background: color-mix(in srgb, var(--tone-soon) 8%, var(--surface)); }
.fresh-failed_since_last_success { border-left-color: var(--tone-over); background: color-mix(in srgb, var(--tone-over) 8%, var(--surface)); }
.fresh-error { display: block; color: var(--ink); }

.tabs { display: flex; gap: .25rem; padding: 0 var(--step); background: var(--surface); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { padding: .75rem .9rem .65rem; color: var(--muted); text-decoration: none; border-bottom: 3px solid transparent; white-space: nowrap; font-weight: 550; }
.tab:hover { color: var(--ink); }
.tab-active { color: var(--link); font-weight: 650; border-bottom-color: var(--accent); }

.view { padding: var(--step); }
.view:focus { outline: none; }

.toast { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin: var(--step) var(--step) 0; padding: .65rem .9rem; border-radius: var(--radius); border: 1px solid color-mix(in srgb, var(--tone-done) 40%, transparent); background: color-mix(in srgb, var(--tone-done) 12%, var(--surface)); }
.toast[hidden] { display: none; }
.toast-error { border-color: color-mix(in srgb, var(--tone-over) 45%, transparent); background: color-mix(in srgb, var(--tone-over) 12%, var(--surface)); }
.toast .button { flex-shrink: 0; }
.notice { padding: .6rem .8rem; border-radius: var(--radius); background: color-mix(in srgb, var(--tone-open) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--tone-open) 40%, transparent); }
.notice-error { background: color-mix(in srgb, var(--tone-over) 12%, var(--surface)); border-color: color-mix(in srgb, var(--tone-over) 45%, transparent); color: var(--ink); }

.queue-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: .75rem 1.5rem; margin-bottom: .75rem; }
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .6rem .9rem; }
.field { display: flex; flex-direction: column; gap: .25rem; }
.field-label { font-size: .875rem; color: var(--muted); }
input, select, textarea, .button { font: inherit; color: var(--ink); }
input:not([type=checkbox]):not([type=file]), select, textarea { background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); padding: .4rem .6rem; min-height: 2.4rem; }
input[type=file] { font-size: .9375rem; }
textarea { resize: vertical; }
.counts { display: flex; gap: 1.1rem; margin: 0; font-size: .875rem; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 2.4rem; padding: .45rem 1rem; border-radius: var(--radius); border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; text-decoration: none; font-weight: 600; font-size: .9375rem; }
.button:not([disabled]):hover { border-color: var(--link); box-shadow: 0 3px 14px var(--selected); }
.button[disabled] { opacity: .65; cursor: not-allowed; }
.button-primary { background: linear-gradient(145deg, #7e58ec, #5d38c4); border-color: #a28ae4; color: #fff; }
.button-primary:not([disabled]):hover { border-color: #a28ae4; }
.button-quiet { background: transparent; border-color: var(--line); }
.button-small { min-height: 2rem; padding: .3rem .75rem; font-size: .8125rem; }

.split-list { overflow-x: auto; }
.grid { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; font-size: .875rem; }
.grid th { white-space: nowrap; text-align: left; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: .6rem .7rem; background: color-mix(in srgb, var(--ink) 4%, var(--surface)); border-bottom: 1px solid var(--line-strong); }
.grid td { padding: .6rem .7rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid tbody tr[tabindex] { cursor: pointer; }
.grid tbody tr[tabindex]:hover td { background: color-mix(in srgb, var(--tone-open) 6%, var(--surface)); }
.grid tbody tr.row-selected td { background: var(--selected); }
.grid tr.row-done td { color: var(--muted); }
.grid tr.row-done .person { font-weight: 500; text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 60%, transparent); }
.person { font-weight: 600; white-space: nowrap; }
.ident { font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; margin-top: .15rem; }
.change { font-size: .75rem; color: var(--ink); font-weight: 600; margin-top: .25rem; }
.change::before { content: ""; display: inline-block; width: .5rem; height: .5rem; border-radius: 50%; background: var(--tone-over); margin-right: .35rem; }
.change-quiet { color: var(--muted); font-weight: 400; }
.change-quiet::before { background: var(--line-strong); }

.status-cell { display: inline-flex; flex-wrap: wrap; gap: .3rem; }
.pill { display: inline-block; white-space: nowrap; font-size: .75rem; font-weight: 600; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); background: var(--sunken); color: var(--ink); }
.pill-new, .pill-in_progress, .tone-open { background: color-mix(in srgb, var(--tone-open) 13%, transparent); border-color: color-mix(in srgb, var(--tone-open) 40%, transparent); }
.pill-waiting, .tone-soon { background: color-mix(in srgb, var(--tone-soon) 20%, transparent); border-color: color-mix(in srgb, var(--tone-soon) 50%, transparent); }
.pill-completed, .pill-run-published, .tone-done { background: color-mix(in srgb, var(--tone-done) 15%, transparent); border-color: color-mix(in srgb, var(--tone-done) 40%, transparent); }
.pill-reopened, .pill-run-failed, .tone-over { background: color-mix(in srgb, var(--tone-over) 16%, transparent); border-color: color-mix(in srgb, var(--tone-over) 45%, transparent); }
.pill-run-superseded { color: var(--muted); }

.split { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--step); align-items: start; }
.divider { display: none; }
@media (min-width: 1280px) {
  .split-open { grid-template-columns: minmax(0, var(--list-share, 65fr)) 12px minmax(340px, var(--panel-share, 35fr)); gap: .4rem; }
  .split-open .divider { display: block; align-self: stretch; cursor: col-resize; border-radius: 6px; position: relative; min-height: 4rem; }
  .split-open .divider::after { content: ""; position: absolute; top: 0; bottom: 0; left: 5px; width: 2px; border-radius: 2px; background: var(--line); }
  .split-open .divider:hover::after, .split-open .divider:focus-visible::after { background: var(--accent); }
  .panel { position: sticky; top: var(--step); max-height: calc(100vh - 2 * var(--step)); overflow-y: auto; }
}
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: var(--step) calc(var(--step) * 1.25); }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.panel-head h2 { margin-bottom: .1rem; }
.facts { display: grid; grid-template-columns: minmax(0, max-content) minmax(0, 1fr); gap: .4rem 1rem; margin: 1rem 0; }
.fact { display: contents; }
.fact dt { color: var(--muted); font-size: .875rem; overflow-wrap: anywhere; }
.fact dd { margin: 0; overflow-wrap: anywhere; }
.facts-compact { font-size: .9375rem; }
.actions { border-top: 1px solid var(--line); padding-top: .9rem; }
.action-buttons { display: flex; flex-wrap: wrap; gap: .5rem; }
.mini-form { display: grid; gap: .6rem; margin-top: .9rem; padding: .9rem; background: var(--sunken); border: 1px solid var(--line); border-radius: var(--radius); }
.mini-form h3 { margin: 0; }
.mini-form .button-primary { justify-self: start; }
.check { display: flex; gap: .4rem; align-items: center; font-size: .9375rem; }
.history { border-top: 1px solid var(--line); margin-top: 1rem; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: .5rem 0 .5rem .8rem; border-left: 2px solid var(--line); }
.timeline li + li { margin-top: .1rem; }
.note { margin: .25rem 0 0; white-space: pre-wrap; }
.plain { padding-left: 1.1rem; margin: .25rem 0; }

.block { margin-bottom: 1.75rem; }
.upload { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: var(--step) calc(var(--step) * 1.25); max-width: 60rem; }
.upload-fields { display: flex; flex-wrap: wrap; gap: .75rem 1.25rem; margin: .75rem 0 1rem; }
.steps { margin: 1rem 0 0; padding-left: 1.3rem; }
.step { padding: .3rem 0; }
.step-label { font-weight: 600; margin-right: .6rem; }
.step-state { font-weight: 600; }
.step-running .step-state::before, .step-done .step-state::before, .step-failed .step-state::before { content: ""; display: inline-block; width: .55rem; height: .55rem; border-radius: 50%; margin-right: .35rem; }
.step-running .step-state::before { background: var(--tone-soon); }
.step-done .step-state::before { background: var(--tone-done); }
.step-failed .step-state::before { background: var(--tone-over); }
.step-extra { margin-top: .25rem; color: var(--muted); }
.errors li::marker { color: var(--tone-over); }

.signin { min-height: 100vh; display: grid; place-items: center; padding: var(--step); }
.signin-card { max-width: 32rem; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 2rem; }
.signin-card p { max-width: 60ch; }
.signin-card .button { margin: .5rem 0 .25rem; }

@media (max-width: 700px) {
  .top { flex-wrap: wrap; }
  .grid, .grid tbody, .grid tr, .grid td { display: block; width: 100%; }
  .grid { border: 0; background: none; border-radius: 0; overflow: visible; }
  .grid thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .grid tbody tr { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .4rem .9rem; margin-bottom: .6rem; }
  .grid td { border: 0; padding: .3rem 0; }
  .grid td[data-label]::before { content: attr(data-label); display: block; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
  .person { white-space: normal; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
