:root {
  color-scheme: dark;
  font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #eef2f8;
  background: #080b10;
  --bg: #080b10;
  --surface: rgba(18, 23, 32, 0.92);
  --surface-raised: #151c27;
  --surface-hover: #1a2432;
  --border: #283445;
  --border-strong: #3b4a60;
  --text: #eef2f8;
  --muted: #8e9aac;
  --accent: #8bb7ff;
  --accent-strong: #4f8ce9;
  --good: #79dda7;
  --warn: #f2c76f;
  --bad: #ff918c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 80% -10%, rgba(62, 105, 170, 0.28), transparent 36rem),
    radial-gradient(circle at -10% 90%, rgba(39, 75, 119, 0.18), transparent 30rem),
    var(--bg);
}

button, input, select { font: inherit; }
button, summary, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.shell { max-width: 1420px; margin: 0 auto; padding: 0 28px 42px; }
.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  gap: 18px;
  border-bottom: 1px solid rgba(68, 83, 104, 0.42);
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-size: 16px; }
.brand strong { color: var(--accent); }
.brand-mark {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid #4878bd;
  border-radius: 9px;
  color: #cfe0ff;
  background: linear-gradient(145deg, #2d5d9f, #193658);
  box-shadow: inset 0 1px rgba(255,255,255,.16), 0 8px 24px rgba(0,0,0,.24);
  font-weight: 800;
}
.identity { margin-left: auto; color: var(--muted); font-size: 13px; }

.surface {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(16px);
}
.gate { max-width: 570px; margin: 84px auto; padding: 36px; }
.gate h1 { margin: 4px 0 10px; font-size: clamp(24px, 4vw, 31px); letter-spacing: -.035em; }
.gate .button { margin-top: 12px; }
.gate-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  margin-bottom: 26px;
  border: 1px solid #436b9f;
  border-radius: 12px;
  color: var(--accent);
  background: #172942;
  font-size: 21px;
}
.error-icon { color: var(--bad); border-color: #70423f; background: #321e20; }
.loading-card { display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 150px; }
.loading-card p { margin: 0; }
.spinner {
  width: 19px;
  height: 19px;
  display: inline-block;
  border: 2px solid #34445a;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.eyebrow { margin: 0 0 7px; color: #8190a4; font-size: 11px; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #4d8be6;
  border-radius: 9px;
  padding: 8px 14px;
  color: #fff;
  background: linear-gradient(#4384e2, #326fc6);
  box-shadow: inset 0 1px rgba(255,255,255,.15), 0 7px 18px rgba(34, 87, 159, .22);
  cursor: pointer;
  text-decoration: none;
}
.button:hover { filter: brightness(1.08); }
.button.compact { min-height: 33px; width: 100%; padding: 6px 10px; font-size: 12px; }

.app { display: grid; grid-template-columns: 274px minmax(0, 1fr); gap: 22px; margin-top: 22px; }
.sidebar { position: sticky; top: 20px; height: max-content; max-height: calc(100vh - 40px); padding: 20px; overflow: auto; }
.sidebar-section { margin-top: 22px; }
.sidebar-section.first { margin-top: 0; }
.github-user { display: flex; align-items: center; gap: 9px; font-size: 15px; font-weight: 700; }
.avatar { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: #233a5a; color: #bcd5fc; text-transform: uppercase; }
.field-label { display: block; margin-bottom: 8px; color: #aab5c4; font-size: 12px; font-weight: 650; }
select, input[type="search"] {
  width: 100%;
  border: 1px solid #334155;
  border-radius: 9px;
  padding: 9px 10px;
  color: var(--text);
  background: #0d131c;
}

.nav { display: grid; gap: 5px; margin: 20px -7px; }
.nav button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 8px 9px;
  color: #b4bfce;
  background: transparent;
  cursor: pointer;
  text-align: left;
}
.nav button:hover { color: var(--text); background: rgba(43, 56, 74, .5); }
.nav button.active { color: #fff; border-color: #3b4c64; background: #202b39; box-shadow: inset 3px 0 #6ca4f5; }
.count { min-width: 25px; border-radius: 999px; padding: 1px 7px; color: #c7d0dd; background: #303d4e; font-size: 11px; text-align: center; }
.nav button.active .count { color: #d8e7ff; background: #35547d; }

.repository-settings { border-top: 1px solid var(--border); padding-top: 15px; }
.repository-settings summary { color: #aab5c4; font-size: 12px; font-weight: 650; cursor: pointer; }
.repository-list { display: grid; gap: 9px; max-height: 260px; margin: 13px 0; overflow: auto; }
.repository-list label { display: grid; grid-template-columns: 15px minmax(0,1fr); gap: 8px; align-items: start; color: var(--muted); font-size: 12px; }
.repository-list label span { overflow-wrap: anywhere; }
.text-button { width: 100%; margin-top: 17px; border: 0; padding: 6px; color: #77869a; background: transparent; cursor: pointer; font-size: 12px; }
.text-button:hover { color: var(--bad); }

.workspace { min-width: 0; }
.workspace-head { min-height: 84px; display: flex; align-items: end; justify-content: space-between; gap: 24px; padding: 8px 4px 18px; }
.workspace-head h1 { margin: 0; font-size: clamp(23px, 3vw, 29px); letter-spacing: -.035em; }
.status { max-width: 520px; margin: 0 0 3px; font-size: 12px; text-align: right; }
.cards { display: grid; gap: 10px; }
.work-card {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0;
  color: inherit;
  background: rgba(19, 25, 35, .88);
  overflow: hidden;
  text-decoration: none;
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}
.work-card:hover { border-color: #496386; background: var(--surface-hover); transform: translateY(-1px); }
.card-main { min-width: 0; display: grid; justify-items: start; border: 0; padding: 16px 18px; color: inherit; background: transparent; cursor: pointer; text-align: left; }
.issue-card .card-main { cursor: inherit; }
.repo { color: var(--accent); font-size: 11px; font-weight: 700; letter-spacing: .02em; }
.title { display: block; margin: 5px 0 4px; font-size: 15px; font-weight: 700; }
.meta, .coordinates { color: var(--muted); font-size: 11px; }
.coordinates { margin-top: 8px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.card-aside { display: flex; align-items: center; gap: 10px; padding-right: 15px; }
.badges { max-width: 290px; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; padding: 12px 15px 12px 0; }
.badge { border: 1px solid #3a485b; border-radius: 999px; padding: 3px 8px; color: #c4cdd9; font-size: 10px; white-space: nowrap; }
.badge.passing, .badge.approved { border-color: #347653; color: var(--good); }
.badge.failing, .badge.changes_requested, .badge.invalidated { border-color: #89443f; color: var(--bad); }
.badge.pending, .badge.pending_corroboration, .badge.stale, .badge.unverified { border-color: #85682f; color: var(--warn); }
.external-link { width: 29px; height: 29px; display: grid; place-items: center; border-radius: 8px; color: #91a1b6; text-decoration: none; }
.external-link:hover { color: #fff; background: #2a3748; }
.empty { min-height: 180px; display: grid; place-items: center; align-content: center; border: 1px dashed #2f3c4e; border-radius: 13px; padding: 32px; color: var(--muted); text-align: center; }
.empty-mark { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: var(--good); background: #173226; }
.empty p { margin: 10px 0 0; }
.error-state .button { margin-top: 12px; width: auto; }

.detail-backdrop { position: fixed; inset: 0; z-index: 9; border: 0; background: rgba(2, 5, 9, .68); backdrop-filter: blur(3px); cursor: default; }
.detail { position: fixed; inset: 0 0 0 auto; z-index: 10; width: min(650px, 100%); padding: 28px; overflow: auto; border-left: 1px solid #39475a; background: #10161f; box-shadow: -32px 0 80px rgba(0,0,0,.5); animation: slide-in .18s ease-out; }
@keyframes slide-in { from { transform: translateX(24px); opacity: .6; } }
.detail-head { display: flex; justify-content: space-between; gap: 18px; }
.detail h2 { margin: 6px 0 12px; font-size: 22px; letter-spacing: -.02em; }
.icon-button { width: 34px; height: 34px; flex: 0 0 auto; border: 1px solid #374457; border-radius: 9px; color: #c8d0db; background: #19212d; cursor: pointer; font-size: 21px; }
.detail-section { margin-top: 28px; }
.detail-section h3 { margin: 0 0 10px; color: #8c99aa; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; }
.body { white-space: pre-wrap; line-height: 1.6; border: 1px solid #283445; border-radius: 10px; padding: 15px; color: #cbd3de; background: #0b1017; }
.stack { display: grid; gap: 8px; }
.stack-item { display: grid; gap: 4px; border: 1px solid #2d3a4b; border-radius: 9px; padding: 11px; color: inherit; text-decoration: none; }
.stack-item:hover { border-color: #4b6689; background: #17202c; }

.htmx-request .spinner, .htmx-request.spinner { display: inline-block; }

@media (max-width: 820px) {
  .shell { padding: 0 14px 28px; }
  .topbar { height: 62px; }
  .identity { max-width: 44vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: none; }
  .workspace-head { align-items: start; flex-direction: column; gap: 8px; }
  .status { text-align: left; }
  .work-card { grid-template-columns: 1fr; }
  .card-aside, .badges { justify-content: flex-start; padding: 0 16px 13px; }
  .issue-card .badges { padding-left: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
