/* Managed Analytics portal. Plain CSS. Light and dark follow the device, and the button can override.
   Nothing here needs inline styles, so the page can run under a strict content security policy. */
:root {
  --bg: #f4f6f9; --card: #ffffff; --ink: #121820; --muted: #566171; --line: #e1e5eb; --brand: #1d5fa3;
  --brand-ink: #ffffff; --soft: #eaf1f9; --good: #1b7a45; --good-bg: #e3f4ea; --warn: #8a5a00; --warn-bg: #fff1d6;
  --bad: #a3262a; --bad-bg: #fde8e8; --radius: 12px; --shadow: 0 1px 2px rgba(15, 25, 40, .06), 0 4px 14px rgba(15, 25, 40, .05);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1319; --card: #171d26; --ink: #e8edf3; --muted: #9aa6b5; --line: #29323f; --brand: #5aa0e6;
    --brand-ink: #0b1118; --soft: #1b2634; --good: #62c58a; --good-bg: #16301f; --warn: #f0b955; --warn-bg: #33270f;
    --bad: #f28b8e; --bad-bg: #3a1a1c; --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}
:root[data-theme="dark"] {
  --bg: #0e1319; --card: #171d26; --ink: #e8edf3; --muted: #9aa6b5; --line: #29323f; --brand: #5aa0e6;
  --brand-ink: #0b1118; --soft: #1b2634; --good: #62c58a; --good-bg: #16301f; --warn: #f0b955; --warn-bg: #33270f;
  --bad: #f28b8e; --bad-bg: #3a1a1c; --shadow: 0 1px 2px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0; }
.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 16px; }
main { flex: 1; padding-top: 20px; padding-bottom: 40px; outline: none; }
.skip { position: absolute; left: -999px; top: 0; background: var(--brand); color: var(--brand-ink); padding: 8px 12px; z-index: 60; }
.skip:focus { left: 8px; top: 8px; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

/* header */
.head { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.head-row { display: flex; align-items: center; gap: 14px; min-height: 60px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.brand { font-weight: 800; letter-spacing: -.01em; text-decoration: none; color: var(--ink); }
.brand small { display: block; font-weight: 500; font-size: .72rem; color: var(--muted); letter-spacing: 0; }
.nav { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; }
.nav a { text-decoration: none; color: var(--muted); font-weight: 600; font-size: .92rem; padding: 8px 12px; border-radius: 999px; }
.nav a:hover { background: var(--soft); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--soft); color: var(--brand); }
.who { display: flex; align-items: center; gap: 8px; }
.who-name { font-size: .85rem; color: var(--muted); }
.icon-btn { border: 1px solid var(--line); background: transparent; color: var(--ink); border-radius: 10px; min-width: 38px; min-height: 38px; cursor: pointer; font-size: 1.05rem; }
@media (max-width: 700px) {
  .brand { flex: 1; }
  .nav { order: 3; flex-basis: 100%; flex-wrap: nowrap; overflow-x: auto; }
  .nav a { white-space: nowrap; }
  .who-name { display: none; }
}

/* layout pieces */
.page-head { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: flex-end; justify-content: space-between; margin-bottom: 16px; }
.page-head .sub { color: var(--muted); max-width: 70ch; margin-top: 4px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row.between { justify-content: space-between; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.three { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 860px) { .grid.two, .grid.three { grid-template-columns: 1fr; } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card h2 { margin-bottom: 10px; }
.muted { color: var(--muted); }
.small-text { font-size: .85rem; }
.loading, .empty { color: var(--muted); padding: 18px 0; }
.error { background: var(--bad-bg); color: var(--bad); border-radius: var(--radius); padding: 12px 14px; }
.note { background: var(--soft); border-radius: var(--radius); padding: 12px 14px; font-size: .9rem; color: var(--muted); }
.note b { color: var(--ink); }

/* buttons and forms */
.btn { font: inherit; font-weight: 700; font-size: .92rem; background: var(--brand); color: var(--brand-ink); border: 1px solid var(--brand); border-radius: 10px; padding: 9px 16px; min-height: 40px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
.btn.small { padding: 5px 11px; min-height: 32px; font-size: .84rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label, .field .label { font-size: .78rem; font-weight: 700; color: var(--muted); }
input, select, textarea { font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; min-height: 42px; max-width: 100%; width: 100%; }
textarea { min-height: 90px; resize: vertical; }
.form { display: flex; flex-direction: column; gap: 12px; }
.form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .form .two { grid-template-columns: 1fr; } }
.hint { font-size: .8rem; color: var(--muted); }
.form-error { color: var(--bad); font-size: .9rem; min-height: 1.2em; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { font: inherit; font-weight: 600; font-size: .88rem; border: 0; background: var(--card); color: var(--muted); padding: 8px 14px; min-height: 38px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"], .seg button[aria-selected="true"] { background: var(--soft); color: var(--brand); }

/* chips and bits */
.chip { display: inline-block; border-radius: 999px; padding: 2px 9px; font-size: .74rem; font-weight: 700; white-space: nowrap; }
.chip.good { background: var(--good-bg); color: var(--good); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.mute { background: var(--soft); color: var(--muted); }
.chip.info { background: var(--soft); color: var(--brand); }
.badge { background: var(--brand); color: var(--brand-ink); border-radius: 999px; font-size: .72rem; font-weight: 800; padding: 1px 7px; margin-left: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--muted); margin-right: 6px; }
progress { width: 100%; height: 8px; border-radius: 99px; accent-color: var(--brand); }

/* lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 10px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; }
.list li:last-child { border-bottom: 0; }
.list .main { min-width: 0; flex: 1; }
.list .title { font-weight: 600; overflow-wrap: anywhere; }
.list a { text-decoration: none; }
.list a:hover { text-decoration: underline; }
.feed .who-line { font-weight: 600; }

/* project cards */
.project-card { display: flex; flex-direction: column; gap: 10px; text-decoration: none; color: inherit; }
.project-card:hover { border-color: var(--brand); }
.project-card h3 { overflow-wrap: anywhere; }
.project-card .meta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; font-size: .85rem; color: var(--muted); }

/* board */
.board { display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.column { background: var(--soft); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 140px; }
.column.over { outline: 2px dashed var(--brand); }
.column h3 { display: flex; justify-content: space-between; font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.task { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 6px; cursor: pointer; text-align: left; font: inherit; color: inherit; width: 100%; }
.task:hover { border-color: var(--brand); }
.task .title { font-weight: 600; overflow-wrap: anywhere; }
.task .meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: .78rem; color: var(--muted); }
.task.dragging { opacity: .45; }
.task.overdue { border-left: 4px solid var(--bad); }
.add-task { display: flex; gap: 6px; }
.add-task input { min-height: 38px; }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 16px 0; overflow-x: auto; }
.tabs button { font: inherit; font-weight: 600; background: none; border: 0; border-bottom: 3px solid transparent; padding: 10px 14px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--brand); border-bottom-color: var(--brand); }

/* messages */
.thread { display: flex; flex-direction: column; gap: 10px; max-height: 55vh; overflow-y: auto; padding: 4px 2px; }
.msg { max-width: 80%; background: var(--soft); border-radius: 12px; padding: 8px 12px; align-self: flex-start; }
.msg.mine { background: var(--brand); color: var(--brand-ink); align-self: flex-end; }
.msg .by { font-size: .75rem; opacity: .8; }
.msg .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.composer { display: flex; gap: 8px; align-items: flex-end; margin-top: 12px; }
.composer textarea { min-height: 46px; }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
th { font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* dialog */
dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--ink); padding: 0; width: min(560px, calc(100vw - 24px)); box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
dialog::backdrop { background: rgba(10, 15, 22, .55); }
dialog .dlg { padding: 18px; display: flex; flex-direction: column; gap: 14px; }

/* login */
.login { max-width: 420px; margin: 8vh auto 0; }
.login .card { display: flex; flex-direction: column; gap: 14px; }
.code-input { font-size: 1.8rem; letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; }

/* toasts */
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 80; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); max-width: 340px; font-size: .9rem; }
.toast.bad { background: var(--bad); color: #fff; }
code { font-size: .85em; background: var(--soft); padding: 1px 5px; border-radius: 5px; }
.secret { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--soft); border-radius: 8px; padding: 2px 8px; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.facts dt { color: var(--muted); font-size: .85rem; }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }

.grow { flex: 1; }
.mt { margin-top: 16px; }
.sr { position: absolute; left: -9999px; }
fieldset { border: 0; padding: 0; margin: 0; }
