:root {
  color-scheme: dark;
  --bg: #14110c;
  --bg-2: #1c1812;
  --bg-3: #262017;
  --ink: #f6efe3;
  --muted: #cbbba0;
  --line: #3a3226;
  --gold: #e8c36a;
  --amber: #d9783a;
  --ok: #7dbe74;
  --warn: #e3b341;
  --bad: #d2655a;
  --info: #7ea7d9;
  --radius: 18px;
  --touch: 48px;
  --font: "Segoe UI", "Trebuchet MS", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
}
body {
  padding-bottom: env(safe-area-inset-bottom);
}
a {
  color: var(--gold);
  text-decoration: none;
}
button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}
.topbar,
.tabbar {
  background: var(--bg-2);
  border-color: var(--line);
}
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.brand img {
  width: 32px;
  height: 32px;
}
.top-meta {
  margin-left: auto;
  font-size: 13px;
  color: var(--muted);
  text-align: right;
}
.hamburger {
  display: none;
  min-width: var(--touch);
  min-height: var(--touch);
  border: 0;
  background: var(--bg-3);
  color: var(--ink);
  border-radius: 12px;
}

.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 0;
}
nav.side {
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
nav.side a,
.tabbar a {
  min-height: var(--touch);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border-radius: 12px;
  color: var(--ink);
}
nav.side a.active,
.tabbar a.active {
  background: var(--bg-3);
  color: var(--gold);
}
main {
  padding: 20px;
  overflow: auto;
}
.tabbar {
  display: none;
  border-top: 1px solid var(--line);
  overflow-x: auto;
  gap: 4px;
  padding: 8px;
}

.grid {
  display: grid;
  gap: 14px;
}
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.card,
.panel,
.event,
.gate,
.empty,
.login-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.card h3,
.panel h2 {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.metric {
  font-size: 28px;
  font-weight: 750;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}
.pill.info {
  background: #1e2c3d;
  color: var(--info);
}
.pill.ok,
.pill.succeeded,
.pill.passed,
.pill.active,
.pill.AUTO_APPROVED,
.pill.approved,
.pill.running {
  background: #1d2c1c;
  color: var(--ok);
}
.pill.warn,
.pill.waiting,
.pill.pending,
.pill.WAITING_TOOL_APPROVAL {
  background: #3a2f12;
  color: var(--warn);
}
.pill.bad,
.pill.blocked,
.pill.failed,
.pill.TRUE_HUMAN_GATE,
.pill.rejected {
  background: #3a1b18;
  color: var(--bad);
}

.event {
  display: grid;
  gap: 8px;
}
.event .tech {
  color: var(--muted);
  font-size: 13px;
}
.progress {
  height: 8px;
  background: var(--bg-3);
  border-radius: 99px;
  overflow: hidden;
}
.progress > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--amber), var(--gold));
}

.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
}
label {
  display: grid;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
}
input,
textarea,
select {
  min-height: var(--touch);
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  padding: 0 12px;
}
textarea {
  min-height: 96px;
  padding: 12px;
}
.btn {
  min-height: var(--touch);
  border: 0;
  border-radius: 14px;
  background: var(--gold);
  color: #1a140c;
  font-weight: 750;
  padding: 0 16px;
  cursor: pointer;
}
.btn.secondary {
  background: var(--bg-3);
  color: var(--ink);
}
.btn.danger {
  background: var(--bad);
  color: white;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.error {
  color: var(--bad);
}
.pipeline {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.pipeline span {
  padding: 6px 8px;
  border-radius: 8px;
  background: var(--bg-3);
  font-size: 11px;
}
.pipeline span.current {
  background: var(--gold);
  color: #1a140c;
  font-weight: 700;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
  }
  nav.side {
    display: none;
  }
  nav.side.open {
    display: flex;
    position: sticky;
    top: 57px;
    z-index: 4;
  }
  .hamburger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .tabbar {
    display: flex;
    position: sticky;
    bottom: 0;
  }
  main {
    padding: 16px 12px 24px;
  }
  .top-meta {
    display: none;
  }
}
