:root {
  --ink: #19212f;
  --muted: #697386;
  --line: #e4e9f1;
  --surface: #ffffff;
  --surface-soft: #f6f8fb;
  --brand: #0b65d8;
  --brand-dark: #074ba5;
  --success: #159a61;
  --warning: #d98213;
  --danger: #d33d4d;
  --shadow: 0 12px 36px rgba(28, 43, 72, 0.08);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: #eef2f7;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 12% -10%, rgba(11, 101, 216, 0.15), transparent 30rem),
    #eef2f7;
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.topbar {
  min-height: 188px;
  padding: 34px max(28px, calc((100vw - 1440px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  color: #fff;
  background: linear-gradient(120deg, #0a2346 0%, #0b4d99 56%, #0878c9 100%);
  box-shadow: inset 0 -1px rgba(255, 255, 255, 0.12);
}

.topbar h1 { margin: 6px 0 8px; font-size: clamp(28px, 3vw, 42px); letter-spacing: -0.03em; }
.topbar p { margin: 0; color: rgba(255, 255, 255, 0.72); }
.eyebrow { font-size: 12px; font-weight: 750; letter-spacing: 0.16em; opacity: 0.72; }

.topbar-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.endpoint { padding: 10px 14px; border: 1px solid rgba(255,255,255,.24); border-radius: 10px; background: rgba(0,0,0,.12); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; }

.page-shell { width: min(1440px, calc(100% - 40px)); margin: -24px auto 60px; }
.status-strip { min-height: 74px; padding: 15px 20px; display: flex; align-items: center; justify-content: space-between; gap: 20px; background: var(--surface); border: 1px solid rgba(255,255,255,.8); border-radius: 16px; box-shadow: var(--shadow); }
.service-state { display: flex; align-items: center; gap: 13px; }
.service-state strong, .service-state span { display: block; }
.service-state strong { font-size: 15px; }
.service-state span:last-child { margin-top: 3px; color: var(--muted); font-size: 12px; }
.status-dot { width: 12px; height: 12px; border-radius: 50%; box-shadow: 0 0 0 5px rgba(105,115,134,.12); background: #8c96a8; }
.status-up { background: var(--success); box-shadow: 0 0 0 5px rgba(21,154,97,.14); }
.status-down { background: var(--danger); box-shadow: 0 0 0 5px rgba(211,61,77,.14); }
.status-loading { animation: pulse 1.2s infinite; }
.last-updated { color: var(--muted); font-size: 12px; }

.metric-grid { margin-top: 18px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.metric-card { min-height: 132px; padding: 22px; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 15px; box-shadow: 0 6px 18px rgba(28,43,72,.035); }
.metric-card-alert { border-top: 3px solid #f2b155; }
.metric-label { color: var(--muted); font-size: 13px; font-weight: 650; }
.metric-value { margin: 11px 0 8px; font-size: 32px; line-height: 1; letter-spacing: -0.04em; }
.metric-note { margin-top: auto; color: #8a94a6; font-size: 11px; line-height: 1.5; }

.panel { margin-top: 18px; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 15px; box-shadow: 0 6px 18px rgba(28,43,72,.035); }
.panel-header { min-height: 86px; padding: 20px 22px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--line); }
.panel-header h2 { margin: 0 0 5px; font-size: 18px; }
.panel-header p { margin: 0; color: var(--muted); font-size: 12px; }
.toolbar { display: flex; align-items: center; gap: 10px; }
.search-box input { width: min(320px, 38vw); height: 38px; padding: 0 13px; border: 1px solid var(--line); border-radius: 9px; outline: none; background: var(--surface-soft); color: var(--ink); }
.search-box input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(11,101,216,.10); background: #fff; }
.count-badge { white-space: nowrap; padding: 6px 9px; color: var(--brand-dark); background: #eaf3ff; border-radius: 999px; font-size: 12px; font-weight: 700; }

.table-wrap { overflow-x: auto; }
table { width: 100%; min-width: 920px; border-collapse: collapse; }
th, td { padding: 14px 18px; text-align: left; border-bottom: 1px solid #edf0f5; font-size: 12px; }
th { color: #5d687b; background: #fafbfd; font-weight: 700; }
tbody tr:hover { background: #fbfdff; }
tbody tr:last-child td { border-bottom: 0; }
.frames-table { min-width: 1320px; }
.frames-table .time-cell { width: 166px; white-space: nowrap; }
.frames-table .source-cell { width: 160px; word-break: break-all; }
.frames-table .actions-column { width: 110px; }
.row-invalid { background: #fff8f8; }
.row-invalid:hover { background: #fff3f4; }
.sample-time, .instrument-cell { min-width: 190px; }
.sample-time strong, .sample-time span, .instrument-cell strong, .instrument-cell span { display: block; }
.sample-time strong, .instrument-cell strong { margin-bottom: 4px; color: #283449; font-size: 12px; }
.sample-time span, .instrument-cell span { color: var(--muted); font-size: 11px; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.hash { display: inline-block; max-width: 185px; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; color: #4c5870; }
.reason { display: inline-flex; padding: 4px 8px; border-radius: 999px; color: #285b49; background: #e8f7ef; font-weight: 650; }
.reason-warning { color: #8a4b00; background: #fff1da; }
.actions-column { width: 148px; text-align: right; }
td.actions-column { white-space: nowrap; }

.result-chips { min-width: 245px; display: flex; flex-wrap: wrap; gap: 5px; }
.result-chip { padding: 4px 7px; border: 1px solid #dce8f7; border-radius: 6px; color: #275783; background: #f3f8ff; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 10px; white-space: nowrap; }
.empty-results { color: var(--muted); font-size: 11px; }
.detail-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.frame-dialog > .dialog-shell > .detail-badges { margin-top: 18px; }
.data-badge { display: inline-flex; align-items: center; width: fit-content; padding: 4px 8px; border-radius: 999px; color: #526077; background: #edf1f6; font-size: 10px; font-weight: 750; white-space: nowrap; }
.data-badge-success { color: #176e4c; background: #e7f7ef; }
.data-badge-warning { color: #8a4b00; background: #fff1da; }
.data-badge-danger { color: #a72535; background: #ffe7ea; }

.button { min-height: 36px; padding: 8px 13px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: #fff; text-decoration: none; cursor: pointer; font-size: 12px; font-weight: 700; transition: .15s ease; }
.button:hover { border-color: #adc4e3; color: var(--brand); transform: translateY(-1px); }
.button-primary { border-color: rgba(255,255,255,.22); color: #fff; background: rgba(255,255,255,.15); }
.button-primary:hover { color: #fff; background: rgba(255,255,255,.23); }
.button-small { min-height: 30px; padding: 5px 10px; }

.event-list { max-height: 420px; overflow: auto; }
.event-item { padding: 13px 20px; display: grid; grid-template-columns: 88px 72px minmax(180px, 1fr) minmax(220px, 1.2fr); gap: 14px; align-items: start; border-bottom: 1px solid #edf0f5; font-size: 12px; }
.event-item:last-child { border-bottom: 0; }
.event-time { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.event-level { width: fit-content; padding: 3px 7px; border-radius: 6px; color: #37608f; background: #eaf3ff; font-size: 10px; font-weight: 750; }
.event-level-WARN { color: #925000; background: #fff1da; }
.event-level-ERROR { color: #a72535; background: #ffe7ea; }
.event-message { font-weight: 650; }
.event-attrs { color: var(--muted); word-break: break-all; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }

.empty-state { padding: 34px 20px !important; text-align: center !important; color: var(--muted); }
.error-state { color: var(--danger); }

.capture-dialog { width: min(1040px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; border: 0; border-radius: 18px; color: var(--ink); background: #fff; box-shadow: 0 24px 80px rgba(8,22,46,.28); }
.capture-dialog::backdrop { background: rgba(10,25,49,.58); backdrop-filter: blur(3px); }
.dialog-shell { padding: 24px; }
.dialog-header { display: flex; justify-content: space-between; gap: 20px; }
.dialog-header .eyebrow { color: var(--brand); opacity: 1; }
.dialog-header h2 { margin: 5px 0; font-size: 21px; }
.dialog-header p { margin: 0; color: var(--muted); font-size: 12px; }
.icon-button { width: 38px; height: 38px; border: 0; border-radius: 50%; color: #526077; background: var(--surface-soft); cursor: pointer; font-size: 24px; }
.dialog-actions { margin: 20px 0 14px; display: flex; gap: 8px; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tab { padding: 11px 15px; border: 0; border-bottom: 2px solid transparent; color: var(--muted); background: transparent; cursor: pointer; font-size: 12px; font-weight: 700; }
.tab.is-active { color: var(--brand); border-bottom-color: var(--brand); }
.preview-note { margin: 14px 0 8px; color: var(--muted); font-size: 11px; }
.capture-preview { min-height: 360px; max-height: 52vh; margin: 0; padding: 16px; overflow: auto; border: 1px solid #dfe5ee; border-radius: 11px; color: #dce9ff; background: #101a2a; font: 12px/1.65 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; word-break: break-all; }

.frame-dialog { overflow-y: auto; }
.detail-summary { margin-top: 14px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.summary-item { min-height: 72px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); }
.summary-item span, .summary-item strong { display: block; }
.summary-item span { margin-bottom: 7px; color: var(--muted); font-size: 10px; }
.summary-item strong { color: #273349; font-size: 12px; line-height: 1.5; word-break: break-all; }
.detail-section { margin-top: 22px; }
.detail-section[hidden] { display: none; }
.detail-section-title { margin-bottom: 10px; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.detail-section-title h3 { margin: 0; font-size: 14px; }
.detail-section-title span { color: var(--muted); font-size: 10px; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.field-item { min-width: 0; padding: 12px 13px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.field-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.field-heading strong { min-width: 0; color: #47536a; font-size: 11px; }
.field-heading code { flex: none; padding: 2px 5px; border-radius: 4px; color: #59718f; background: #edf3fa; font-size: 9px; }
.field-value { margin-top: 8px; color: #17243a; font-size: 14px; font-weight: 700; word-break: break-all; }
.warning-list { margin: 0; padding: 12px 16px 12px 34px; border: 1px solid #f4d7a9; border-radius: 9px; color: #7a4807; background: #fff8e9; font-size: 11px; line-height: 1.7; }
.technical-preview { max-height: 260px; margin: 0; padding: 14px; overflow: auto; border-radius: 9px; color: #dce9ff; background: #101a2a; font: 11px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; word-break: break-all; }

.toast { position: fixed; right: 22px; bottom: 22px; max-width: min(420px, calc(100vw - 44px)); padding: 11px 15px; border-radius: 10px; color: #fff; background: #1c2b43; box-shadow: var(--shadow); opacity: 0; transform: translateY(10px); pointer-events: none; transition: .2s ease; font-size: 12px; }
.toast.is-visible { opacity: 1; transform: translateY(0); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@keyframes pulse { 50% { opacity: .45; } }

@media (max-width: 980px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .event-item { grid-template-columns: 80px 64px 1fr; }
  .event-attrs { grid-column: 3; }
}

@media (max-width: 680px) {
  .topbar { padding: 28px 20px 46px; align-items: flex-start; flex-direction: column; }
  .topbar-actions { justify-content: flex-start; }
  .page-shell { width: calc(100% - 20px); margin-top: -22px; }
  .status-strip, .panel-header { align-items: flex-start; flex-direction: column; }
  .last-updated { align-self: flex-end; }
  .metric-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 126px; }
  .detail-summary, .field-grid { grid-template-columns: 1fr; }
  .toolbar { width: 100%; }
  .search-box { flex: 1; }
  .search-box input { width: 100%; }
  .event-item { grid-template-columns: 72px 1fr; }
  .event-message, .event-attrs { grid-column: 1 / -1; }
  .dialog-shell { padding: 18px; }
}
