:root {
  --bg:            #0a0a0a;
  --surface:       #1a1a1a;
  --surface-alt:   #111;
  --border:        #222;
  --border-strong: #333;
  --text:          #e0e0e0;
  --muted:         #888;
  --muted-dim:     #555;
  --accent:        #5b9cf6;
  --row-hover:     rgba(255, 255, 255, 0.035);
  --shadow:        0 1px 3px rgba(0, 0, 0, 0.4);
  color-scheme: light dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg:            #f4f4f5;
    --surface:       #ffffff;
    --surface-alt:   #eaeaec;
    --border:        #e2e2e5;
    --border-strong: #d2d2d6;
    --text:          #1a1a1a;
    --muted:         #6a6a70;
    --muted-dim:     #9a9aa0;
    --accent:        #2563eb;
    --row-hover:     rgba(0, 0, 0, 0.025);
    --shadow:        0 1px 3px rgba(0, 0, 0, 0.08);
  }
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, sans-serif;
  font-size: 0.85rem;
  min-height: 100vh;
}

header {
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  align-items: baseline;
  gap: 20px;
  flex-wrap: wrap;

  h1 {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.5px;

    a { color: inherit; text-decoration: none; }
    span { color: var(--accent); }
  }

  /* Live-status mark beside the logo: a pill with a pulsing dot. */
  .indicator {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-left: 8px;
    padding: 2px 7px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--muted);
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    vertical-align: middle;
    cursor: help;

    &::before {
      content: "";
      width: 6px;
      height: 6px;
      border-radius: 50%;
      background: var(--accent);
      animation: indicator-pulse 2s ease-in-out infinite;
    }
  }

  nav {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;

    a {
      color: var(--muted);
      text-decoration: none;
      font-size: 0.8rem;
      padding: 4px 8px;
      border-bottom: 2px solid transparent;
      transition: color 0.15s, border-color 0.15s;

      &:hover { color: var(--accent); border-color: var(--accent); }
    }
  }
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

footer.container { color: var(--muted-dim); font-size: 0.75rem; text-align: center; padding-top: 4px; padding-bottom: 20px; }

.hero {
  padding: 6px 0 4px;

  h2 {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--accent);
    margin-bottom: 8px;
  }
  p { color: var(--muted); font-size: 0.9rem; }
  a {
    color: var(--accent);
    text-decoration: none;

    &:hover { text-decoration: underline; }
  }
}

#stats { display: flex; flex-direction: column; gap: 20px; }

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  padding: 8px 16px;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.badge {
  display: inline-block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  font-weight: 600;
  vertical-align: middle;
  margin-left: 6px;
  color: var(--muted);
}
.badge.kind-shell { background: rgba(91, 156, 246, 0.15); color: #5b9cf6; }
.badge.kind-file  { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.badge.kind-other { background: rgba(168, 85, 247, 0.15); color: #a855f7; }
.badge.kind-skill { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }

.facets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.badge.facet {
  margin-left: 0;
  text-decoration: none;
  border: 1px solid transparent;
  background: var(--surface-alt);
  color: var(--muted);

  &:hover { color: var(--text); }
  &.active { border-color: currentColor; }
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}
.card-header h3,
.card .card-header h3 {
  margin-bottom: 0;
}

.filter-input,
.repl-form input[type="text"],
.rename-cell input[type="text"] {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text);
  font-size: 0.85rem;

  &:focus { outline: none; border-color: var(--accent); }
}

.filter-input {
  font-family: inherit;
  width: 100%;
  max-width: 320px;
  box-sizing: border-box;
  transition: border-color 0.15s;

  &::placeholder { color: var(--muted-dim); }
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 12px;
  font-size: 0.8rem;

  a { color: var(--accent); text-decoration: none; }
  a:hover { text-decoration: underline; }
  .disabled { color: var(--muted-dim); }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  box-shadow: var(--shadow);

  h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 12px;
  }
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.stat { display: flex; flex-direction: column; gap: 4px; }
.stat-label { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--accent); }

.stat-value.muted { color: var(--muted); font-size: 1.15rem; font-style: italic; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
th { color: var(--muted); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.5px; white-space: nowrap; }
tbody tr:hover { background: var(--row-hover); }
tr:last-child td { border-bottom: none; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.8rem; color: var(--muted); overflow-wrap: anywhere; }
.nowrap { white-space: nowrap; }
.muted { color: var(--muted); }
.empty {
  color: var(--muted-dim);
  font-style: italic;

  a {
    color: var(--accent);
    text-decoration: underline;
    font-style: normal;
    margin-left: 4px;

    &:hover {
      color: var(--text);
    }
  }
}

.log-table { table-layout: fixed; }
.log-table col.col-time { width: 7em; }
.log-table col.col-session { width: 11em; }
.log-table col.col-tool { width: 14em; }
.log-table col.col-cmd { width: auto; }

.log-table td.cell-session {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-table td.cell-tool {
  overflow: hidden;
  white-space: nowrap;
}

.cell-tool-inner {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
}

.cell-tool-inner .tool-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-tool-inner .badge {
  flex-shrink: 0;
  margin-left: 0;
}

.cell-time {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.cell-time .date {
  display: block;
  font-size: 0.7rem;
  color: var(--muted-dim);
  line-height: 1.2;
}
.cell-time .clock {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.2;
}

.note { color: var(--muted); font-weight: 400; font-size: 0.75rem; }

.repl-form .repl-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.repl-form label { display: flex; flex-direction: column; gap: 4px; font-size: 0.75rem; color: var(--muted); }

/* Columns, not a grid: a grid row is as tall as its tallest card, which leaves
   a hole beside every short one. */
.price-grid {
  columns: 340px;
  column-gap: 16px;

  > * { break-inside: avoid; margin-bottom: 16px; }
  > .empty, > .other { column-span: all; }
}
.price-card { display: flex; flex-direction: column; gap: 12px; scroll-margin-top: 16px; }
.price-card:target { border-color: var(--accent); }
.price-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;

  h3 { margin-bottom: 0; overflow-wrap: anywhere; }
  .badge { margin-left: 0; flex-shrink: 0; }
}
.badge.warn { background: rgba(245, 158, 11, 0.15); border-color: transparent; color: #d97706; }

.unit { color: var(--muted-dim); font-weight: 400; font-size: 0.7rem; }

table.rates {
  th, td { padding: 5px 0; }
  td { padding-left: 12px; }
  thead th { font-size: 0.7rem; vertical-align: bottom; }
  .col-source { display: block; font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--muted-dim); }
  tbody th {
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.8rem;
    font-weight: 400;
    color: var(--muted);
    white-space: normal;
  }
  tbody tr:hover { background: none; }
  tr:last-child th { border-bottom: none; }
}

.history {
  h4 { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
  ol { list-style: none; border-left: 2px solid var(--border-strong); margin-left: 4px; }
  li { padding-left: 12px; position: relative; }
  li::before {
    content: "";
    position: absolute;
    left: -6px;
    top: 0.75em;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--surface);
    border: 2px solid var(--border-strong);
  }
  li:has(.tag.current)::before { border-color: var(--accent); background: var(--accent); }
  li:has(.tag.scheduled)::before { border-color: var(--accent); }
}
details.period {
  > summary {
    list-style: none;
    cursor: pointer;
    padding: 6px 0;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 8px;
    font-size: 0.8rem;

    &::-webkit-details-marker { display: none; }
    &:hover .range { color: var(--accent); }
  }
  .range { font-weight: 600; font-variant-numeric: tabular-nums; }
  .changes { flex-basis: 100%; color: var(--muted); }
  .period-body { display: flex; flex-direction: column; gap: 10px; padding: 4px 0 12px; }
}
.tag {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--muted);
}
.tag.current, .tag.scheduled { background: rgba(97, 175, 239, 0.15); color: var(--accent); }

.edits { display: flex; flex-wrap: wrap; gap: 8px; }
.edits > details[open] { flex-basis: 100%; }
details.edit > summary {
  list-style: none;
  cursor: pointer;
  width: fit-content;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;

  &::-webkit-details-marker { display: none; }
  &:hover { border-color: var(--accent); }
}
details.edit[open] > summary { margin-bottom: 12px; }
details.edit.other > summary { border: none; padding: 0; font-size: 0.95rem; color: var(--text); }
details.edit.other > summary::before { content: "+ "; color: var(--accent); }

.rate-form {
  display: flex;
  flex-direction: column;
  gap: 12px;

  .rate-fields {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
  }
  label { display: flex; flex-direction: column; gap: 4px; font-size: 0.75rem; color: var(--muted); }
  input, select {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    color: var(--text);
    font: inherit;
    font-size: 0.85rem;
    min-width: 0;

    &:focus { outline: none; border-color: var(--accent); }
  }
  input:user-invalid { border-color: #e06c75; }
  button { align-self: flex-start; }
}

.rename-cell { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.rename-cell form { display: flex; gap: 6px; }
.rename-cell input[type="text"] {
  padding: 6px 10px;
  width: 12em;
  max-width: 100%;
}

.card button, .banner button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.card button:hover, .banner button:hover { filter: brightness(1.1); }
.banner button { margin-left: 8px; }
.card button.danger { background: transparent; color: #e06c75; border: 1px solid var(--border-strong); padding: 4px 10px; }
.card button.danger:hover { background: rgba(224, 108, 117, 0.12); filter: none; }
.card table button { padding: 4px 10px; margin-right: 4px; }
.card table button:not(.danger) { background: transparent; color: var(--muted); border: 1px solid var(--border-strong); }
.card table button:not(.danger):hover { background: rgba(255, 255, 255, 0.06); filter: none; }

tr.disabled { opacity: 0.5; }

.kv tr:last-child th { border-bottom: none; }
.upd-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.card button[disabled] { opacity: 0.4; cursor: not-allowed; }
.card button[disabled]:hover { filter: none; }

.banner {
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.8rem;
}
.banner.error { background: rgba(224, 108, 117, 0.12); border: 1px solid rgba(224, 108, 117, 0.4); color: #e06c75; }
.banner.info { background: rgba(97, 175, 239, 0.12); border: 1px solid rgba(97, 175, 239, 0.4); color: #61afef; }
.banner.note { background: var(--surface-alt); border: 1px solid var(--border-strong); color: var(--muted); }

.bars { display: flex; flex-direction: column; gap: 6px; }
.bar-row {
  display: grid;
  grid-template-columns: minmax(70px, 160px) 1fr 56px;
  align-items: center;
  gap: 8px;
}
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; word-break: normal; }
.bar-track { background: var(--surface-alt); border: 1px solid var(--border); border-radius: 4px; }
.bar { display: flex; height: 16px; border-radius: 3px; overflow: hidden; }
.seg { height: 100%; }
.bar-total { text-align: right; font-variant-numeric: tabular-nums; font-size: 0.75rem; color: var(--muted); }

.c0 { background: #5b9cf6; }
.c1 { background: #f6a75b; }
.c2 { background: #6fce8f; }
.c3 { background: #ce6f9e; }
.c4 { background: #b58bf6; }
.c5 { background: #cec36f; }

.legend { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; font-size: 0.75rem; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 4px; }

.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }

.histogram { display: flex; flex-direction: column; gap: 8px; }
.hist-chart { display: flex; gap: 10px; width: 100%; }
/* space-between aligns label *boxes* to the plot's edges, which leaves every
   label's text half a line-height off the gridline it names. Growing the box
   by one line-height and pulling half of it back at each end puts the first
   and last text centres on the plot's top and bottom instead. */
.hist-scale {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex: 0 0 auto;
  height: calc(180px + 1em);
  margin-block: -0.5em;
  font-size: 0.7rem;
  color: var(--muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
/* Columns run oldest-left to newest-right (histogramViewOf reverses them), so
   the interesting end is the far right — an RTL scroll container starts there.
   The children switch back to ltr so only the scroll origin is reversed, not
   their layout. */
.hist-scroll { flex: 1 1 auto; min-width: 0; overflow-x: auto; direction: rtl; }
.hist-plot, .hist-labels { direction: ltr; }
/* One gridline per tick interval: a single top-edge line tiled by
   background-size, whose step comes from histogramView.GridStep inline rather
   than a constant duplicated here. border-bottom draws the zero line. */
.hist-plot {
  display: flex;
  width: fit-content;
  align-items: flex-end;
  gap: 4px;
  height: 180px;
  background-image: linear-gradient(to bottom, var(--border) 0 1px, transparent 1px);
  border-bottom: 1px solid var(--border-strong);
}
.hist-col { flex: 0 0 auto; width: 14px; height: 100%; }
.hist-track { display: flex; align-items: flex-end; width: 100%; height: 100%; }
.hist-bar { display: flex; flex-direction: column-reverse; width: 100%; border-radius: 2px 2px 0 0; overflow: hidden; }
.hseg { width: 100%; transition: filter 0.1s; }
.hist-col:hover .hseg { filter: brightness(1.2); }
.hist-labels { display: flex; width: fit-content; gap: 4px; margin-top: 4px; }
.hist-label {
  flex: 0 0 auto;
  width: 14px;
  font-size: 0.7rem;
  color: var(--muted);
  text-align: center;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  white-space: nowrap;
}

.clickable-row {
  cursor: pointer;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;

  &:hover { background: var(--row-hover); }
  &:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
}

.cell-link {
  display: block;
  color: var(--accent);
  text-decoration: none;

  &:hover {
    text-decoration: underline;
  }
}

.cmd-preview {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* A path — or an mcp__server__tool name — is identified by its tail, so clip
   the head: the RTL direction moves the clip and its ellipsis to the start of
   the line. The &#8206; (LRM) markers the templates wrap the path in keep its
   leading/trailing separators in place — remove them and "/src/main.go"
   renders as "src/main.go/". */
.cmd-preview.path-preview,
.tool-name.path-preview {
  direction: rtl;
  text-align: left;
}

.rollup-table { table-layout: fixed; }
.rollup-table col.col-subject { width: auto; }
.rollup-table col.col-tool { width: 12em; }
.rollup-table col.col-count { width: 8em; }
.rollup-table td.cell-clip { overflow: hidden; }

dialog.modal {
  margin: auto;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0;
  max-width: min(840px, 92vw);
  width: 100%;
  max-height: 85vh;
  box-shadow: var(--shadow), 0 20px 50px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

dialog.modal::backdrop {
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(2px);
}

.modal-card {
  display: flex;
  flex-direction: column;
  max-height: 85vh;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
  gap: 12px;
}

.modal-title {
  font-weight: 600;
  font-size: 1rem;
  min-width: 0;
}

.modal-tool {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  color: var(--accent);
}

.modal-meta {
  display: block;
  font-size: 0.75rem;
  font-weight: normal;
  color: var(--muted);
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;

  &:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
  }
}

.modal-body {
  padding: 16px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-copy {
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  color: var(--muted);
  font-size: 0.75rem;
  padding: 4px 10px;
  cursor: pointer;
  transition: all 0.15s;

  &:hover {
    color: var(--text);
    border-color: var(--accent);
    background: rgba(255, 255, 255, 0.04);
  }
}

.code-block {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  font-size: 0.8rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 55vh;
  overflow-y: auto;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

@media (max-width: 640px) {
  .card-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .filter-input {
    max-width: none;
    width: 100%;
    flex: 1 1 auto;
    min-width: 0;
  }

  .rollup-table col.col-tool { width: 7em; }
  .rollup-table col.col-count { width: 4.5em; }

  .log-table,
  .log-table tbody {
    display: block;
  }

  .log-table thead,
  .log-table colgroup {
    display: none;
  }

  .log-table tr.clickable-row {
    display: grid;
    grid-template-areas:
      "cmd time"
      "session tool";
    grid-template-columns: 1fr auto;
    align-items: baseline;
    gap: 4px 10px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
  }

  .log-table td {
    padding: 0;
    border-bottom: none;
    min-width: 0;
  }

  .log-table td.cell-cmd {
    grid-area: cmd;
    font-weight: 600;
    color: var(--text);
    min-width: 0;
    overflow: hidden;
  }

  .log-table td.cell-time {
    grid-area: time;
    text-align: right;
    font-size: 0.75rem;
    color: var(--muted);
    white-space: nowrap;
    flex-shrink: 0;
  }

  .log-table td.cell-time .date {
    display: none;
  }

  .log-table td.cell-time .clock {
    display: inline;
    font-size: 0.75rem;
  }

  .log-table td.cell-session {
    grid-area: session;
    font-size: 0.75rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--muted-dim);
    min-width: 0;
  }

  .log-table td.cell-tool {
    grid-area: tool;
    text-align: right;
    font-size: 0.7rem;
    color: var(--muted);
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 0;
  }

  .log-table td.cell-tool .cell-tool-inner {
    justify-content: flex-end;
  }

  dialog.modal {
    max-width: 95vw;
    max-height: 90vh;
  }

  .modal-card {
    max-height: 90vh;
  }

  .modal-header {
    padding: 10px 14px;
  }

  .modal-body {
    padding: 12px 14px;
  }

  .code-block {
    font-size: 0.75rem;
    padding: 10px;
    max-height: 60vh;
  }
}

@media (max-width: 480px) {
  .container { padding: 10px; gap: 14px; }
  .card { padding: 12px; border-radius: 8px; }
  th, td { padding: 6px 8px; }

  .stat-grid { grid-template-columns: 1fr; }

  header {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;

    nav { gap: 2px 10px; }
  }

  .tab {
    padding: 10px 14px;
    font-size: 0.85rem;
  }

  .filter-input {
    padding: 10px 12px;
  }

  .pagination {
    justify-content: space-between;
    font-size: 0.85rem;
  }
  .pagination a, .pagination span {
    padding: 6px 8px;
  }

  .card table button { padding: 10px 14px; margin-bottom: 4px; }
  .cell-link { padding: 8px 0; }
  .rename-cell input[type="text"] { padding: 10px 12px; width: 100%; }
  .rename-cell form { flex: 1 1 100%; }
}

/* Status text colors are tuned against the dark bg, where they clear 4.5:1;
   against the light bg they measure ~2:1, so light mode darkens the text and
   leaves the tinted background alone. Last in the file: an override earlier
   than the rule it overrides loses to it at equal specificity. */
@media (prefers-color-scheme: light) {
  .banner.error { color: #b91c1c; }
  .banner.info  { color: #1d4ed8; }
  .badge.warn   { color: #92400e; }
}

@keyframes indicator-pulse { 50% { opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) { header .indicator::before { animation: none; } }
