:root {
  color-scheme: light;
  --bg: #f5f7f9;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #647080;
  --line: #d9e0e7;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --danger: #b42318;
  --warn: #b54708;
  --shadow: 0 10px 30px rgba(21, 32, 43, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  background: var(--accent);
  color: white;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

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

button.secondary {
  background: #e8edf2;
  color: var(--ink);
}

input,
select,
textarea {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: white;
  color: var(--ink);
}

textarea {
  grid-column: 1 / -1;
  min-height: 72px;
  padding: 10px;
  resize: vertical;
}

.shell {
  width: min(1280px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 36px;
}

.topbar,
.auth-panel,
.metrics,
.workbench,
.log-panel {
  margin-bottom: 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.15;
}

h2 {
  font-size: 16px;
}

.status {
  border-radius: 999px;
  padding: 8px 12px;
  background: #eef2f6;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.status.ok {
  background: #dff7ed;
  color: #067647;
}

.status.bad {
  background: #fee4e2;
  color: var(--danger);
}

.top-status {
  display: grid;
  justify-items: end;
  gap: 6px;
}

.auth-panel,
.queue-panel,
.detail-panel,
.log-panel,
.intel-panel,
.report-panel,
.metrics > div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.auth-panel {
  padding: 14px;
}

.auth-panel label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.token-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 8px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.metrics > div {
  padding: 14px;
}

.metrics span {
  display: block;
  margin-bottom: 4px;
  font-size: 24px;
  font-weight: 800;
}

.metrics p,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(360px, 0.82fr) minmax(520px, 1.18fr);
  gap: 16px;
}

.queue-panel,
.detail-panel,
.log-panel,
.intel-panel,
.report-panel {
  padding: 14px;
}

.detail-panel {
  position: sticky;
  top: 16px;
  align-self: start;
}

.section-head {
  display: flex;
  min-height: 38px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.queue-list {
  display: grid;
  gap: 8px;
}

.queue-item {
  width: 100%;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 62px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfd;
  color: var(--ink);
  text-align: left;
}

.queue-item:hover {
  border-color: #9fb4c8;
  background: #f3f7fa;
}

.queue-item.selected {
  border-color: var(--accent);
  background: #e6f4f1;
  box-shadow: inset 4px 0 0 var(--accent);
}

.priority {
  border-radius: 6px;
  padding: 7px 8px;
  background: #eef2f6;
  color: var(--muted);
  text-align: center;
  font-weight: 800;
}

.priority.p1,
.priority.p2 {
  background: #fee4e2;
  color: var(--danger);
}

.event-main {
  min-width: 0;
}

.event-main strong,
.event-main span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-main span,
.event-time {
  color: var(--muted);
  font-size: 13px;
}

.detail-box {
  display: grid;
  gap: 12px;
  min-height: 360px;
  max-height: 620px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfd;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.5;
}

.empty-detail {
  place-content: center;
  color: var(--muted);
  text-align: center;
}

.event-summary,
.ops-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.hero-event {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid #badbd4;
  border-radius: 8px;
  padding: 12px;
  background: #eef8f6;
}

.hero-event h3 {
  margin: 8px 0 4px;
  font-size: 20px;
}

.hero-event p {
  color: var(--muted);
}

.hero-event > strong {
  border-radius: 999px;
  padding: 7px 10px;
  background: white;
  color: var(--accent-strong);
  white-space: nowrap;
}

.event-field {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: white;
}

.event-field.full {
  grid-column: 1 / -1;
}

.event-field span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.event-field strong,
.event-field code {
  overflow-wrap: anywhere;
  font-weight: 750;
}

.ops-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: white;
}

.ops-card.span-2 {
  grid-column: 1 / -1;
}

.ops-card h3 {
  margin: 0 0 10px;
  font-size: 14px;
}

.ops-card dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

.ops-card dl > div {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 8px;
}

.ops-card dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.ops-card dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.ops-card pre {
  max-height: 150px;
  margin: 0;
  overflow: auto;
  border-radius: 6px;
  padding: 10px;
  background: #111827;
  color: #d1fae5;
  font-size: 12px;
}

.secret-box {
  border-radius: 8px;
  padding: 14px;
  background: #fff7ed;
  color: #9a3412;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.contacts {
  display: grid;
  gap: 8px;
}

.contacts > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.contacts span {
  color: var(--muted);
}

.contacts a {
  color: var(--accent-strong);
  font-weight: 800;
  text-decoration: none;
}

.audit-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.audit-list li {
  border-left: 3px solid var(--line);
  padding-left: 8px;
  color: var(--muted);
}

.actions {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  background: var(--panel);
}

.actions button {
  font-weight: 800;
}

.actions button.busy {
  background: var(--warn);
}

.actions button.done {
  background: #067647;
}

.actions select {
  min-width: 0;
}

.actions textarea {
  min-width: 0;
}

.log-panel ol {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 13px;
}

.empty {
  display: grid;
  gap: 6px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.empty strong {
  color: var(--ink);
}

.empty span {
  font-size: 13px;
}

.intel-panel,
.report-panel {
  margin-bottom: 16px;
}

.intel-alerts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.intel-card {
  border: 1px solid var(--line);
  border-left: 5px solid var(--warn);
  border-radius: 8px;
  padding: 12px;
  background: #fffaf0;
}

.intel-card.critical {
  border-left-color: var(--danger);
  background: #fff5f5;
}

.intel-card strong,
.habit-card span,
.report-summary span,
.report-rows span,
.report-rows time {
  color: var(--muted);
  font-size: 12px;
}

.intel-card h3 {
  margin: 4px 0;
  font-size: 16px;
}

.habit-list,
.report-rows {
  display: grid;
  gap: 8px;
}

.habit-card,
.report-rows article {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) repeat(3, minmax(120px, 1fr));
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfd;
}

.habit-card.missed_arm {
  border-color: #f59e0b;
  background: #fffbeb;
}

.habit-card div {
  display: grid;
  gap: 2px;
}

.report-filters {
  display: grid;
  grid-template-columns: 1.4fr 1fr repeat(4, minmax(130px, 0.7fr));
  gap: 10px;
  margin-bottom: 12px;
}

.report-filters label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.report-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.report-summary div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfd;
}

.report-summary strong {
  display: block;
  font-size: 24px;
}

.report-rows article {
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) 0.8fr 0.8fr 1fr;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.46);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(760px, 100%);
  max-height: min(780px, calc(100vh - 48px));
  overflow: auto;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.32);
  padding: 18px;
}

.modal-head,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-head {
  margin-bottom: 14px;
}

.modal-head h2 {
  font-size: 22px;
}

.resolve-context {
  display: grid;
  gap: 4px;
  border: 1px solid #badbd4;
  border-radius: 8px;
  padding: 12px;
  background: #eef8f6;
  margin-bottom: 12px;
}

.resolve-context strong {
  font-size: 18px;
}

.resolve-context span {
  color: var(--muted);
}

.modal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.modal-grid label,
.modal-note {
  min-width: 0;
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.checklist {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.checklist label {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfd;
  font-weight: 700;
}

.checklist input {
  width: 18px;
  height: 18px;
  min-height: 0;
}

.modal-note textarea {
  min-height: 120px;
}

.modal-actions {
  margin-top: 14px;
  justify-content: flex-end;
}

.modal select,
.modal textarea {
  width: 100%;
  min-width: 0;
}

@media (max-width: 860px) {
  .shell {
    width: min(100vw - 20px, 760px);
    padding-top: 16px;
  }

  .topbar,
  .token-row,
  .workbench,
  .metrics,
  .actions,
  .event-summary,
  .ops-grid,
  .modal-grid,
  .checklist,
  .intel-alerts,
  .habit-card,
  .report-filters,
  .report-summary,
  .report-rows article,
  .contacts > div,
  .ops-card dl > div {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-status {
    justify-items: start;
  }

  .detail-panel {
    position: static;
  }

  .modal {
    padding: 14px;
  }

  .modal-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
}
