:root {
  --bg: #0b0e0d;
  --line: #26302c;
  --muted: #7f8c86;
  --text: #edf3f0;
  --accent: #a8ffcb;
  --danger: #ff8f83;
  --font: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); color: var(--text); font-family: var(--font); }
body { margin: 0; min-height: 100vh; }
button { font: inherit; }

.topbar {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  height: 56px;
  justify-content: space-between;
  padding: 0 2.5vw;
}
.brand {
  align-items: center; color: var(--text); display: flex; font-size: 12px;
  font-weight: 750; letter-spacing: .16em; text-decoration: none;
}
.brand-mark {
  background: var(--accent); border-radius: 50%;
  box-shadow: 0 0 14px rgba(168, 255, 203, .3);
  height: 7px; margin-right: 10px; width: 7px;
}
.status { align-items: center; color: var(--muted); display: flex; font-size: 11px; gap: 8px; }
.status-dot { background: var(--accent); border-radius: 50%; height: 5px; width: 5px; }
.status.error .status-dot { background: var(--danger); }

main { padding: 0 2.5vw 32px; }
.controlbar {
  align-items: center; border-bottom: 1px solid var(--line);
  display: flex; height: 58px; justify-content: space-between;
}
.controlbar > div { align-items: baseline; display: flex; gap: 14px; white-space: nowrap; }
.controlbar strong { font-size: 14px; font-weight: 600; }
.controlbar time { color: var(--muted); font-size: 10px; }
.filters { display: flex; gap: 22px; height: 100%; overflow-x: auto; }
.filters button {
  background: none; border: 0; color: var(--muted); cursor: pointer;
  font-size: 11px; padding: 0; position: relative; white-space: nowrap;
}
.filters button.active { color: var(--text); }
.filters button.active::after {
  background: var(--accent); bottom: -1px; content: ""; height: 2px;
  left: 0; position: absolute; right: 0;
}

.group { border-bottom: 1px solid var(--line); padding: 18px 0 20px; }
.calendar-panel {
  border-bottom: 1px solid var(--line); display: flex; flex-direction: column;
  min-height: 0; padding: 12px 16px 8px;
}
.calendar-heading {
  align-items: start; display: flex; flex: none; justify-content: space-between;
  margin-bottom: 10px;
}
.calendar-heading span {
  color: var(--accent); font-size: 9px; letter-spacing: .14em;
}
.calendar-heading h2 { font-size: 15px; font-weight: 560; margin: 4px 0 0; }
.calendar-heading small { color: var(--muted); font-size: 9px; font-weight: 400; }
.event-list {
  border-top: 1px solid var(--line); min-height: 0; overflow-y: auto;
  overscroll-behavior: contain; scrollbar-color: var(--line) transparent;
  scrollbar-width: thin;
}
.event-row {
  align-items: center; border-bottom: 1px solid var(--line);
  display: grid; gap: 10px; grid-template-columns: 118px minmax(130px, 1fr);
  min-height: 70px; padding: 8px 0;
}
.event-row > time {
  color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums;
}
.event-main { min-width: 0; }
.event-main a {
  color: var(--text); display: block; font-size: 12px; overflow: hidden;
  text-decoration: none; text-overflow: ellipsis; white-space: nowrap;
}
.event-main a:hover { color: var(--accent); }
.event-main > span { color: var(--muted); display: block; font-size: 9px; margin-top: 4px; }
.event-values {
  display: grid; grid-column: 1 / -1; grid-template-columns: repeat(4, 1fr);
  padding-left: 128px;
}
.event-values span { display: flex; flex-direction: column; gap: 3px; }
.event-values i { color: var(--muted); font-size: 8px; font-style: normal; }
.event-values strong { font-size: 11px; font-weight: 540; }
.group.compact-all { padding-top: 10px; }
.group-title {
  color: var(--muted); font-size: 10px; letter-spacing: .13em;
  margin: 0 0 10px; text-transform: uppercase;
}
.metrics {
  display: grid; grid-auto-rows: 156px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.metric {
  border-bottom: 1px solid var(--line); border-left: 1px solid var(--line);
  min-height: 0; overflow: hidden;
  padding: 12px 16px 8px; transition: background-color .18s ease;
}
.metric:first-child { border-left: 0; padding-left: 0; }
.metric:nth-child(4n + 1) { border-left: 0; }
.metric:hover { background: rgba(168, 255, 203, .025); }
.metric-head { align-items: start; display: flex; gap: 8px; justify-content: space-between; }
.metric-name {
  display: -webkit-box; font-size: 12px; font-weight: 520; line-height: 1.35;
  margin: 0; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
}
.metric-subtitle {
  color: var(--muted); font-size: 9px; margin: 4px 0 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.metric-time { color: var(--muted); flex: none; font-size: 9px; }
.metric-value {
  font-size: clamp(27px, 2.4vw, 40px); font-variant-numeric: tabular-nums;
  letter-spacing: -.045em; margin: 18px 0 4px;
}
.metric-value small { color: var(--muted); font-size: .36em; letter-spacing: 0; margin-left: 5px; }
.chart { height: 52px; margin-top: 8px; position: relative; width: 100%; }
.chart svg { height: 100%; overflow: visible; width: 100%; }
.chart path.line, .chart path.series-line {
  fill: none; stroke-linecap: round; stroke-linejoin: round;
  stroke-width: 1.5; vector-effect: non-scaling-stroke;
}
.chart path.line { stroke: var(--accent); }
.chart path.area { opacity: .18; }
.chart .baseline { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-empty {
  align-items: center; border-top: 1px dashed var(--line); color: var(--muted);
  display: flex; font-size: 9px; height: 100%;
}
.tooltip {
  background: var(--text); color: var(--bg); display: none; font-size: 9px;
  padding: 5px 7px; pointer-events: none; position: absolute;
  transform: translate(-50%, -115%); white-space: nowrap; z-index: 2;
}
.chart:hover .tooltip { display: block; }

.dashboard-tile { grid-column: span 2; grid-row: span 2; }
.metric-multi {
  display: flex; flex-direction: column; min-height: 0;
}
.series-legend {
  display: grid; gap: 5px 14px; grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 12px; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  scrollbar-color: var(--line) transparent; scrollbar-width: thin;
}
.series-item { align-items: center; display: grid; font-size: 9px; gap: 6px; grid-template-columns: 5px 1fr auto; min-width: 0; }
.series-item i { border-radius: 50%; height: 5px; width: 5px; }
.series-item span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.series-item strong { font-size: 10px; font-variant-numeric: tabular-nums; font-weight: 550; }
.multi-chart { flex: none; height: 82px; margin-top: 12px; }

.loading { color: var(--muted); padding: 80px 0; text-align: center; }
.loading span {
  animation: pulse 1s infinite alternate; background: var(--accent);
  display: inline-block; height: 5px; margin: 0 4px; width: 5px;
}
.loading span:nth-child(2) { animation-delay: .2s; }
.loading span:nth-child(3) { animation-delay: .4s; }
.error-panel { color: var(--danger); padding: 60px 0; }
footer {
  align-items: center; border-top: 1px solid var(--line); color: var(--muted);
  display: flex; font-size: 10px; justify-content: space-between; padding: 18px 2.5vw;
}
footer button { background: none; border: 0; color: var(--accent); cursor: pointer; }

@keyframes pulse { to { opacity: .18; transform: translateY(-5px); } }
@keyframes enter { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
.group { animation: enter .3s both; }

@media (max-width: 1100px) {
  .metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .metric:nth-child(4n + 1) { border-left: 1px solid var(--line); }
  .metric:nth-child(3n + 1) { border-left: 0; }
}

@media (max-width: 760px) {
  .topbar { height: 52px; padding: 0 16px; }
  main { padding: 0 16px 24px; }
  .controlbar { align-items: stretch; display: block; height: auto; padding-top: 13px; }
  .controlbar > div { justify-content: space-between; width: 100%; }
  .filters { gap: 24px; height: 42px; margin-top: 4px; width: 100%; }
  .filters button { min-height: 42px; }
  .metrics { grid-auto-rows: auto; grid-template-columns: 1fr; }
  .metric, .metric:first-child, .metric:nth-child(3n + 1), .metric:nth-child(4n + 1) {
    border-left: 0; border-top: 1px solid var(--line);
    min-height: 166px; padding: 14px 0 8px;
  }
  .metric:first-child { border-top: 0; }
  .dashboard-tile { grid-column: span 1; grid-row: auto; }
  .metric-multi { min-height: 240px; }
  .series-legend { grid-template-columns: 1fr; max-height: 112px; overflow-y: auto; }
  .metric-value { font-size: 34px; }
  .calendar-panel { height: 320px; padding: 14px 0 8px; }
  .calendar-heading { align-items: start; display: block; }
  .calendar-heading small { display: block; margin-top: 7px; }
  .event-row {
    gap: 7px; grid-template-columns: 1fr; padding: 13px 0;
  }
  .event-values { margin-top: 4px; padding-left: 0; }
  .chart { height: 68px; }
  .multi-chart { height: 88px; }
  footer { padding: 18px 16px; }
}

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