/* ==========================================================================
   LogPose — panels: the detail drawer, document-page surfaces (metrics,
   tables, run timeline), code rendering and the sign-in screen.
   ========================================================================== */

/* ============================================================ detail drawer */
/* Unchanged in behaviour — click a line, it slides in from the right; Esc or
   the close button dismisses it; it enters and exits along the same path.
   Only wider, because on a 27"+ display a 540px column wastes the room a
   traceback actually needs. */
.drawer-scrim {
  position: fixed; inset: 0; z-index: 45; display: none;
  background: var(--bg-scrim);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none;
  transition: opacity var(--t-base) var(--ease-out);
}

.drawer {
  position: fixed; top: var(--topbar-h); right: 0; z-index: 50;
  width: min(var(--drawer-w), 94vw);
  height: calc(100dvh - var(--topbar-h));
  display: flex; flex-direction: column;
  background: var(--bg-surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-3);
  transform: translateX(102%);
  pointer-events: none;
  transition: transform var(--t-slow) var(--ease-expo);
  will-change: transform;
}
.drawer.is-open { transform: translateX(0); pointer-events: auto; }

@media (min-width: 1500px) { :root { --drawer-w: 660px; } }
@media (min-width: 1900px) { :root { --drawer-w: 780px; } }

/* Below 860px the panel stops coexisting with the stream and becomes a proper
   overlay: full height, above the top bar, with a tap-to-dismiss scrim. The
   scrim is display:none on desktop so the list stays usable behind the panel. */
@media (max-width: 860px) {
  .drawer { top: 0; height: 100dvh; width: min(92vw, 460px); z-index: 60; }
  .drawer-scrim { display: block; z-index: 55; }
  .drawer-scrim.is-open { opacity: 1; pointer-events: auto; }
  .facts { grid-template-columns: 92px minmax(0, 1fr); }
}

.drawer-head {
  flex: none;
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px 11px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-chrome);
}
.drawer-head .spacer { flex: 1; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 18px 48px; }

.drawer-title {
  display: inline-flex; align-items: center; gap: 7px;
  color: var(--tone, var(--fg-strong));
  font-size: var(--fs-sm); font-weight: 650;
  letter-spacing: 0.04em; text-transform: uppercase;
}
.drawer-title .lucide { width: 15px; height: 15px; }

/* Facts grid: label / value pairs, hairline-separated, no boxes. */
.facts { display: grid; grid-template-columns: 104px minmax(0, 1fr); margin: 0 0 18px; }
.facts dt {
  padding: 7px 0; border-top: 1px solid var(--line);
  color: var(--fg-faint);
  font-size: var(--fs-2xs); font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase;
}
.facts dd {
  margin: 0; padding: 7px 0; border-top: 1px solid var(--line);
  font-size: var(--fs-sm); color: var(--fg-strong);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.facts dt:first-of-type, .facts dd:first-of-type { border-top: none; }
.facts .fact-service { display: inline-flex; align-items: center; gap: 7px; }

.block { margin-top: 16px; }
.block-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-bottom: 6px; min-height: 24px;
}
.block-label {
  font-size: var(--fs-2xs); font-weight: 600;
  letter-spacing: 0.07em; text-transform: uppercase; color: var(--fg-faint);
}
.block-body {
  padding: 11px 13px;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  font-size: var(--fs-sm);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.block-body.tone-bad {
  background: color-mix(in oklab, var(--bad) 7%, var(--bg-sunken));
  border-color: color-mix(in oklab, var(--bad) 26%, var(--line));
  color: var(--fg-strong);
}

/* ------------------------------------------------------------------ code */
.json-pretty, .json-inline {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.78125rem; /* 12.5px — dense but legible at mono metrics */
  line-height: 1.6;
}
.json-pretty { white-space: pre-wrap; overflow-wrap: anywhere; }
.jv-key   { color: var(--code-key); }
.jv-str   { color: var(--code-str); }
.jv-num   { color: var(--code-num); }
.jv-null  { color: var(--code-null); font-style: italic; }
.jv-true  { color: var(--code-true); font-weight: 600; }
.jv-false { color: var(--code-false); font-weight: 600; }
.kw-ok    { color: var(--ok); font-weight: 600; }
.kw-bad   { color: var(--bad); font-weight: 600; }

pre.traceback {
  margin: 0; padding: 11px 13px;
  background: var(--bg-sunken); border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow-x: auto; white-space: pre-wrap; overflow-wrap: anywhere;
  font-family: var(--font-mono); font-size: 0.75rem; line-height: 1.6;
  color: var(--fg-muted);
}

/* ------------------------------------------------------------------ tags */
/* Severity / status tag. Dot + label, tinted from --tone. */
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  height: 21px; padding: 0 9px 0 7px;
  border-radius: var(--r-pill);
  background: color-mix(in oklab, var(--tone, var(--fg-muted)) 14%, transparent);
  color: var(--tone, var(--fg-muted));
  font-size: var(--fs-2xs); font-weight: 650; letter-spacing: 0.02em;
  text-transform: uppercase; white-space: nowrap;
}
.tag .lucide { width: 12px; height: 12px; }
.tag::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%;
  background: currentColor; flex: none;
}
.tag.has-icon::before { display: none; }
.tag-num { font-variant-numeric: tabular-nums; text-transform: none; letter-spacing: 0; }

/* =========================================================== document pages */
/* Dashboard and run detail. Same shell, same type, but they read top-to-bottom
   and scroll as a document instead of streaming. */

/* Stat strip: hairline-divided columns, not four identical boxes. */
.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  border: 1px solid var(--line); border-radius: var(--r-xl);
  background: var(--bg-surface);
  box-shadow: var(--shadow-1);
  overflow: hidden;
  margin-bottom: 26px;
}
.stat {
  display: block; padding: 16px 18px 17px;
  border-left: 1px solid var(--line);
  color: inherit;
  transition: background-color var(--t-fast) var(--ease-out);
}
.stat:first-child { border-left: none; }
a.stat:hover { background: var(--bg-raised); text-decoration: none; }
.stat-label {
  display: flex; align-items: center; gap: 7px;
  color: var(--fg-muted); font-size: var(--fs-xs); font-weight: 550;
}
.stat-label .lucide { width: 15px; height: 15px; color: var(--fg-faint); }
.stat-value {
  display: block; margin-top: 9px;
  font-size: var(--fs-3xl); font-weight: 660; line-height: 1;
  letter-spacing: -0.035em; color: var(--fg-strong);
  font-variant-numeric: tabular-nums;
}
.stat-sub { display: block; margin-top: 7px; font-size: var(--fs-2xs); color: var(--fg-faint); }
.stat.tone-bad .stat-value { color: var(--bad); }
.stat.tone-bad .stat-label .lucide { color: var(--bad); }

@media (max-width: 700px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(odd) { border-left: none; }
  .stat:nth-child(n + 3) { border-top: 1px solid var(--line); }
}

/* Document table: hairlines only, no vertical rules, no wrapping card. */
.doc-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.doc-table thead th {
  position: sticky; top: 0; z-index: 2;
  padding: 8px 12px; text-align: left;
  background: var(--bg-base);
  border-bottom: 1px solid var(--line);
  color: var(--fg-faint); font-size: var(--fs-2xs); font-weight: 600;
  letter-spacing: 0.07em; text-transform: uppercase; white-space: nowrap;
}
.doc-table tbody td {
  padding: 9px 12px; border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.doc-table tbody tr { transition: background-color var(--t-instant) var(--ease-out); }
.doc-table tbody tr:hover { background: var(--bg-raised); }
.doc-table tbody tr:last-child td { border-bottom: none; }
.doc-table th:first-child, .doc-table td:first-child { padding-left: 4px; }
.doc-table th:last-child,  .doc-table td:last-child  { padding-right: 4px; }
.col-num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--fg-muted); }
.col-svc { white-space: nowrap; }
.doc-scroll { overflow-x: auto; }

.empty-row td {
  padding: 44px 12px !important; text-align: center;
  color: var(--fg-muted); font-size: var(--fs-sm);
}

/* ---------------------------------------------------------- run detail */
.run-hero {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px;
  padding: 16px 18px; margin-bottom: 20px;
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-1);
}
.run-hero.tone-running   { border-color: color-mix(in oklab, var(--st-running) 30%, var(--line)); }
.run-hero.tone-completed { border-color: color-mix(in oklab, var(--st-completed) 28%, var(--line)); }
.run-hero.tone-failed    { border-color: color-mix(in oklab, var(--st-failed) 34%, var(--line)); }
.run-hero-title { flex: 1 1 260px; min-width: 0; font-size: var(--fs-lg); font-weight: 640; color: var(--fg-strong); letter-spacing: -0.016em; }
.run-hero .meta { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; color: var(--fg-muted); font-size: var(--fs-xs); }
.run-hero .meta .lucide { width: 14px; height: 14px; color: var(--fg-faint); }

.step {
  padding: 13px 16px; margin-bottom: 8px;
  background: var(--bg-surface); border: 1px solid var(--line);
  border-radius: var(--r-lg);
}
.step-title { display: flex; align-items: center; gap: 9px; font-weight: 600; color: var(--fg-strong); font-size: var(--fs-sm); }
.step .meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-top: 7px; color: var(--fg-muted); font-size: var(--fs-xs); }

/* -------------------------------------------------------------- timeline */
.timeline-panel {
  padding: 16px 18px 12px; margin-bottom: 24px;
  background: var(--bg-surface); border: 1px solid var(--line);
  border-radius: var(--r-xl);
}
.timeline-row { display: flex; align-items: center; gap: 14px; padding: 5px 0; }
.timeline-label {
  flex: 0 0 210px; width: 210px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: var(--fs-xs); color: var(--fg-muted);
}
.timeline-row.root .timeline-label { font-weight: 640; color: var(--fg-strong); }
.timeline-track { position: relative; flex: 1; height: 18px; border-radius: var(--r-xs); background: var(--bg-sunken); }
.timeline-block {
  position: absolute; top: 3px; bottom: 3px; min-width: 5px;
  border-radius: 5px; background: var(--tone, var(--fg-faint));
  transition: filter var(--t-fast) var(--ease-out);
}
.timeline-block:hover { filter: brightness(1.12); }
.timeline-axis {
  display: flex; justify-content: space-between;
  margin: 9px 0 0 224px;
  font-size: var(--fs-2xs); color: var(--fg-faint);
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------ pagination */
/* Document pages keep an explicit pager; only the stream replaces it with
   directional rails. */
.pager {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin-top: 20px;
}
.pager-status { min-width: 108px; text-align: center; font-size: var(--fs-xs); color: var(--fg-muted); font-variant-numeric: tabular-nums; }
.pager-status strong { color: var(--fg-strong); font-weight: 640; }

/* ---------------------------------------------------------------- login */
.login-wrap { display: grid; place-items: center; height: 100%; padding: 24px; overflow-y: auto; }
.login-card {
  width: 348px; max-width: 100%; padding: 28px;
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-3), var(--inner-lip);
}
.login-brand { display: flex; align-items: center; gap: 10px; font-size: var(--fs-xl); font-weight: 640; letter-spacing: -0.022em; color: var(--fg-strong); }
.login-brand img { height: 26px; width: auto; }
.login-sub { color: var(--fg-muted); font-size: var(--fs-xs); margin: 7px 0 22px; }
.login-card .field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.login-card .field > label { font-size: var(--fs-2xs); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-faint); }
.login-card .input, .login-card .btn { width: 100%; }
.login-error {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 16px; padding: 9px 11px;
  border-radius: var(--r-md); font-size: var(--fs-xs);
  color: var(--bad);
  background: color-mix(in oklab, var(--bad) 10%, transparent);
  border: 1px solid color-mix(in oklab, var(--bad) 30%, transparent);
}
.login-error .lucide { width: 14px; height: 14px; flex: none; }

/* Login lives outside the app shell: one full-height row, no topbar. */
.login-body { grid-template-rows: minmax(0, 1fr); }

/* Run-detail breadcrumb strip. */
.run-crumb { font-size: var(--fs-sm); font-weight: 600; color: var(--fg-strong); letter-spacing: -0.01em; }
.run-id { font-size: var(--fs-2xs); }
@media (max-width: 860px) { .run-id { display: none; } }
