:root {
  color-scheme: light;
  --ink: #17201d;
  --muted: #64706b;
  --line: #dfe6e2;
  --surface: #ffffff;
  --canvas: #f4f7f5;
  --brand: #126b4f;
  --brand-dark: #0c533d;
  --brand-soft: #e5f4ee;
  --warning: #a66208;
  --warning-soft: #fff2d8;
  --danger: #a53b32;
  --danger-soft: #fdeae7;
  --shadow: 0 18px 55px rgb(28 48 40 / 10%);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid rgb(18 107 79 / 35%);
  outline-offset: 3px;
}
.shell { min-height: 100vh; }
.topbar { height: 68px; padding: 0 clamp(20px, 4vw, 64px); display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); background: rgb(255 255 255 / 92%); backdrop-filter: blur(18px); position: sticky; top: 0; z-index: 10; }
.brand { display: flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; }
.brand span:last-child { display: grid; line-height: 1.05; }
.brand strong { font-size: 15px; letter-spacing: -.01em; }
.brand small { margin-top: 3px; color: var(--muted); font-size: 11px; letter-spacing: .13em; text-transform: uppercase; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--brand); font-family: Georgia, serif; font-size: 20px; }
.brand-mark.large { width: 48px; height: 48px; margin: 0 auto 20px; font-size: 27px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.api-state { font-size: 12px; color: var(--muted); margin-right: 6px; }
.api-state::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: #9aa39f; }
.api-state[data-tone="ok"]::before { background: #22a06b; box-shadow: 0 0 0 4px #e1f5ec; }
.api-state[data-tone="error"]::before { background: var(--danger); box-shadow: 0 0 0 4px var(--danger-soft); }
.tabs { padding: 14px clamp(20px, 4vw, 64px) 0; display: flex; gap: 4px; overflow-x: auto; background: var(--surface); border-bottom: 1px solid var(--line); }
.tab { min-width: max-content; padding: 11px 16px 13px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font-size: 14px; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 650; }
main { width: min(1440px, 100%); margin: 0 auto; padding: 36px clamp(20px, 4vw, 64px) 80px; }
.view { display: none; }
.view.active { display: block; }
.section-heading, .panel-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; }
.section-heading { margin-bottom: 24px; }
.eyebrow { margin: 0 0 7px; color: var(--brand); font-size: 10px; line-height: 1; font-weight: 750; letter-spacing: .18em; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(28px, 4vw, 42px); letter-spacing: -.035em; }
h2 { margin-bottom: 5px; font-size: 18px; letter-spacing: -.015em; }
.muted, .panel-heading p { color: var(--muted); }
.panel-heading p { margin-bottom: 0; font-size: 13px; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric { min-height: 126px; padding: 20px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: 0 5px 18px rgb(28 48 40 / 4%); }
.metric-label { color: var(--muted); font-size: 12px; }
.metric-value { display: block; margin-top: 15px; font-size: 32px; line-height: 1; font-weight: 690; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.metric-note { margin: 9px 0 0; color: var(--muted); font-size: 11px; }
.panel, .table-panel { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: 0 5px 18px rgb(28 48 40 / 4%); overflow: hidden; }
.panel { padding: 20px; }
.panel-heading { margin-bottom: 14px; }
.anomaly-list { display: grid; gap: 8px; }
.anomaly { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px; border: 0; border-radius: 11px; background: #f7f9f8; color: inherit; text-align: left; }
.anomaly:hover { filter: brightness(.98); }
.anomaly strong { display: block; font-size: 14px; }
.anomaly small { color: var(--muted); }
.anomaly[data-severity="critical"] { background: var(--danger-soft); }
.anomaly[data-severity="warning"] { background: var(--warning-soft); }
.count-pill, .status { display: inline-flex; align-items: center; min-width: max-content; border-radius: 999px; font-size: 11px; font-weight: 670; }
.count-pill { padding: 5px 9px; background: rgb(255 255 255 / 70%); }
.status { padding: 4px 8px; background: #eef2f0; color: #53605b; }
.status.ok { background: var(--brand-soft); color: var(--brand-dark); }
.status.warning { background: var(--warning-soft); color: var(--warning); }
.status.danger { background: var(--danger-soft); color: var(--danger); }
.filters { display: flex; gap: 10px; margin-bottom: 16px; }
.search { flex: 1; }
input, select { width: 100%; min-height: 42px; padding: 0 12px; border: 1px solid #cdd7d2; border-radius: 10px; background: white; color: var(--ink); outline: none; }
select { width: auto; min-width: 150px; }
input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgb(18 107 79 / 12%); }
.button { min-height: 38px; padding: 0 14px; border: 1px solid transparent; border-radius: 9px; font-size: 13px; font-weight: 650; }
.button.primary { color: white; background: var(--brand); }
.button.primary:hover { background: var(--brand-dark); }
.button.secondary { color: var(--ink); background: white; border-color: var(--line); }
.button.ghost { color: var(--muted); background: transparent; }
.button.danger { color: var(--danger); background: var(--danger-soft); }
.button.wide { width: 100%; min-height: 46px; }
.button:disabled { opacity: .55; cursor: wait; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 12px 16px; color: var(--muted); background: #f8faf9; font-size: 10px; letter-spacing: .08em; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { padding: 14px 16px; border-top: 1px solid #edf0ee; vertical-align: middle; }
tbody tr:hover { background: #fafcfb; }
.mono { font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; color: #45514c; }
.clickable { color: var(--brand); font-weight: 650; text-decoration: none; }
.clickable:hover { text-decoration: underline; }
.empty { padding: 48px 24px; color: var(--muted); text-align: center; }
.pagination { min-height: 58px; padding: 10px 14px; display: flex; align-items: center; justify-content: flex-end; gap: 10px; border-top: 1px solid #edf0ee; color: var(--muted); font-size: 12px; }
.loading { position: relative; color: transparent !important; }
.loading::after { content: ""; position: absolute; inset: 50% auto auto 50%; width: 18px; height: 18px; margin: -9px; border: 2px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .65s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
dialog { border: 0; padding: 0; background: transparent; }
dialog::backdrop { background: rgb(17 28 24 / 48%); backdrop-filter: blur(4px); }
.login-dialog { width: min(440px, calc(100vw - 32px)); }
.login-card { padding: 34px; border-radius: 20px; background: var(--surface); box-shadow: var(--shadow); text-align: center; }
.login-card h1 { margin-bottom: 11px; font-size: 30px; }
.login-card .muted { margin-bottom: 24px; font-size: 13px; line-height: 1.6; }
.token-field { display: grid; gap: 8px; margin-bottom: 14px; color: var(--muted); font-size: 12px; text-align: left; }
.form-error { min-height: 18px; margin: 0 0 8px; color: var(--danger); font-size: 12px; }
.detail-dialog { width: min(920px, calc(100vw - 32px)); max-height: calc(100vh - 40px); }
.detail-card { max-height: calc(100vh - 40px); padding: 26px; border-radius: 20px; background: white; box-shadow: var(--shadow); overflow: auto; }
.detail-header { display: flex; align-items: start; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.detail-header h2 { font-size: 24px; }
.icon-button { width: 36px; height: 36px; border: 0; border-radius: 50%; background: #eef2f0; color: var(--muted); font-size: 23px; }
.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
.detail-field { padding: 13px; border-radius: 10px; background: #f5f8f6; }
.detail-field small { display: block; margin-bottom: 5px; color: var(--muted); }
.detail-section { margin-top: 22px; }
.detail-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 9px; }
.detail-section h3 { margin: 0; font-size: 14px; }
.toast { position: fixed; right: 22px; bottom: 22px; max-width: min(420px, calc(100vw - 44px)); padding: 12px 16px; border-radius: 10px; background: #20352e; color: white; font-size: 13px; box-shadow: var(--shadow); opacity: 0; transform: translateY(10px); pointer-events: none; transition: .2s ease; z-index: 30; }
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); }
.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; }

@media (max-width: 900px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 620px) {
  .topbar { padding: 0 16px; }
  .api-state { display: none; }
  .tabs { padding-left: 10px; padding-right: 10px; }
  main { padding: 26px 14px 60px; }
  .metrics { grid-template-columns: 1fr 1fr; gap: 9px; }
  .metric { min-height: 110px; padding: 15px; }
  .metric-value { font-size: 27px; }
  .filters { flex-wrap: wrap; }
  .search { flex-basis: 100%; }
  select { flex: 1; min-width: 0; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-card { padding: 20px 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
