:root {
  --bg: #0f172a;
  --fg: #f8fafc;
  --card: #1b2336;
  --muted: #272f42;
  --muted-fg: #94a3b8;
  --border: #475569;
  --accent: #22c55e;
  --on-accent: #0f172a;
  --danger: #ef4444;
  --primary: #1e293b;
  --ring: #f8fafc;
  --warn: #f59e0b;
  font-family: "Fira Sans", system-ui, sans-serif;
  color: var(--fg);
  background: var(--bg);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
}

::selection {
  background: #22c55e;
  color: #0f172a;
}

:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

button, select, input {
  font: inherit;
  cursor: pointer;
}

input, select {
  cursor: text;
}

select { cursor: pointer; }

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

a { color: var(--accent); }

.shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

.rail {
  background: #121a2b;
  border-right: 1px solid var(--border);
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.brand {
  font-weight: 700;
  letter-spacing: -0.02em;
  font-size: 1.125rem;
}

.brand span {
  display: block;
  font-weight: 400;
  color: var(--muted-fg);
  font-size: 0.8125rem;
  margin-top: 0.25rem;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav button {
  background: transparent;
  color: var(--fg);
  border: 0;
  text-align: left;
  padding: 0.65rem 0.75rem;
  border-radius: 6px;
  min-height: 44px;
}

.nav button:hover { background: var(--muted); }

.nav button[aria-current="page"] {
  background: var(--muted);
  box-shadow: inset 3px 0 0 var(--accent);
}

.who {
  margin-top: auto;
  font-size: 0.8125rem;
  color: var(--muted-fg);
}

.who strong {
  display: block;
  color: var(--fg);
  margin-bottom: 0.5rem;
}

.main {
  padding: 1.75rem 1.75rem 3rem;
  overflow: auto;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

h1 {
  margin: 0 0 0.35rem;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
}

.lede {
  margin: 0;
  color: var(--muted-fg);
  max-width: 65ch;
}

.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }

.create-jira {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
}

.create-jira input[name="key"] {
  width: 6.5rem;
  font-family: "Fira Code", ui-monospace, monospace;
  text-transform: uppercase;
}

.btn {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg);
  padding: 0.55rem 0.9rem;
  border-radius: 6px;
  min-height: 44px;
  transition: background 180ms ease;
}

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

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
  font-weight: 600;
}

.btn-primary:hover { filter: brightness(1.05); }

.btn-ghost { background: transparent; }

.table-wrap {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: auto;
  background: var(--card);
}

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

th, td {
  padding: 0.7rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid #334155;
  vertical-align: middle;
}

th {
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted-fg);
  background: #161e30;
  position: sticky;
  top: 0;
}

.id {
  font-family: "Fira Code", ui-monospace, monospace;
  font-size: 0.75rem;
  color: var(--muted-fg);
}

.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
}

.live { background: #14532d; color: #bbf7d0; }
.idle { background: #3f2a0a; color: #fde68a; }
.miss { background: #3f1212; color: #fecaca; }

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
}

.login-card {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2rem;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

.login-card h1 { margin-bottom: 0.5rem; }

.err {
  background: #3f1212;
  color: #fecaca;
  padding: 0.65rem 0.85rem;
  border-radius: 6px;
  margin: 1rem 0;
}

.hint {
  background: #1f2937;
  color: #e2e8f0;
  padding: 0.65rem 0.85rem;
  border-radius: 6px;
  margin: 1rem 0;
  max-width: 72ch;
}

.hint a { color: #93c5fd; }

.row-actions {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
}

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

select.field, input.field {
  background: #0f172a;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.55rem;
  min-height: 40px;
  min-width: 140px;
}

.toast {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  background: var(--muted);
  border: 1px solid var(--border);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.35);
}

.sk {
  height: 14px;
  background: linear-gradient(90deg, #1b2336, #272f42, #1b2336);
  background-size: 200% 100%;
  animation: sk 1.2s linear infinite;
  border-radius: 4px;
}

@keyframes sk { to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

.empty {
  padding: 2.5rem 1.25rem;
  color: var(--muted-fg);
}

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .rail {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .nav { flex-direction: row; overflow: auto; }
  .who { margin-top: 0; }
}
