:root {
  color-scheme: light;
  --radius: 6px;
  --background: var(--gray-1, #fcfcfc);
  --foreground: var(--gray-12, #202020);
  --card: var(--gray-1, #fcfcfc);
  --muted: var(--gray-3, #f0f0f0);
  --muted-foreground: var(--gray-11, #646464);
  --border: var(--gray-6, #d9d9d9);
  --input: var(--gray-7, #cecece);
  --ring: var(--gray-12, #202020);
  --success: var(--green-9, #30a46c);
  --success-soft: var(--green-3, #e9f6e9);
  --warning: var(--amber-9, #ffc53d);
  --warning-soft: var(--amber-3, #fff7c2);
  --danger: var(--red-9, #e5484d);
  --danger-soft: var(--red-3, #ffe9e9);
  --info: var(--blue-9, #0090ff);
  --info-soft: var(--blue-3, #e6f4fe);
  --violet: var(--violet-9, #6e56cf);
}

* {
  box-sizing: border-box;
}

html {
  font-family: "IBM Plex Sans Thai", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--background);
  color: var(--foreground);
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.shell {
  width: min(1480px, calc(100% - 24px));
  margin: 0 auto;
  padding: 14px 0 22px;
}

.topbar,
.toolbar,
.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar {
  min-height: 46px;
  margin-bottom: 10px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.brand-mark,
.brand-logo {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.brand-mark {
  background:
    linear-gradient(135deg, var(--foreground) 0 48%, transparent 48%),
    linear-gradient(315deg, var(--muted) 0 52%, var(--success) 52%);
}

.brand-logo {
  display: block;
  object-fit: contain;
  background: var(--foreground);
}

.brand-kicker,
.summary-label,
.summary-note,
.monitor-since,
.stat-row small,
.history-day small,
.footer {
  color: var(--muted-foreground);
}

.brand-kicker {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.brand-title {
  display: block;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.05;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.source-link,
.icon-button,
.segmented button {
  height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--background);
  color: var(--foreground);
}

.source-link {
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 600;
}

.icon-button {
  display: inline-grid;
  width: 34px;
  place-items: center;
}

.icon-button:hover,
.source-link:hover,
.period-nav a:hover,
.period-nav button:hover {
  background: var(--muted);
}

.icon-button svg,
.search-field svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.notice {
  margin-bottom: 10px;
  padding: 10px 12px;
  border: 1px solid #f59e0b;
  border-radius: var(--radius);
  background: var(--warning-soft);
  color: #92400e;
  font-size: 13px;
}

.summary-grid {
  display: grid;
  grid-template-columns: 1.4fr repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 10px;
}

.summary-card,
.monitor-card,
.detail-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
}

.summary-card {
  min-height: 104px;
  padding: 14px;
}

.summary-card strong {
  display: block;
  margin: 6px 0;
  font-size: 28px;
  line-height: 1.05;
}

.summary-card-primary {
  color: var(--background);
  border-color: var(--foreground);
  background: var(--foreground);
}

.summary-card-primary .summary-label,
.summary-card-primary .summary-note {
  color: #d4d4d4;
}

.summary-card-primary .status-pill {
  border-color: #404040;
  background: #171717;
  color: var(--background);
}

.summary-time {
  font-size: 18px !important;
  line-height: 1.25 !important;
}

.toolbar {
  margin: 6px 0 10px;
  align-items: stretch;
}

.search-field {
  display: flex;
  align-items: center;
  width: min(420px, 100%);
  height: 38px;
  gap: 8px;
  padding: 0 11px;
  border: 1px solid var(--input);
  border-radius: var(--radius);
  background: var(--background);
}

.search-field input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--foreground);
}

.segmented {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--muted);
}

.segmented [role="tablist"] {
  display: flex;
  width: 100%;
}

.segmented button {
  min-width: 84px;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.segmented button.is-active,
.segmented [data-state="active"] {
  background: var(--background);
}

.monitor-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.monitor-card {
  display: grid;
  gap: 11px;
  min-width: 0;
  padding: 14px;
}

.monitor-card[hidden] {
  display: none;
}

.monitor-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.monitor-title {
  display: block;
  overflow-wrap: anywhere;
  font-size: 17px;
  font-weight: 700;
}

.monitor-title:hover,
.footer a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.monitor-since {
  display: block;
  margin-top: 3px;
  font-size: 12px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  min-height: 24px;
  padding: 0 9px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill.good,
.day-dot.good,
.history-day.good {
  background: var(--success-soft);
  color: #047857;
}

.status-pill.good {
  border-color: #bbf7d0;
}

.status-pill.warn,
.day-dot.warn,
.history-day.warn {
  background: var(--warning-soft);
  color: #b45309;
}

.status-pill.warn {
  border-color: #fde68a;
}

.status-pill.bad,
.day-dot.bad,
.history-day.bad {
  background: var(--danger-soft);
  color: var(--danger);
}

.status-pill.bad {
  border-color: #fecaca;
}

.status-pill.muted,
.day-dot.muted,
.history-day.muted {
  background: var(--muted);
  color: var(--muted-foreground);
}

.status-pill.muted {
  border-color: var(--border);
}

.uptime-row {
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  gap: 8px;
}

.uptime-row > span {
  color: var(--muted-foreground);
  font-weight: 600;
}

.uptime-row > strong {
  font-size: 19px;
}

.day-strip {
  display: grid;
  grid-template-columns: repeat(7, minmax(9px, 1fr));
  gap: 5px;
}

.day-dot {
  height: 9px;
  border-radius: 999px;
}

.metric-list {
  display: grid;
  gap: 8px;
}

.metric-row,
.network-row {
  display: grid;
  grid-template-columns: 62px minmax(72px, 1fr) minmax(72px, auto);
  align-items: center;
  gap: 8px;
  min-height: 22px;
}

.metric-row > span,
.network-row > span {
  color: var(--muted-foreground);
  font-size: 13px;
  font-weight: 600;
}

.metric-row > strong,
.network-row > strong {
  overflow-wrap: anywhere;
  text-align: right;
  font-size: 13px;
}

.meter,
.network-meter {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf1;
}

.meter span {
  display: block;
  width: var(--value);
  height: 100%;
  border-radius: inherit;
  background: currentColor;
}

.meter.good {
  color: #059669;
}

.meter.warn {
  color: #b7791f;
}

.meter.bad {
  color: var(--danger);
}

.network-meter {
  display: flex;
}

.network-meter span {
  height: 100%;
}

.net-in {
  width: var(--value);
  background: var(--info);
}

.net-out {
  width: var(--value);
  background: var(--violet);
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

.stat-row span,
.uptime-stat-grid span,
.downtime-list span {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--muted);
}

.stat-row span {
  padding: 8px;
}

.stat-row small,
.stat-row strong {
  display: block;
}

.stat-row strong {
  margin-top: 2px;
  font-size: 13px;
}

.history-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
}

.history-day {
  min-width: 0;
  padding: 7px 5px;
  border-radius: var(--radius);
  text-align: center;
}

.history-day small,
.history-day strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-day strong {
  margin-top: 2px;
  font-size: 11px;
}

.empty-state {
  padding: 20px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--background);
  color: var(--muted-foreground);
  text-align: center;
}

.footer {
  margin-top: 14px;
  padding: 10px 0;
  font-size: 13px;
}

.report-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin: 2px 0 12px;
  padding: 4px 0 0;
}

.report-hero h1 {
  margin: 3px 0 4px;
  overflow-wrap: anywhere;
  font-size: 34px;
  line-height: 1.08;
}

.report-hero p {
  margin: 0;
  color: var(--muted-foreground);
}

.report-summary {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.period-nav {
  margin: 4px 0 10px;
}

.period-nav [role="tablist"] {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.period-nav a,
.period-nav button {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--background);
  color: var(--muted-foreground);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.period-nav a.is-active,
.period-nav [data-state="active"] {
  border-color: var(--foreground);
  background: var(--foreground);
  color: var(--background);
}

.report-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 10px;
  margin-bottom: 10px;
}

.detail-panel {
  min-width: 0;
  padding: 14px;
}

.detail-panel h2 {
  margin: 0 0 12px;
  font-size: 16px;
  line-height: 1.2;
}

.detail-list {
  display: grid;
  gap: 8px;
  margin: 0;
}

.detail-list div {
  display: grid;
  grid-template-columns: minmax(120px, 0.7fr) minmax(0, 1fr);
  gap: 10px;
  min-height: 24px;
}

.detail-list dt,
.uptime-stat-grid small {
  color: var(--muted-foreground);
  font-size: 13px;
  font-weight: 600;
}

.detail-list dd {
  margin: 0;
  overflow-wrap: anywhere;
  text-align: right;
  font-weight: 700;
}

.uptime-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.uptime-stat-grid span {
  padding: 10px;
}

.uptime-stat-grid small,
.uptime-stat-grid strong {
  display: block;
}

.uptime-stat-grid strong {
  margin-top: 3px;
  font-size: 18px;
}

.report-history {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.downtime-list {
  display: grid;
  gap: 6px;
}

.downtime-list span {
  padding: 9px 10px;
}

.radix-tooltip-content {
  z-index: 50;
  max-width: 280px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--foreground);
  color: var(--background);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
}

.radix-tooltip-arrow {
  fill: var(--foreground);
}

.app-state {
  display: grid;
  min-height: 220px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  text-align: center;
}

.app-state strong,
.app-state span {
  display: block;
}

.app-state strong {
  font-size: 20px;
}

.app-state span {
  margin-top: 6px;
  color: var(--muted-foreground);
}

.icon-button[data-refreshing="true"] svg {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

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

  .monitor-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .report-summary,
  .report-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 18px, 720px);
    padding-top: 10px;
  }

  .topbar,
  .toolbar,
  .footer {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    flex-direction: row;
  }

  .summary-grid,
  .monitor-grid {
    grid-template-columns: 1fr;
  }

  .summary-card {
    min-height: 94px;
  }

  .summary-card strong {
    font-size: 26px;
  }

  .segmented {
    width: 100%;
  }

  .segmented button {
    min-width: 0;
    flex: 1;
  }

  .stat-row,
  .history-row,
  .report-history,
  .uptime-stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .report-hero {
    flex-direction: column;
  }

  .report-hero h1 {
    font-size: 28px;
  }

  .report-summary,
  .report-grid {
    grid-template-columns: 1fr;
  }

  .detail-list div {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .detail-list dd {
    text-align: left;
  }
}
