:root {
  --black: #0A0A0A;
  --yellow: #EAF044;
  --grey-light: #D7D7D7;
  --grey-mid: #9C9C9C;
  --grey-dark: #4F4F4F;
  --white: #F6F6F6;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  background: var(--black);
  color: var(--grey-light);
  font-family: 'Chakra Petch', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}
a { color: var(--yellow); text-decoration: none; }
a:hover { color: var(--white); }
code, pre { font-family: 'Space Mono', monospace; font-size: 12.5px; }

.layout { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: #050505;
  border-right: 1px solid var(--grey-dark);
  padding: 32px 20px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar .brand {
  font-family: 'Chakra Petch', sans-serif;
  font-weight: 700;
  color: var(--white);
  font-size: 18px;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
  border-left: 3px solid var(--yellow);
  padding-left: 10px;
}
.sidebar .brand-sub {
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--grey-mid);
  text-transform: uppercase;
  padding-left: 13px;
  margin-bottom: 32px;
}
.sidebar nav { display: flex; flex-direction: column; gap: 4px; margin-bottom: 32px; }
.sidebar nav a {
  color: var(--grey-light);
  padding: 8px 12px;
  border-radius: 2px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar nav a.active, .sidebar nav a:hover { background: rgba(234,240,68,0.08); color: var(--white); }
.sidebar .nav-icon { font-family: 'Space Mono', monospace; color: var(--yellow); font-size: 11px; }
/* Settings link goes red whenever any token health-check is failing.
   We override the yellow nav-icon to match so the whole row reads as
   warning, not "active item with a tiny red dot tacked on." */
.sidebar nav a.nav-warning,
.sidebar nav a.nav-warning .nav-icon {
  color: #E26A6A;
}
.sidebar nav a.nav-warning:hover {
  background: rgba(226,106,106,0.10);
  color: #F4A6A6;
}
.sidebar nav a.nav-warning .nav-icon {
  /* nav-icon is normally yellow; keep it red here too. */
  color: #E26A6A;
}
.sidebar .nav-warn-badge {
  display: inline-block;
  margin-left: auto;
  background: #E26A6A;
  color: var(--black);
  font-family: 'Space Mono', monospace;
  font-weight: 700;
  font-size: 10px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  text-align: center;
  line-height: 16px;
  animation: nav-warn-pulse 1.6s ease-in-out infinite;
}
@keyframes nav-warn-pulse {
  0%, 100% { opacity: 0.7; box-shadow: 0 0 0 0 rgba(226,106,106,0.0); }
  50%      { opacity: 1; box-shadow: 0 0 0 4px rgba(226,106,106,0.18); }
}

.sidebar .weeks {
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--grey-mid);
  text-transform: uppercase;
  margin-bottom: 8px;
}
.sidebar .week-list { display: flex; flex-direction: column; gap: 2px; }
.sidebar .week-row {
  position: relative;
  display: flex;
  align-items: stretch;
  border-left: 2px solid transparent;
}
.sidebar .week-row .week-link {
  flex: 1 1 auto;
  min-width: 0;
  font-family: 'Space Mono', monospace;
  font-size: 11.5px;
  color: var(--grey-light);
  padding: 6px 28px 6px 12px;     /* right padding leaves room for × */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar .week-row:hover { border-left-color: var(--grey-dark); }
.sidebar .week-row:hover .week-link { color: var(--white); }
.sidebar .week-row.active { border-left-color: var(--yellow); background: rgba(234,240,68,0.06); }
.sidebar .week-row.active .week-link { color: var(--yellow); }
.sidebar .week-row .week-del {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent !important;
  border: 0 !important;
  color: var(--grey-mid);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  opacity: 0;
  transition: opacity 100ms, color 100ms;
}
.sidebar .week-row:hover .week-del,
.sidebar .week-row:focus-within .week-del { opacity: 1; }
.sidebar .week-row .week-del:hover { color: #E26A6A; }

.sidebar .week-add { margin-top: 10px; }
.sidebar .week-add button#week-add-btn {
  background: transparent;
  border: 1px dashed var(--grey-dark);
  color: var(--grey-mid);
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.1em;
  padding: 6px 12px;
  cursor: pointer;
  width: 100%;
  text-align: left;
}
.sidebar .week-add button#week-add-btn:hover { color: var(--white); border-color: var(--grey-mid); }
/* `:not([hidden])` — our author-side display rule has higher specificity
   than the user-agent `[hidden] { display: none }`, so we must scope it
   ourselves. Otherwise the form renders even when JS sets `hidden=true`. */
.sidebar .week-add form:not([hidden]) { display: flex; flex-direction: column; gap: 6px; padding: 6px 0; }
.sidebar .week-add form select {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--grey-dark);
  color: var(--white);
  font-family: 'Space Mono', monospace;
  font-size: 11.5px;
  padding: 5px 8px;
  width: 100%;
  color-scheme: dark;
}
.sidebar .week-add .week-add-actions { display: flex; gap: 6px; }
.sidebar .week-add .week-add-actions button {
  flex: 1;
  background: rgba(234,240,68,0.08);
  border: 1px solid var(--yellow);
  color: var(--yellow);
  font-family: 'Space Mono', monospace;
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 5px 10px;
  cursor: pointer;
}
.sidebar .week-add .week-add-actions button:disabled { opacity: 0.5; cursor: not-allowed; }
.sidebar .week-add .week-add-actions button#week-add-cancel {
  background: transparent;
  border-color: var(--grey-dark);
  color: var(--grey-mid);
}
.sidebar .week-add #week-add-status {
  font-family: 'Space Mono', monospace;
  font-size: 10.5px;
  color: var(--grey-mid);
  padding: 4px 0;
  line-height: 1.4;
}

.main { padding: 48px 56px 80px; max-width: 1400px; min-width: 0; box-sizing: border-box; overflow: hidden; }

.table-wrap { overflow-x: auto; margin-bottom: 24px; max-width: 100%; }
.table-wrap table { margin-bottom: 0; min-width: 720px; }

/* Chart.js canvases need explicit containers + max-width or they push out of grid tracks. */
.main canvas { max-width: 100% !important; }
.chart-box { position: relative; width: 100%; height: 280px; margin-bottom: 24px; }
.chart-box.tall { height: 360px; }
.chart-box canvas { max-width: 100% !important; max-height: 100% !important; }

.kicker {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--yellow);
  text-transform: uppercase;
  margin-bottom: 16px;
}
h1 {
  font-family: 'Chakra Petch', sans-serif;
  font-weight: 700;
  font-size: 40px;
  line-height: 1.05;
  color: var(--white);
  letter-spacing: -0.01em;
  margin-bottom: 8px;
}
h2 {
  font-family: 'Chakra Petch', sans-serif;
  font-weight: 600;
  font-size: 20px;
  color: var(--white);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin: 48px 0 18px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--grey-dark);
}
h3 {
  font-family: 'Chakra Petch', sans-serif;
  font-weight: 600;
  font-size: 15px;
  color: var(--white);
  margin-bottom: 12px;
}

.meta {
  font-family: 'Space Mono', monospace;
  font-size: 12px;
  color: var(--grey-mid);
  margin-bottom: 32px;
}

.methodology {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--grey-dark);
  padding: 20px 24px;
  font-size: 13px;
  color: var(--grey-light);
  margin-bottom: 32px;
}
.methodology p { margin-bottom: 8px; }
.methodology p:last-child { margin-bottom: 0; }
.methodology strong { color: var(--white); }

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 32px;
}
.stat {
  border: 1px solid var(--grey-dark);
  padding: 18px 20px;
  background: rgba(255,255,255,0.015);
}
.stat .label {
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--grey-mid);
  text-transform: uppercase;
  margin-bottom: 8px;
}
.stat .value {
  font-family: 'Space Mono', monospace;
  font-weight: 700;
  font-size: 34px;
  color: var(--yellow);
  line-height: 1;
}
.stat .sub {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  color: var(--grey-mid);
  margin-top: 8px;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-bottom: 24px;
  font-size: 12.5px;
}
thead th {
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--grey-mid);
  text-transform: uppercase;
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--grey-dark);
  background: rgba(0,0,0,0.4);
  vertical-align: bottom;
  font-weight: 400;
}
thead th[data-sort] { cursor: pointer; transition: color 120ms; }
thead th[data-sort]:hover { color: var(--white); }
thead th[data-sort]::after {
  content: ' ↕';
  color: var(--grey-dark);
  font-size: 10px;
  letter-spacing: 0;
  margin-left: 2px;
}
thead th[data-sort][data-dir="asc"],
thead th[data-sort][data-dir="desc"] { color: var(--yellow); }
thead th[data-sort][data-dir="asc"]::after { content: ' ↑'; color: var(--yellow); }
thead th[data-sort][data-dir="desc"]::after { content: ' ↓'; color: var(--yellow); }
tbody tr { background: rgba(255,255,255,0.015); }
tbody tr:nth-child(even) { background: rgba(255,255,255,0.03); }
tbody td {
  padding: 14px 10px;
  border-bottom: 1px solid var(--grey-dark);
  vertical-align: top;
  color: var(--grey-light);
}
tbody td:first-child { padding-left: 16px; }

tbody tr.flag-customer td:first-child { border-left: 3px solid #3FA9F5; }
tbody tr.flag-open td:first-child { border-left: 3px solid var(--yellow); }
tbody tr.flag-uncertain td:first-child { border-left: 3px solid #F58A3F; }

@keyframes rowFlash {
  0% { background: rgba(234,240,68,0.22); box-shadow: inset 4px 0 0 var(--yellow); }
  60% { background: rgba(234,240,68,0.12); box-shadow: inset 4px 0 0 var(--yellow); }
  100% { background: rgba(255,255,255,0.015); box-shadow: none; }
}
tr.row-flash { animation: rowFlash 3s ease-out; }

@keyframes cellFlash {
  0% { background: rgba(234,240,68,0.25); }
  100% { background: transparent; }
}
td.cell-flash { animation: cellFlash 3s ease-out; }

/* Trends page "data changed" banner. */
#refresh-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--yellow);
  color: var(--black);
  padding: 12px 20px;
  font-family: 'Space Mono', monospace;
  font-size: 11.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-align: center;
  font-weight: 700;
  z-index: 100;
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(0,0,0,0.4);
  animation: bannerSlide 240ms ease-out;
}
#refresh-banner:hover { background: var(--white); }
#refresh-banner .banner-count {
  display: inline-block;
  background: var(--black);
  color: var(--yellow);
  padding: 2px 10px;
  margin-right: 8px;
  border-radius: 2px;
}
@keyframes bannerSlide {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}

/* Dramatic S1 reset animation: pulse red → snap to yellow zero. */
@keyframes s1Reset {
  0%   { color: #B83232; text-shadow: 0 0 70px rgba(184,50,50,0.7); transform: scale(1.18); }
  35%  { color: #B83232; text-shadow: 0 0 50px rgba(184,50,50,0.45); transform: scale(1.06); }
  100% { color: var(--yellow); text-shadow: 0 0 40px rgba(234,240,68,0.18); transform: scale(1); }
}
.s1-hero-number.s1-hero-resetting { animation: s1Reset 2.2s ease-out; }

/* Recovery: green pulse when an S1 is downgraded and the streak walks back. */
@keyframes s1Recover {
  0%   { color: var(--yellow); transform: scale(1); }
  30%  { color: #5DAF4A; transform: scale(1.12); text-shadow: 0 0 50px rgba(93,175,74,0.5); }
  100% { color: var(--yellow); transform: scale(1); text-shadow: 0 0 40px rgba(234,240,68,0.18); }
}
.s1-hero-number.s1-hero-recovering { animation: s1Recover 2.2s ease-out; }

.incident-id {
  font-family: 'Space Mono', monospace;
  font-weight: 700;
  color: var(--yellow);
  font-size: 13px;
}
.incident-id a { color: var(--yellow); border-bottom: 1px dotted var(--yellow); }
.incident-id a:hover { color: var(--white); border-color: var(--white); }
.incident-title {
  color: var(--white);
  font-weight: 500;
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.35;
}

.badges { display: flex; flex-direction: column; gap: 6px; }
.badge {
  display: inline-block;
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  text-transform: uppercase;
  border-radius: 2px;
}
.sev-S1 { background: #B83232; color: var(--white); }
.sev-S2 { background: #D86A2C; color: var(--black); }
.sev-S3 { background: #D8B82C; color: var(--black); }
.sev-S4 { background: #5DAF4A; color: var(--black); }
.sev-unknown { background: var(--grey-dark); color: var(--grey-light); }
.status-Resolved { background: rgba(93,175,74,0.18); color: #8FD37A; border: 1px solid #5DAF4A; padding: 2px 7px; }
.status-Mitigated { background: rgba(216,184,44,0.18); color: var(--yellow); border: 1px solid var(--yellow); padding: 2px 7px; }
.status-Open { background: rgba(184,50,50,0.18); color: #E07878; border: 1px solid #B83232; padding: 2px 7px; }

.date { font-family: 'Space Mono', monospace; font-size: 11.5px; color: var(--grey-light); }
.date .time { color: var(--grey-mid); display: block; margin-top: 3px; font-size: 10.5px; }

.responders { list-style: none; font-size: 11.5px; color: var(--grey-light); max-width: 180px; word-break: break-word; }
.responders li { padding: 2px 0; line-height: 1.3; }
.responders .more { color: var(--grey-mid); font-style: italic; font-size: 10.5px; }
.responders .more a { color: var(--grey-mid); border-bottom: 1px dotted var(--grey-dark); }
.responders .more a:hover { color: var(--yellow); border-color: var(--yellow); }

.customer { font-family: 'Chakra Petch', sans-serif; font-weight: 600; color: var(--white); font-size: 12.5px; max-width: 200px; word-break: break-word; }
.customer.internal { color: var(--grey-mid); font-weight: 400; font-style: italic; }

.duration { font-family: 'Space Mono', monospace; font-size: 14px; font-weight: 700; color: var(--yellow); }
.duration.small { font-size: 12.5px; color: var(--grey-light); font-weight: 400; }
.est-tag {
  display: block;
  margin-top: 4px;
  font-family: 'Space Mono', monospace;
  font-size: 9px;
  letter-spacing: 0.1em;
  color: #F58A3F;
  font-weight: 700;
}
.na-tag { color: var(--grey-mid); font-weight: 400; font-size: 11px; font-family: 'Space Mono', monospace; }

.notes { font-size: 12px; color: var(--grey-light); line-height: 1.45; min-width: 240px; max-width: 360px; }
.notes em { color: var(--grey-mid); font-style: normal; }
.tag {
  display: inline-block;
  font-family: 'Space Mono', monospace;
  font-size: 9px;
  letter-spacing: 0.1em;
  color: var(--black);
  background: var(--yellow);
  padding: 2px 6px;
  margin-right: 4px;
  text-transform: uppercase;
  font-weight: 700;
}

.legend {
  display: flex;
  gap: 24px;
  margin-top: 16px;
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  color: var(--grey-mid);
  flex-wrap: wrap;
}
.legend .sw { display: inline-block; width: 12px; height: 12px; margin-right: 8px; vertical-align: middle; }
.sw-blue { background: #3FA9F5; }
.sw-yellow { background: var(--yellow); }
.sw-orange { background: #F58A3F; }

footer {
  margin-top: 64px;
  padding-top: 24px;
  border-top: 1px solid var(--grey-dark);
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--grey-mid);
  text-transform: uppercase;
  display: flex;
  justify-content: space-between;
  gap: 16px;
}
.webhook-status::before {
  content: '●';
  margin-right: 6px;
  font-size: 11px;
}
.webhook-status[data-freshness="live"]::before { color: #5DAF4A; }
.webhook-status[data-freshness="stale"]::before { color: #F5C94A; }
.webhook-status[data-freshness="cold"]::before { color: #E07878; }
.webhook-status[data-freshness="never"]::before { color: var(--grey-dark); }
.webhook-status[data-freshness=""]::before { display: none; }

.search-form { display: flex; gap: 8px; margin-bottom: 24px; }
.search-form input {
  flex: 1;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--grey-dark);
  color: var(--white);
  padding: 10px 14px;
  font-family: 'Space Mono', monospace;
  font-size: 13px;
}
.search-form input:focus { outline: none; border-color: var(--yellow); }
.search-form button {
  background: var(--yellow);
  color: var(--black);
  border: 0;
  padding: 0 18px;
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
  cursor: pointer;
}
.search-form button:hover { background: var(--white); }
.search-results .result {
  padding: 14px 16px;
  border: 1px solid var(--grey-dark);
  margin-bottom: 8px;
  background: rgba(255,255,255,0.015);
}
.search-results .result mark { background: var(--yellow); color: var(--black); padding: 0 2px; }
.search-results .result .meta-line {
  font-family: 'Space Mono', monospace;
  font-size: 10.5px;
  color: var(--grey-mid);
  margin-top: 4px;
}

.empty {
  text-align: center;
  padding: 80px 24px;
  color: var(--grey-mid);
  font-family: 'Space Mono', monospace;
  font-size: 13px;
}
.empty h2 { border: 0; margin-bottom: 12px; }

.themes { display: flex; flex-direction: column; gap: 12px; margin-bottom: 32px; }
.theme {
  border: 1px solid var(--grey-dark);
  border-left: 3px solid var(--yellow);
  padding: 16px 20px;
  background: rgba(255,255,255,0.015);
}
.theme h3 { color: var(--white); margin-bottom: 6px; font-size: 14px; }
.theme p { font-size: 12.5px; color: var(--grey-light); }
.theme .incidents-ref { font-family: 'Space Mono', monospace; font-size: 10.5px; color: var(--grey-mid); margin-top: 6px; }

.message-list {
  border: 1px solid var(--grey-dark);
  max-height: 600px;
  overflow-y: auto;
}
.message {
  padding: 10px 14px;
  border-bottom: 1px solid var(--grey-dark);
  font-size: 12.5px;
  line-height: 1.4;
}
.message:last-child { border-bottom: 0; }
.message .user { font-family: 'Chakra Petch', sans-serif; font-weight: 600; color: var(--white); }
.message .ts { font-family: 'Space Mono', monospace; color: var(--grey-mid); font-size: 10.5px; margin-left: 8px; }
.message.bot { opacity: 0.55; }
.message .text { margin-top: 4px; color: var(--grey-light); white-space: pre-wrap; }

/* Laptop sizes: tighten the sidebar + padding so the table has more room. */
@media (max-width: 1280px) {
  .layout { grid-template-columns: 200px 1fr; }
  .sidebar { width: 200px; padding: 24px 16px; }
  .main { padding: 32px 32px 56px; }
  h1 { font-size: 34px; }
  h2 { font-size: 18px; margin-top: 40px; }
  .stats { gap: 12px; }
  .stat .value { font-size: 30px; }
}

/* Hero on /trends: switch to single column earlier so the side stats don't squeeze. */
@media (max-width: 1100px) {
  .s1-hero { grid-template-columns: 1fr; }
  .s1-hero-side { border-left: 0; border-top: 1px solid var(--grey-dark); padding-left: 0; padding-top: 18px; flex-direction: row; gap: 32px; }
  .s1-hero-number { font-size: 84px; }
}

@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; width: auto; }
  .main { padding: 20px 16px 48px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  h1 { font-size: 28px; }
  .s1-hero { padding: 20px 22px; }
  .s1-hero-number { font-size: 64px; }
}
