:root {
  color-scheme: light;
  --ink: #14212d;
  --muted: #657689;
  --line: #dce4eb;
  --panel: #ffffff;
  --canvas: #f3f6f8;
  --accent: #087f73;
  --accent-dark: #05675e;
  --danger: #b42318;
  --warning: #9a6700;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--canvas); color: var(--ink); }
button, input, select { font: inherit; }
button { cursor: pointer; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px clamp(24px, 5vw, 76px);
  color: white;
  background: linear-gradient(115deg, #102a35, #103e44 62%, #0c625b);
  box-shadow: 0 8px 28px rgb(16 42 53 / 18%);
}
.topbar h1 { margin: 3px 0 0; font-size: clamp(28px, 4vw, 43px); letter-spacing: -.04em; }
.eyebrow { margin: 0; font-size: 12px; font-weight: 800; letter-spacing: .18em; color: #58d4c3; }
.topbar-actions { display: flex; align-items: center; gap: 18px; }
.connection-state { display: inline-flex; align-items: center; gap: 9px; font-weight: 700; }
.connection-state i { width: 10px; height: 10px; border-radius: 99px; background: #fbbf24; box-shadow: 0 0 0 5px rgb(251 191 36 / 18%); }
.connection-state.is-live i { background: #52d273; box-shadow: 0 0 0 5px rgb(82 210 115 / 18%); }
.connection-state.is-error i { background: #ff746a; box-shadow: 0 0 0 5px rgb(255 116 106 / 18%); }
.ghost-button, .secondary-button, .icon-button { border: 1px solid currentColor; background: transparent; border-radius: 10px; }
.ghost-button { padding: 9px 15px; color: white; }

.page-shell { width: min(1680px, calc(100% - 40px)); margin: 28px auto 50px; }
.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(130px, 1fr)) 2fr; gap: 14px; margin-bottom: 18px; }
.summary-grid article { padding: 18px 20px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 10px 32px rgb(28 50 64 / 5%); }
.summary-grid span { display: block; margin-bottom: 8px; color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.summary-grid strong { font-size: 25px; }
.summary-wide strong { font-size: 17px; }

.data-card { overflow: hidden; padding: 24px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 14px 42px rgb(28 50 64 / 7%); }
.table-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 22px; margin-bottom: 20px; }
.table-heading h2 { margin: 5px 0 0; font-size: 25px; }
.filters { display: flex; gap: 10px; }
.filters input, .filters select { min-height: 42px; padding: 9px 12px; color: var(--ink); background: white; border: 1px solid #cdd8e1; border-radius: 10px; }
.filters input { width: min(340px, 32vw); }
.table-footnote { margin: 14px 0 0; color: var(--muted); font-size: 13px; }
.payload-preview { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.status-badge { display: inline-flex; padding: 4px 8px; border-radius: 99px; font-size: 11px; font-weight: 800; text-transform: uppercase; background: #e7edf2; color: #506273; }
.status-pending { background: #fff3cd; color: #805b00; }
.status-processing { background: #dbeafe; color: #1d4ed8; }
.status-sent { background: #dcfce7; color: #16803b; }
.status-dead { background: #fee2e2; color: var(--danger); }
.tabulator { border: 1px solid var(--line); border-radius: 12px; background: white; font-size: 13px; }
.tabulator .tabulator-header { border-bottom-color: var(--line); background: #f7f9fb; color: #536577; }
.tabulator .tabulator-header .tabulator-col { background: transparent; border-right-color: var(--line); }
.tabulator .tabulator-row { border-bottom-color: #e7edf2; }
.tabulator .tabulator-row:hover { background: #edf9f7; }

.json-dialog { width: min(900px, calc(100vw - 36px)); max-height: 88vh; padding: 0; border: 0; border-radius: 18px; color: #e8eef2; background: #101820; box-shadow: 0 30px 100px rgb(0 0 0 / 45%); }
.json-dialog::backdrop { background: rgb(8 18 24 / 68%); backdrop-filter: blur(3px); }
.dialog-heading { display: flex; justify-content: space-between; gap: 18px; padding: 24px 26px 16px; border-bottom: 1px solid #293640; }
.dialog-heading h2 { margin: 5px 0; }
.dialog-heading p:last-child { margin: 0; color: #91a4b2; }
.icon-button { width: 38px; height: 38px; color: #b7c5ce; font-size: 27px; line-height: 1; }
.dialog-actions { display: flex; gap: 9px; padding: 14px 26px; border-bottom: 1px solid #293640; }
.secondary-button { padding: 7px 11px; color: #b7c5ce; }
.json-viewer { min-height: 280px; max-height: 60vh; overflow: auto; padding: 24px 28px 32px; font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; }

.login-page { display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at top, #174c52, #0d2530 55%, #091820); }
.login-card { width: min(430px, 100%); padding: 38px; background: white; border-radius: 22px; box-shadow: 0 28px 90px rgb(0 0 0 / 30%); }
.brand-mark { display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 24px; border-radius: 14px; color: white; background: var(--accent); font-weight: 900; }
.login-card .eyebrow { color: var(--accent); }
.login-card h1 { margin: 8px 0; font-size: 29px; letter-spacing: -.03em; }
.login-hint { margin: 0 0 26px; color: var(--muted); }
.login-form { display: grid; gap: 17px; }
.login-form label span { display: block; margin-bottom: 7px; color: #536577; font-size: 13px; font-weight: 700; }
.login-form input { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid #bdcbd5; border-radius: 10px; }
.login-form button { min-height: 47px; margin-top: 5px; border: 0; border-radius: 10px; color: white; background: var(--accent); font-weight: 800; }
.login-form button:hover { background: var(--accent-dark); }
.login-error { display: none; margin: 16px 0 0; color: var(--danger); font-size: 13px; }
.has-login-error .login-error { display: block; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

@media (max-width: 900px) {
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .summary-wide { grid-column: 1 / -1; }
  .table-heading { align-items: stretch; flex-direction: column; }
  .filters input { width: 100%; }
}

@media (max-width: 600px) {
  .topbar { align-items: flex-start; padding: 20px; }
  .topbar-actions { align-items: flex-end; flex-direction: column; gap: 10px; }
  .connection-state span { display: none; }
  .page-shell { width: calc(100% - 20px); margin-top: 12px; }
  .summary-grid { gap: 8px; }
  .summary-grid article, .data-card { padding: 15px; }
  .filters { flex-direction: column; }
}
