/* ============================================================
   PSI Status — Clean Redesign
   Refined utilitarian. No decoration without function.
   ============================================================ */

/* ---- Themes ---- */
:root,
[data-theme="light"] {
  --bg: #f7f5f0;
  --bg-card: #ffffff;
  --bg-hover: #faf9f6;
  --text: #1a1a19;
  --text-2: #5c5c58;
  --text-3: #767670;
  --border: #e2ded6;
  --border-light: #edeae4;

  --operational: #4a9b1e;
  --degraded: #e5a816;
  --partial: #d04a1a;
  --major: #c23030;
  --maintenance: #3a7fbf;
  --unknown: #9e9e96;

  --op-bg: #eef5e4;
  --op-text: #3a6b12;
  --dg-bg: #fdf5e6;
  --dg-text: #7a5c10;
  --pt-bg: #fceee6;
  --pt-text: #8b3d17;
  --mj-bg: #fbeaea;
  --mj-text: #8b2525;
  --mt-bg: #e8f0fa;
  --mt-text: #1e5a8c;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] {
  --bg: #0e1015;
  --bg-card: #171a22;
  --bg-hover: #1c1f28;
  --text: #e8e6e1;
  --text-2: #a8a6a0;
  --text-3: #8a8880;
  --border: #282b34;
  --border-light: #1f222a;

  --op-bg: rgba(74, 155, 30, 0.12);
  --op-text: #8cd44a;
  --dg-bg: rgba(229, 168, 22, 0.12);
  --dg-text: #f5c23a;
  --pt-bg: rgba(208, 74, 26, 0.12);
  --pt-text: #f07050;
  --mj-bg: rgba(194, 48, 48, 0.12);
  --mj-text: #f06b6b;
  --mt-bg: rgba(58, 127, 191, 0.12);
  --mt-text: #6ba8d9;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
}

:root {
  --sans: "DM Sans", -apple-system, BlinkMacSystemFont, sans-serif;
  --serif: "Instrument Serif", Georgia, serif;
  --mono: "JetBrains Mono", "SF Mono", monospace;
  --max-w: 940px;
  --r: 10px;
  --r-sm: 6px;
}

/* ---- Reset ---- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
html {
  scroll-behavior: smooth;
}
.hidden {
  display: none !important;
}

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition:
    background 0.25s ease,
    color 0.25s ease;
}

/* ---- Animations ---- */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ============================================================
   TOP BAR — status color strip
   ============================================================ */
.top-bar {
  width: 100%;
  transition: background 0.3s ease;
}
.top-bar-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 10px 28px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 500;
}
.top-bar-icon {
  display: flex;
  align-items: center;
}
.top-bar--operational {
  background: var(--op-bg);
  color: var(--op-text);
}
.top-bar--degraded {
  background: var(--dg-bg);
  color: var(--dg-text);
}
.top-bar--partial {
  background: var(--pt-bg);
  color: var(--pt-text);
}
.top-bar--major {
  background: var(--mj-bg);
  color: var(--mj-text);
}
.top-bar--maintenance {
  background: var(--mt-bg);
  color: var(--mt-text);
}
.top-bar--unknown {
  background: var(--border-light);
  color: var(--text-3);
}

/* ============================================================
   PAGE
   ============================================================ */
.page {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 28px 64px;
}

/* ============================================================
   HEADER
   ============================================================ */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 0 20px;
  animation: fadeUp 0.5s ease-out both;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}
.logo-mark {
  font-family: var(--serif);
  font-size: 28px;
  line-height: 1;
}
.logo-text {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.header-meta {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-3);
}
.meta-dot {
  margin: 0 4px;
  opacity: 0.4;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Live dot */
.live-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-right: 4px;
}
.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--operational);
  animation: pulse 2.5s ease-in-out infinite;
}
@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(74, 155, 30, 0.4);
  }
  50% {
    box-shadow: 0 0 0 5px rgba(74, 155, 30, 0);
  }
}
.live-label {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Buttons */
.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s;
}
.btn-icon:hover {
  color: var(--text);
  border-color: var(--text-3);
}
[data-theme="light"] .icon-moon {
  display: none;
}
[data-theme="dark"] .icon-sun {
  display: none;
}

.btn-secondary {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--sans);
  color: var(--text-2);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all 0.15s;
}
.btn-secondary:hover {
  color: var(--text);
  border-color: var(--text-3);
}

.btn-text {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-3);
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 3px 10px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-text:hover {
  color: var(--text);
  border-color: var(--text-3);
}

/* ============================================================
   SUMMARY
   ============================================================ */
.summary {
  padding: 20px 0 16px;
  animation: fadeUp 0.5s ease-out 0.05s both;
}
.summary-text {
  font-size: 15px;
  line-height: 1.65;
  color: var(--text-2);
  margin-bottom: 14px;
}
.summary-text strong {
  color: var(--text);
  font-weight: 600;
}

/* Pills */
.pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  transition: transform 0.12s;
}
.pill:hover {
  transform: translateY(-1px);
}
.pill-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.pill--operational {
  background: var(--op-bg);
  color: var(--op-text);
}
.pill--operational .pill-dot {
  background: var(--operational);
}
.pill--degraded {
  background: var(--dg-bg);
  color: var(--dg-text);
}
.pill--degraded .pill-dot {
  background: var(--degraded);
}
.pill--partial {
  background: var(--pt-bg);
  color: var(--pt-text);
}
.pill--partial .pill-dot {
  background: var(--partial);
}
.pill--major {
  background: var(--mj-bg);
  color: var(--mj-text);
}
.pill--major .pill-dot {
  background: var(--major);
}
.pill--maintenance {
  background: var(--mt-bg);
  color: var(--mt-text);
}
.pill--maintenance .pill-dot {
  background: var(--maintenance);
}
.pill--unknown {
  background: var(--border-light);
  color: var(--text-3);
}
.pill--unknown .pill-dot {
  background: var(--text-3);
}

/* ============================================================
   ACTIVE INCIDENTS
   ============================================================ */
.active-incidents {
  margin-bottom: 20px;
}
.active-incident {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--major);
  border-radius: var(--r);
  padding: 16px 18px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
}
.active-incident-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.active-incident-title {
  font-size: 14px;
  font-weight: 600;
}
.active-incident-severity {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.sev--minor {
  background: var(--dg-bg);
  color: var(--dg-text);
}
.sev--major {
  background: var(--pt-bg);
  color: var(--pt-text);
}
.sev--critical {
  background: var(--mj-bg);
  color: var(--mj-text);
}
.sev--maintenance {
  background: var(--mt-bg);
  color: var(--mt-text);
}

/* ============================================================
   SECTIONS
   ============================================================ */
.section {
  margin-bottom: 28px;
  animation: fadeUp 0.4s ease-out both;
}
.section:nth-child(4) {
  animation-delay: 0.1s;
}
.section:nth-child(5) {
  animation-delay: 0.15s;
}
.section:nth-child(6) {
  animation-delay: 0.2s;
}
.section:nth-child(7) {
  animation-delay: 0.25s;
}
.section-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  margin-bottom: 10px;
}
.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.section-title-row .section-title {
  margin-bottom: 0;
}

/* ============================================================
   TABLE
   ============================================================ */
.table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table thead th {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.table tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: background 0.1s;
}
.table tbody tr:last-child {
  border-bottom: none;
}
.table tbody tr:hover {
  background: var(--bg-hover);
}
.table tbody td {
  padding: 12px 14px;
  vertical-align: middle;
}
.col-svc {
  width: 30%;
}
.col-st {
  width: 22%;
}
.col-up {
  width: 14%;
  text-align: right;
}
.col-spark {
  width: 18%;
}
.col-lat {
  width: 16%;
  text-align: right;
}

.td-service {
  font-weight: 500;
}
.td-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.td-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot--operational {
  background: var(--operational);
}
.dot--degraded {
  background: var(--degraded);
}
.dot--partial {
  background: var(--partial);
}
.dot--major {
  background: var(--major);
}
.dot--maintenance {
  background: var(--maintenance);
}
.dot--unknown {
  background: var(--text-3);
}
.td-status-text {
  font-size: 12px;
  color: var(--text-2);
}
.td-uptime {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
}
.td-latency {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-3);
}

/* Sparkline */
.sparkline-cell {
  padding: 0 6px;
}
.sparkline-svg {
  display: block;
  width: 100%;
  height: 24px;
}
.sparkline-line {
  fill: none;
  stroke: var(--text-3);
  stroke-width: 1.5;
}
.sparkline-area {
  fill: rgba(74, 155, 30, 0.06);
}
[data-theme="dark"] .sparkline-area {
  fill: rgba(74, 155, 30, 0.1);
}

/* ============================================================
   HEATMAP
   ============================================================ */
.heatmap-container {
  display: flex;
  gap: 0;
  overflow-x: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 8px;
}
.heatmap-labels {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-right: 12px;
  flex-shrink: 0;
}
.heatmap-label {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-3);
  height: 20px;
  line-height: 20px;
  text-align: right;
  white-space: nowrap;
}
.heatmap-grid-wrapper {
  flex: 1;
  min-width: 0;
}
.heatmap-grid {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.heatmap-row {
  display: flex;
  gap: 1.5px;
  height: 20px;
}
.heatmap-cell {
  flex: 1;
  min-width: 5px;
  border-radius: 2px;
  cursor: pointer;
  position: relative;
  transition:
    transform 0.1s ease,
    box-shadow 0.1s ease;
}
.heatmap-cell:hover {
  transform: scale(1.6);
  z-index: 10;
}
.heatmap-cell.highlighted {
  box-shadow: 0 0 0 2px var(--degraded);
  transform: scale(2);
  z-index: 11;
}
.hc--operational {
  background: var(--operational);
}
.hc--degraded {
  background: var(--degraded);
}
.hc--partial {
  background: var(--partial);
}
.hc--major {
  background: var(--major);
}
.hc--maintenance {
  background: var(--maintenance);
}
.hc--nodata {
  background: var(--border-light);
}
.hc--unknown {
  background: var(--unknown);
}
.heatmap-axis {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text-3);
  margin-top: 6px;
}
.heatmap-week-sep {
  width: 3px;
  flex-shrink: 0;
}

.heatmap-legend {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-3);
}
.swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
  margin-left: 10px;
}
.swatch:first-child {
  margin-left: 0;
}
.swatch--operational {
  background: var(--operational);
}
.swatch--degraded {
  background: var(--degraded);
}
.swatch--partial {
  background: var(--partial);
}
.swatch--major {
  background: var(--major);
}
.swatch--maintenance {
  background: var(--maintenance);
}
.swatch--nodata {
  background: var(--border-light);
}

/* Tooltip */
.heatmap-tooltip {
  position: fixed;
  display: none;
  background: var(--text);
  color: var(--bg);
  font-family: var(--mono);
  font-size: 11px;
  padding: 5px 10px;
  border-radius: var(--r-sm);
  pointer-events: none;
  z-index: 150;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
}
.heatmap-tooltip.visible {
  display: block;
}

/* ============================================================
   INCIDENTS
   ============================================================ */
.incident-day {
  margin-bottom: 20px;
}
.incident-day.empty-day {
  display: none;
}
.incident-day.empty-day.show-empty {
  display: block;
}
.incident-day-header {
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-light);
}
.incident-date {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.incident-day.highlight-day {
  background: var(--dg-bg);
  border-radius: var(--r);
  padding: 12px;
  margin: -12px;
  margin-bottom: 8px;
}
.incident-none {
  font-size: 13px;
  color: var(--text-3);
}
.incident-entry {
  margin-bottom: 14px;
  padding-left: 14px;
  border-left: 2px solid var(--border);
  transition: border-color 0.15s;
}
.incident-entry:hover {
  border-left-color: var(--text-3);
}
.incident-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
}
.incident-update {
  display: flex;
  gap: 0;
  margin-bottom: 5px;
  font-size: 13px;
  line-height: 1.5;
}
.incident-status-tag {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  white-space: nowrap;
  min-width: 90px;
  padding-top: 3px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.tag--investigating {
  color: var(--degraded);
}
.tag--identified {
  color: var(--partial);
}
.tag--monitoring {
  color: var(--maintenance);
}
.tag--update {
  color: var(--text-3);
}
.tag--resolved {
  color: var(--operational);
}
.incident-msg {
  color: var(--text-2);
}
.incident-ts {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-3);
  margin-top: 2px;
}

/* ============================================================
   FOOTER
   ============================================================ */
.footer {
  padding: 20px 0;
  margin-top: 12px;
  border-top: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-3);
  display: flex;
  align-items: center;
  animation: fadeIn 0.4s ease-out 0.3s both;
}
.footer-dot {
  margin: 0 6px;
  opacity: 0.4;
}
.footer-link {
  color: var(--text-3);
  text-decoration: none;
  transition: color 0.12s;
}
.footer-link:hover {
  color: var(--text);
}

/* ============================================================
   MODAL
   ============================================================ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(3px);
}
[data-theme="dark"] .modal-backdrop {
  background: rgba(0, 0, 0, 0.5);
}
.modal-box {
  position: relative;
  background: var(--bg-card);
  border-radius: var(--r);
  padding: 24px;
  max-width: 380px;
  width: 90%;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.15),
    0 0 0 1px var(--border);
  animation: fadeUp 0.2s ease-out;
}
.modal-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.modal-top h3 {
  font-size: 16px;
  font-weight: 600;
}
.modal-box p {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.6;
  margin-bottom: 12px;
}
/* Subscribe form */
.subscribe-form {
  margin-top: 4px;
}
.subscribe-input-row {
  display: flex;
  gap: 8px;
}
.subscribe-input {
  flex: 1;
  padding: 9px 12px;
  font-family: var(--sans);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  outline: none;
  transition: border-color 0.15s;
}
.subscribe-input:focus {
  border-color: var(--text-3);
}
.subscribe-input::placeholder {
  color: var(--text-3);
}
.subscribe-btn {
  padding: 9px 18px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: var(--text);
  border: none;
  border-radius: var(--r-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s;
}
.subscribe-btn:hover {
  opacity: 0.85;
}
.subscribe-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.subscribe-feedback {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.4;
  min-height: 18px;
}
.subscribe-feedback.success {
  color: var(--operational);
}
.subscribe-feedback.error {
  color: var(--major);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 640px) {
  .page {
    padding: 0 16px 48px;
  }
  .header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .header-meta {
    display: none;
  }
  .col-spark,
  .sparkline-cell {
    display: none;
  }
  .live-label {
    display: none;
  }
  .top-bar-inner {
    padding: 8px 16px;
    font-size: 13px;
  }
  .heatmap-container {
    padding: 12px;
  }
}
