/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --color-bg: #0f172a;
  --color-surface: #1e293b;
  --color-surface-alt: #243044;
  --color-border: #334155;
  --color-border-muted: #475569;
  --color-text: #f8fafc;
  --color-muted: #94a3b8;
  --color-dim: #64748b;
  --color-gold: #fbbf24;
  --color-gold-hover: #f59e0b;
  --color-gold-text: #1a365d;
  --color-danger: #f87171;
  --color-danger-hover: #ef4444;
  --color-success: #4ade80;

  /* Status colors */
  --color-operational: #4ade80;
  --color-operational-bg: rgba(74, 222, 128, 0.12);
  --color-degraded: #fbbf24;
  --color-degraded-bg: rgba(251, 191, 36, 0.12);
  --color-partial: #fb923c;
  --color-partial-bg: rgba(251, 146, 60, 0.12);
  --color-major: #f87171;
  --color-major-bg: rgba(248, 113, 113, 0.12);
  --color-maintenance: #a78bfa;
  --color-maintenance-bg: rgba(167, 139, 250, 0.12);
  --color-investigating: #f87171;
  --color-identified: #fbbf24;
  --color-monitoring: #60a5fa;
  --color-resolved: #4ade80;

  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
}

body {
  font-family: 'Roboto', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
}

a { color: var(--color-gold); text-decoration: none; }
a:hover { color: var(--color-gold-hover); text-decoration: none; }

/* ===== Top Bar ===== */
.topbar {
  display: flex;
  align-items: center;
  gap: 0;
  height: 52px;
  background: #1A2F3F;
  border-bottom: 2px solid #FCD55B;
  padding: 0 24px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
}

.topbar-brand {
  font-size: 18px;
  line-height: 28px;
  margin-right: 32px;
  flex-shrink: 0;
  color: #fff;
  letter-spacing: 0;
  display: flex;
  align-items: baseline;
}
.topbar-brand a { color: #fff; }
.topbar-brand strong { font-weight: 900; font-style: italic; letter-spacing: -0.5px; }
.topbar-brand em { font-weight: 300; font-style: italic; }
.topbar-appname {
  color: #FCD55B;
  font-size: 14px;
  letter-spacing: 2.1px;
  text-transform: uppercase;
  margin-left: 6px;
  font-style: normal;
  font-weight: 400;
}

.topbar-nav {
  display: flex;
  gap: 4px;
  flex: 1;
}
.topbar-nav a {
  padding: 6px 12px;
  border-radius: var(--radius);
  color: var(--color-muted);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.topbar-nav a:hover { background: rgba(255,255,255,0.07); color: var(--color-text); }
.topbar-nav a.active { background: rgba(251,191,36,0.15); color: var(--color-gold); }
.topbar-nav a.nav-external { margin-left: 8px; color: var(--color-dim); }

.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.user-name { font-size: 13px; color: var(--color-muted); }

/* ===== Main Area ===== */
.main-area {
  max-width: 1100px;
  margin: 0 auto;
  padding: 80px 24px 28px;
}

.page-header {
  margin-bottom: 24px;
}
.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--color-text);
}

/* ===== Cards ===== */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 24px;
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-alt);
}
.card-header h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
}

/* ===== Tables ===== */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table th {
  text-align: left;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-dim);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-alt);
}
.table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
  color: var(--color-text);
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: rgba(255,255,255,0.03); }

.actions-cell { white-space: nowrap; }
.url-cell { font-size: 12px; word-break: break-all; color: var(--color-muted); }

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

/* Incident status badges */
.badge-investigating { background: var(--color-major-bg); color: var(--color-major); border: 1px solid rgba(248,113,113,0.3); }
.badge-identified    { background: var(--color-degraded-bg); color: var(--color-degraded); border: 1px solid rgba(251,191,36,0.3); }
.badge-monitoring    { background: rgba(96,165,250,0.12); color: #60a5fa; border: 1px solid rgba(96,165,250,0.3); }
.badge-resolved      { background: var(--color-operational-bg); color: var(--color-operational); border: 1px solid rgba(74,222,128,0.3); }

/* Service status badges */
.badge-status-operational  { background: var(--color-operational-bg); color: var(--color-operational); border: 1px solid rgba(74,222,128,0.3); }
.badge-status-degraded     { background: var(--color-degraded-bg); color: var(--color-degraded); border: 1px solid rgba(251,191,36,0.3); }
.badge-status-partial      { background: var(--color-partial-bg); color: var(--color-partial); border: 1px solid rgba(251,146,60,0.3); }
.badge-status-major        { background: var(--color-major-bg); color: var(--color-major); border: 1px solid rgba(248,113,113,0.3); }
.badge-status-maintenance  { background: var(--color-maintenance-bg); color: var(--color-maintenance); border: 1px solid rgba(167,139,250,0.3); }
.badge-status-unknown      { background: rgba(100,116,139,0.15); color: var(--color-muted); border: 1px solid rgba(100,116,139,0.3); }
.badge-confidential        { background: rgba(251,191,36,0.1); color: #fbbf24; border: 1px solid rgba(251,191,36,0.3); font-size: 10px; letter-spacing: 0.5px; text-transform: uppercase; }
.badge-private             { background: rgba(96,165,250,0.1); color: #60a5fa; border: 1px solid rgba(96,165,250,0.3); font-size: 10px; letter-spacing: 0.5px; text-transform: uppercase; }
.service-name-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.badge-xs { font-size: 11px; padding: 1px 6px; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary, .btn-gold { background: var(--color-gold); color: var(--color-gold-text); font-weight: 600; }
.btn-primary:hover, .btn-gold:hover { background: var(--color-gold-hover); color: var(--color-gold-text); }
.btn-secondary { background: transparent; color: var(--color-text); border: 1px solid var(--color-border-muted); }
.btn-secondary:hover { background: rgba(255,255,255,0.06); border-color: var(--color-gold); color: var(--color-gold); }
.btn-danger { background: rgba(248,113,113,0.15); color: var(--color-danger); border: 1px solid rgba(248,113,113,0.3); }
.btn-danger:hover { background: rgba(248,113,113,0.25); }
.btn-ghost { background: transparent; color: var(--color-muted); }
.btn-ghost:hover { background: rgba(255,255,255,0.06); color: var(--color-text); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-full { width: 100%; }

/* ===== Forms ===== */
.form-grid { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-group { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 160px; }
.form-group label { font-size: 12px; font-weight: 500; color: var(--color-muted); }
.form-check { justify-content: flex-end; padding-bottom: 4px; }
.form-check label { font-size: 13px; color: var(--color-text); display: flex; align-items: center; gap: 6px; }
.form-divider { border: none; border-top: 1px solid var(--color-border); margin: 4px 0; }
.form-section-title { font-size: 13px; font-weight: 600; color: var(--color-muted); }
.form-actions { display: flex; gap: 8px; align-items: center; }

/* Test result */
.test-result { padding: 10px 14px; border-radius: var(--radius); font-size: 13px; margin-bottom: 4px; }
.test-running { background: rgba(96, 165, 250, 0.1); border: 1px solid rgba(96, 165, 250, 0.3); color: #60a5fa; }
.test-ok { background: var(--color-operational-bg); border: 1px solid rgba(74, 222, 128, 0.3); color: var(--color-operational); }
.test-fail { background: var(--color-major-bg); border: 1px solid rgba(248, 113, 113, 0.3); color: var(--color-major); }

/* Event test cards */
.event-card { padding: 16px; background: var(--color-bg); border: 1px solid var(--color-border); border-radius: var(--radius); }
.event-header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.event-payload { background: rgba(0,0,0,0.3); border: 1px solid var(--color-border); border-radius: 6px; padding: 8px 12px; margin: 10px 0; overflow-x: auto; }
.event-payload code { font-size: 11px; color: var(--color-muted); background: none; padding: 0; word-break: break-all; }
.form-inline { display: flex; gap: 8px; align-items: center; padding: 8px 0; flex-wrap: wrap; }

.input {
  padding: 7px 10px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 13px;
  background: #0f172a;
  color: var(--color-text);
  width: 100%;
  transition: border-color 0.15s;
}
.input:focus { outline: none; border-color: var(--color-gold); box-shadow: 0 0 0 2px rgba(251,191,36,0.15); }
.input::placeholder { color: var(--color-dim); }
.input-sm { padding: 4px 8px; font-size: 12px; }
.textarea { resize: vertical; min-height: 72px; }
.select-sm {
  padding: 4px 8px;
  font-size: 12px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: #0f172a;
  color: var(--color-text);
}

.checkbox-group { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 0; }
.checkbox-label { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; color: var(--color-text); }

/* ===== Flash ===== */
.flash {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  background: rgba(96,165,250,0.12);
  color: #60a5fa;
  border: 1px solid rgba(96,165,250,0.3);
  font-size: 13px;
}
.flash-error { background: var(--color-major-bg); color: var(--color-danger); border-color: rgba(248,113,113,0.3); }

/* ===== ExpertMaker Landing (login / denied) ===== */
.em-landing {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1A2F3F;
  color: #ffffff;
  font-family: 'Roboto', system-ui, sans-serif;
}
.em-landing__inner {
  text-align: center;
  max-width: 28rem;
  padding: 0 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}
.em-landing__brand {
  font-size: 1.5rem;
  letter-spacing: 0.025em;
  color: #ffffff;
}
.em-landing__brand strong {
  font-weight: 900;
  font-style: italic;
}
.em-landing__brand em {
  font-weight: 300;
  font-style: italic;
}
.em-landing__appname {
  font-size: 1.125rem;
  letter-spacing: 0.15em;
  color: #FCD55B;
  text-transform: uppercase;
  margin-left: 0.375rem;
  font-weight: 400;
}
.em-landing__subtitle {
  color: #94a3b8;
  margin: 0;
  font-size: 1rem;
}
.em-landing__button {
  display: inline-block;
  background: #FCD55B;
  color: #1a365d;
  padding: 0.75rem 2rem;
  border-radius: 0.5rem;
  font-weight: 500;
  font-size: 1rem;
  text-decoration: none;
  transition: background-color 0.15s ease;
}
.em-landing__button:hover { background: #fbbf24; }

/* ===== Public Status Page ===== */
.public-body {
  background: var(--color-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.public-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 52px;
  background: #1A2F3F;
  border-bottom: 2px solid #FCD55B;
  position: sticky;
  top: 0;
  z-index: 100;
}
.public-brand {
  font-size: 18px;
  line-height: 28px;
  color: #fff;
  letter-spacing: 0;
  display: flex;
  align-items: baseline;
}
.public-brand strong { font-weight: 900; font-style: italic; letter-spacing: -0.5px; }
.public-brand em { font-weight: 300; font-style: italic; }
.public-brand a { color: #fff; }
.public-brand .appname {
  color: #FCD55B;
  font-size: 14px;
  letter-spacing: 2.1px;
  text-transform: uppercase;
  margin-left: 6px;
  font-style: normal;
  font-weight: 400;
}
.public-nav { display: flex; gap: 16px; }
.public-nav a { font-size: 13px; color: var(--color-muted); }
.public-nav a.active, .public-nav a:hover { color: var(--color-gold); }
.public-nav .nav-login {
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.3);
  color: var(--color-gold);
  padding: 4px 14px;
  border-radius: 6px;
  font-weight: 500;
  margin-left: 8px;
}
.public-nav .nav-login:hover { background: rgba(251, 191, 36, 0.2); }

.public-main {
  flex: 1;
  max-width: 1000px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.public-footer {
  padding: 20px 24px;
  text-align: center;
  font-size: 12px;
  color: var(--color-dim);
  border-top: 1px solid var(--color-border);
}
.public-footer a { color: var(--color-dim); }
.public-footer a:hover { color: var(--color-gold); }

/* ===== Status Banner ===== */
.status-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  border: 1px solid transparent;
}
.status-banner-icon { font-size: 20px; }
.status-banner-operational { background: var(--color-operational-bg); color: var(--color-operational); border-color: rgba(74,222,128,0.2); }
.status-banner-degraded    { background: var(--color-degraded-bg); color: var(--color-degraded); border-color: rgba(251,191,36,0.2); }
.status-banner-partial     { background: var(--color-partial-bg); color: var(--color-partial); border-color: rgba(251,146,60,0.2); }
.status-banner-major       { background: var(--color-major-bg); color: var(--color-major); border-color: rgba(248,113,113,0.2); }
.status-banner-maintenance { background: var(--color-maintenance-bg); color: var(--color-maintenance); border-color: rgba(167,139,250,0.2); }
.status-banner-unknown     { background: rgba(100,116,139,0.12); color: var(--color-muted); border-color: rgba(100,116,139,0.2); }

/* ===== Services Section ===== */
.section { display: flex; flex-direction: column; gap: 0; }
.section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--color-dim);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 12px;
}

.group-section { margin-bottom: 16px; }
.group-header {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-dim);
  padding: 8px 0 4px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 4px;
}

.service-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
  gap: 16px;
}
.service-row:last-child { border-bottom: none; }
.service-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.service-name { font-weight: 500; color: var(--color-text); text-decoration: none; }
a.service-name:hover { color: var(--color-gold); }
.external-arrow { font-size: 11px; opacity: 0.4; margin-left: 2px; }
a.service-name:hover .external-arrow { opacity: 1; }
.service-desc { font-size: 12px; color: var(--color-muted); }
.service-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }

/* ===== Uptime Bar (90 blocks) ===== */
.uptime-bar {
  display: flex;
  gap: 2px;
  align-items: center;
}
.uptime-block {
  width: 6px;
  height: 24px;
  border-radius: 2px;
  flex-shrink: 0;
}
.uptime-operational    { background: var(--color-operational); }
.uptime-degraded       { background: var(--color-degraded); }
.uptime-partial_outage { background: var(--color-partial); }
.uptime-major_outage   { background: var(--color-major); }
.uptime-maintenance    { background: var(--color-maintenance); }
.uptime-no-data        { background: #1e293b; border: 1px solid #334155; }

/* ===== Incident Cards ===== */
.incident-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
}
.incident-card-active { border-left: 3px solid var(--color-major); }
.incident-header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.incident-title { font-weight: 600; font-size: 14px; color: var(--color-text); }
.incident-meta { font-size: 12px; color: var(--color-dim); margin-top: 4px; }
.incident-latest { font-size: 13px; color: var(--color-muted); margin-top: 4px; }

/* ===== Incident Detail ===== */
.incident-detail { display: flex; flex-direction: column; gap: 16px; }
.incident-detail-header { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.incident-detail-title { font-size: 22px; font-weight: 700; color: var(--color-text); }
.incident-detail-meta { font-size: 13px; color: var(--color-muted); }

/* ===== Timeline ===== */
.timeline { display: flex; flex-direction: column; gap: 0; padding-left: 16px; border-left: 2px solid var(--color-border); }
.timeline-entry { position: relative; padding: 0 0 20px 20px; }
.timeline-entry:last-child { padding-bottom: 0; }
.timeline-dot {
  position: absolute;
  left: -9px;
  top: 4px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--color-bg);
}
.timeline-dot-investigating { background: var(--color-major); }
.timeline-dot-identified    { background: var(--color-degraded); }
.timeline-dot-monitoring    { background: #60a5fa; }
.timeline-dot-resolved      { background: var(--color-operational); }

.timeline-header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.timeline-time { font-size: 12px; color: var(--color-dim); }
.timeline-message { font-size: 13px; color: var(--color-text); }

/* ===== History ===== */
.history-filter { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 20px; }
.month-btn {
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-muted);
  text-decoration: none;
  transition: all 0.15s;
}
.month-btn:hover { border-color: var(--color-gold); color: var(--color-gold); }
.month-btn.active { background: rgba(251,191,36,0.15); color: var(--color-gold); border-color: var(--color-gold); }

/* ===== Admin Incident List ===== */
.incident-admin-row {
  padding: 14px 20px;
  border-bottom: 1px solid var(--color-border);
}
.incident-admin-row:last-child { border-bottom: none; }
.incident-admin-row.incident-active { border-left: 3px solid var(--color-major); }
.incident-admin-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.incident-admin-title { font-weight: 600; font-size: 14px; flex: 1; color: var(--color-text); }

.updates-list { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--color-border); display: flex; flex-direction: column; gap: 4px; }
.update-entry { display: flex; align-items: baseline; gap: 8px; font-size: 12px; }
.update-time { color: var(--color-dim); white-space: nowrap; }
.update-msg { color: var(--color-muted); }

/* ===== Misc ===== */
.empty-state { padding: 32px; text-align: center; color: var(--color-dim); font-size: 13px; }
.text-muted { color: var(--color-muted); }
.text-danger { color: var(--color-danger); }
code { font-family: ui-monospace, monospace; font-size: 12px; background: rgba(255,255,255,0.07); color: var(--color-muted); padding: 1px 4px; border-radius: 4px; border: 1px solid var(--color-border); }
