:root {
  color-scheme: dark;
  --bg: #070a12;
  --bg-2: #0b1120;
  --panel: #111827;
  --panel-2: #172033;
  --panel-3: #1f2a44;
  --text: #f4f7fb;
  --muted: #94a3b8;
  --muted-2: #64748b;
  --line: rgba(148, 163, 184, .22);
  --line-strong: rgba(148, 163, 184, .34);
  --accent: #6ee7b7;
  --accent-2: #7dd3fc;
  --warning: #fbbf24;
  --danger: #fb7185;
  --success: #86efac;
  --shadow: 0 24px 80px rgba(0, 0, 0, .34);
}

* { box-sizing: border-box; }
html { scroll-padding-top: 104px; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(110, 231, 183, .16) 0, transparent 34rem),
    radial-gradient(circle at top right, rgba(125, 211, 252, .12) 0, transparent 30rem),
    linear-gradient(180deg, var(--bg-2) 0, var(--bg) 46rem);
  color: var(--text);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(255,255,255,.026) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.026) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.62), transparent 70%);
}

.auth-body { display: grid; place-items: center; padding: 24px; }
.admin-body { padding-bottom: 48px; }

.shell {
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
}
.shell.auth-shell { padding: 56px 0; width: min(460px, calc(100% - 32px)); }
.shell.admin-main { padding: 30px 0 64px; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(18px);
  background: linear-gradient(180deg, rgba(7, 10, 18, .92), rgba(7, 10, 18, .78));
  border-bottom: 1px solid var(--line);
  box-shadow: 0 10px 40px rgba(0, 0, 0, .24);
}
.app-header-inner {
  width: min(1180px, calc(100% - 36px));
  min-height: 74px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
}
.app-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
  min-width: 0;
}
.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: inline-grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04111d;
  font-weight: 950;
  box-shadow: 0 14px 36px rgba(110, 231, 183, .22);
}
.brand-copy { display: grid; line-height: 1.08; }
.brand-copy strong { font-size: 16px; letter-spacing: -.02em; }
.brand-copy small { color: var(--muted); font-size: 12px; }
.app-nav {
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(15, 23, 42, .62);
  overflow-x: auto;
  max-width: 100%;
}
.app-nav-link {
  flex: 0 0 auto;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 800;
  padding: 9px 12px;
  border-radius: 999px;
  transition: color .16s ease, background .16s ease, box-shadow .16s ease;
}
.app-nav-link:hover { color: var(--text); background: rgba(148, 163, 184, .10); }
.app-nav-link.active {
  color: #04111d;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 26px rgba(110, 231, 183, .18);
}
.app-nav-link-sub { color: var(--accent-2); }
.app-user-actions { display: inline-flex; justify-content: flex-end; align-items: center; gap: 10px; min-width: 0; }
.user-chip {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(15, 23, 42, .7);
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 800;
}
.logout-form { margin: 0; }

.card, .metric {
  background: linear-gradient(180deg, rgba(17, 24, 39, .92), rgba(15, 23, 42, .78));
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
}
.card { padding: 26px; }
.card:hover, .metric:hover { border-color: var(--line-strong); }
.narrow { max-width: 420px; margin: 0 auto; }
.login-card { position: relative; overflow: hidden; }
.login-card::before {
  content: "";
  position: absolute;
  inset: -1px -1px auto -1px;
  height: 4px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2), #c4b5fd);
}
.eyebrow { color: var(--accent); text-transform: uppercase; letter-spacing: .14em; font-size: 12px; font-weight: 850; }
h1 { margin: 0 0 10px; font-size: clamp(34px, 5vw, 54px); letter-spacing: -.055em; line-height: .98; }
.title-count { color: var(--accent); font-size: .58em; letter-spacing: -.03em; vertical-align: baseline; }
h2 { margin: 0 0 12px; font-size: 20px; letter-spacing: -.025em; }
p { line-height: 1.55; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.alert { color: white; background: rgba(251,113,133,.16); border: 1px solid rgba(251,113,133,.42); padding: 12px 14px; border-radius: 16px; }

.form { display: grid; gap: 16px; margin-top: 24px; }
label { display: grid; gap: 8px; color: var(--muted); font-size: 14px; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(15, 23, 42, .84);
  color: var(--text);
  border-radius: 14px;
  padding: 13px 14px;
  font: inherit;
  outline: none;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
input:focus, textarea:focus, select:focus { border-color: rgba(110,231,183,.7); box-shadow: 0 0 0 4px rgba(110,231,183,.10); background: rgba(15,23,42,.96); }
textarea { min-height: 130px; resize: vertical; }
select { cursor: pointer; }
.alert ul { margin: 8px 0 0; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.task-form-note { margin: -4px 0 0; }

button, .button {
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #062016;
  font-weight: 850;
  padding: 13px 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  line-height: 1;
  box-shadow: 0 14px 32px rgba(110, 231, 183, .16);
}
button:hover, .button:hover { transform: translateY(-1px); }
button.secondary, .button.secondary { background: rgba(15, 23, 42, .76); color: var(--text); border: 1px solid var(--line); box-shadow: none; }
button.compact, .button.compact { padding: 10px 12px; border-radius: 12px; font-size: 13px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.hero-panel {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: linear-gradient(135deg, rgba(110,231,183,.10), rgba(125,211,252,.08) 42%, rgba(17,24,39,.72));
  box-shadow: var(--shadow);
}
.top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.compact-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.metric { padding: 20px; display: grid; gap: 8px; }
.metric span { color: var(--muted); font-size: 13px; }
.metric strong { font-size: 28px; letter-spacing: -.035em; }
.columns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.dashboard-cards { align-items: start; }
.ops-health-card { margin-bottom: 16px; }
.ops-health-card h2 { margin-bottom: 0; }
.ops-health-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.ops-health-row {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(23, 32, 51, .66);
  padding: 14px;
  display: grid;
  gap: 6px;
  min-width: 0;
}
.ops-health-row span { color: var(--muted); font-size: 12px; font-weight: 850; text-transform: uppercase; letter-spacing: .08em; }
.ops-health-row strong { color: var(--text); font-size: 22px; letter-spacing: -.03em; overflow-wrap: anywhere; }
.ops-health-row small { color: var(--muted); line-height: 1.45; overflow-wrap: anywhere; }
.ops-health-deploy { grid-column: span 2; }
ul { margin-bottom: 0; padding-left: 20px; }
li + li { margin-top: 8px; }

.task-next-steps { margin-bottom: 16px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px; align-items: center; }
.task-next-steps h2 { margin-bottom: 4px; }
.task-next-step-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.task-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.task-item { background: rgba(23,32,51,.72); border: 1px solid var(--line); border-radius: 20px; padding: 16px; transition: transform .16s ease, border-color .16s ease, background .16s ease; }
.task-item:hover { transform: translateY(-1px); border-color: var(--line-strong); background: rgba(30,41,59,.78); }
.task-title { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.task-id { color: var(--accent); font-weight: 850; text-decoration: none; }
.task-badges { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.badge { border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: rgba(15,23,42,.48); padding: 4px 9px; font-size: 12px; }
.badge.status, .badge.priority { color: var(--text); }
.badge.status { font-weight: 850; letter-spacing: .01em; }
.badge.status-new { color: #cbd5e1; background: rgba(148,163,184,.12); border-color: rgba(148,163,184,.35); }
.badge.status-ready { color: #7dd3fc; background: rgba(14,165,233,.14); border-color: rgba(125,211,252,.48); }
.badge.status-in_progress { color: #93c5fd; background: rgba(59,130,246,.14); border-color: rgba(147,197,253,.45); }
.badge.status-in_review { color: #c4b5fd; background: rgba(139,92,246,.15); border-color: rgba(196,181,253,.45); }
.badge.status-testing { color: #fcd34d; background: rgba(245,158,11,.15); border-color: rgba(252,211,77,.45); }
.badge.status-deploying { color: #fb7185; background: rgba(244,63,94,.15); border-color: rgba(251,113,133,.48); }
.badge.status-done { color: #86efac; background: rgba(34,197,94,.14); border-color: rgba(134,239,172,.45); }
.badge.status-on_hold { color: #fdba74; background: rgba(249,115,22,.15); border-color: rgba(253,186,116,.45); }
.badge.status-canceled { color: #fda4af; background: rgba(244,63,94,.14); border-color: rgba(253,164,175,.45); }
.badge.status-idea { color: #cbd5e1; background: rgba(148,163,184,.12); border-color: rgba(148,163,184,.35); }
.badge.status-active { color: #6ee7b7; background: rgba(16,185,129,.14); border-color: rgba(110,231,183,.48); }
.project-links { margin-top: 14px; }
.project-summary { margin-top: 12px; }
.task-meta { color: var(--muted); margin: 10px 0 0; font-size: 14px; }
.task-done-preflight { margin: 10px 0 0; font-size: 13px; font-weight: 850; }
.task-done-preflight-missing { color: #fdba74; }
.task-done-preflight-ready, .task-done-preflight-ok { color: #86efac; }
.task-link { display: inline-flex; gap: 10px; align-items: baseline; flex-wrap: wrap; color: var(--text); text-decoration: none; }
.task-link:hover strong { color: var(--accent); }
.detail-title { margin: 0; color: var(--text); font-size: 20px; font-weight: 850; }
.detail-section + .detail-section { margin-top: 16px; }
.detail-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.detail-metric { border: 1px solid var(--line); border-radius: 16px; background: rgba(23,32,51,.62); padding: 12px; display: grid; gap: 5px; }
.detail-metric span { color: var(--muted); font-size: 12px; }
.detail-metric strong { color: var(--text); font-size: 16px; overflow-wrap: anywhere; }
.ledger-line, .run-meta { color: var(--muted); margin: 14px 0 0; font-size: 14px; }
.preserve-lines { white-space: pre-wrap; color: var(--text); }
.run-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.run-item { border: 1px solid var(--line); border-radius: 20px; background: rgba(23,32,51,.66); padding: 16px; }
.run-heading { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; }
.run-summary { margin: 10px 0 0; }
.run-sync-status { margin: 8px 0 0; font-size: 13px; }
.run-sync-ok { color: var(--success); }
.run-sync-waiting { color: var(--warning); }
.run-sync-missing { color: #fdba74; }
.done-gate-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 10px; }
.done-gate-item { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 14px; background: rgba(23,32,51,.62); padding: 12px; }
.done-gate-ok { border-color: rgba(134,239,172,.35); }
.done-gate-missing { border-color: rgba(253,186,116,.35); }
.token-badge {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  border: 1px solid rgba(110,231,183,.55);
  border-radius: 999px;
  background: rgba(110,231,183,.12);
  color: var(--text);
  padding: 3px 9px;
  font-weight: 850;
  box-shadow: 0 0 0 1px rgba(110,231,183,.08), 0 0 18px rgba(110,231,183,.10);
}
.token-badge span { color: var(--accent); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.token-badge strong { color: #ffffff; font-size: 15px; }
.task-summary { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0 10px; }
.summary-pill { display: inline-flex; align-items: baseline; gap: 8px; border: 1px solid var(--line); border-radius: 999px; background: rgba(23,32,51,.7); padding: 7px 12px; }
.summary-pill span { color: var(--muted); font-size: 13px; }
.summary-pill strong { color: var(--text); font-size: 16px; }
.task-filter-card { margin-bottom: 16px; padding: 18px; }
.filter-toggle { display: grid; gap: 12px; }
.filter-toggle-button {
  list-style: none;
  width: fit-content;
  border: 1px solid rgba(110,231,183,.45);
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(110,231,183,.18), rgba(125,211,252,.10));
  color: var(--text);
  box-shadow: 0 0 0 1px rgba(110,231,183,.08), 0 12px 30px rgba(0,0,0,.18);
  padding: 10px 14px;
  font-weight: 850;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}
.filter-toggle-button::-webkit-details-marker { display: none; }
.filter-toggle[open] .filter-toggle-icon { transform: rotate(180deg); }
.filter-toggle-icon { color: var(--accent); transition: transform .16s ease; }
.task-filter-form { display: grid; gap: 12px; margin-top: 14px; }
.task-filter-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; align-items: end; }
.task-filter-form label { font-size: 13px; }
.task-filter-form input, .task-filter-form select { border-radius: 12px; padding: 10px 12px; }
.task-filter-actions { margin-top: 2px; }
.active-filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 0; }
.filter-chip { border: 1px solid rgba(110,231,183,.45); border-radius: 999px; background: rgba(110,231,183,.10); color: var(--text); font-size: 12px; padding: 5px 9px; }
.empty-state { margin: 0; }
.code-block { overflow-x: auto; border: 1px solid var(--line); border-radius: 16px; background: #07101e; padding: 16px; }
.code-block code, code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.deploy-item a { color: var(--accent); text-decoration: none; }
.deploy-item a:hover { text-decoration: underline; }

@media (max-width: 900px) {
  .app-header-inner {
    min-height: auto;
    padding: 12px 0;
    grid-template-columns: 1fr;
    justify-items: stretch;
    gap: 10px;
  }
  .app-brand { justify-content: space-between; }
  .app-nav { justify-self: stretch; justify-content: flex-start; border-radius: 18px; }
  .app-user-actions { justify-content: space-between; }
  .user-chip { max-width: 60vw; }
  .topbar { display: grid; }
  .grid, .columns, .detail-grid, .form-grid, .task-filter-grid, .ops-health-grid { grid-template-columns: 1fr; }
  .ops-health-deploy { grid-column: auto; }
}

@media (max-width: 560px) {
  .shell, .app-header-inner { width: min(100% - 24px, 1180px); }
  .card, .metric, .hero-panel { border-radius: 18px; padding: 18px; }
  .brand-copy small { display: none; }
  .app-user-actions { display: grid; grid-template-columns: 1fr auto; }
}
