:root {
  --ink: #172026;
  --muted: #64727c;
  --line: #d8e0e3;
  --paper: #f5f7f4;
  --panel: #ffffff;
  --blue: #2166d1;
  --teal: #0f8c79;
  --red: #c4443c;
  --amber: #b06b00;
  --rail: #dde7e0;
  --shadow: 0 12px 30px rgba(25, 38, 45, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(33, 102, 209, 0.05) 1px, transparent 1px),
    linear-gradient(0deg, rgba(15, 140, 121, 0.05) 1px, transparent 1px),
    var(--paper);
  background-size: 32px 32px;
}

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

button {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fff;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 6px;
  cursor: pointer;
}

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

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(33, 102, 209, 0.24);
  outline-offset: 2px;
}

.shell {
  width: min(1480px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: clamp(30px, 5vw, 58px);
  line-height: 1;
  font-weight: 850;
}

h2 {
  font-size: 16px;
  font-weight: 820;
}

.status-strip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--muted);
  box-shadow: var(--shadow);
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--amber);
}

.status-dot.ok {
  background: var(--teal);
}

.status-dot.bad {
  background: var(--red);
}

.controls {
  display: grid;
  grid-template-columns: 180px minmax(180px, 1fr) 140px minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: end;
  padding: 14px;
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

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

textarea {
  min-height: 92px;
  padding: 10px;
  resize: vertical;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.metric {
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric span,
.callback-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
  line-height: 1;
}

.metric.ok strong {
  color: var(--teal);
}

.metric.bad strong {
  color: var(--red);
}

.metric.warn strong {
  color: var(--amber);
}

.workbench {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  gap: 12px;
  align-items: start;
  margin-bottom: 12px;
}

.panel {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-wide {
  grid-row: span 4;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  min-height: 52px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(250, 252, 251, 0.92);
}

.panel-head span,
.pager {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.panel-head > div {
  min-width: 0;
}

.panel-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.device-panel {
  margin-bottom: 12px;
}

.scheduler-panel {
  margin-bottom: 12px;
}

.scheduler-controls {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(130px, 180px) 120px auto auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
}

.scheduler-controls button {
  min-height: 48px;
}

.switch-field {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 0 12px;
  color: var(--ink);
  background: #f5f8f6;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.switch-field input {
  flex: 0 0 22px;
  width: 22px;
  min-height: 22px;
  margin: 0 10px 0 0;
}

.scheduler-state {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
}

.scheduler-state.enabled {
  color: #075c4f;
  background: #dff4ee;
}

.scheduler-state.running {
  color: #174f9b;
  background: #e0ecfb;
}

.scheduler-state.disabled {
  color: #744800;
  background: #f6ead1;
}

.scheduler-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  padding: 0 14px 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

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

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 960px;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 12px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  background: #fbfcfb;
  font-weight: 820;
}

td {
  color: #2a363d;
}

.mono {
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 11px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 820;
}

.pill.sent,
.pill.active {
  color: #075c4f;
  background: #dff4ee;
}

.pill.failed,
.pill.invalid {
  color: #8f201b;
  background: #fae1df;
}

.pill.replaced {
  color: #744800;
  background: #f6ead1;
}

.stack-list,
.bar-list {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.list-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--line);
  font-size: 12px;
}

.list-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.list-row b {
  overflow-wrap: anywhere;
}

.bar-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 60px;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.bar-track {
  height: 8px;
  background: var(--rail);
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--blue));
}

.callback-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
}

.callback-grid div {
  padding: 14px;
  background: #fff;
}

.callback-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 22px;
}

.note {
  margin: 0;
  padding: 12px 14px 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.pager {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.pager button {
  min-height: 30px;
  padding: 0 10px;
  color: var(--ink);
  background: #fff;
}

.table-action {
  min-width: 88px;
  min-height: 48px;
  padding: 0 12px;
  white-space: nowrap;
}

dialog {
  width: min(680px, calc(100vw - 24px));
  max-height: min(90dvh, 820px);
  padding: 0;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 28px 80px rgba(15, 26, 33, 0.24);
  overflow: auto;
}

dialog::backdrop {
  background: rgba(16, 28, 35, 0.55);
  backdrop-filter: blur(3px);
}

.push-dialog {
  display: grid;
}

.dialog-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 74px;
  padding: 14px 18px;
  background: rgba(250, 252, 251, 0.98);
  border-bottom: 1px solid var(--line);
}

.icon-button {
  flex: 0 0 48px;
  width: 48px;
  min-height: 48px;
  padding: 0;
  color: var(--ink);
  background: #fff;
  border-color: var(--line);
  font-size: 28px;
  line-height: 1;
}

.dialog-device {
  display: grid;
  gap: 4px;
  margin: 18px 18px 0;
  padding: 12px 14px;
  background: #f5f8f6;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.dialog-device span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
}

.dialog-device code {
  color: var(--muted);
  font-size: 11px;
}

.dialog-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 18px;
}

.field-wide {
  grid-column: 1 / -1;
}

.form-status {
  min-height: 22px;
  margin: 0 18px 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.form-status.loading {
  color: var(--blue);
}

.form-status.success {
  color: var(--teal);
}

.form-status.error {
  color: var(--red);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 18px;
  background: rgba(250, 252, 251, 0.98);
  border-top: 1px solid var(--line);
}

.dialog-actions button {
  min-height: 48px;
}

.secondary-button {
  color: var(--ink);
  background: #fff;
  border-color: var(--line);
}

.empty {
  color: var(--muted);
  padding: 16px;
  font-size: 13px;
}

@media (max-width: 980px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .controls,
  .metric-grid,
  .workbench,
  .scheduler-controls {
    grid-template-columns: 1fr;
  }

  .panel-wide {
    grid-row: auto;
  }

  .dialog-fields {
    grid-template-columns: 1fr;
  }

  .field-wide {
    grid-column: auto;
  }

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