/* RAGI · Sky ops: navy with a sky-blue accent. Contrast targets WCAG AA. */
:root {
  --bg: #0a1428;
  --bg-2: #0d1a33;
  --panel: #12213f;
  --panel-2: #172a4d;
  --line: #24395f;
  --text: #e8eef8;
  --muted: #a9b8d0;      /* 7.9:1 on --panel */
  --sky: #38bdf8;
  --sky-2: #7dd3fc;
  --sky-ink: #04263a;
  --ok: #4ade80;
  --bad: #fca5a5;
  --warn: #fcd34d;
  --radius: 14px;
  --tap: 44px;
  --side: 248px;
  --tabbar: 68px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: linear-gradient(180deg, var(--bg-2), var(--bg) 320px); overflow-x: hidden; }
a { color: var(--sky-2); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--sky); outline-offset: 2px; border-radius: 8px;
}
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--sky); color: var(--sky-ink); padding: 10px 14px; border-radius: 8px; z-index: 50; }
.skip:focus { left: 8px; }
.noscript { padding: 24px; }

/* Layout */
.shell { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 20px;
  padding: 20px 14px; background: rgba(10, 20, 40, .85); border-right: 1px solid var(--line);
}
.brand { display: flex; gap: 12px; align-items: center; text-decoration: none; color: var(--text); padding: 4px 8px; min-height: var(--tap); }
.brand span { display: flex; flex-direction: column; line-height: 1.2; }
.brand strong { font-size: 1.15rem; letter-spacing: .04em; }
.brand small { color: var(--muted); font-size: .8rem; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
  display: flex; align-items: center; gap: 12px; min-height: var(--tap); padding: 10px 12px; border-radius: 10px;
  color: var(--muted); text-decoration: none; font-weight: 600;
}
.nav a:hover { background: var(--panel); color: var(--text); }
.nav a[aria-current="page"] { background: rgba(56, 189, 248, .14); color: var(--sky-2); box-shadow: inset 3px 0 0 var(--sky); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; font-size: .85rem; }
.side-foot .status { margin: 0; color: var(--muted); }
.money-link { display: inline-flex; align-items: center; min-height: var(--tap); }
main { min-width: 0; padding: 24px 28px 40px; outline: none; }

/* Typography */
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0; }
h2 { font-size: 1.1rem; margin: 0 0 12px; }
h3 { font-size: 1rem; margin: 0; }
.lede { color: var(--muted); margin: 4px 0 0; }
.head { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; justify-content: space-between; margin-bottom: 20px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--tap); min-width: var(--tap);
  padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--sky); }
.btn.primary { background: var(--sky); border-color: var(--sky); color: var(--sky-ink); }
.btn.primary:hover { background: var(--sky-2); }
.btn[disabled] { opacity: .6; cursor: progress; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* Banner */
.banner { margin: 0 0 16px; padding: 12px 14px; border-radius: 12px; border: 1px solid #7a5d12; background: #2a2208; color: #fde68a; }
.banner.info { border-color: var(--line); background: var(--panel); color: var(--text); }

/* KPI row */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 24px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; min-width: 0; text-decoration: none; color: var(--text); display: block; }
a.kpi:hover { border-color: var(--sky); }
.kpi .label { color: var(--muted); font-size: .85rem; font-weight: 600; }
.kpi .value { font-size: 1.9rem; font-weight: 750; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi.bad .value { color: var(--bad); }
.kpi.good .value { color: var(--ok); }

/* Board (Trello-style columns) */
.board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; align-items: start; }
.col { background: rgba(18, 33, 63, .55); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; min-width: 0; }
.col-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 2px 4px 10px; }
.col-head .count { background: var(--panel-2); color: var(--muted); border-radius: 99px; padding: 0 10px; font-size: .85rem; font-weight: 700; }
.col-hint { color: var(--muted); font-size: .8rem; margin: -6px 4px 10px; }
.cards { display: flex; flex-direction: column; gap: 10px; list-style: none; margin: 0; padding: 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; min-width: 0; }
.card:hover { border-color: #3b5a8f; }
.card a.title { color: var(--text); font-weight: 700; text-decoration: none; overflow-wrap: anywhere; display: inline-flex; align-items: center; min-height: 32px; }
.card a.title:hover { color: var(--sky-2); text-decoration: underline; }
.card p { margin: 4px 0 8px; color: var(--muted); font-size: .9rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .row { margin-top: 8px; }
.empty { color: var(--muted); font-size: .9rem; padding: 6px 4px; }

/* Badges */
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { display: inline-flex; align-items: center; gap: 6px; border-radius: 99px; padding: 2px 10px; font-size: .8rem; font-weight: 650; border: 1px solid var(--line); color: var(--muted); background: var(--bg-2); white-space: nowrap; }
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.badge.ok { color: var(--ok); border-color: #1f5136; }
.badge.bad { color: var(--bad); border-color: #6b2a2a; }
.badge.warn { color: var(--warn); border-color: #6b5314; }
.badge.sky { color: var(--sky-2); border-color: #1d4a68; }
.badge.plain::before { display: none; }
.new-tag { background: var(--sky); color: var(--sky-ink); border-radius: 6px; font-size: .7rem; font-weight: 800; padding: 1px 6px; margin-left: 6px; }

/* Lists / tables */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; padding: 10px 0; border-top: 1px solid var(--line); min-width: 0; }
.list li:first-child { border-top: 0; }
.list .main { min-width: 0; }
.list a { overflow-wrap: anywhere; }
.list .meta { color: var(--muted); font-size: .82rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.input, select.input {
  min-height: var(--tap); padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-2);
  color: var(--text); font: inherit; min-width: 0; flex: 1 1 220px;
}
select.input { flex: 0 1 200px; }
.repo-table { width: 100%; border-collapse: collapse; }
.repo-table th { text-align: left; color: var(--muted); font-size: .82rem; font-weight: 650; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.repo-table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.repo-table tr:hover td { background: rgba(23, 42, 77, .5); }

/* Sites grid */
.sites { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.site-url { color: var(--muted); font-size: .85rem; overflow-wrap: anywhere; margin: 4px 0 10px; }

/* Viewer */
.viewer { display: flex; flex-direction: column; gap: 10px; height: calc(100dvh - 64px); }
.viewer-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.viewer-bar .where { flex: 1 1 160px; min-width: 0; color: var(--muted); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.frame-wrap { position: relative; flex: 1; min-height: 320px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; }
.frame-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.fallback { padding: 24px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }

/* Detail page */
.crumbs { margin-bottom: 8px; }
.crumbs a { display: inline-flex; align-items: center; min-height: var(--tap); }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin: 16px 0; }
.fact { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.fact .k { color: var(--muted); font-size: .8rem; }
.fact .v { font-weight: 650; overflow-wrap: anywhere; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85em; color: var(--sky-2); }

/* Tablet */
@media (max-width: 1180px) {
  .board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Phone: sidebar becomes a glassy bottom tab bar */
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; z-index: 20; padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    flex-direction: row; gap: 0; border-right: 0; border-top: 1px solid rgba(125, 211, 252, .22);
    background: rgba(13, 26, 51, .72); backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4);
  }
  .brand, .side-foot { display: none; }
  .nav { flex-direction: row; width: 100%; gap: 2px; }
  .nav a { flex: 1 1 0; min-width: 0; flex-direction: column; gap: 2px; padding: 6px 2px; min-height: 56px; font-size: .72rem; justify-content: center; text-align: center; }
  .nav a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nav a[aria-current="page"] { box-shadow: inset 0 3px 0 var(--sky); }
  main { padding: 16px 14px calc(var(--tabbar) + 28px + env(safe-area-inset-bottom)); }
  h1 { font-size: 1.35rem; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpis .kpi:first-child { grid-column: 1 / -1; }
  .kpi .value { font-size: 1.6rem; }
  .board, .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .repo-table thead { display: none; }
  .repo-table, .repo-table tbody, .repo-table tr, .repo-table td { display: block; width: 100%; }
  .repo-table tr { border-bottom: 1px solid var(--line); padding: 8px 0; }
  .repo-table td { border: 0; padding: 4px 0; }
  .viewer { height: calc(100dvh - var(--tabbar) - 60px - env(safe-area-inset-bottom)); }
  .mobile-only-hide { display: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .card, .kpi, .btn, .nav a { transition: border-color .15s, background-color .15s, color .15s; }
}
.mt { margin-top: 16px; }
.m0 { margin: 0; }
.btn.more { width: 100%; margin-top: 10px; background: transparent; }
