:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #272824;
  background: #f4f2ed;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --canvas: #f4f2ed;
  --paper: #fffefa;
  --ink: #272824;
  --muted: #777871;
  --line: #e5e2da;
  --line-strong: #d4d0c6;
  --accent: #a26b32;
  --success: #286b59;
  --success-bg: #e8f1ed;
  --warning: #956322;
  --warning-bg: #f8f0e3;
  --danger: #a34235;
  --danger-bg: #f8ebe7;
  --unknown: #6e6d67;
  --unknown-bg: #f0eee9;
  --shadow: 0 12px 35px rgb(46 41 33 / 4%);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--canvas);
}

button, select { font: inherit; }
button { color: inherit; }

:focus-visible {
  outline: 3px solid #9a642b;
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 10;
  transform: translateY(-160%);
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: white;
}
.skip-link:focus { transform: translateY(0); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 66px;
  padding: 0 clamp(18px, 4vw, 58px);
  border-bottom: 1px solid var(--line);
  background: rgb(255 254 250 / 88%);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .01em;
  text-decoration: none;
}
.brand-mark {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 9px 9px 9px 3px;
  background: #282923;
  color: #fffefa;
  font-family: Georgia, serif;
  font-size: 17px;
}
.brand-divider { padding: 0 4px; color: #aaa79e; font-weight: 400; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }

.environment-pill, .count-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: #595a54;
  font-size: 12px;
  font-weight: 600;
}
.environment-dot, .status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warning);
}
.quiet-button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: transparent;
  color: #4d4e48;
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
}
.quiet-button:hover { background: #f7f4ed; }
.quiet-button[hidden] { display: none; }

.page-shell {
  width: min(1380px, calc(100% - 2 * clamp(18px, 4vw, 58px)));
  margin: 0 auto;
  padding: 36px 0 28px;
}
.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}
.eyebrow, .section-kicker {
  margin: 0 0 8px;
  color: #827f76;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .13em;
  text-transform: uppercase;
}
h1, h2, h3, p { margin-top: 0; }
h1 {
  margin-bottom: 6px;
  font-family: Georgia, "Noto Serif TC", serif;
  font-size: clamp(27px, 4vw, 37px);
  font-weight: 600;
  letter-spacing: -.035em;
}
.page-subtitle { margin-bottom: 0; color: var(--muted); font-size: 13px; }
.scenario-control {
  display: grid;
  gap: 6px;
  min-width: min(285px, 48vw);
  color: #686960;
  font-size: 11px;
  font-weight: 650;
}
.scenario-control[hidden] { display: none; }
.scenario-control select {
  width: 100%;
  min-height: 39px;
  padding: 0 34px 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  font-size: 12px;
}
.scenario-control:has(select:disabled) { opacity: .52; }

.mode-notice {
  display: flex;
  align-items: center;
  min-height: 42px;
  margin-bottom: 14px;
  padding: 9px 13px;
  border: 1px solid #e4d7c2;
  border-radius: 9px;
  color: #6f542d;
  font-size: 12px;
  line-height: 1.5;
}
.notice-synthetic { background: #f8f1e6; }
.notice-live { background: #f3f0e8; color: #615744; }
.notice-unknown { background: #f1efe9; color: #595951; }
.notice-loading { background: #f7f4ed; color: #595951; }

.overview-strip, .panel, .domain-card {
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--paper);
  box-shadow: var(--shadow);
}
.overview-strip {
  display: grid;
  grid-template-columns: minmax(145px, .8fr) 1px minmax(250px, 1.65fr) minmax(190px, .9fr);
  align-items: center;
  gap: 22px;
  min-height: 122px;
  padding: 20px 24px;
  margin-bottom: 14px;
}
.overall-state, .overview-meta { display: grid; gap: 5px; }
.overview-divider { width: 1px; height: 62px; background: var(--line); }
.state-label, .status-label { width: fit-content; font-size: 15px; font-weight: 750; }
.state-normal { color: var(--success); }
.state-abnormal { color: var(--danger); }
.state-stale { color: var(--warning); }
.state-unknown { color: var(--unknown); }
.muted-copy { color: var(--muted); font-size: 11px; line-height: 1.5; }
.primary-event {
  display: grid;
  gap: 5px;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}
.primary-event:disabled { color: inherit; opacity: 1; cursor: default; }
.primary-event strong { font-size: 14px; }
.primary-event:hover strong { text-decoration: underline; text-underline-offset: 3px; }
.primary-event:disabled:hover strong { text-decoration: none; }
.overview-meta strong { font-size: 12px; font-weight: 650; }

.domain-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 11px;
  margin-bottom: 14px;
}
.domain-card {
  display: flex;
  min-width: 0;
  min-height: 137px;
  flex-direction: column;
  align-items: stretch;
  padding: 14px;
  text-align: left;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.domain-card:hover { transform: translateY(-2px); border-color: #c5bba9; box-shadow: 0 14px 30px rgb(46 41 33 / 8%); }
.domain-card[aria-pressed="true"] { border-color: #897655; box-shadow: inset 0 0 0 1px #897655; }
.domain-card-heading { display: flex; align-items: center; gap: 7px; min-width: 0; margin-bottom: 14px; }
.domain-icon {
  display: grid;
  width: 23px;
  height: 23px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 7px;
  background: #f1eee6;
  color: #6a5941;
  font-size: 10px;
  font-weight: 750;
}
.domain-name { overflow: hidden; color: #686960; font-size: 11px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.domain-card .status-dot { width: 6px; height: 6px; margin-left: auto; }
.domain-card.state-normal .status-dot { background: var(--success); }
.domain-card.state-abnormal .status-dot { background: var(--danger); }
.domain-card.state-stale .status-dot { background: var(--warning); }
.domain-card.state-unknown .status-dot { background: #8a8982; }
.domain-status { margin-bottom: 4px; font-size: 14px; font-weight: 700; }
.domain-note { overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.domain-metric { overflow: hidden; margin-top: auto; padding-top: 11px; color: #4c4d47; font-size: 11px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }

.analysis-layout { display: grid; grid-template-columns: minmax(280px, .83fr) minmax(420px, 1.45fr); gap: 14px; }
.panel { min-width: 0; padding: 20px 21px; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.panel-heading h2 { margin: 0; font-family: Georgia, "Noto Serif TC", serif; font-size: 18px; font-weight: 600; letter-spacing: -.02em; }
.segmented-control { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 8px; background: #f6f4ef; }
.segmented-control button {
  min-height: 27px;
  padding: 0 9px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #76766f;
  cursor: pointer;
  font-size: 10px;
}
.segmented-control button[aria-pressed="true"] { background: white; color: #2e302b; box-shadow: 0 1px 3px rgb(0 0 0 / 9%); }
.chart-caption { margin: 9px 0 20px; }
.chart-bars { display: grid; gap: 13px; min-height: 126px; align-content: center; }
.chart-row { display: grid; grid-template-columns: 74px minmax(45px, 1fr) 20px; align-items: center; gap: 10px; }
.chart-row-label { color: #66675f; font-size: 10px; }
.chart-track { display: block; height: 8px; overflow: hidden; border-radius: 99px; background: #efede7; }
.chart-bar { display: block; height: 100%; min-width: 0; border-radius: inherit; transition: width .2s ease; }
.bar-normal { background: #578a75; }
.bar-abnormal { background: #b65b4b; }
.bar-stale { background: #c18a3f; }
.bar-unknown { background: #aaa8a1; }
.bar-size-0 { width: 0; }
.bar-size-1 { width: 16.6667%; }
.bar-size-2 { width: 33.3333%; }
.bar-size-3 { width: 50%; }
.bar-size-4 { width: 66.6667%; }
.bar-size-5 { width: 83.3333%; }
.bar-size-6 { width: 100%; }
.chart-count { color: #55564f; font-size: 11px; font-weight: 650; text-align: right; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 15px; margin-top: 16px; }

.detail-heading { align-items: center; }
.count-chip { min-height: 25px; color: #6f7069; font-size: 10px; }
.domain-tabs { display: flex; gap: 17px; overflow-x: auto; margin: 13px 0 10px; border-bottom: 1px solid var(--line); }
.domain-tabs button {
  position: relative;
  flex: 0 0 auto;
  padding: 7px 1px 10px;
  border: 0;
  background: transparent;
  color: #787971;
  cursor: pointer;
  font-size: 11px;
}
.domain-tabs button[aria-selected="true"] { color: #272824; font-weight: 750; }
.domain-tabs button[aria-selected="true"]::after { position: absolute; right: 0; bottom: -1px; left: 0; height: 2px; background: #5e5140; content: ""; }
.detail-list { display: grid; max-height: 420px; gap: 9px; overflow: auto; padding: 2px 2px 2px 0; }
.detail-list:focus-visible { outline-offset: 1px; }
.detail-card { padding: 13px 14px; border: 1px solid var(--line); border-radius: 9px; background: #fffefa; }
.detail-card-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 11px; }
.detail-card-title .section-kicker { margin-bottom: 3px; }
.detail-card-title h3 { margin: 0; font-size: 13px; font-weight: 700; }
.status-label { padding: 4px 8px; border-radius: 999px; font-size: 10px; white-space: nowrap; }
.detail-card.state-normal .status-label { background: var(--success-bg); color: var(--success); }
.detail-card.state-abnormal .status-label { background: var(--danger-bg); color: var(--danger); }
.detail-card.state-stale .status-label { background: var(--warning-bg); color: var(--warning); }
.detail-card.state-unknown .status-label { background: var(--unknown-bg); color: var(--unknown); }
.detail-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; margin: 0; }
.detail-field { min-width: 0; }
.detail-field dt { margin-bottom: 3px; color: #87877f; font-size: 9px; }
.detail-field dd { overflow-wrap: anywhere; margin: 0; color: #454640; font-size: 10px; line-height: 1.45; }

.page-footer { display: flex; justify-content: space-between; gap: 12px; padding: 17px 2px 0; color: #898980; font-size: 10px; }

@media (max-width: 1100px) {
  .domain-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .analysis-layout { grid-template-columns: minmax(250px, .85fr) minmax(360px, 1.35fr); }
}

@media (max-width: 760px) {
  .topbar { min-height: 59px; padding: 0 17px; }
  .topbar-actions { gap: 7px; }
  .environment-pill { padding: 0 8px; font-size: 10px; }
  .quiet-button { min-height: 31px; padding: 0 8px; font-size: 10px; }
  .page-shell { width: calc(100% - 34px); padding-top: 27px; }
  .page-heading { align-items: stretch; flex-direction: column; gap: 16px; }
  .scenario-control { min-width: 100%; }
  .overview-strip { grid-template-columns: 1fr 1fr; gap: 15px; padding: 17px; }
  .overview-divider { display: none; }
  .primary-event { grid-column: 1 / -1; grid-row: 2; padding-top: 14px; border-top: 1px solid var(--line); }
  .overview-meta { grid-column: 1 / -1; padding-top: 12px; border-top: 1px solid var(--line); }
  .domain-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .domain-card { min-height: 128px; padding: 12px; }
  .analysis-layout { grid-template-columns: 1fr; }
  .panel { padding: 17px; }
  .detail-list { max-height: none; }
}

@media (max-width: 430px) {
  .brand { gap: 7px; font-size: 11px; }
  .brand-mark { width: 25px; height: 25px; }
  .environment-pill { gap: 5px; min-height: 27px; }
  .environment-dot { width: 6px; height: 6px; }
  .quiet-button { padding: 0 7px; font-size: 9px; }
  .overview-strip { grid-template-columns: 1fr; }
  .overall-state, .overview-meta { grid-column: 1; }
  .primary-event { grid-column: 1; grid-row: auto; }
  .detail-fields { grid-template-columns: 1fr; }
  .panel-heading { flex-direction: column; }
  .segmented-control { align-self: flex-start; }
  .page-footer { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
