:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #050a12;
  color: #edf4ff;
  --panel: rgba(15, 27, 45, 0.86);
  --panel-solid: #0f1b2d;
  --border: rgba(148, 177, 216, 0.18);
  --muted: #96a8c3;
  --blue: #5ea3ff;
  --green: #4ade80;
  --amber: #fbbf24;
  --red: #fb7185;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% -10%, rgba(44, 115, 220, 0.28), transparent 34rem),
    radial-gradient(circle at 90% 18%, rgba(77, 208, 225, 0.1), transparent 28rem),
    #050a12;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, calc((100vw - 1100px) / 2));
  border-bottom: 1px solid var(--border);
  background: rgba(5, 10, 18, 0.84);
  backdrop-filter: blur(18px);
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.15rem, 4vw, 1.55rem); letter-spacing: -0.03em; }
h2 { margin-bottom: 0.4rem; font-size: clamp(1.45rem, 5vw, 2.1rem); letter-spacing: -0.035em; }

.eyebrow {
  margin-bottom: 0.25rem;
  color: #81b5ff;
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.topbar-actions { display: flex; align-items: center; gap: 0.65rem; }
.health-pill, .badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.38rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 700;
}
.health-pill::before { content: ""; width: 0.48rem; height: 0.48rem; border-radius: 50%; background: var(--amber); }
.health-pill[data-state="ok"]::before { background: var(--green); box-shadow: 0 0 0 4px rgba(74, 222, 128, 0.12); }
.health-pill[data-state="error"]::before { background: var(--red); }

.icon-button {
  min-width: 2.5rem;
  min-height: 2.5rem;
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  font-size: 1.2rem;
}

main { width: min(1100px, calc(100% - 2rem)); margin: 0 auto; padding: 1.5rem 0 5rem; }

.hero {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1.25rem;
  align-items: end;
  padding: 1.6rem;
  border: 1px solid var(--border);
  border-radius: 1.35rem;
  background: linear-gradient(145deg, rgba(25, 52, 87, 0.88), rgba(9, 20, 35, 0.9));
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
}

.operator { color: #c6d8f4; font-size: 0.84rem; margin-bottom: 1.3rem; }
.muted { color: var(--muted); margin-bottom: 0; line-height: 1.55; }

.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; }
.summary-grid article {
  display: flex;
  min-height: 5.5rem;
  flex-direction: column;
  justify-content: center;
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: rgba(3, 9, 17, 0.42);
}
.summary-grid strong { font-size: 1.65rem; }
.summary-grid span { color: var(--muted); font-size: 0.74rem; }

.tabs { display: flex; gap: 0.4rem; margin: 1.3rem 0 0.9rem; overflow-x: auto; }
.tab {
  flex: 0 0 auto;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.65rem 0.9rem;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}
.tab.active { border-color: rgba(94, 163, 255, 0.42); background: rgba(94, 163, 255, 0.12); color: #dbeafe; }

.filters { display: flex; gap: 0.75rem; margin-bottom: 1rem; }
.filters label { flex: 1; }
label span { display: block; margin-bottom: 0.35rem; color: var(--muted); font-size: 0.74rem; font-weight: 700; }
select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  background: var(--panel-solid);
  color: #fff;
}
select { min-height: 2.75rem; padding: 0 0.75rem; }
textarea { min-height: 6rem; padding: 0.75rem; resize: vertical; }

.queue { display: grid; gap: 0.75rem; }
.queue-card {
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1rem;
  background: var(--panel);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.16);
}
.queue-card button.card-open { width: 100%; border: 0; padding: 0; text-align: left; background: transparent; color: inherit; }
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.8rem; }
.card-title { margin: 0.35rem 0 0.5rem; font-size: 1rem; line-height: 1.4; }
.card-meta { display: flex; flex-wrap: wrap; gap: 0.45rem 0.8rem; color: var(--muted); font-size: 0.77rem; }
.badge.pending_approval { color: #ffe8a3; border-color: rgba(251, 191, 36, 0.42); background: rgba(251, 191, 36, 0.08); }
.badge.completed { color: #bbf7d0; border-color: rgba(74, 222, 128, 0.38); }
.badge.failed, .badge.cancelled { color: #fecdd3; border-color: rgba(251, 113, 133, 0.38); }
.badge.claimed, .badge.queued { color: #bfdbfe; border-color: rgba(94, 163, 255, 0.38); }

.message { margin-bottom: 1rem; border: 1px solid rgba(251, 113, 133, 0.35); border-radius: 0.9rem; padding: 0.85rem; background: rgba(127, 29, 29, 0.22); color: #fecdd3; }
.empty { padding: 2.4rem 1rem; text-align: center; color: var(--muted); border: 1px dashed var(--border); border-radius: 1rem; }
.hidden { display: none !important; }

dialog {
  width: min(680px, calc(100% - 1.2rem));
  max-height: calc(100dvh - 1.2rem);
  border: 1px solid var(--border);
  border-radius: 1.2rem;
  padding: 0;
  background: #091321;
  color: #edf4ff;
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.65);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.72); backdrop-filter: blur(5px); }
.dialog-shell > header { position: sticky; top: 0; display: flex; justify-content: space-between; padding: 1rem; border-bottom: 1px solid var(--border); background: #091321; }
.detail-content { padding: 1rem; overflow-wrap: anywhere; }
.detail-row { padding: 0.7rem 0; border-bottom: 1px solid var(--border); }
.detail-row dt { margin-bottom: 0.3rem; color: var(--muted); font-size: 0.73rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
.detail-row dd { margin: 0; line-height: 1.55; white-space: pre-wrap; }
.decision-form { position: sticky; bottom: 0; padding: 1rem; border-top: 1px solid var(--border); background: #091321; }
.decision-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.65rem; margin-top: 0.75rem; }
.button { min-height: 2.8rem; border: 1px solid transparent; border-radius: 0.8rem; color: white; font-weight: 800; }
.button.primary { background: #2563eb; }
.button.danger { border-color: rgba(251, 113, 133, 0.45); background: rgba(159, 18, 57, 0.25); color: #fecdd3; }
.button:disabled { cursor: wait; opacity: 0.55; }

@media (max-width: 700px) {
  .topbar { padding-left: 1rem; padding-right: 1rem; }
  .health-pill { max-width: 8rem; overflow: hidden; white-space: nowrap; }
  .hero { grid-template-columns: 1fr; padding: 1.1rem; }
  .summary-grid article { min-height: 4.5rem; }
  .filters { display: grid; grid-template-columns: 1fr 1fr; }
  dialog { margin-bottom: max(0.6rem, env(safe-area-inset-bottom)); }
}
