:root {
  color-scheme: light;
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #172033;
  --muted: #667085;
  --border: #dfe5ee;
  --border-strong: #cbd5e1;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --cyan: #0891b2;
  --green: #0f9f6e;
  --amber: #e68a00;
  --violet: #7c3aed;
  --rose: #e54863;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 8px 24px rgba(16, 24, 40, 0.04);
}

* { box-sizing: border-box; }
html { overflow-x: clip; }
body {
  margin: 0;
  overflow-x: clip;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: 0;
}
a { color: inherit; }
.icon { width: 18px; height: 18px; display: block; flex: 0 0 auto; }
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.topbar {
  height: 68px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 8px rgba(16, 24, 40, 0.04);
}
.topbar-inner {
  width: min(1600px, calc(100% - 64px));
  height: 100%;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 260px 1fr 260px;
  align-items: center;
  gap: 24px;
}
.brand { display: flex; align-items: center; gap: 11px; font-weight: 700; text-decoration: none; white-space: nowrap; }
.brand-mark {
  position: relative;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--primary);
  color: white;
  box-shadow: 0 5px 14px rgba(37, 99, 235, 0.24);
}
.brand-mark::after { content: ""; position: absolute; top: -2px; right: -2px; width: 9px; height: 9px; border: 2px solid white; border-radius: 50%; background: var(--rose); }
.brand-name { font-size: 16px; color: #344054; }
.brand-name strong { color: var(--text); }
.topbar nav { height: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; }
.topbar nav a {
  min-width: 96px;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 7px;
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
  transition: background-color 140ms ease, color 140ms ease;
}
.topbar nav a:hover { background: #f1f5f9; color: #344054; }
.topbar nav a.active { background: #eaf1ff; color: var(--primary); }
.logout-form { display: flex; justify-content: flex-end; }
.logout-form input { display: none; }
.logout-form button { min-height: 38px; color: var(--muted); }
.logout-form button:hover { color: var(--text); }

.login-page { background: #eef2f7; }
.login-shell {
  width: 100%;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
}
.login-panel {
  width: min(400px, 100%);
  padding: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 16px 40px rgba(16, 24, 40, 0.1);
}
.login-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 34px; }
.login-heading { margin-bottom: 24px; }
.login-heading h1 { margin-bottom: 5px; font-size: 24px; }
.login-heading p { margin-bottom: 0; color: var(--muted); }
.login-form { display: grid; gap: 18px; }
.login-form button { width: 100%; margin-top: 4px; }
.login-error { display: flex; align-items: center; gap: 9px; margin-bottom: 18px; padding: 10px 12px; border: 1px solid #fecdd3; border-radius: 7px; background: #fff1f2; color: #9f1239; font-weight: 600; }
.login-error .icon { width: 17px; height: 17px; }

main { width: min(1600px, calc(100% - 64px)); margin: 0 auto; padding: 38px 0 64px; }
.page-heading { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.page-title, .section-title { display: flex; align-items: center; gap: 14px; min-width: 0; }
.page-title-icon, .section-icon, .health-icon, .stat-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 8px;
}
.page-title-icon { width: 44px; height: 44px; }
.page-title-icon .icon { width: 22px; height: 22px; }
.section-icon { width: 38px; height: 38px; }
.health-icon { width: 44px; height: 44px; }
.blue { color: #1d4ed8; background: #dbeafe; }
.cyan { color: #0e7490; background: #cffafe; }
.green { color: #047857; background: #d1fae5; }
.amber { color: #b45309; background: #fef3c7; }
.violet { color: #6d28d9; background: #ede9fe; }
.rose { color: #be123c; background: #ffe4e6; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 3px; font-size: 28px; line-height: 1.25; }
h2 { margin-bottom: 2px; font-size: 18px; }
.page-heading p, .section-heading p { margin-bottom: 0; color: var(--muted); }

button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, .pagination a {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 15px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: var(--surface);
  color: #344054;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 140ms ease, background-color 140ms ease, color 140ms ease, transform 140ms ease;
}
button:hover, .pagination a:hover { border-color: #94a3b8; background: #f8fafc; color: var(--text); }
button:active { transform: translateY(1px); }
button.primary { background: var(--primary); border-color: var(--primary); color: white; box-shadow: 0 5px 14px rgba(37, 99, 235, 0.18); }
button.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: white; }
input, select, textarea {
  width: 100%;
  min-height: 42px;
  margin-top: 7px;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
}
textarea { min-height: 112px; resize: vertical; }
input::placeholder { color: #98a2b3; }
input:hover, select:hover, textarea:hover { border-color: #aab5c4; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 3px solid rgba(37, 99, 235, 0.18); outline-offset: 1px; border-color: var(--primary); }
.field-label { display: flex; align-items: center; gap: 7px; color: #475467; font-size: 13px; font-weight: 600; }
.field-label .icon { width: 15px; height: 15px; color: #7b8798; }

.notice { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; padding: 11px 14px; border: 1px solid #a7f3d0; border-radius: 7px; background: #ecfdf5; color: #047857; font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  min-height: 104px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.stat-icon { width: 46px; height: 46px; }
.stat-icon .icon { width: 22px; height: 22px; }
.stat-card > div > span { display: block; color: var(--muted); font-size: 13px; font-weight: 600; }
.stat-card strong { display: block; margin-top: 1px; font-size: 28px; line-height: 1.15; }
.stat-queued .stat-icon { color: #b45309; background: #fef3c7; }
.stat-queued strong { color: #92400e; }
.stat-delivered .stat-icon { color: #047857; background: #d1fae5; }
.stat-delivered strong { color: #047857; }
.stat-failed .stat-icon { color: #be123c; background: #ffe4e6; }
.stat-failed strong { color: #be123c; }
.source-stats { margin-bottom: 20px; }
.source-stats > header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
.source-stats > header > div { display: flex; align-items: center; gap: 8px; color: #344054; }
.source-stats > header .icon { width: 16px; height: 16px; color: var(--cyan); }
.source-stats > header > span, .source-stats > p { margin: 0; color: var(--muted); font-size: 12px; }
.source-stat-list { display: flex; gap: 10px; padding: 2px 2px 8px; overflow-x: auto; scrollbar-width: thin; }
.source-stat {
  min-width: 190px;
  max-width: 310px;
  min-height: 46px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  align-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: #475467;
  overflow: hidden;
}
.source-stat:hover { border-color: #93c5fd; background: #f8fbff; color: var(--primary); }
.source-stat.active { border-color: #93c5fd; background: #eaf1ff; color: var(--primary); }
.source-stat-link { min-width: 0; min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 6px 8px 12px; color: inherit; text-decoration: none; }
.source-stat-link > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.source-stat-link > strong { min-width: 30px; padding: 2px 7px; border-radius: 5px; background: #eef2f7; color: #344054; text-align: center; }
.source-stat.active .source-stat-link > strong { background: #dbeafe; color: #1d4ed8; }
.source-stat form { display: flex; padding-right: 4px; }
.source-stat form input { display: none; }
.source-delete { width: 34px; min-height: 34px; padding: 0; border-color: transparent; background: transparent; color: #98a2b3; }
.source-delete .icon { width: 16px; height: 16px; }
.source-delete:hover { border-color: #fecdd3; background: #fff1f2; color: #be123c; }
.source-delete:disabled { border-color: transparent; background: transparent; color: #cbd5e1; cursor: not-allowed; }
.range-filter {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px 15px;
  border: 1px solid #bae6fd;
  border-radius: 7px;
  background: #f0f9ff;
  color: #0e7490;
}
.range-filter > div { flex: 1; }
.range-filter span { display: block; color: #527084; font-size: 12px; font-weight: 600; }
.range-filter strong { color: #164e63; }
.range-filter a { color: #0369a1; font-weight: 700; }
.filters {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) 230px auto;
  align-items: end;
  gap: 14px;
  margin-bottom: 16px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.03);
}
.filters button { min-width: 92px; }
.table-wrap { overflow: visible; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
table { width: 100%; min-width: 860px; border-collapse: collapse; table-layout: fixed; }
th, td { padding: 15px 18px; text-align: left; border-bottom: 1px solid #e9edf3; }
th { color: #667085; font-size: 12px; font-weight: 700; background: #f8fafc; }
th:nth-child(1) { width: 100px; }
th:nth-child(2) { width: 35%; }
th:nth-child(3) { width: 25%; }
th:nth-child(4) { width: 150px; }
th:nth-child(5) { width: 220px; }
th:nth-child(6) { width: 68px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8fbff; }
.row-link { color: #1f2937; font-weight: 700; text-decoration: none; }
.row-link:hover { color: var(--primary); text-decoration: underline; }
.title-cell { position: relative; }
.title-cell:hover, .title-cell:focus-within { z-index: 20; }
.notification-preview {
  position: absolute;
  z-index: 30;
  top: calc(100% - 4px);
  left: calc(100% + 12px);
  display: none;
  width: min(500px, calc(100vw - 96px));
  padding: 18px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 45px rgba(16, 24, 40, 0.18);
  color: var(--text);
}
.title-cell:hover .notification-preview,
.title-cell:focus-within .notification-preview { display: block; }
.preview-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.preview-heading > strong { min-width: 0; overflow-wrap: anywhere; font-size: 15px; }
.notification-preview dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 18px; margin: 0 0 14px; }
.notification-preview dt, .preview-message > span, .preview-error > span { color: var(--muted); font-size: 11px; font-weight: 700; }
.notification-preview dd { margin: 2px 0 0; color: #344054; overflow-wrap: anywhere; }
.preview-message pre, .preview-error pre { max-height: 160px; margin-top: 5px; padding: 10px 12px; overflow-y: auto; border-radius: 6px; background: #f8fafc; color: #344054; }
.preview-error { margin-top: 10px; }
.preview-error pre { background: #fff1f2; color: #9f1239; }
.source-value { color: #475467; }
.time-value { color: #667085; }
.status { min-width: 72px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 4px 9px; border-radius: 5px; font-size: 12px; font-weight: 700; }
.status i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-queued { background: #fff7df; color: #b45309; }
.status-delivered { background: #e7f8f0; color: #047857; }
.status-failed { background: #fff0f2; color: #be123c; }
.row-actions { padding-right: 14px; padding-left: 14px; }
.row-actions form { display: flex; justify-content: center; }
.delete-button {
  width: 34px;
  min-height: 34px;
  padding: 0;
  border-color: transparent;
  color: #be123c;
}
.delete-button .icon { width: 17px; height: 17px; }
.delete-button:hover { border-color: #fecdd3; background: #fff1f2; color: #9f1239; }
.empty { padding: 54px; text-align: center; color: var(--muted); }
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.empty-state .icon { width: 30px; height: 30px; margin-bottom: 4px; color: #94a3b8; }
.empty-state strong { color: #475467; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: #667085; }
.nowrap { white-space: nowrap; }
.pagination { display: flex; justify-content: space-between; margin-top: 16px; }
.pagination .icon { width: 16px; height: 16px; }
.back { display: inline-flex; align-items: center; gap: 5px; margin-bottom: 5px; color: var(--primary); font-size: 13px; font-weight: 600; text-decoration: none; }
.back .icon { width: 15px; height: 15px; }
.detail-actions { display: flex; align-items: center; gap: 10px; }

.statistics-heading { min-height: 64px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.statistics-heading .page-title { margin-right: auto; }
.statistics-date { height: 46px; display: grid; grid-template-columns: 220px auto; align-items: stretch; gap: 10px; }
.statistics-date button { min-width: 82px; min-height: 46px; }
.statistics-date input { min-height: 46px; margin-top: 0; }
.segmented {
  height: 46px;
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: #e9edf3;
}
.segmented a {
  min-width: 94px;
  min-height: 38px;
  display: grid;
  place-items: center;
  padding: 7px 14px;
  border-radius: 5px;
  color: #667085;
  font-weight: 700;
  text-decoration: none;
}
.segmented a:hover { color: #344054; }
.segmented a.active { background: var(--surface); color: var(--primary); box-shadow: 0 1px 3px rgba(16, 24, 40, 0.12); }
.statistics-nav { height: 46px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.statistics-nav > strong { min-width: 112px; text-align: center; font-size: 15px; }
.icon-button, .reset-range {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: var(--surface);
  color: #344054;
  font-weight: 700;
  text-decoration: none;
}
.icon-button { width: 46px; padding: 0; }
.icon-button .icon { width: 17px; height: 17px; }
.icon-button:hover, .reset-range:hover { border-color: #94a3b8; color: var(--primary); }
.icon-button.disabled { color: #b8c1ce; background: #f5f7fa; }
.reset-range { padding: 8px 14px; color: #047857; }
.chart-panel {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.chart-panel > header {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}
.chart-panel > header span { display: block; margin-bottom: 2px; color: var(--muted); font-size: 12px; font-weight: 600; }
.chart-panel > header strong { font-size: 16px; }
.chart-scroll { overflow-x: auto; padding: 122px 20px 12px; }
.bar-chart {
  position: relative;
  height: 150px;
  display: grid;
  grid-template-columns: repeat(24, minmax(36px, 1fr));
  gap: 7px;
  align-items: stretch;
  min-width: 1080px;
  padding-top: 18px;
  background: repeating-linear-gradient(to top, transparent 0, transparent 34px, #eef2f6 35px);
}
.bar-chart.daily { grid-template-columns: repeat(30, minmax(36px, 1fr)); min-width: 1260px; }
.bar-column {
  position: relative;
  min-width: 0;
  height: 100%;
  display: grid;
  grid-template-rows: 24px minmax(0, 1fr) 30px;
  align-items: end;
  color: #667085;
  text-align: center;
  text-decoration: none;
}
.bar-count { align-self: center; font-size: 11px; font-weight: 700; }
.bar-track {
  width: 72%;
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-self: center;
  overflow: hidden;
  border-radius: 4px 4px 0 0;
  background: #edf1f5;
}
.bar-fill {
  width: 100%;
  min-height: 0;
  display: block;
  border-radius: 4px 4px 0 0;
  background: var(--cyan);
  transition: background-color 140ms ease, filter 140ms ease;
}
.bar-column:hover .bar-fill, .bar-column:focus-visible .bar-fill { background: var(--primary); filter: saturate(1.08); }
.bar-column:hover .bar-label, .bar-column:focus-visible .bar-label { color: var(--primary); font-weight: 700; }
.bar-label { align-self: end; padding-top: 7px; border-top: 1px solid var(--border); font-size: 11px; white-space: nowrap; }
.bar-tooltip {
  position: absolute;
  z-index: 10;
  top: -8px;
  left: 50%;
  display: none;
  width: 196px;
  padding: 10px 12px;
  transform: translate(-50%, -100%);
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: 0 10px 24px rgba(16, 24, 40, 0.16);
  color: #344054;
  text-align: left;
}
.bar-tooltip strong, .bar-tooltip span, .bar-tooltip small { display: block; }
.bar-tooltip strong { margin-bottom: 2px; }
.bar-tooltip span { color: var(--primary); font-weight: 700; }
.bar-tooltip small { margin-top: 3px; color: var(--muted); }
.bar-column:hover .bar-tooltip, .bar-column:focus-visible .bar-tooltip { display: block; }
.bar-column:first-child .bar-tooltip { left: 0; transform: translateY(-100%); }
.bar-column:last-child .bar-tooltip { right: 0; left: auto; transform: translateY(-100%); }
.statistics-results { margin-top: 18px; scroll-margin-top: 16px; }

.upstream-heading { min-height: 64px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.upstream-heading .page-title { margin-right: auto; }
.upstream-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.upstream-summary > div { min-height: 92px; padding: 18px 20px; border-right: 1px solid var(--border); }
.upstream-summary > div:last-child { border-right: 0; }
.upstream-summary span, .upstream-connection span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 12px; font-weight: 600; }
.upstream-summary strong { display: block; font-size: 24px; }
.upstream-state-connected { color: #047857; }
.upstream-state-connecting { color: #b45309; }
.upstream-state-error { color: #be123c; }
.upstream-state-disabled { color: #64748b; }
.upstream-connection {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.upstream-connection > div { min-width: 0; padding: 16px 20px; border-right: 1px solid var(--border); }
.upstream-connection > div:last-child { border-right: 0; }
.upstream-connection strong { display: block; overflow-wrap: anywhere; }
.activity-legend { display: flex; align-items: center; flex-wrap: wrap; gap: 18px; margin: 20px 0 12px; color: var(--muted); font-size: 12px; font-weight: 600; }
.activity-legend span { display: inline-flex; align-items: center; gap: 7px; }
.activity-legend i { width: 14px; height: 14px; display: block; border: 1px solid rgba(71, 84, 103, .16); border-radius: 3px; }
.activity-missing { background: #e5eaf0; }
.activity-active { background: #7dd3fc; }
.activity-messages { background: #22c55e; }
.activity-error { background: #fb7185; }
.upstream-activity-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.upstream-grid-scroll { overflow-x: auto; padding: 18px 20px 22px; }
.upstream-grid { min-width: 960px; }
.upstream-grid-head, .upstream-grid-row {
  display: grid;
  grid-template-columns: 52px repeat(24, minmax(0, 1fr));
  gap: 4px;
  align-items: center;
}
.upstream-grid-head { margin-bottom: 7px; color: var(--muted); font-size: 11px; text-align: center; }
.upstream-grid-head span:first-child { text-align: left; }
.upstream-grid-row { margin-top: 5px; }
.upstream-grid-row > strong { color: #475467; font-size: 12px; }
.activity-cell {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  display: block;
  border: 1px solid rgba(71, 84, 103, .12);
  border-radius: 3px;
  transition: filter 140ms ease, transform 140ms ease;
}
.activity-cell:hover, .activity-cell:focus-visible { z-index: 30; filter: saturate(1.15); transform: translateY(-1px); }
.activity-cell:focus-visible { outline: 3px solid rgba(37, 99, 235, .3); outline-offset: 2px; }
.activity-cell.activity-missing { background: #e5eaf0; }
.activity-cell.activity-active { background: #7dd3fc; }
.activity-cell.activity-messages { background: #22c55e; }
.activity-cell.activity-error { background: #fb7185; }
.activity-cell.activity-future { background: #f8fafc; }
.activity-tooltip {
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  z-index: 40;
  width: max-content;
  min-width: 230px;
  max-width: 320px;
  padding: 12px 14px;
  border: 1px solid #344054;
  border-radius: 7px;
  background: #101828;
  box-shadow: 0 14px 32px rgba(16, 24, 40, .3);
  color: #f2f4f7;
  text-align: left;
  transform: translate(-50%, -4px);
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease, transform 120ms ease, visibility 120ms ease;
}
.activity-tooltip::after {
  content: "";
  position: absolute;
  top: -6px;
  left: calc(50% - 6px);
  width: 10px;
  height: 10px;
  border-top: 1px solid #344054;
  border-left: 1px solid #344054;
  background: #101828;
  transform: rotate(45deg);
}
.activity-tooltip strong { display: block; color: white; font-size: 13px; line-height: 1.4; }
.activity-tooltip span { display: block; margin-top: 6px; color: #d0d5dd; font-size: 12px; line-height: 1.5; }
.activity-tooltip em { display: block; margin-top: 8px; color: #fda4af; font-size: 12px; font-style: normal; line-height: 1.5; overflow-wrap: anywhere; }
.activity-cell:hover .activity-tooltip,
.activity-cell:focus-visible .activity-tooltip {
  visibility: visible;
  opacity: 1;
  transform: translate(-50%, 0);
}
.activity-cell:nth-child(2) .activity-tooltip { left: -12px; transform: translate(0, -4px); }
.activity-cell:nth-child(2):hover .activity-tooltip,
.activity-cell:nth-child(2):focus-visible .activity-tooltip { transform: translate(0, 0); }
.activity-cell:nth-child(2) .activity-tooltip::after { left: 24px; }
.activity-cell:last-child .activity-tooltip { right: -12px; left: auto; transform: translate(0, -4px); }
.activity-cell:last-child:hover .activity-tooltip,
.activity-cell:last-child:focus-visible .activity-tooltip { transform: translate(0, 0); }
.activity-cell:last-child .activity-tooltip::after { right: 24px; left: auto; }
.upstream-grid-row:nth-last-child(-n+3) .activity-tooltip { top: auto; bottom: calc(100% + 10px); }
.upstream-grid-row:nth-last-child(-n+3) .activity-tooltip::after {
  top: auto;
  bottom: -6px;
  border: 0;
  border-right: 1px solid #344054;
  border-bottom: 1px solid #344054;
}
.upstream-log-section { margin-top: 24px; }
.upstream-log-section > .section-title { margin-bottom: 12px; }
.upstream-log-wrap { max-height: 520px; overflow: auto; }
.upstream-log-table { min-width: 980px; }
.upstream-log-table thead { position: sticky; top: 0; z-index: 2; }
.upstream-log-table th:nth-child(1) { width: 190px; }
.upstream-log-table th:nth-child(2) { width: 180px; }
.upstream-log-table th:nth-child(3),
.upstream-log-table th:nth-child(4),
.upstream-log-table th:nth-child(5),
.upstream-log-table th:nth-child(6) { width: 80px; }
.upstream-log-table th:nth-child(7) { width: auto; }
.upstream-result { display: inline-flex; align-items: center; gap: 7px; font-weight: 700; }
.upstream-result i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.upstream-result-active { color: #0284c7; }
.upstream-result-messages { color: #15803d; }
.upstream-result-error { color: #be123c; }
.upstream-error-text { overflow-wrap: anywhere; color: #9f1239; }

.detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.detail-grid > div { min-height: 92px; padding: 18px 20px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.detail-grid > div:nth-child(3n) { border-right: 0; }
.detail-grid .full { grid-column: 1 / -1; min-height: 112px; border-right: 0; }
.detail-grid > div:last-child { border-bottom: 0; }
.detail-grid span:not(.status) { display: block; margin-bottom: 7px; color: var(--muted); font-size: 12px; font-weight: 600; }
.detail-grid pre { padding: 14px; border-radius: 6px; background: #f8fafc; color: #344054; }
pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; }

.settings-form { overflow: hidden; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.settings-form > section { padding: 26px 28px; border-bottom: 1px solid var(--border); }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 22px; }
.section-title { gap: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.form-grid .span-2 { grid-column: span 2; }
.switch { display: flex; align-items: center; gap: 9px; color: #475467; font-weight: 600; white-space: nowrap; cursor: pointer; }
.switch input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.switch-track { position: relative; width: 40px; height: 22px; flex: 0 0 auto; border-radius: 11px; background: #cbd5e1; transition: background-color 160ms ease; }
.switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: white; box-shadow: 0 1px 3px rgba(16, 24, 40, 0.24); transition: transform 160ms ease; }
.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { outline: 3px solid rgba(37, 99, 235, 0.2); outline-offset: 2px; }
.section-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 12px; margin-top: 20px; scroll-margin-top: 32px; }
.action-feedback { min-width: 0; max-width: 720px; display: flex; align-items: center; gap: 8px; padding: 8px 11px; border: 1px solid; border-radius: 7px; font-weight: 600; animation: feedback-arrive 360ms ease-out; }
.action-feedback span { overflow-wrap: anywhere; }
.action-feedback time { flex: 0 0 auto; padding-left: 8px; border-left: 1px solid currentColor; font-variant-numeric: tabular-nums; opacity: .72; }
.action-feedback.success { border-color: #a7f3d0; background: #ecfdf5; color: #047857; }
.action-feedback.failed { border-color: #fecdd3; background: #fff1f2; color: #9f1239; }
@keyframes feedback-arrive {
  from { opacity: .25; transform: translateY(3px); }
}
.form-actions { display: flex; justify-content: flex-end; padding: 18px 28px; background: #f8fafc; }
.curl-dialog {
  width: min(860px, calc(100% - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 64px rgba(16, 24, 40, .24);
  color: var(--text);
}
.curl-dialog::backdrop { background: rgba(16, 24, 40, .52); }
.curl-dialog > header, .curl-dialog > footer { display: flex; align-items: center; gap: 16px; padding: 18px 20px; }
.curl-dialog > header { justify-content: space-between; border-bottom: 1px solid var(--border); }
.curl-dialog > header > div { min-width: 0; display: flex; align-items: center; gap: 12px; }
.curl-dialog h2 { font-size: 17px; }
.curl-dialog p { margin: 0; color: var(--muted); font-size: 13px; }
.dialog-close { width: 38px; min-height: 38px; flex: 0 0 auto; padding: 0; }
.curl-code {
  max-height: min(520px, calc(100vh - 230px));
  padding: 22px;
  overflow: auto;
  background: #101828;
  color: #d0d5dd;
  white-space: pre;
  overflow-wrap: normal;
  font: 13px/1.7 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
.curl-command { color: #7dd3fc; font-weight: 700; }
.curl-flag { color: #c4b5fd; }
.curl-method { color: #fbbf24; font-weight: 700; }
.curl-string { color: #86efac; }
.curl-dialog > footer { justify-content: flex-end; border-top: 1px solid var(--border); }
#curl-copy-status { margin-right: auto; color: #047857; font-size: 13px; font-weight: 600; }

.health-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.system-section-title { margin: 28px 0 12px; }
.health-item { min-height: 112px; display: flex; align-items: center; gap: 15px; padding: 20px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.health-item > div > span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 13px; font-weight: 600; }
.health-item strong { display: block; line-height: 1.35; }
.health-ok { color: var(--green); }
.agent-connection {
  min-height: 116px;
  display: grid;
  grid-template-columns: 120px minmax(240px, 1fr) minmax(210px, 280px) minmax(210px, 280px);
  align-items: center;
  gap: 24px;
  margin-top: 16px;
  padding: 20px 24px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.agent-signal { height: 58px; display: flex; align-items: center; gap: 14px; }
.agent-live-icon {
  position: relative;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 8px;
  background: #f1f5f9;
  color: #94a3b8;
}
.agent-live-icon .icon { width: 24px; height: 24px; }
.agent-live-icon::after {
  content: "";
  position: absolute;
  inset: -1px;
  border: 2px solid currentColor;
  border-radius: 9px;
  opacity: 0;
}
.agent-wave { width: 40px; height: 34px; display: flex; align-items: center; justify-content: center; gap: 3px; }
.agent-wave i { width: 4px; height: 24px; display: block; border-radius: 2px; background: #cbd5e1; transform: scaleY(.2); transform-origin: center; }
.agent-summary > span, .agent-metric > span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 12px; font-weight: 600; }
.agent-summary > div { display: flex; align-items: center; gap: 9px; }
.agent-summary strong { font-size: 20px; }
.agent-summary em {
  padding: 3px 7px;
  border-radius: 5px;
  background: #f1f5f9;
  color: #64748b;
  font-size: 11px;
  font-style: normal;
  font-weight: 700;
}
.agent-summary small, .agent-metric small { display: block; margin-top: 4px; color: var(--muted); }
.agent-metric { min-width: 0; padding-left: 22px; border-left: 1px solid var(--border); }
.agent-metric strong { display: block; overflow-wrap: anywhere; font-size: 16px; }
.agent-connected .agent-live-icon { background: #d1fae5; color: #047857; }
.agent-connected .agent-summary strong { color: #047857; }
.agent-connected .agent-summary em { background: #ecfdf3; color: #047857; }
.agent-connected .agent-live-icon::after { animation: agent-pulse 2.4s ease-out infinite; }
.agent-connected .agent-wave i { background: #10b981; animation: agent-wave 1.15s ease-in-out infinite; }
.agent-connected .agent-wave i:nth-child(2), .agent-connected .agent-wave i:nth-child(4) { animation-delay: 140ms; }
.agent-connected .agent-wave i:nth-child(3) { animation-delay: 280ms; }
.agent-connected.heartbeat .agent-live-icon { animation: agent-heartbeat 600ms ease-out; }
.agent-disconnected .agent-summary strong { color: #64748b; }
@keyframes agent-wave {
  0%, 100% { transform: scaleY(.2); }
  50% { transform: scaleY(1); }
}
@keyframes agent-pulse {
  0% { opacity: .45; transform: scale(1); }
  70%, 100% { opacity: 0; transform: scale(1.45); }
}
@keyframes agent-heartbeat {
  0%, 100% { transform: scale(1); }
  45% { transform: scale(1.14); }
}
.error-block { display: flex; align-items: flex-start; gap: 10px; margin-top: 18px; padding: 15px; border: 1px solid #fecdd3; border-radius: 7px; background: #fff1f2; color: #9f1239; }

@media (max-width: 1100px) {
  .topbar-inner { grid-template-columns: 220px 1fr 220px; }
  .stats, .health-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .upstream-summary, .upstream-connection { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .upstream-summary > div:nth-child(2), .upstream-connection > div:nth-child(2) { border-right: 0; }
  .upstream-summary > div:nth-child(-n+2), .upstream-connection > div:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
  .agent-connection { grid-template-columns: 100px repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
  .agent-signal { grid-row: 1 / 3; }
  .agent-summary { grid-column: 2 / -1; }
  .statistics-heading .page-title { flex-basis: calc(100% - 220px); }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid .span-2 { grid-column: span 2; }
  .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-grid > div, .detail-grid > div:nth-child(3n) { border-right: 1px solid var(--border); }
  .detail-grid > div:nth-child(2n) { border-right: 0; }
}

@media (max-width: 900px) {
  .table-wrap { overflow-x: auto; }
  .notification-preview { display: none !important; }
}

@media (max-width: 720px) {
  .topbar { height: auto; }
  .topbar-inner { width: calc(100% - 28px); grid-template-columns: 1fr; gap: 8px; }
  .brand { min-height: 56px; }
  .brand-mark { width: 34px; height: 34px; }
  .brand-name { font-size: 15px; }
  .topbar nav { grid-column: 1 / -1; height: 48px; justify-content: stretch; border-top: 1px solid var(--border); }
  .topbar nav a { min-width: 0; min-height: 38px; flex: 1; gap: 4px; padding: 6px 2px; white-space: nowrap; }
  .topbar nav a .icon { width: 15px; height: 15px; }
  .logout-form { position: absolute; top: 9px; right: 14px; }
  .logout-form button { width: 38px; padding: 0; }
  .logout-form button span { display: none; }
  main { width: calc(100% - 28px); padding-top: 26px; }
  .login-shell { width: 100%; padding: 20px 14px; }
  .login-panel { padding: 28px 22px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .page-heading form, .page-heading button { width: 100%; }
  h1 { font-size: 25px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat-card { min-height: 92px; gap: 11px; padding: 14px; }
  .stat-icon { width: 38px; height: 38px; }
  .stat-card strong { font-size: 24px; }
  .source-stat { min-width: 182px; }
  .filters, .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .filters button { width: 100%; }
  .upstream-summary, .upstream-connection { grid-template-columns: 1fr; }
  .upstream-summary > div, .upstream-summary > div:nth-child(2),
  .upstream-connection > div, .upstream-connection > div:nth-child(2) { border-right: 0; border-bottom: 1px solid var(--border); }
  .upstream-summary > div:last-child, .upstream-connection > div:last-child { border-bottom: 0; }
  .table-wrap { border-radius: 7px; }
  .statistics-date { width: 100%; height: auto; grid-template-columns: 1fr; }
  .statistics-date button { width: 100%; }
  .segmented { width: 100%; }
  .segmented a { flex: 1; }
  .statistics-nav { flex-wrap: wrap; }
  .statistics-nav > strong { min-width: 180px; }
  .chart-panel > header { grid-template-columns: 1fr; gap: 10px; }
  .chart-scroll { padding-right: 14px; padding-left: 14px; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-grid > div, .detail-grid > div:nth-child(2n), .detail-grid > div:nth-child(3n) { grid-column: 1; border-right: 0; }
  .settings-form > section { padding: 22px 18px; }
  .section-heading { align-items: flex-start; }
  .section-actions button, .action-feedback { width: 100%; }
  .form-actions { padding: 16px 18px; }
  .form-actions button { width: 100%; }
  .curl-dialog { width: calc(100% - 20px); max-height: calc(100vh - 20px); }
  .curl-dialog > header, .curl-dialog > footer { padding: 14px; }
  .curl-dialog > header .section-icon { display: none; }
  .curl-code { max-height: calc(100vh - 190px); padding: 16px; font-size: 12px; }
  .health-grid { grid-template-columns: 1fr; }
  .agent-connection { grid-template-columns: 1fr; gap: 14px; padding: 18px; }
  .agent-signal { grid-row: auto; }
  .agent-summary { grid-column: auto; }
  .agent-metric { padding-top: 14px; padding-left: 0; border-top: 1px solid var(--border); border-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .agent-connected .agent-live-icon::after,
  .agent-connected .agent-wave i,
  .agent-connected.heartbeat .agent-live-icon,
  .action-feedback { animation: none; }
  .agent-connected .agent-wave i { transform: scaleY(.7); }
}
