/* The extension popup's palette and shapes (apps/extension/ui/popup.css),
   stretched over a page: wider container, wrapping header, stat tiles and
   tables that scroll instead of breaking on a phone. Dark first; light is a
   chosen set of the same steps, not an automatic flip. */

:root {
  --bg: #0b0a14; --panel: #15131f; --panel-2: #1d1a2b; --line: #2a2640; --text: #eceaf6; --muted: #9a95b4;
  --accent: #7d66f2; --accent-2: #ec4899; --good: #34d399; --bad: #f87171; --warn: #fbbf24;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f7f6fc; --panel: #ffffff; --panel-2: #f0eef9; --line: #e2def2; --text: #1b1830; --muted: #6b6689;
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]):not([data-theme="light"]) {
    --bg: #f7f6fc; --panel: #ffffff; --panel-2: #f0eef9; --line: #e2def2; --text: #1b1830; --muted: #6b6689;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--bg); }
html, body { margin: 0; }
body {
  background: radial-gradient(120% 60% at 0% 0%, color-mix(in srgb, var(--accent) 20%, transparent), transparent 60%),
              radial-gradient(90% 50% at 100% 0%, color-mix(in srgb, var(--accent-2) 12%, transparent), transparent 60%), var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  min-height: 100vh;
}

/* ---- header ---- */
#top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); font-weight: 700; }
.logo { width: 20px; height: 20px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-2)); flex: none; }
.brand-name { white-space: nowrap; }
.pill { font-size: 11px; padding: 3px 8px; border-radius: 999px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.pill.good { color: var(--good); }
.pill.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); background: color-mix(in srgb, var(--warn) 10%, var(--panel)); }

#search { display: flex; align-items: center; gap: 6px; flex: 1 1 260px; min-width: 200px; flex-wrap: wrap; }
#search input[type="search"] {
  flex: 1 1 180px; background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px; font: inherit;
}
#search-msg { flex-basis: 100%; }
#search-msg .msg { display: inline-block; }

#settings { position: relative; }
#settings summary { cursor: pointer; color: var(--muted); padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; list-style: none; white-space: nowrap; }
#settings summary::after { content: none; }
#settings[open] summary { color: var(--text); }
.settings-body {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 6; width: min(340px, calc(100vw - 24px));
  display: flex; flex-direction: column; gap: 8px; padding: 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 12px 30px rgb(0 0 0 / 0.35);
}
.settings-body .msg { display: inline-block; }

button {
  appearance: none; border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  border-radius: 10px; padding: 8px 12px; font: inherit; font-weight: 600; cursor: pointer;
}
button.ghost { background: none; font-size: 15px; padding: 6px 9px; }
button.copy { padding: 3px 8px; font-size: 11px; font-weight: 500; color: var(--muted); white-space: nowrap; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- layout ---- */
.container { max-width: 1080px; margin: 0 auto; padding: 16px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 8px; align-items: center; min-width: 0; }
.row > * { min-width: 0; }
.row.tight { gap: 6px; }
.row.spread { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.page-title { font-size: 18px; margin: 0; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.mono.wrap, .wrap .mono { overflow-wrap: anywhere; }
.source { margin: 0; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.card > h2 { font-size: 13px; margin: 0; color: var(--muted); font-weight: 600; }

.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; font-size: 13px; }
.kv > :nth-child(odd) { color: var(--muted); }
.kv > :nth-child(even) { overflow-wrap: anywhere; min-width: 0; }

/* ---- stat tiles (one hero figure per view at most) ---- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tile-label { font-size: 12px; color: var(--muted); }
.tile-value { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.tile.major .tile-value { font-size: 30px; }
.tile.big .tile-value { font-size: 34px; }
.tile-sub { font-size: 11px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.hero { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

/* ---- tables ---- */
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th { text-align: left; font-size: 11px; font-weight: 600; color: var(--muted); padding: 4px 10px 4px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 7px 10px 7px 0; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: top; }
tr:last-child td { border-bottom: none; }

/* ---- status ---- */
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; display: inline-block; }
.dot.done { background: var(--good); }
.dot.failed { background: var(--bad); }
.dot.pending { background: var(--warn); }
.msg { font-size: 12px; padding: 8px 10px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); overflow-wrap: anywhere; }
.msg.error { color: var(--bad); }
.msg.ok { color: var(--good); }
.msg.warn { color: var(--warn); }

/* ---- events, details ---- */
.event { display: flex; flex-direction: column; gap: 5px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.event:last-child { border-bottom: none; }
details { min-width: 0; }
details summary { cursor: pointer; color: var(--muted); font-size: 12px; }
details > *:not(summary) { margin-top: 6px; }

/* ---- loading ---- */
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 24px 4px; }
.spin {
  width: 16px; height: 16px; border-radius: 50%; flex: none;
  border: 2px solid var(--line); border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- footer ---- */
#foot { color: var(--muted); border-top: 1px solid var(--line); margin-top: 28px; }
#foot p { margin: 8px 0; }

/* ---- phones ---- */
@media (max-width: 640px) {
  .container { padding: 12px; }
  #top { padding: 8px 12px; }
  .kv { grid-template-columns: 110px 1fr; }
  .tile.major .tile-value { font-size: 26px; }
  th, td { padding-right: 8px; }
}
