/* Container Nanny dashboard styles.
   Plain CSS, no framework — keeps the static asset footprint tiny. */

:root {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-sidebar: #0b1326;
  --bg-row-alt: #18253d;
  --border: #2d3b55;
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --accent: #38bdf8;
  --accent-hover: #0ea5e9;
  --accent-soft: rgba(56, 189, 248, 0.15);
  --ok: #4ade80;
  --warn: #facc15;
  --bad: #f87171;
  --muted: #64748b;
  --shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
  --radius: 10px;
  --sidebar-w: 220px;
  --topbar-h: 64px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
}

/* ====================================================================
   App shell — sidebar + main pane
   ==================================================================== */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ----- Sidebar ------------------------------------------------------- */

.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0 1.25rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  letter-spacing: 0.01em;
}

.sidebar__brand-mark {
  width: 28px;
  height: 28px;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
}

.sidebar__brand-text {
  font-size: 1.02rem;
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  padding: 0.75rem 0.5rem;
  gap: 0.15rem;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.85rem;
  border-radius: 8px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.95rem;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
}

.nav-item.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

/* ── Settings nav group (expandable) ─────────────────────────────────── */
.nav-group { display: flex; flex-direction: column; }

.nav-group__toggle {
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}

.nav-group__chevron {
  margin-left: auto;
  font-size: 0.65rem;
  color: var(--text-dim);
  transition: transform 0.2s;
  display: inline-block;
}

.nav-group.is-open .nav-group__chevron { transform: rotate(90deg); }

.nav-group__children {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding-left: 0.25rem;
}

.nav-item--child {
  font-size: 0.875rem;
  padding: 0.45rem 0.85rem 0.45rem 2.1rem;
  border-left: 2px solid transparent;
  border-radius: 0 8px 8px 0;
  margin-left: 0.5rem;
}

.nav-item--child:hover { border-left-color: var(--border); }
.nav-item--child.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}

.nav-item__icon {
  display: inline-flex;
  width: 1.1rem;
  justify-content: center;
  font-size: 1rem;
}

.sidebar__footer {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
}

/* ----- Main pane ----------------------------------------------------- */

.app-main {
  display: flex;
  flex-direction: column;
  min-width: 0; /* prevents the grid track from overflowing */
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 5;
  min-height: var(--topbar-h);
}

.topbar__title {
  flex: 1;
  min-width: 0;
}

.topbar__title h1 {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.1;
}

.subtitle {
  margin: 0.15rem 0 0;
  color: var(--text-dim);
  font-size: 0.85rem;
}

.topbar__controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.content {
  flex: 1;
  padding: 1.5rem;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

.view[hidden] {
  display: none !important;
}

/* ----- Buttons ------------------------------------------------------- */

.btn-refresh,
.btn-secondary {
  border: 0;
  font-weight: 600;
  padding: 0.55rem 1rem;
  border-radius: var(--radius);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: background 0.15s ease, transform 0.05s ease;
  font-size: 0.9rem;
}

.btn-refresh {
  background: var(--accent);
  color: #0f172a;
}

.btn-refresh:hover {
  background: var(--accent-hover);
}

.btn-refresh:active,
.btn-secondary:active {
  transform: translateY(1px);
}

.btn-refresh[disabled],
.btn-secondary[disabled] {
  opacity: 0.6;
  cursor: progress;
}

.btn-refresh__icon {
  display: inline-block;
  font-size: 1.1rem;
}

.btn-refresh.loading .btn-refresh__icon {
  animation: spin 0.9s linear infinite;
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
}

.icon-btn {
  background: transparent;
  border: 0;
  color: var(--text-dim);
  font-size: 1.4rem;
  padding: 0.3rem 0.55rem;
  border-radius: 8px;
  cursor: pointer;
  display: none; /* shown on mobile only */
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.last-updated {
  color: var(--text-dim);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

/* ====================================================================
   Card / table
   ==================================================================== */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card + .card {
  margin-top: 1.25rem;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.card-header h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.badge {
  background: var(--border);
  color: var(--text);
  font-size: 0.78rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}

.badge--muted {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

thead th {
  text-align: left;
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
}

thead th.sortable {
  cursor: pointer;
  transition: color 0.12s ease, background 0.12s ease;
}

thead th.sortable:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

thead th.is-sorted {
  color: var(--accent);
}

.sort-indicator {
  display: inline-block;
  min-width: 0.85em;
  margin-left: 0.35em;
  font-size: 0.75em;
  color: var(--accent);
  text-align: center;
  vertical-align: baseline;
}

/* Empty indicator on un-sorted columns reserves a slim hint so the
   layout doesn't shift when sort state changes. */
thead th.sortable:not(.is-sorted) .sort-indicator::before {
  content: "↕";
  color: rgba(148, 163, 184, 0.35);
}

tbody td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr:nth-child(even) td {
  background: var(--bg-row-alt);
}

tbody tr:last-child td {
  border-bottom: 0;
}

td.num,
th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
}

.placeholder td {
  text-align: center;
  color: var(--text-dim);
  font-style: italic;
  padding: 2rem 1rem;
}

/* Status dot column */
.status-cell {
  width: 36px;
  text-align: center;
}

.status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.04);
}

.status-dot.ok {
  background: var(--ok);
}
.status-dot.warn {
  background: var(--warn);
}
.status-dot.bad {
  background: var(--bad);
}
.status-dot.muted {
  background: var(--muted);
}

.num.bad {
  color: var(--bad);
  font-weight: 600;
}

.num.warn {
  color: var(--warn);
  font-weight: 600;
}

.row-error td {
  border-bottom: 1px solid rgba(248, 113, 113, 0.4);
}
.row-error .status-dot {
  background: var(--bad);
}

/* ====================================================================
   Settings tabs (stab = settings tab)
   ==================================================================== */

/* ── Settings individual pages ─────────────────────────────────────── */
.settings-page { display: flex; flex-direction: column; gap: 1.25rem; }

.settings-page__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.settings-breadcrumb {
  font-size: 0.85rem;
  color: var(--text-dim);
}

.settings-breadcrumb span:last-child {
  color: var(--text);
  font-weight: 600;
}

/* No extra padding — sp-section items provide their own */
.settings-page__card { padding: 0; overflow: hidden; }

/* ── Settings page sections (CloudScape-style Container pattern) ────── */
.sp-section {
  border-bottom: 1px solid var(--border);
}
.sp-section:last-child { border-bottom: none; }

.sp-section__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.5rem 0.9rem;
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,0.1);
}

.sp-section__title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 0.2rem;
}

.sp-section__desc {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin: 0;
  line-height: 1.4;
}

.sp-section__body {
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

/* ── Alert banner (replaces .restart-warning) ───────────────────────── */
.sp-alert {
  display: flex;
  gap: 0.75rem;
  padding: 0.8rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  line-height: 1.5;
}
.sp-alert--warning {
  background: rgba(251,191,36,0.08);
  border: 1px solid rgba(251,191,36,0.3);
  color: #fde68a;
}
.sp-alert--info {
  background: rgba(56,189,248,0.07);
  border: 1px solid rgba(56,189,248,0.25);
  color: var(--text);
}
.sp-alert__icon { flex-shrink: 0; font-size: 1rem; margin-top: 0.05rem; }
.sp-alert__body strong { display: block; margin-bottom: 0.15rem; }
.sp-alert__body code {
  font-family: var(--mono);
  font-size: 0.82em;
  background: rgba(255,255,255,0.1);
  padding: 0.05rem 0.3rem;
  border-radius: 3px;
}

/* ── Status key-value display ───────────────────────────────────────── */
.sp-kv {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem 1.5rem;
  margin: 0;
  padding: 0;
}
.sp-kv__item { display: flex; flex-direction: column; gap: 0.2rem; }
.sp-kv dt {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}
.sp-kv dd {
  font-size: 0.9rem;
  color: var(--text);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.sp-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.sp-status-dot--ok      { background: var(--ok); box-shadow: 0 0 5px var(--ok); }
.sp-status-dot--warn    { background: var(--warn); }
.sp-status-dot--bad     { background: var(--bad); }
.sp-status-dot--muted   { background: var(--text-dim); }

/* ── Field description (helper text) ───────────────────────────────── */
.field__desc {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 0.15rem;
  line-height: 1.4;
}

.settings-page__restart {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: rgba(250,204,21,0.07);
  border: 1px solid rgba(250,204,21,0.25);
  border-radius: 8px;
  padding: 0.55rem 1rem;
  font-size: 0.83rem;
}

.settings-page__restart .restart-bar__right { display: flex; align-items: center; gap: 0.75rem; }

/* Legacy settings-tabs-card ─────────────────────────────────────────── */
.settings-tabs-card {
  /* Remove the default card gap so the tab bar sits flush */
  padding: 0;
  overflow: hidden;
}

/* Tab bar ------------------------------------------------------------ */
.stab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.15);
}

.stab-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  /* Offset the bottom border so active indicator overlaps the bar border */
  margin-bottom: -1px;
}

.stab-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.stab-btn--active,
.stab-btn[aria-selected="true"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: none;
}

.stab-btn .badge {
  font-size: 0.72rem;
  padding: 0.1rem 0.45rem;
}

/* Tab panels --------------------------------------------------------- */
.stab-panel {
  display: block;
}

.stab-panel[hidden] {
  display: none;
}

/* ====================================================================
   Settings view
   ==================================================================== */

.settings-body {
  padding: 1.25rem;
}

.settings-intro {
  margin: 0 0 1rem;
  color: var(--text-dim);
  font-size: 0.92rem;
}

/* Add-instance toggle & collapsible panel */
.add-instance-toggle {
  margin-top: 1.25rem;
}

.add-instance-panel {
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255,255,255,0.025);
  overflow: hidden;
  animation: slideDown 0.18s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.add-instance-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem 0;
}

.add-instance-panel__header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.add-instance-panel__close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  font-size: 1.3rem;
  line-height: 1;
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}

.add-instance-panel__close:hover {
  color: var(--text);
  background: rgba(255,255,255,0.07);
}

.add-instance-panel .instance-form {
  padding: 1rem 1.25rem 1.25rem;
}

.settings-intro code {
  background: rgba(255, 255, 255, 0.06);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 0.85rem;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(180px, 220px) 1fr;
  gap: 0.4rem 1rem;
  margin: 0;
}

.settings-grid dt {
  color: var(--text-dim);
  font-size: 0.88rem;
  padding: 0.4rem 0;
  border-top: 1px solid var(--border);
}

.settings-grid dd {
  margin: 0;
  padding: 0.4rem 0;
  border-top: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 0.9rem;
  word-break: break-all;
}

.settings-grid dt:first-of-type,
.settings-grid dd:first-of-type {
  border-top: 0;
}

.test-result {
  margin-top: 0.85rem;
  font-size: 0.9rem;
  min-height: 1.2em;
}

/* Setting history table */
.history-keys-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  padding-top: 0.45rem;
  padding-bottom: 0.45rem;
}
.history-detail-row td {
  padding: 0 !important;
}
.history-detail-row .terminal-result {
  border-radius: 0;
  border-left: none;
  border-right: none;
}

.test-result.ok {
  color: var(--ok);
}

.test-result.bad {
  color: var(--bad);
}

/* Terminal-style output box */
.terminal-result {
  margin-top: 0.85rem;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  overflow: hidden;
  font-family: "SF Mono", "Fira Mono", "Cascadia Code", "Consolas", monospace;
  font-size: 0.82rem;
}

.terminal-result__bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: #21262d;
  border-bottom: 1px solid #30363d;
  user-select: none;
}

.terminal-result__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.terminal-result__dot:nth-child(1) { background: #ff5f57; }
.terminal-result__dot:nth-child(2) { background: #febc2e; }
.terminal-result__dot:nth-child(3) { background: #28c840; }

.terminal-result__label {
  margin-left: 4px;
  color: #8b949e;
  font-size: 0.75rem;
  letter-spacing: 0.02em;
}

.terminal-result__body {
  padding: 0.65rem 1rem;
  color: #3fb950;
  min-height: 2.5em;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.55;
}

.terminal-result__body.is-error {
  color: #f85149;
}

.terminal-result__body.is-idle {
  color: #484f58;
}

/* ====================================================================
   Banners + footer
   ==================================================================== */

.error-banner {
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.6);
  color: #fecaca;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

.error-banner strong {
  color: #fee2e2;
}

.site-footer {
  text-align: center;
  padding: 1.25rem 1rem 2rem;
  color: var(--text-dim);
}

/* ====================================================================
   Pills / chips / inline highlights
   ==================================================================== */

.pill {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.1);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.pill--ok {
  background: rgba(74, 222, 128, 0.12);
  color: var(--ok);
}

.pill--muted {
  background: rgba(148, 163, 184, 0.12);
  color: var(--text-dim);
}

/* ====================================================================
   Forms (instance CRUD)
   ==================================================================== */

.instance-form { /* border/margin handled by sp-section now */ }

.instance-form h3 {
  margin: 0 0 0.85rem;
  font-size: 0.98rem;
  font-weight: 600;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field--span {
  grid-column: 1 / -1;
}

.field--inline {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

.field__label {
  font-size: 0.82rem;
  color: var(--text-dim);
}

.field input[type="text"],
.field input[type="url"],
.field input[type="password"],
.field input[type="email"],
.field input[type="number"],
.field input[type="search"],
.field select {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.form-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: flex-end;
  margin-top: 1rem;
}

.btn-primary {
  background: var(--accent);
  color: #0f172a;
  border: 0;
  border-radius: var(--radius);
  padding: 0.55rem 1.1rem;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.92rem;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-primary[disabled] {
  opacity: 0.6;
  cursor: progress;
}

.btn-link {
  background: transparent;
  border: 0;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  font-size: 0.88rem;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
}

.btn-link:hover {
  background: rgba(56, 189, 248, 0.08);
}

.btn-link.danger {
  color: var(--bad);
}

.btn-link.danger:hover {
  background: rgba(248, 113, 113, 0.1);
}

.row-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

/* ====================================================================
   Poller status panel
   ==================================================================== */

.poller-status {
  font-size: 0.92rem;
  line-height: 1.5;
  font-family: var(--mono);
}

.poller-status__err {
  margin-top: 0.4rem;
  color: var(--bad);
}

/* ====================================================================
   Analysis activity stats grid
   ==================================================================== */

.analysis-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.analysis-stat-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.analysis-stat-card__value {
  font-size: 1.55rem;
  font-weight: 700;
  font-family: var(--mono);
  line-height: 1;
}

.analysis-stat-card__label {
  font-size: 0.74rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.analysis-stat-card--ok   .analysis-stat-card__value { color: var(--ok); }
.analysis-stat-card--warn .analysis-stat-card__value { color: var(--warn); }
.analysis-stat-card--bad  .analysis-stat-card__value { color: var(--bad); }
.analysis-stat-card--dim  .analysis-stat-card__value { color: var(--text-dim); }

.analysis-stats-meta {
  font-size: 0.82rem;
  color: var(--text-dim);
  font-family: var(--mono);
  margin-bottom: 1rem;
}

/* ====================================================================
   Login page
   ==================================================================== */

.login-body {
  background: radial-gradient(
      ellipse at top,
      rgba(56, 189, 248, 0.08),
      transparent 60%
    ),
    var(--bg);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login-shell {
  width: 100%;
  max-width: 380px;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 2rem 1.75rem;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.1rem;
}

.login-brand__mark {
  width: 64px;
  height: 64px;
  object-fit: contain;
  display: block;
  margin: 0 auto 0.5rem;
  filter: drop-shadow(0 4px 12px rgba(56, 189, 248, 0.25));
}

/* The brand block on the login card looks better centered with the
   image stacked above the title, given the larger artwork. */
.login-brand {
  flex-direction: column;
  text-align: center;
  gap: 0.35rem;
}

.login-tagline {
  margin: 0.4rem 0 1.4rem;
  color: var(--text-dim);
  font-size: 0.95rem;
}

#login-form .field + .field {
  margin-top: 0.85rem;
}

#login-form .btn-primary {
  width: 100%;
  margin-top: 1rem;
  padding: 0.7rem;
  font-size: 0.95rem;
}

.login-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.25rem;
  gap: 0;
}

.login-tab {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0.55rem 0;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}

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

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

.login-error {
  margin-top: 0.85rem;
  color: var(--bad);
  font-size: 0.9rem;
}

.login-success {
  margin-top: 0.85rem;
  color: var(--ok);
  font-size: 0.9rem;
  line-height: 1.45;
}

.login-hint {
  margin-top: 1.25rem;
  font-size: 0.8rem;
  color: var(--text-dim);
  line-height: 1.45;
}

.login-hint code {
  background: rgba(255, 255, 255, 0.06);
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
  font-family: var(--mono);
}

/* ====================================================================
   Environment tile grid (dashboard — grid mode)
   ==================================================================== */

.dashboard-filters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 260px) auto;
  gap: 0.75rem;
  align-items: end;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.015);
}

.dashboard-filter {
  min-width: 0;
}

.dashboard-filter-clear {
  min-height: 38px;
  align-self: end;
}

.env-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 152px);
  gap: 1rem;
  padding: 1.25rem;
  justify-content: start;
}

.env-grid__placeholder {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-dim);
  font-style: italic;
  padding: 2rem 1rem;
}

.env-tile {
  width: 152px;
  height: 152px;
  position: relative;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  text-align: left;
  overflow: hidden;
  transition: border-color 0.12s ease, transform 0.12s ease,
    box-shadow 0.12s ease;
}

.env-tile:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.env-tile:focus-within {
  border-color: var(--accent);
}

.env-tile__open:focus-visible,
.env-tile__edit:focus-visible,
.modal-close:focus-visible,
.icon-choice:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.env-tile__open {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  padding: 0.75rem;
  background: transparent;
  border: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.env-tile__top {
  width: 100%;
  min-height: 32px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  padding-right: 1.6rem;
}

.env-tile__icon {
  width: 30px;
  height: 30px;
  object-fit: contain;
  flex: none;
  filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.3));
}

.env-tile__icon--empty {
  border: 1px dashed rgba(148, 163, 184, 0.38);
  border-radius: 8px;
  filter: none;
}

.env-tile__top .env-tile__status {
  width: 12px;
  height: 12px;
  flex: none;
  margin-top: 0.2rem;
}

.env-tile__edit {
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
  z-index: 2;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.78);
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 8px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.86rem;
  line-height: 1;
}

.env-tile__edit:hover {
  color: var(--accent);
  border-color: rgba(56, 189, 248, 0.5);
  background: rgba(15, 23, 42, 0.92);
}

.env-tile__name {
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.env-tile__instance {
  font-size: 0.72rem;
  color: var(--text-dim);
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.env-tile__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  width: 100%;
  min-height: 1.25rem;
  overflow: hidden;
}

/* Counts are pinned to the bottom of the tile. */
.env-tile__counts {
  margin-top: auto;
  font-size: 0.72rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ====================================================================
   Environment detail (dashboard — drill-down mode)
   ==================================================================== */

/* Override the default space-between header so the back link, title and
   status pill sit together on the left with the pill trailing. */
.card-header.detail-header {
  justify-content: flex-start;
  gap: 0.85rem;
}

.detail-header .btn-link {
  flex: none;
}

.detail-header h2 {
  margin: 0;
}

.detail-header #detail-status-pill {
  margin-left: auto;
}

.detail-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.45rem 1.5rem;
  padding: 1rem 1.25rem 1.25rem;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.detail-summary strong {
  color: var(--text);
  font-weight: 600;
}

.detail-summary code {
  font-family: var(--mono);
  font-size: 0.85rem;
  word-break: break-all;
}

.ports-cell {
  white-space: normal;
}

.ports-cell code {
  font-family: var(--mono);
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.05);
  padding: 0.05rem 0.3rem;
  border-radius: 4px;
}

/* State badge in the container table. */
.state-pill {
  display: inline-block;
  padding: 0.12rem 0.55rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: capitalize;
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-dim);
}

.state-pill--ok {
  background: rgba(74, 222, 128, 0.14);
  color: var(--ok);
}
.state-pill--warn {
  background: rgba(250, 204, 21, 0.14);
  color: var(--warn);
}
.state-pill--bad {
  background: rgba(248, 113, 113, 0.14);
  color: var(--bad);
}
.state-pill--muted {
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-dim);
}

/* Pill colour variants used by the detail status pill + unhealthy tag. */
.pill--warn {
  background: rgba(250, 204, 21, 0.14);
  color: var(--warn);
}

.pill--bad {
  background: rgba(248, 113, 113, 0.14);
  color: var(--bad);
}

/* ====================================================================
   Tags, icons, and metadata editor
   ==================================================================== */

.tag-list,
.env-tile__tags {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.tag-chip {
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  min-height: 1.2rem;
  padding: 0.08rem 0.4rem;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.12);
  color: #bae6fd;
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tag-chip--muted {
  background: rgba(148, 163, 184, 0.12);
  color: var(--text-dim);
}

.tag-chip--portainer {
  background: rgba(74, 222, 128, 0.14);
  color: #bbf7d0;
}

.tag-list__empty {
  color: var(--text-dim);
  font-size: 0.86rem;
}

.detail-meta {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.detail-meta--tags {
  flex-wrap: wrap;
}

.detail-meta__icon {
  width: 22px;
  height: 22px;
  object-fit: contain;
  flex: none;
}

.detail-meta__icon--empty {
  border: 1px dashed rgba(148, 163, 184, 0.5);
  border-radius: 7px;
}

.detail-meta__edit {
  margin-left: 0.1rem;
}

/* ====================================================================
   Restart overlay
   ==================================================================== */

.restart-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.restart-overlay[hidden] {
  display: none !important;
}

.restart-overlay__card {
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 12px;
  padding: 2.5rem 3rem;
  text-align: center;
  max-width: 380px;
  width: 90%;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
}

.restart-overlay__spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto 1.75rem;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.06);
  border-top-color: #3fb950;
  animation: overlaySpinSvg 0.72s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes overlaySpinSvg {
  to { transform: rotate(360deg); }
}

.restart-overlay__title {
  margin: 0 0 1.25rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: #e6edf3;
}

.restart-overlay__timer {
  font-family: "SF Mono", "Fira Mono", "Consolas", monospace;
  font-size: 3rem;
  font-weight: 700;
  line-height: 1;
  color: #3fb950;
  margin-bottom: 0.75rem;
  letter-spacing: -0.02em;
  transition: color 0.3s;
}

.restart-overlay__timer.is-done  { color: #3fb950; }
.restart-overlay__timer.is-error { color: #f85149; }

.restart-overlay__status {
  font-size: 0.85rem;
  color: #8b949e;
  margin-bottom: 1.5rem;
  min-height: 1.4em;
  transition: color 0.25s;
}

.restart-overlay__status.is-done  { color: #3fb950; }
.restart-overlay__status.is-error { color: #f85149; }

.restart-overlay__dots {
  display: flex;
  justify-content: center;
  gap: 7px;
}

.restart-overlay__dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3fb950;
  animation: overlayDot 1.4s ease-in-out infinite;
}

.restart-overlay__dots span:nth-child(2) { animation-delay: 0.22s; }
.restart-overlay__dots span:nth-child(3) { animation-delay: 0.44s; }

@keyframes overlayDot {
  0%, 80%, 100% { opacity: 0.15; transform: scale(0.85); }
  40%           { opacity: 1;    transform: scale(1); }
}

.restart-overlay__dismiss {
  margin-top: 1.5rem;
}

/* ====================================================================
   Original modal backdrop
   ==================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(2, 6, 23, 0.72);
}

.modal-backdrop[hidden] {
  display: none !important;
}

.modal {
  width: min(680px, 100%);
  max-height: calc(100vh - 3rem);
  overflow: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.modal-header,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  margin: 0;
  font-size: 1.02rem;
}

.modal-close {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1.4rem;
  line-height: 1;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.modal-body {
  padding: 1.25rem;
}

.modal-actions {
  justify-content: flex-end;
  border-top: 1px solid var(--border);
  border-bottom: 0;
}

.icon-picker {
  margin: 1rem 0 0;
  padding: 0;
  border: 0;
}

.icon-picker legend {
  margin: 0 0 0.55rem;
  color: var(--text-dim);
  font-size: 0.82rem;
}

.icon-picker__search {
  width: 100%;
  margin-bottom: 0.65rem;
  padding: 0.4rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.55);
  color: var(--text);
  font-size: 0.85rem;
  box-sizing: border-box;
}

.icon-picker__search:focus {
  outline: none;
  border-color: rgba(56, 189, 248, 0.65);
}

.icon-picker__empty {
  grid-column: 1 / -1;
  color: var(--text-dim);
  font-size: 0.85rem;
  text-align: center;
  padding: 0.75rem 0;
}

.icon-picker__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 0.55rem;
  max-height: 200px;
  overflow-y: auto;
  padding-right: 2px;
}

.icon-choice {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 44px;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.45);
  color: var(--text);
  cursor: pointer;
  font-size: 0.82rem;
  line-height: 1.2;
  min-width: 0;
}

.icon-choice:hover,
.icon-choice.is-selected {
  border-color: rgba(56, 189, 248, 0.65);
  background: rgba(56, 189, 248, 0.1);
}

.icon-choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.icon-picker__icon,
.icon-picker__none {
  width: 24px;
  height: 24px;
  flex: none;
}

.icon-picker__none {
  border: 1px dashed rgba(148, 163, 184, 0.55);
  border-radius: 7px;
}

/* ====================================================================
   Log-analysis Dashboard (problems feed)
   ==================================================================== */

/* ----- Stat cards row ------------------------------------------------ */

.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.stat-card__label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  font-weight: 600;
}

.stat-card__value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.stat-card--critical .stat-card__value { color: #fb7185; }
.stat-card--error    .stat-card__value { color: var(--bad); }
.stat-card--warning  .stat-card__value { color: var(--warn); }
.stat-card--failed   .stat-card__value { color: var(--text-dim); }

.stat-card--critical { border-color: rgba(251, 113, 133, 0.35); }
.stat-card--error    { border-color: rgba(248, 113, 113, 0.35); }
.stat-card--warning  { border-color: rgba(250, 204, 21, 0.25); }

.stat-card--clickable {
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s, border-color 0.15s;
}
.stat-card--clickable:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}
.stat-card--active {
  box-shadow: 0 0 0 2px rgba(56,189,248,0.7);
  border-color: rgba(56,189,248,0.6) !important;
}
.stat-card--active .stat-card__label::after {
  content: " ✕";
  font-size: 0.7em;
  opacity: 0.6;
}

/* ----- Problems filter bar ------------------------------------------- */

.problems-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: flex-end;
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.015);
}

.problems-filters .field {
  min-width: 130px;
  flex: 1 1 130px;
}

.problems-filters .field--narrow {
  flex: 0 1 150px;
}

.problems-filters__actions {
  display: flex;
  gap: 0.4rem;
  align-items: flex-end;
  flex: none;
}

/* ----- Severity / classification pills in the table ------------------ */

.sev-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  padding: 0.12rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}

.sev-pill::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.75;
  flex: none;
}

.sev-pill--critical {
  background: rgba(251, 113, 133, 0.15);
  color: #fb7185;
}
.sev-pill--error {
  background: rgba(248, 113, 113, 0.14);
  color: var(--bad);
}
.sev-pill--warning {
  background: rgba(250, 204, 21, 0.14);
  color: var(--warn);
}
.sev-pill--info {
  background: rgba(56, 189, 248, 0.12);
  color: var(--accent);
}
.sev-pill--unknown,
.sev-pill--failed {
  background: rgba(148, 163, 184, 0.12);
  color: var(--text-dim);
}

/* Classification pill (no dot) */
.cls-pill {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 6px;
  font-size: 0.74rem;
  font-weight: 600;
  white-space: nowrap;
  background: rgba(148, 163, 184, 0.1);
  color: var(--text-dim);
}
.cls-pill--critical_failure  { background: rgba(251,113,133,0.15); color: #fb7185; }
.cls-pill--probable_failure  { background: rgba(248,113,113,0.13); color: var(--bad); }
.cls-pill--warning_needs_cleanup { background: rgba(250,204,21,0.13); color: var(--warn); }
.cls-pill--failed_analysis   { background: rgba(148,163,184,0.12); color: var(--text-dim); }

/* ----- Table row priority indicators --------------------------------- */

.problem-row--critical td:first-child {
  box-shadow: inset 3px 0 0 #fb7185;
}
.problem-row--error td:first-child {
  box-shadow: inset 3px 0 0 var(--bad);
}
.problem-row--warning td:first-child {
  box-shadow: inset 3px 0 0 var(--warn);
}

.problem-row {
  cursor: pointer;
  transition: background 0.1s ease;
}
.problem-row:hover td {
  background: rgba(56, 189, 248, 0.04) !important;
}

/* Truncate long summary text in the table */
.summary-cell {
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ----- Confidence bar ------------------------------------------------ */

.confidence-bar {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
}

.confidence-bar__track {
  flex: 1;
  height: 5px;
  border-radius: 3px;
  background: rgba(148, 163, 184, 0.18);
  min-width: 48px;
  overflow: hidden;
}

.confidence-bar__fill {
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
  transition: width 0.3s ease;
}

.confidence-bar__fill--low   { background: var(--text-dim); }
.confidence-bar__fill--mid   { background: var(--warn); }
.confidence-bar__fill--high  { background: var(--accent); }
.confidence-bar__fill--full  { background: var(--ok); }

/* ----- Problem detail modal ------------------------------------------ */

.problem-detail {
  font-size: 0.92rem;
}

.problem-detail__section {
  margin-bottom: 1.25rem;
}

.problem-detail__section:last-child {
  margin-bottom: 0;
}

.problem-detail__heading {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 0 0 0.5rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}

.problem-detail__meta-grid {
  display: grid;
  grid-template-columns: minmax(120px, 160px) 1fr;
  gap: 0.3rem 0.75rem;
}

.problem-detail__meta-grid dt {
  color: var(--text-dim);
  font-size: 0.85rem;
}

.problem-detail__meta-grid dd {
  margin: 0;
  font-size: 0.88rem;
  word-break: break-word;
}

.problem-detail__summary {
  line-height: 1.55;
  color: var(--text);
}

.problem-detail__hypothesis {
  line-height: 1.55;
  color: var(--text);
  font-style: italic;
}

.problem-detail__actions-list,
.problem-detail__terms-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.problem-detail__actions-list li {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.problem-detail__actions-list li::before {
  content: "→";
  color: var(--accent);
  flex: none;
  margin-top: 0.05em;
}

.problem-detail__terms-list li {
  display: inline-flex;
}

.gh-term {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.7rem;
  background: rgba(56, 189, 248, 0.1);
  color: var(--accent);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 6px;
  font-size: 0.82rem;
  font-family: var(--mono);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s;
}

.gh-term:hover {
  background: rgba(56, 189, 248, 0.2);
}

/* Evidence list */
.evidence-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.evidence-item {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
}

.evidence-item__ts {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-dim);
  flex: none;
  white-space: nowrap;
}

.evidence-item__body {
  min-width: 0;
}

.evidence-item__message {
  word-break: break-word;
  line-height: 1.4;
}

/* Raw response block */
.raw-response {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 240px;
  overflow-y: auto;
  color: var(--text-dim);
}

/* Detail modal — wider than default */
.modal--wide {
  width: min(860px, 100%);
}

/* Actions row in detail */
.detail-action-btns {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

/* ── Icon-only button (gear) ────────────────────────────────────────── */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  font-size: 1rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.btn-icon:hover {
  color: var(--text);
  border-color: rgba(56,189,248,0.55);
  background: rgba(56,189,248,0.08);
}

/* ── Preferences modal — column list ────────────────────────────────── */
.col-prefs-hint {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin: 0 0 0.75rem;
}

.col-prefs-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0.4rem;
  border-radius: 6px;
  cursor: grab;
  font-size: 0.875rem;
  user-select: none;
  transition: background 0.1s;
}
.col-prefs-item:hover         { background: rgba(56,189,248,0.07); }
.col-prefs-item.drag-over     { background: rgba(56,189,248,0.18); outline: 1px solid rgba(56,189,248,0.4); }
.col-prefs-item.dragging      { opacity: 0.35; }
.col-prefs-item.no-drag       { cursor: default; }

.col-prefs-handle {
  color: var(--text-dim);
  font-size: 1rem;
  line-height: 1;
  flex-shrink: 0;
}
.col-prefs-handle--disabled   { opacity: 0.25; cursor: default; }

.col-prefs-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Model picker modal ─────────────────────────────────────────────── */
.model-picker-list {
  max-height: 420px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 0.5rem;
}

.model-picker-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.9rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}

.model-picker-item:last-child { border-bottom: none; }

.model-picker-item:hover { background: rgba(56,189,248,0.06); }

.model-picker-item__name {
  flex: 1;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  font-family: var(--mono);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-picker-item__meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  font-size: 0.78rem;
  color: var(--text-dim);
}

.model-cost-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

.model-cost-badge--free      { background: rgba(52,211,153,0.15); color:#6ee7b7; border:1px solid rgba(52,211,153,0.3); }
.model-cost-badge--free-cold { background: rgba(250,204,21,0.12);  color:#fde68a; border:1px solid rgba(250,204,21,0.25); }
.model-cost-badge--paid      { background: rgba(251,113,133,0.12); color:#fca5a5; border:1px solid rgba(251,113,133,0.25); }
.model-cost-badge--local     { background: rgba(56,189,248,0.12);  color:rgba(56,189,248,0.9); border:1px solid rgba(56,189,248,0.25); }

/* ── Settings section actions row ───────────────────────────────────── */
.sp-section__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem;
  padding-top: 1rem;
  margin-top: 0.25rem;
  border-top: 1px solid var(--border);
}

/* ── Field with inline action button ────────────────────────────────── */
.field-with-action {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.field-with-action input,
.field-with-action select { flex: 1; min-width: 0; }
.field-with-action .btn-secondary { white-space: nowrap; font-size: 0.82rem; flex-shrink: 0; }

/* ── Field group label (above provider cards) ───────────────────────── */
.sp-field-group-label {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin: 1rem 0 0.5rem;
  font-weight: 500;
}

/* ── Inline link in sp-alert ─────────────────────────────────────────── */
.sp-link {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ── LLM provider cards ─────────────────────────────────────────────── */
.provider-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.provider-card {
  position: relative;
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: rgba(0,0,0,0.15);
  user-select: none;
}

.provider-card:hover {
  border-color: rgba(56,189,248,0.45);
  background: rgba(56,189,248,0.04);
}

.provider-card input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.provider-card.is-selected {
  border-color: rgba(56,189,248,0.85);
  background: rgba(56,189,248,0.07);
}

.provider-card.is-selected .provider-card__check {
  opacity: 1;
}

.provider-card__header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.35rem;
}

.provider-card__logo {
  font-size: 1.35rem;
  line-height: 1;
  flex-shrink: 0;
}

.provider-card__name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.provider-card__check {
  margin-left: auto;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(56,189,248,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
  flex-shrink: 0;
  font-size: 0.65rem;
  color: #0f172a;
  font-weight: 700;
}

.provider-card__desc {
  font-size: 0.8rem;
  color: var(--text-dim);
  line-height: 1.4;
}

.provider-card__badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  margin-top: 0.4rem;
}

.provider-card__badge--local {
  background: rgba(52,211,153,0.15);
  color: #6ee7b7;
  border: 1px solid rgba(52,211,153,0.3);
}

.provider-card__badge--cloud {
  background: rgba(56,189,248,0.12);
  color: rgba(56,189,248,0.9);
  border: 1px solid rgba(56,189,248,0.25);
}

/* LLM enabled row */
.llm-enabled-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.llm-enabled-row__label {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
}

.llm-enabled-row__desc {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 0.1rem;
}

/* Provider config sub-heading */
.provider-config-heading {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
  margin: 1.25rem 0 0.65rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.provider-config-heading::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Toggle switch ──────────────────────────────────────────────────── */
.toggle-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  cursor: pointer;
}
.toggle-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-switch__track {
  display: block;
  width: 2.2rem;
  height: 1.2rem;
  border-radius: 999px;
  background: rgba(148,163,184,0.25);
  border: 1px solid var(--border);
  transition: background 0.2s, border-color 0.2s;
  position: relative;
}
.toggle-switch__track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: calc(1.2rem - 6px);
  height: calc(1.2rem - 6px);
  border-radius: 50%;
  background: var(--text-dim);
  transition: transform 0.2s, background 0.2s;
}
.toggle-switch input:checked + .toggle-switch__track {
  background: rgba(56,189,248,0.75);
  border-color: rgba(56,189,248,0.9);
}
.toggle-switch input:checked + .toggle-switch__track::after {
  transform: translateX(1rem);
  background: #fff;
}
.toggle-switch input:disabled + .toggle-switch__track {
  opacity: 0.45;
  cursor: not-allowed;
}
.toggle-switch:has(input:disabled) { cursor: not-allowed; }

/* ── Full-screen table ──────────────────────────────────────────────── */

/* Native fullscreen: style the card when it is the fullscreen element */
#problems-card:fullscreen,
#problems-card:-webkit-full-screen {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border-radius: 0;
  overflow: hidden;
}

/* The table area grows to fill the fullscreen space and scrolls */
#problems-card:fullscreen #problems-table-area,
#problems-card:-webkit-full-screen #problems-table-area {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

/* CSS fallback for browsers that block fullscreen API */
#problems-card.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 400;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#problems-card.is-fullscreen #problems-table-area {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

/* Button active state */
#problems-fullscreen-btn[aria-pressed="true"] svg {
  transform: rotate(45deg);
}
#problems-fullscreen-btn[aria-pressed="true"] {
  color: var(--accent);
  border-color: rgba(56,189,248,0.55);
  background: rgba(56,189,248,0.08);
}

/* ── Sortable th ────────────────────────────────────────────────────── */
#problems-table th[data-sortable]:hover {
  background: rgba(56,189,248,0.06);
  color: var(--text);
}
#problems-table th.th-sort-active {
  color: rgba(56,189,248,0.95);
}
.sort-idle {
  opacity: 0.35;
  font-size: 0.75em;
}

/* ── Resizable th ───────────────────────────────────────────────────── */
#problems-table th {
  position: relative;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#problems-table th .col-resize-handle {
  position: absolute;
  right: 0;
  top: 0;
  width: 5px;
  height: 100%;
  cursor: col-resize;
  z-index: 1;
}

#problems-table th .col-resize-handle:hover,
#problems-table th .col-resize-handle.resizing {
  background: rgba(56,189,248,0.45);
}

/* Empty / loading / error states for problems table */
.problems-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  padding: 3.5rem 2rem;
  color: var(--text-dim);
  text-align: center;
}

.problems-state[hidden] {
  display: none;
}

.problems-state__icon {
  font-size: 2.5rem;
  opacity: 0.55;
}

.problems-state__title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.problems-state__body {
  margin: 0;
  font-size: 0.9rem;
  max-width: 360px;
}

/* ====================================================================
   Settings — env-var key badges
   ==================================================================== */

/* Inline monospace badge showing the env var name */
.env-key {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.06);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  margin-left: 0.35rem;
  user-select: all;
  white-space: nowrap;
}

/* Section heading within a settings panel */
.settings-section-heading {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin: 1.5rem 0 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}
.settings-section-heading:first-child {
  margin-top: 0;
}

/* Restart-required warning banner */
.restart-warning {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.35);
  color: #fde68a;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius);
  font-size: 0.88rem;
  margin-bottom: 1.25rem;
}
.restart-warning--result {
  margin-top: 0.85rem;
  margin-bottom: 0;
}
.restart-warning code {
  background: rgba(255, 255, 255, 0.1);
  padding: 0.05rem 0.3rem;
  border-radius: 3px;
  font-family: var(--mono);
}

/* Cleaner rules table */
.rules-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  margin-bottom: 0.75rem;
}
.rules-table th {
  text-align: left;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--border);
}
.rules-table td {
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: middle;
}
.rules-table tr:last-child td {
  border-bottom: 0;
}
.rules-table input[type="text"],
.rules-table input[type="number"] {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  padding: 0.3rem 0.5rem;
  font-size: 0.88rem;
  font-family: var(--mono);
}
.rules-table input[type="number"] {
  font-family: inherit;
  width: 80px;
}
.rules-table td.col-enabled {
  text-align: center;
  width: 60px;
}
.rules-table td.col-del {
  width: 38px;
  text-align: center;
}
.rules-table .btn-link.danger {
  padding: 0.25rem 0.4rem;
}

/* ====================================================================
   Restart bar
   ==================================================================== */

.restart-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 1rem;
  background: rgba(251, 191, 36, 0.06);
  border-bottom: 1px solid rgba(251, 191, 36, 0.18);
  font-size: 0.82rem;
  flex-wrap: wrap;
}

.restart-bar__hint {
  color: #fde68a;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.restart-bar__right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.restart-bar__status {
  font-size: 0.82rem;
  min-width: 0;
}

.restart-bar__status.is-ok  { color: #4ade80; }
.restart-bar__status.is-bad { color: #f87171; }

/* The Restart app button */
.btn-restart {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.85rem;
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.35);
  border-radius: 6px;
  color: #fde68a;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
  white-space: nowrap;
}

.btn-restart:hover:not(:disabled) {
  background: rgba(251, 191, 36, 0.22);
  border-color: rgba(251, 191, 36, 0.55);
}

.btn-restart:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-restart__icon {
  font-size: 1rem;
  line-height: 1;
}

/* Spinning animation while restarting */
.btn-restart--spinning .btn-restart__icon {
  display: inline-block;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ====================================================================
   Responsive
   ==================================================================== */

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 240px;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 20;
    box-shadow: var(--shadow);
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .icon-btn {
    display: inline-flex;
  }

  .btn-refresh__label {
    display: none;
  }
}

@media (max-width: 480px) {
  .content {
    padding: 1rem 0.75rem 2rem;
  }
  .topbar {
    padding: 0.7rem 1rem;
  }
  .settings-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .settings-grid dt {
    padding-bottom: 0;
  }
  .settings-grid dd {
    padding-top: 0.2rem;
    border-top: 0;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .dashboard-filters {
    grid-template-columns: 1fr;
  }
  .dashboard-filter-clear {
    justify-self: start;
  }
}
