/* ---------- Tokens ---------- */
:root {
  --font-display: "Rubik", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: "Rubik", -apple-system, BlinkMacSystemFont, sans-serif;

  --bg: #ffffff;
  --bg-elev: #fbfaf8;
  --bg-card: #ffffff;
  --ink: #14110d;
  --ink-soft: #59544c;
  --ink-muted: #8a847a;
  --line: #ece8e0;
  --line-strong: #d9d3c7;

  --ok: #1f8b5a;
  --ok-soft: #e6f3ec;
  --warn: #b97600;
  --warn-soft: #faf0d8;
  --bad: #c1382f;
  --bad-soft: #f8e3df;
  --info: #2b6cb0;
  --info-soft: #e3edf7;

  --accent: #14110d;
  --heading: #000000;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;

  --shadow-card: 0 1px 0 rgba(20, 17, 13, 0.04);
  --shadow-pop: 0 14px 30px -16px rgba(20, 17, 13, 0.22), 0 2px 8px rgba(20, 17, 13, 0.06);

  --container: 880px;
}

[data-theme="dark"] {
  --bg: #0e0d0b;
  --bg-elev: #16140f;
  --bg-card: #1b1813;
  --ink: #f4efe5;
  --ink-soft: #b8b0a1;
  --ink-muted: #807a6f;
  --line: #2a2620;
  --line-strong: #3a352c;

  --ok: #4dbf85;
  --ok-soft: #1b2c23;
  --warn: #e0a93a;
  --warn-soft: #2e2516;
  --bad: #e36b62;
  --bad-soft: #2e1c1a;
  --info: #6ba6e0;
  --info-soft: #16222f;

  --heading: #ffffff;

  --shadow-card: 0 1px 0 rgba(0, 0, 0, 0.3);
  --shadow-pop: 0 18px 40px -16px rgba(0, 0, 0, 0.6), 0 2px 8px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-feature-settings: "ss01", "ss02", "cv01";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

button {
  font-family: inherit;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

/* ---------- Layout ---------- */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- Top bar ---------- */
.topbar {
  background: var(--bg);
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 80px;
}
.brand-name {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--heading);
  line-height: 1;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  min-height: 36px;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  transition: background .15s ease, border-color .15s ease, transform .1s ease;
}
.btn:hover { background: var(--bg-elev); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.btn-primary:hover { background: color-mix(in oklab, var(--ink) 88%, transparent); }

/* ---------- Hero overall status ---------- */
.hero {
  padding: 28px 0 20px;
}
.hero-inner { display: flex; }
.status-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px 18px;
  border-radius: 12px;
  background: var(--ok-soft);
  color: var(--ok);
  border: 1px solid color-mix(in oklab, var(--ok) 22%, transparent);
}
.hero[data-state="warn"] .status-card {
  background: var(--warn-soft); color: var(--warn);
  border-color: color-mix(in oklab, var(--warn) 24%, transparent);
}
.hero[data-state="bad"] .status-card {
  background: var(--bad-soft); color: var(--bad);
  border-color: color-mix(in oklab, var(--bad) 24%, transparent);
}
.status-icon {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--ok);
  color: var(--bg-card);
  display: grid; place-items: center;
  flex: 0 0 24px;
}
.hero[data-state="warn"] .status-icon { background: var(--warn); }
.hero[data-state="bad"] .status-icon { background: var(--bad); }
.status-icon svg { color: var(--bg-card); stroke: var(--bg-card); }
.status-text {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.005em;
  flex: 1;
  color: color-mix(in oklab, currentColor 92%, var(--ink));
}

/* ---------- Section ---------- */
.section { padding: 28px 0; }
.section + .section { border-top: 1px solid var(--line); padding-top: 36px; }
.section-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 18px; gap: 16px; flex-wrap: wrap;
}
.section-title {
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--heading);
}
.section-aside {
  font-size: 12px; color: var(--ink-muted);
  display: flex; align-items: center; gap: 14px;
  flex-wrap: nowrap;
}
.section-aside .legend {
  display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}
.legend-swatch {
  width: 10px; height: 10px; min-width: 10px; min-height: 10px; border-radius: 2px;
  background: var(--ok);
  flex: 0 0 10px;
  flex-shrink: 0;
  display: block;
}

/* ---------- Service card ---------- */
.svc-group {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  overflow: hidden;
  margin-bottom: 14px;
}
.svc-group-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  user-select: none;
}
.svc-group-head h3 {
  margin: 0; font-size: 14px; font-weight: 600; letter-spacing: -0.005em;
  display: flex; align-items: center; gap: 10px;
  color: var(--heading);
}
.chev {
  width: 14px; height: 14px; color: var(--ink-muted);
  transition: transform .2s ease;
}
.svc-group[data-open="false"] .chev { transform: rotate(-90deg); }
.svc-group[data-open="false"] .svc-list { display: none; }
.svc-group-status {
  font-size: 12px; color: var(--ink-soft);
  display: inline-flex; align-items: center; gap: 8px;
}

.svc-list {
  list-style: none; margin: 0; padding: 0;
}
.svc-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--line);
}
.svc-row:first-child { border-top: 0; }
.svc-row-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
}
.svc-row-name {
  display: flex; align-items: center; gap: 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--heading);
}
.svc-row-desc {
  font-size: 12.5px;
  color: var(--heading);
  line-height: 1.4;
  text-align: left;
}
.svc-bars-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.svc-bars-track {
  flex: 1;
  min-width: 0;
}
.svc-bars {
  display: grid;
  gap: 2px;
  height: 28px;
  width: 100%;
}
.svc-bars .bar {
  background: var(--ok);
  border-radius: 1px;
  opacity: 0.85;
  transition: opacity .15s ease, transform .15s ease;
  pointer-events: none;
  position: relative;
}
.svc-bars .bar.warn { background: var(--warn); }
.svc-bars .bar.bad { background: var(--bad); }
.svc-bars .bar.info { background: var(--info); }
.svc-bars .bar.is-active {
  opacity: 1;
  transform: scaleY(1.15);
}

.svc-bars-row {
  display: flex; flex-direction: column; gap: 4px;
}
.svc-bars-line {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.svc-bars-meta {
  display: flex;
  justify-content: flex-start;
  align-items: baseline;
  gap: 10px;
  font-size: 11px;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
  min-width: 0;
}
.svc-uptime {
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  color: var(--ink-muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.svc-bars-line .pill {
  flex-shrink: 0;
  align-self: center;
}

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  background: var(--ok-soft);
  color: var(--ok);
  white-space: nowrap;
}
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill .ddot {
  width: 6px; height: 6px; border-radius: 50%; background: currentColor;
}

/* ---------- Filter chips ---------- */
.chips {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.chip {
  font-size: 12px; padding: 6px 10px; border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-card);
  color: var(--ink-soft);
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.chip:hover { background: var(--bg-elev); color: var(--ink); }
.chip[data-active="true"] {
  background: var(--ink); color: var(--bg); border-color: var(--ink);
}

/* ---------- Incidents ---------- */
.incidents { display: flex; flex-direction: column; gap: 14px; }
.day-group {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  overflow: hidden;
}
.day-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elev);
}
.day-date {
  font-size: 13px; font-weight: 500;
  color: var(--heading);
}
.day-count {
  font-size: 12px; color: var(--ink-muted);
}
.incident {
  padding: 18px 20px;
  border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 12px;
}
.incident:first-child { border-top: 0; }
.incident-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
}
.incident-title {
  font-size: 15px; font-weight: 500; letter-spacing: -0.005em;
  margin: 0;
  color: var(--heading);
}
.incident-meta {
  font-size: 12px; color: var(--ink-muted);
  display: flex; align-items: center; gap: 8px;
  white-space: nowrap;
}
.incident-services {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.tag {
  font-size: 11px; padding: 3px 8px; border-radius: 4px;
  background: var(--bg-elev); color: var(--ink-soft);
  border: 1px solid var(--line);
}
.timeline {
  border-left: 2px solid var(--line);
  margin-left: 6px;
  padding-left: 18px;
  display: flex; flex-direction: column; gap: 16px;
  margin-top: 4px;
}
.tl-step { position: relative; }
.tl-step::before {
  content: "";
  position: absolute;
  left: -25px;
  top: 6px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--ink-muted);
}
.tl-step[data-kind="resolved"]::before { border-color: var(--ok); background: var(--ok); }
.tl-step[data-kind="monitoring"]::before { border-color: var(--info); background: var(--info); }
.tl-step[data-kind="identified"]::before { border-color: var(--warn); background: var(--warn); }
.tl-step[data-kind="investigating"]::before { border-color: var(--bad); background: var(--bad); }
.tl-kind {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  font-weight: 600; color: var(--ink-soft);
}
.tl-text { font-size: 13.5px; line-height: 1.5; color: var(--ink); margin: 4px 0 0; }
.tl-time { font-size: 11.5px; color: var(--ink-muted); margin-top: 4px; font-variant-numeric: tabular-nums; }

/* ---------- Maintenance ---------- */
.maint {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  background: var(--bg-card);
  display: flex; flex-direction: column; gap: 10px;
}
.maint-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  flex-wrap: wrap;
}
.maint-title {
  font-size: 14px; font-weight: 500; margin: 0;
  display: flex; align-items: center; gap: 10px;
  min-width: 0;
  color: var(--heading);
}
.maint-time {
  font-size: 12px; color: var(--ink-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ---------- Footer ---------- */
.footer { padding: 32px 0; }

/* ---------- Tooltip ---------- */
.tooltip {
  position: fixed;
  z-index: 150;
  background: var(--ink);
  color: var(--bg);
  font-size: 12px;
  line-height: 1.4;
  padding: 8px 10px;
  border-radius: 6px;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: var(--shadow-pop);
  transform: translate(-50%, calc(-100% - 8px));
  transition: left 0.1s ease;
}
.tooltip strong { font-weight: 600; }
.tooltip .tt-sub {
  color: color-mix(in oklab, var(--bg) 70%, transparent);
  font-size: 11px;
  margin-top: 2px;
}

#status-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
}
#status-sheet-layer,
#status-sheet-layer .sheet-backdrop {
  pointer-events: auto;
}
#status-toast-layer,
#status-tip-layer {
  pointer-events: none;
}
#status-toast-layer {
  position: fixed;
  inset: 0;
  z-index: 210;
}
#status-tip-layer {
  position: fixed;
  inset: 0;
  z-index: 150;
}
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 17, 13, 0.4);
  display: grid;
  place-items: center;
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
.sheet {
  width: min(440px, calc(100% - 32px));
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-pop);
  animation: rise .25s cubic-bezier(.2,.8,.2,1);
}
@keyframes rise { from { transform: translateY(8px); opacity: 0 } to { transform: none; opacity: 1 } }
.sheet h3 { margin: 0 0 6px; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; color: var(--heading); }
.sheet p { margin: 0 0 18px; color: var(--ink-soft); font-size: 13.5px; line-height: 1.5; }
.field {
  display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px;
}
.field label { font-size: 12px; color: var(--ink-soft); }
.field input {
  font-family: inherit; font-size: 14px;
  padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--line-strong); background: var(--bg);
  color: var(--ink);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field input:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--ink) 10%, transparent);
}
.channels { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.channel {
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  font-size: 13px;
  display: flex; align-items: center; gap: 8px;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.channel[data-active="true"] {
  border-color: var(--ink); background: var(--bg-elev);
}
.sheet-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px;
  transform: translateX(-50%);
  background: var(--ink); color: var(--bg);
  font-size: 13px;
  padding: 10px 14px; border-radius: 999px;
  box-shadow: var(--shadow-pop);
}
.toast.toast-show {
  animation: toastIn .2s ease forwards;
}
@keyframes toastIn { from { transform: translate(-50%, 8px); opacity: 0 } to { transform: translate(-50%, 0); opacity: 1 } }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .container { padding: 0 16px; }
  .topbar-inner {
    height: 56px;
    gap: 8px;
    flex-wrap: nowrap;
  }
  .brand-name {
    flex: 0 1 auto;
    min-width: 0;
    font-size: 20px;
  }
  .topbar-actions {
    flex: 0 0 auto;
    display: flex;
    gap: 6px;
    min-width: 0;
  }
  .topbar-actions .btn {
    width: auto;
    min-width: 0;
    padding: 0 10px;
    font-size: 11px;
    min-height: 32px;
    height: 32px;
  }
  .hero { padding: 10px 0 12px; }
  .status-card {
    padding: 10px 12px;
    gap: 10px;
  }
  .status-icon {
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
  }
  .status-text {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
  }
  .topnav .hide-sm { display: none; }
  .svc-bars-line {
    flex-wrap: wrap;
    row-gap: 8px;
  }
  .svc-bars-line .pill {
    margin-left: auto;
    align-self: center;
  }
  .section { padding: 24px 0; }
  .section-head {
    flex-direction: column;
    align-items: stretch;
    flex-wrap: nowrap;
    gap: 10px;
    margin-bottom: 14px;
  }
  .section-aside {
    width: 100%;
    justify-content: space-between;
    gap: 6px;
    font-size: 10.5px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .section-aside::-webkit-scrollbar { display: none; }
  .section-aside .legend { gap: 4px; }
}
