/* Unity SDTM in Unity's Clinic theme (the owner, 2026-12-04: "SDTM service should use same UI theme (clinic theme) as
   unity"). The values are Clinic's own, from apps/unity/service/app/static/clinic.css; a test keeps the two the same.
   Loaded last on the home page and on the skill's gate page, whose own file stays unchanged: only its colour, font and
   corner variables are set here. The colours that say a status (a question, passed, failed) stay the skill's. */
:root, :root[data-theme="light"] {
  --bg: #f6f7f5; --panel: #ffffff; --panel-2: #f1f4f3;
  --ink: #1c2326; --ink-2: #1c2326; --muted: #59636b;
  --line: #e7eae8; --line-2: #e7eae8; --line-strong: #d3d8d5;
  --accent: #0f766e; --accent-soft: #e2f1ee; --accent-ink: #ffffff;
  --choice: #0f766e; --choice-soft: #e2f1ee;
  --ai: #7c3aed; --ai-soft: #f1ebfd; --on-ai: #ffffff;
  --brand: linear-gradient(135deg, #2dd4bf, #0f766e);
  --shadow: 0 1px 2px rgba(20, 30, 32, .04), 0 6px 20px rgba(20, 30, 32, .05);
  --shadow-lg: 0 16px 48px rgba(20, 30, 32, .16);
  --r: 14px;
  --font: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, "Helvetica Neue", Arial, sans-serif;
}
:root[data-theme="dark"] {
  --bg: #0f1416; --panel: #171d20; --panel-2: #20282c;
  --ink: #e6eaec; --ink-2: #e6eaec; --muted: #a3adb5;
  --line: #262f33; --line-2: #262f33; --line-strong: #36424a;
  --accent: #4fd1c5; --accent-soft: #143531; --accent-ink: #062825;
  --choice: #4fd1c5; --choice-soft: #143531;
  --ai: #a78bfa; --ai-soft: #251c3d; --on-ai: #1b1033;
  --shadow: 0 0 0 transparent; --shadow-lg: 0 16px 48px rgba(0, 0, 0, .55);
}
body { font-family: var(--font); }
.brand .logo, h1::before { background: var(--brand); }
section, .cardbox, .qcard, .stat, dialog, .modal .box { border-radius: var(--r); }
button.primary, .btn.primary { color: var(--accent-ink); }
button.primary:hover, .btn.primary:hover { background: var(--accent); filter: brightness(.93); }
button:hover, .btn:hover { border-color: var(--line-strong); }
select:focus, input:focus, textarea:focus { outline-color: var(--accent-soft); }
/* this service's bar on a gate page: Clinic's white top bar, not a dark one */
.sdtm-bar { background: var(--panel); color: var(--ink); border-bottom: 1px solid var(--line); font-family: var(--font); }
.sdtm-bar a { color: var(--accent); }
.sdtm-st { color: #fff; }
.sdtm-btn { font-family: var(--font); border-color: var(--line-strong); border-radius: 8px; background: var(--panel); color: var(--ink); }
.sdtm-btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
/* the SDTM AI Coworker: Clinic's neutral surfaces, the AI colour only as an accent (a top line, a left edge, the AI's
   name), never a fill (the owner, 2026-12-04) */
.cw-open { background: var(--panel); border-color: var(--line-strong); border-left: 3px solid var(--ai); color: var(--ink); font-family: var(--font); }
.cw-open:hover, .cw-open:focus-visible { border-color: var(--ai); color: var(--ai); }
.cw { border-color: var(--line-strong); border-top-color: var(--ai); border-radius: 0; background: var(--panel); color: var(--ink);
      font-family: var(--font); }
.cw-head, .cw form { border-color: var(--line); }
.cw-head .note, .cw-turns .meta { color: var(--muted); }
.cw-turns .ai { border-left-color: var(--ai); }
.cw textarea { background: var(--panel); color: var(--ink); border-color: var(--line-strong); border-radius: 8px; }

/* the home page's top: the study menu at the top middle (Unity's Clinic study button and its list), Ask AI at the
   right of the subtitle */
header.band .wrap { position: relative; }
.st-pick { position: absolute; top: -6px; left: 50%; transform: translateX(-50%); height: 24px; display: inline-flex; align-items: center;
           gap: 4px; max-width: 34vw; padding: 0 6px; border: 0; background: none; font: 500 12px var(--font); color: var(--ink); cursor: pointer; }
.st-pick span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-pick i { font-style: normal; font-size: 9px; color: var(--muted); }
.st-pick:hover, .st-pick:focus-visible { color: var(--accent); text-decoration: underline; border: 0; }
.st-pick[hidden], .st-menu[hidden] { display: none; }
.st-menu { position: fixed; top: 34px; left: 50%; transform: translateX(-50%); z-index: 1100; min-width: 220px; max-width: 420px;
           max-height: 70vh; overflow-y: auto; padding: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
           box-shadow: 0 8px 28px rgba(0,0,0,.14); font-family: var(--font); }
.st-head { padding: 6px 12px; font-size: 12px; color: var(--muted); }
.st-mi { display: flex; align-items: baseline; gap: 10px; width: 100%; border: 0; background: none; text-align: left; padding: 9px 12px;
         border-radius: 10px; color: var(--ink); font-size: 14px; cursor: pointer; }
.st-mi:hover { background: var(--bg); border: 0; }
.st-mi.on { color: var(--accent); font-weight: 600; }
.st-mi.line { border-top: 1px solid var(--line); border-radius: 0 0 10px 10px; margin-top: 4px; }
.st-mi small { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.sub-row .subtitle { margin: 0; }
/* the title: its badge and name at the left, Ask AI at the right (three items spread evenly put the name in the middle) */
h1.sub-row { justify-content: flex-start; }
h1.sub-row #cw-slot { margin-left: auto; }
.st-head { text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.st-table { max-height: 60vh; overflow: auto; }
dialog:has(.st-table) { width: min(1100px, 94vw); max-width: 94vw; }
#dlg-form input[type=file] { display: block; margin: 2px 0 10px; font: inherit; }
/* the Studies page, as Unity's: one card with its head, the table, a row of small buttons per study */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; margin: 14px 0; }
.card .ch { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.card .ch h3 { margin: 0; font-size: 15px; }
.tbl-wrap { overflow-x: auto; }
.studies-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.studies-table th { text-align: left; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--line-strong); padding: 6px 8px; white-space: nowrap; }
.studies-table td { border-bottom: 1px solid var(--line); padding: 7px 8px; vertical-align: middle; }
.studies-table th.num, .studies-table td.num { text-align: right; }
.studies-table tr.clickable { cursor: pointer; }
.studies-table tr.clickable:hover td { background: var(--panel-2); }
.studies-table tr.on td { background: var(--accent-soft); }
.studies-table td.sid { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 600; color: var(--accent); }
.studies-table td.nowrap { white-space: nowrap; }
.jbtn { display: inline-block; font-size: 11.5px; padding: 2px 8px; border: 1px solid var(--accent); color: var(--accent); background: var(--panel);
        border-radius: 4px; cursor: pointer; text-decoration: none; font-family: var(--font); }
.jbtn.solid { background: var(--accent); color: var(--accent-ink); font-size: 12px; padding: 3px 10px; }
.jbtn.muted { border-color: var(--line-strong); color: var(--muted); }
.jbtn.danger { border-color: #b3261e; color: #b3261e; }
.badge { display: inline-block; font: 600 10.5px var(--font); padding: 1px 6px; border-radius: 8px; }
.badge.b-ok { background: var(--accent-soft); color: var(--accent); }
#cf-text { width: 100%; font: inherit; padding: 6px 8px; margin-top: 4px; }
/* the AI status panel (the job) in Clinic: a white card with Clinic's corners, shadow, font and lines; the AI's own
   working box in the AI colour; a status by its pill only (the owner, 2026-12-04) */
.sdtm-job { background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r);
            box-shadow: var(--shadow-lg); font: 400 13px/1.45 var(--font); padding: 12px 14px; }
.sdtm-job.ok { background: var(--panel); color: var(--ink); border-color: var(--accent); }
.sdtm-job.bad { background: var(--panel); color: var(--ink); border-color: #dc2626; }
/* waiting for the person (a token warning, a question): amber, so it is told apart from the AI working and from a failure
   at a glance (the owner, 2026-12-04) */
.sdtm-job.wait { background: #fffbeb; color: var(--ink); border: 2px solid #f59e0b; box-shadow: 0 0 0 4px rgba(245,158,11,.18), var(--shadow-lg); }
.sdtm-job.wait .sj-ask { background: #fef3c7; color: #78350f; border-radius: 8px; padding: 8px 10px; font-weight: 600; }
.sdtm-job.wait .sdtm-btn.primary { background: #d97706; border-color: #d97706; color: #fff; }
:root[data-theme="dark"] .sdtm-job.wait { background: #2a1f08; border-color: #f59e0b; }
:root[data-theme="dark"] .sdtm-job.wait .sj-ask { background: #3a2a0a; color: #fcd34d; }
.sj-head { font-weight: 600; color: var(--ink); }
.sj-state { background: var(--panel-2); color: var(--muted); font-weight: 600; }
.sj-state.s-running { background: var(--ai-soft); color: var(--ai); }
.sj-state.s-done { background: var(--accent-soft); color: var(--accent); }
.sj-state.s-failed, .sj-state.s-stopped { background: #fdecec; color: #b91c1c; }
.sj-time { color: var(--muted); font-weight: 500; }
.sj-now { color: var(--ink); }
.sj-bar { background: var(--panel-2); }
.sj-bar i { background: var(--accent); }
.sj-ai { background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--ai); border-radius: 10px; }
.sj-ai-head b { color: var(--ai); }
.sj-tail { color: var(--muted); }
.sdtm-job .note { color: var(--muted); }
.sdtm-job details summary { color: var(--accent); cursor: pointer; }
.sj-steps { color: var(--ink); }
:root[data-theme="dark"] .sj-state.s-failed, :root[data-theme="dark"] .sj-state.s-stopped { background: #3a1616; color: #fca5a5; }
.sj-state.s-waiting, .sj-state.s-for_you { background: #fef3c7; color: #92400e; }
:root[data-theme="dark"] .sj-state.s-waiting, :root[data-theme="dark"] .sj-state.s-for_you { background: #3a2a0a; color: #fcd34d; }
/* the dialogs after Approve, in Clinic */
.sb-next-card { background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r);
                box-shadow: var(--shadow-lg); font: 400 14px/1.5 var(--font); }
