/* An element with the hidden attribute stays hidden, whatever display its class sets. */
[hidden] { display: none !important; }

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #17191c;
  --muted: #5d6470;
  --border: #dfe3e8;
  --accent: #2f5bd3;
  --accent-soft: #e6edfc;
  --good: #1f7a4d;
  --good-soft: #e3f4ea;
  --warn: #9a5b00;
  --warn-soft: #fbf0dc;
  --bad: #b3261e;
  --bad-soft: #fbe6e4;
  --shadow: 0 10px 30px rgba(20, 24, 31, 0.12);
  --radius: 10px;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121418;
    --surface: #1b1e24;
    --surface-2: #23272f;
    --text: #e8eaee;
    --muted: #9aa2ae;
    --border: #2f343d;
    --accent: #7ea2ff;
    --accent-soft: #1f2a45;
    --good: #6fd19b;
    --good-soft: #17301f;
    --warn: #f0b65a;
    --warn-soft: #33270f;
    --bad: #ff8a80;
    --bad-soft: #3a1b19;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }

.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; }
.brand-mark {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
  background: var(--accent); color: var(--surface); font-size: 12px; letter-spacing: .5px;
}
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.shell { max-width: 1280px; margin: 0 auto; padding: 18px 20px 40px; }
.banner { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; background: var(--warn-soft); color: var(--warn); }

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.metric { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.metric b { display: block; font-size: 24px; font-weight: 600; }
.metric span { color: var(--muted); font-size: 12.5px; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.tab { border: 1px solid transparent; background: none; padding: 5px 10px; border-radius: 999px; cursor: pointer; color: var(--muted); }
.tab[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-soft); font-weight: 600; }
.tab small { opacity: .75; margin-left: 4px; }
.search { display: flex; flex-direction: row; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: 8px; padding: 0 10px; background: var(--surface-2); }
.search input { border: 0; background: transparent; padding: 7px 0; width: 240px; outline: none; }

.table-wrap { overflow-x: auto; }
table.jobs { width: 100%; border-collapse: collapse; }
.jobs th { text-align: left; font-weight: 600; font-size: 12px; color: var(--muted); padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.jobs td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.jobs tbody tr { cursor: pointer; }
.jobs tbody tr:hover { background: var(--surface-2); }
.jobs tbody tr.selected { background: var(--accent-soft); }
.role-title { font-weight: 600; }
.role-sub { color: var(--muted); font-size: 12.5px; }
.empty { padding: 30px; text-align: center; color: var(--muted); }
.footnote { color: var(--muted); font-size: 12px; margin-top: 12px; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--muted); }
.pill-good { background: var(--good-soft); color: var(--good); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-bad { background: var(--bad-soft); color: var(--bad); }
.pill-accent { background: var(--accent-soft); color: var(--accent); }
.pill-muted { background: var(--surface-2); color: var(--muted); }

.btn { border: 1px solid var(--border); background: var(--surface); padding: 6px 12px; border-radius: 8px; cursor: pointer; }
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.btn-primary:hover:not(:disabled) { background: var(--accent); filter: brightness(1.08); }
.btn-danger { color: var(--bad); }
.btn-small { padding: 3px 9px; font-size: 12.5px; }

.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .25); z-index: 8; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(620px, 100vw); z-index: 9;
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow);
  transform: translateX(100%); transition: transform .18s ease; overflow-y: auto;
}
.drawer.open { transform: none; }
.drawer-inner { padding: 18px 20px 40px; }
.drawer h2 { margin: 0 0 2px; font-size: 19px; }
.drawer h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); margin: 22px 0 8px; }
.drawer-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; font-size: 13px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: 13px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.box { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; background: var(--surface-2); }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.row label { flex: 1 1 140px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
input, select, textarea { border: 1px solid var(--border); background: var(--surface); border-radius: 7px; padding: 6px 8px; color: var(--text); }
textarea { resize: vertical; }
.actions-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 10px; }
.task { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.task:last-child { border-bottom: 0; }
.task-meta { color: var(--muted); font-size: 12px; }
.files { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.files li { padding: 4px 0; display: flex; justify-content: space-between; gap: 10px; }
.files span { color: var(--muted); font-size: 12px; }
.error-text { color: var(--bad); font-size: 13px; }
.muted { color: var(--muted); }

dialog { border: 1px solid var(--border); border-radius: 12px; padding: 0; background: var(--surface); color: var(--text); box-shadow: var(--shadow); width: min(620px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, .35); }
.dialog-form { padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.dialog-form h2 { margin: 0; font-size: 18px; }
.hint { margin: 0; color: var(--muted); font-size: 13px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.form-message { margin: 0; font-size: 13px; color: var(--bad); }
.log-dialog { width: min(980px, calc(100vw - 32px)); }
.log-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.log-head div { display: flex; gap: 8px; }
.log-summary { margin: 0; white-space: pre-wrap; font-size: 13px; }
.log { margin: 0; max-height: 60vh; overflow: auto; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px; font: 12px/1.45 Consolas, "Cascadia Mono", monospace; white-space: pre-wrap; word-break: break-word; }

@media (max-width: 720px) {
  .shell { padding: 12px 16px 30px; }
  .topbar { padding: 10px 16px; }
  .search input { width: 100%; }
  .search { flex: 1 1 100%; }
  .grid2 { grid-template-columns: 1fr; }
  .jobs th:nth-child(3), .jobs td:nth-child(3), .jobs th:nth-child(7), .jobs td:nth-child(7) { display: none; }
}

/* Fit section in the drawer */
.fit-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.fit-summary { margin: 8px 0 0; }
.fit h4 { margin: 12px 0 4px; font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.fit-list { margin: 0; padding-left: 18px; }
.fit-list li { margin: 4px 0; }
.fit-source { margin: 10px 0 0; font-size: 12px; overflow-wrap: anywhere; }
.warn-box { border-color: var(--warn); background: var(--warn-soft); }

/* Notes */
.doc-dialog { height: min(92vh, 900px); }
.doc-dialog .dialog-form { height: 100%; box-sizing: border-box; }
.doc-meta { margin: -6px 0 0; font-size: 12px; }
.doc-view { flex: 1; overflow: auto; min-height: 0; padding: 4px 2px; font-size: 14px; line-height: 1.55; }
.doc-view h1 { font-size: 20px; } .doc-view h2 { font-size: 17px; } .doc-view h3 { font-size: 15px; }
.doc-view table { border-collapse: collapse; font-size: 12px; display: block; overflow-x: auto; }
.doc-view th, .doc-view td { border: 1px solid var(--border); padding: 4px 6px; text-align: left; vertical-align: top; }
.doc-view blockquote { margin: 8px 0; padding: 4px 12px; border-left: 3px solid var(--border); color: var(--muted); }
.doc-view pre, .doc-view code { background: var(--surface-2); border-radius: 4px; font-size: 12px; }
.doc-view pre { padding: 8px; overflow-x: auto; }
.doc-text { flex: 1; min-height: 40vh; font: 13px/1.5 ui-monospace, Menlo, Consolas, monospace; padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text); resize: none; }
.doc-append { display: flex; gap: 8px; }
.doc-append input { flex: 1; min-width: 0; }
.notes { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.notes li { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--border); }
.notes button { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-align: left; font: inherit; }
.notes span { color: var(--muted); font-size: 12px; white-space: nowrap; }
@media (max-width: 640px) {
  .doc-dialog { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; }
}

/* Two-step sign-in and new notes */
.mfa { border-top: 1px solid var(--border); padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.mfa h3 { margin: 0; font-size: 14px; }
.mfa-qr { background: #ffffff; padding: 6px; border-radius: 8px; align-self: flex-start; }
.mfa-secret { font-size: 12px; overflow-wrap: anywhere; background: var(--surface-2); padding: 2px 6px; border-radius: 4px; }
.new-note { display: flex; gap: 8px; margin-top: 10px; }
.new-note input { flex: 1; min-width: 0; }
