/* ==========================================================================
   UAT portal styling. Extends the look of the original offline handbook so the
   hosted version feels familiar, with tokens in one place at the top.
   ========================================================================== */
:root {
  --bg: #0f172a; --bg2: #111c33; --panel: #fff; --ink: #0f172a; --muted: #64748b;
  --line: #e2e8f0; --brand: #2563eb; --brand-ink: #1d4ed8; --brand-bg: #eff6ff;
  --ok: #16a34a; --ok-bg: #f0fdf4; --warn: #d97706; --warn-bg: #fffbeb;
  --danger: #dc2626; --danger-bg: #fef2f2; --accent: #7c3aed;
  --shadow: 0 1px 2px rgba(15,23,42,.06), 0 8px 24px rgba(15,23,42,.08);
  --radius: 12px; --sidebar: 300px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

/* The `hidden` attribute must ALWAYS win.
   Browsers implement it as a user-agent rule (`[hidden] { display: none }`), and any
   author rule that sets `display` outranks it — so `.modal { display: grid }` or
   `.btn { display: inline-block }` would keep a hidden element on screen and make
   `element.hidden = true` look broken. This one line keeps the attribute authoritative. */
[hidden] { display: none !important; }
body {
  font-family: "Segoe UI", Roboto, -apple-system, Arial, sans-serif;
  color: var(--ink); background: #f1f5f9; line-height: 1.55;
}
a { color: var(--brand-ink); text-decoration: none; }
code { background: #f1f5f9; border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px;
  font-family: Consolas, monospace; font-size: .92em; }

/* ---------- login ---------- */
body.centered { display: grid; place-items: center; min-height: 100vh;
  background: linear-gradient(160deg, var(--bg), var(--bg2)); }
.authcard { background: #fff; width: 100%; max-width: 400px; border-radius: 16px;
  padding: 32px; box-shadow: 0 20px 60px rgba(2,6,23,.35); }
.authbrand { text-align: center; margin-bottom: 22px; }
.authmark { width: 54px; height: 54px; border-radius: 14px; margin: 0 auto 12px;
  background: var(--brand); color: #fff; display: grid; place-items: center;
  font-weight: 700; letter-spacing: .5px; }
.authbrand h1 { font-size: 20px; margin: 0 0 4px; }
.authfoot { text-align: center; margin: 20px 0 0; font-size: 12px; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
aside { background: linear-gradient(180deg, var(--bg), var(--bg2)); color: #cbd5e1;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.brand { padding: 18px 20px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand h1 { font-size: 15px; margin: 0; color: #fff; letter-spacing: .3px; }
.brand p { margin: 4px 0 0; font-size: 11px; color: #94a3b8; }
.progwrap { padding: 12px 20px; border-bottom: 1px solid rgba(255,255,255,.08); }
.progbar { height: 8px; border-radius: 99px; background: rgba(255,255,255,.12); overflow: hidden; }
.progbar > span { display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, #22c55e, #16a34a); transition: width .3s; }
.progmeta { display: flex; justify-content: space-between; font-size: 11px; color: #94a3b8; margin-top: 6px; }
nav { flex: 1; padding-bottom: 10px; }
.navgroup > .grouphead { padding: 12px 20px 6px; font-size: 10px; letter-spacing: 1.4px;
  text-transform: uppercase; color: #64748b; }
nav a.item { display: flex; align-items: center; gap: 10px; padding: 9px 20px; font-size: 13px;
  color: #cbd5e1; cursor: pointer; border-left: 3px solid transparent; }
nav a.item:hover { background: rgba(255,255,255,.05); color: #fff; }
nav a.item.active { background: rgba(37,99,235,.16); border-left-color: var(--brand); color: #fff; font-weight: 600; }
nav a.item .ic { width: 18px; text-align: center; }
nav a.item .badge { margin-left: auto; font-size: 10px; background: rgba(255,255,255,.1);
  border-radius: 99px; padding: 1px 7px; color: #94a3b8; }
nav a.item.done .badge { background: var(--ok); color: #fff; }
.sidefoot { padding: 14px 20px 18px; border-top: 1px solid rgba(255,255,255,.08); }
.ghostbtn { display: block; width: 100%; padding: 8px; border: 1px solid rgba(255,255,255,.15);
  background: transparent; color: #94a3b8; border-radius: 8px; cursor: pointer;
  font-size: 12px; text-align: center; margin-bottom: 10px; }
.ghostbtn:hover { color: #fff; border-color: #fff; }
.whoami { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: #94a3b8; }
.whoami a { color: #93c5fd; }
.poweredby { margin: 12px 0 0; font-size: 10.5px; color: #64748b; text-align: center; }

main { padding: 0 0 80px; overflow-x: hidden; }
.topbar { position: sticky; top: 0; background: rgba(241,245,249,.94); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line); padding: 12px 40px; z-index: 4;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.topbar .crumb { font-size: 12px; color: var(--muted); }
.topbar .crumb b { color: var(--ink); }
.topactions { display: flex; gap: 8px; flex-wrap: wrap; }
.content { padding: 28px 40px; max-width: 1080px; }

/* ---------- typography blocks ---------- */
.sec-title { font-size: 26px; font-weight: 700; margin: 0 0 4px; display: flex; align-items: center; gap: 12px; }
.sec-intro { color: var(--muted); font-size: 14px; margin: 0 0 22px; max-width: 840px; }
.subhead { font-size: 12px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase;
  color: var(--muted); margin: 26px 0 10px; }
.callout { border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius);
  padding: 14px 16px; margin: 0 0 18px; box-shadow: var(--shadow); font-size: 13.5px; }
.callout.tip { border-left: 4px solid var(--brand); background: var(--brand-bg); }
.callout.warn { border-left: 4px solid var(--warn); background: var(--warn-bg); }
.callout.role { border-left: 4px solid var(--accent); background: #f5f3ff; }

/* ---------- steps ---------- */
.step { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); margin: 0 0 14px; overflow: hidden; }
.step > .head { display: flex; align-items: flex-start; gap: 12px; padding: 15px 18px;
  cursor: pointer; user-select: none; }
.step > .head:hover { background: #f8fafc; }
.step .chk { width: 22px; height: 22px; flex: 0 0 auto; border: 2px solid var(--line);
  border-radius: 6px; display: grid; place-items: center; background: #fff; margin-top: 1px;
  font-size: 14px; color: #fff; }
.step.checked .chk { background: var(--ok); border-color: var(--ok); }
.step .htext { flex: 1; }
.step .htext .t { font-weight: 650; font-size: 15px; }
.step .htext .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.step .role-pill { font-size: 11px; font-weight: 600; color: var(--accent); background: #f5f3ff;
  border: 1px solid #e9d5ff; border-radius: 99px; padding: 2px 10px; white-space: nowrap; }
.step .caret { color: var(--muted); transition: transform .2s; margin-top: 2px; }
.step.open .caret { transform: rotate(90deg); }
.step > .body { display: none; padding: 2px 18px 18px 52px; border-top: 1px solid var(--line); }
.step.open > .body { display: block; }
.field { margin: 12px 0 0; }
.field > .lab { font-size: 11px; letter-spacing: .6px; text-transform: uppercase;
  color: var(--muted); font-weight: 700; margin-bottom: 4px; }
.field ul { margin: 4px 0 0; padding-left: 18px; }
.field li { font-size: 13.5px; margin: 3px 0; }
.field p { margin: 2px 0; font-size: 13.5px; }
.nav-path { font-family: Consolas, monospace; font-size: 12.5px; background: #f1f5f9;
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; display: inline-block; color: #334155; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 26px; }
.tagrow { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 5px; }
.tag { font-size: 11px; background: #f1f5f9; border: 1px solid var(--line); border-radius: 6px;
  padding: 2px 8px; color: #475569; }
.tag.creates { background: var(--ok-bg); border-color: #bbf7d0; color: #166534; }
.tag.consumes { background: var(--brand-bg); border-color: #bfdbfe; color: #1e40af; }

.stepactions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line); }
.feedcount { font-size: 11.5px; color: var(--brand-ink); }
.feedlist { margin-top: 12px; }
.feeditem { background: #f8fafc; border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; margin-top: 6px; font-size: 13px; }
.feeditem p { margin: 4px 0 0; }

/* ---------- checklists / readiness ---------- */
.clist { display: grid; gap: 6px; }
.clist.cols { grid-template-columns: 1fr 1fr; gap: 6px 20px; }
.ci { display: flex; align-items: flex-start; gap: 9px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; cursor: pointer; font-size: 13.5px; }
.ci:hover { border-color: #cbd5e1; }
.ci .box { width: 19px; height: 19px; flex: 0 0 auto; border: 2px solid var(--line);
  border-radius: 5px; display: grid; place-items: center; font-size: 12px; color: #fff; background: #fff; }
.ci.on { background: var(--ok-bg); border-color: #bbf7d0; }
.ci.on .box { background: var(--ok); border-color: var(--ok); }
.legend { display: flex; gap: 18px; font-size: 12px; color: var(--muted); margin: 0 0 10px; flex-wrap: wrap; }
.pf { display: grid; grid-template-columns: 1fr auto 260px; gap: 12px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; margin-bottom: 7px; }
.pf-t { font-size: 13.5px; }
.seg { display: flex; gap: 6px; }
.seg button { border: 1px solid var(--line); background: #fff; border-radius: 7px;
  padding: 5px 12px; cursor: pointer; font-size: 12px; }
.seg button.pass.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.seg button.fail.on { background: var(--danger); border-color: var(--danger); color: #fff; }
.note { border: 1px solid var(--line); border-radius: 7px; padding: 6px 9px; font-size: 12.5px; width: 100%; }

/* ---------- generic ui ---------- */
.btn { display: inline-block; border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 8px; padding: 8px 14px; font-size: 13px; cursor: pointer; text-align: center; }
.btn:hover { border-color: #94a3b8; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-ink); }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.done { background: var(--ok-bg); border-color: #bbf7d0; color: #166534; font-weight: 600; }
.btn.small { padding: 5px 11px; font-size: 12px; }
.btn.tiny { padding: 4px 10px; font-size: 11.5px; }
.btn.block { width: 100%; margin-top: 8px; }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.iconbtn { background: none; border: 0; font-size: 24px; line-height: 1; cursor: pointer; color: var(--muted); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.stack { display: grid; gap: 6px; }
.stack label { font-size: 12px; font-weight: 600; color: #334155; margin-top: 6px; }
input, select, textarea { font-family: inherit; font-size: 13.5px; border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 11px; width: 100%; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-bg); border-color: var(--brand); }
textarea { resize: vertical; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin: 0 0 18px; }
.panel h3 { margin: 0 0 10px; font-size: 15px; }
.panel.danger { border-color: #fecaca; background: var(--danger-bg); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.alert { border-radius: 8px; padding: 10px 12px; font-size: 13px; margin-bottom: 10px; }
.alert.error { background: var(--danger-bg); border: 1px solid #fecaca; color: #991b1b; }
.alert.ok { background: var(--ok-bg); border: 1px solid #bbf7d0; color: #166534; }
.empty { background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 40px; text-align: center; color: var(--muted); }
.loading { color: var(--muted); padding: 30px 0; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 14px; margin-bottom: 22px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; }
.card h3 { margin: 8px 0 6px; font-size: 15px; }
.card p { margin: 0 0 10px; font-size: 13px; color: #475569; }
.cardnum { width: 26px; height: 26px; border-radius: 8px; background: var(--brand-bg);
  color: var(--brand-ink); display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.statrow { display: flex; gap: 12px; flex-wrap: wrap; margin: 0 0 18px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 18px; box-shadow: var(--shadow); min-width: 120px; }
.stat b { display: block; font-size: 24px; }
.stat span { font-size: 11.5px; color: var(--muted); }
.stat.urgent b { color: var(--danger); }

.table { width: 100%; border-collapse: collapse; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-top: 12px; font-size: 13px; }
.table th { background: #f8fafc; text-align: left; padding: 9px 11px; font-size: 11px;
  text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.table td { padding: 9px 11px; border-top: 1px solid var(--line); vertical-align: top; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover { background: #f8fafc; }

.badge2 { font-size: 10.5px; font-weight: 700; border-radius: 99px; padding: 2px 9px;
  text-transform: uppercase; letter-spacing: .04em; background: #f1f5f9; color: #475569; }
.badge2.open { background: var(--warn-bg); color: #92400e; }
.badge2.in_progress { background: var(--brand-bg); color: #1e40af; }
.badge2.answered, .badge2.acknowledged { background: #ecfeff; color: #155e75; }
.badge2.closed, .badge2.resolved { background: var(--ok-bg); color: #166534; }
.pri { font-size: 11px; font-weight: 700; }
.pri.high { color: var(--danger); }
.pri.normal { color: #475569; }
.pri.low { color: var(--muted); }
.metarow { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.attached { background: var(--brand-bg); border: 1px solid #bfdbfe; border-radius: 9px;
  padding: 9px 12px; margin: 8px 0; font-size: 13px; }
.attached .lab { display: block; font-size: 10.5px; text-transform: uppercase;
  letter-spacing: .06em; color: #1e40af; font-weight: 700; margin-bottom: 2px; }
.msg { border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; border: 1px solid var(--line); }
.msg.mine { background: #f8fafc; }
.msg.theirs { background: var(--brand-bg); border-color: #bfdbfe; }
.msghead { font-size: 12px; font-weight: 700; margin-bottom: 4px; display: flex; gap: 8px; align-items: baseline; }
.msgbody { font-size: 13.5px; white-space: pre-wrap; }
.feedcard p { white-space: pre-wrap; font-size: 13.5px; }

.doctree { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px; }
.doctree ul { list-style: none; margin: 0; padding-left: 16px; }
.doctree > ul { padding-left: 0; }
.doctree li { margin: 3px 0; font-size: 13.5px; }
.doctree summary { cursor: pointer; font-weight: 600; padding: 3px 0; text-transform: capitalize; }
.markdown { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 26px 30px; margin-top: 14px; font-size: 14px; }
.markdown h1, .markdown h2, .markdown h3 { line-height: 1.3; margin: 22px 0 8px; }
.markdown h1 { font-size: 24px; } .markdown h2 { font-size: 19px; } .markdown h3 { font-size: 16px; }
.markdown table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: 13px; }
.markdown th, .markdown td { border: 1px solid var(--line); padding: 7px 9px; text-align: left; }
.markdown pre { background: #0f172a; color: #e2e8f0; padding: 14px; border-radius: 10px; overflow-x: auto; }
.markdown pre code { background: none; border: 0; color: inherit; }
.markdown blockquote { border-left: 4px solid var(--line); margin: 12px 0; padding: 4px 14px; color: #475569; }
.markdown img { max-width: 100%; }

/* ---------- modal + toasts ---------- */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.55); display: grid;
  place-items: center; z-index: 50; padding: 20px; }
.modalcard { background: #fff; border-radius: 14px; width: 100%; max-width: 560px;
  box-shadow: 0 24px 70px rgba(2,6,23,.4); max-height: 88vh; display: flex; flex-direction: column; }
.modalhead { display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modalhead h2 { margin: 0; font-size: 16px; }
.modalbody { padding: 18px; overflow-y: auto; }
.toasthost { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 60; }
.toast { background: #0f172a; color: #fff; padding: 10px 14px; border-radius: 9px; font-size: 13px;
  opacity: 0; transform: translateY(8px); transition: all .2s; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: none; }
.toast.error { background: #991b1b; }
.toast.warn { background: #92400e; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  aside { position: relative; height: auto; }
  .grid2, .clist.cols { grid-template-columns: 1fr; }
  .pf { grid-template-columns: 1fr; }
  .content, .topbar { padding-left: 18px; padding-right: 18px; }
}

/* ---------- log viewer ---------- */
.logbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 12px; }
.logbar label { font-size: 11px; font-weight: 600; color: #334155; display: grid; gap: 3px; }
.logbar label.inline { display: flex; align-items: center; gap: 6px; font-weight: 500; }
.logbar label.inline input { width: auto; }
.logbar select, .logbar input { min-width: 130px; }
.logview {
  background: #0f172a; color: #cbd5e1; border-radius: 10px; padding: 14px 16px; margin: 0;
  font-family: Consolas, ui-monospace, SFMono-Regular, monospace; font-size: 12px;
  line-height: 1.5; max-height: 62vh; overflow: auto; white-space: pre-wrap; word-break: break-word;
}
.logline { display: block; }
.logline.lvl-error { color: #fca5a5; }
.logline.lvl-warn { color: #fcd34d; }
.logline.lvl-info { color: #cbd5e1; }
.logline.lvl-debug { color: #94a3b8; }
.logline.lvl-none { color: #94a3b8; }
