/* ══════════════════════════════════════════════════════════
   St. Clair Dev Status — the one stylesheet
   Tokens first, then the public status page, then the admin
   shell and UI kit. The CSP forbids inline style attributes,
   so every visual choice lives here as a class.
   Palette follows the stclairdev.com admin (dark navy).
   ══════════════════════════════════════════════════════════ */

/* ── Tokens ─────────────────────────────────────────────── */
:root {
  --black: #1c2230;  --deep: #252c3d;   --panel: #303a50;  --sidebar: #232a3a;
  --border: #46516e; --muted: #8b96b6;  --subtle: #b8c1da; --body: #d5dcee;
  --light: #e7ebf7;  --white: #fafbff;
  --brand: #e8423a;                       /* logo mark only */
  --accent: #5b8def; --accent-hover: #4676d6;
  --link: #7ab0ff;

  /* status colours — shared by pills, bars, banners and alerts */
  --up: #3cb371;  --degraded: #e0b43c;  --partial: #f08a3c;  --down: #e8423a;
  --nodata: #46516e;  --info: #7ab0ff;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 6px;
  --sidebar-w: 230px;
}

/* ── Base ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body { background: var(--black); color: var(--body); font-family: var(--font); font-size: 15px; line-height: 1.55; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: 0.88em; }
h1, h2, h3 { color: var(--white); line-height: 1.25; }

.muted  { color: var(--muted); }
.subtle { color: var(--subtle); }
.small  { font-size: 0.84rem; }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.mt-1 { margin-top: 0.75rem; }  .mt-2 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.75rem; } .mb-2 { margin-bottom: 1.5rem; }
.hidden { display: none; }

.logo-mark {
  width: 30px; height: 30px; flex-shrink: 0; background: var(--brand);
  display: inline-flex; align-items: center; justify-content: center;
  clip-path: polygon(0 0, 100% 0, 100% 75%, 75% 100%, 0 100%);
  font-weight: 800; font-size: 0.8rem; color: #fff; letter-spacing: 0.02em;
}

/* ── Pills (state, roll-up, incident status) ────────────── */
.pill {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 0.2rem 0.6rem; border-radius: 999px; border: 1px solid; white-space: nowrap;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill-up, .pill-resolved                { color: var(--up);       border-color: rgba(60,179,113,0.45);  background: rgba(60,179,113,0.1); }
.pill-degraded, .pill-identified        { color: var(--degraded); border-color: rgba(224,180,60,0.45);  background: rgba(224,180,60,0.1); }
.pill-partial                           { color: var(--partial);  border-color: rgba(240,138,60,0.45);  background: rgba(240,138,60,0.1); }
.pill-down, .pill-investigating         { color: var(--down);     border-color: rgba(232,66,58,0.45);   background: rgba(232,66,58,0.1); }
.pill-monitoring, .pill-info            { color: var(--info);     border-color: rgba(122,176,255,0.45); background: rgba(122,176,255,0.1); }
.pill-unknown                           { color: var(--muted);    border-color: var(--border);          background: transparent; }
.pill-outage                            { color: var(--down);     border-color: rgba(232,66,58,0.45);   background: transparent; }

/* ══ Public status page ═════════════════════════════════ */
.wrap { max-width: 880px; margin: 0 auto; padding: 0 16px; }

.pub-header { background: var(--deep); border-bottom: 1px solid var(--border); }
.pub-header-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 64px; flex-wrap: wrap; padding-top: 0.6rem; padding-bottom: 0.6rem; }
.brand { display: inline-flex; align-items: center; gap: 0.65rem; color: var(--white); font-weight: 700; font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.pub-nav { display: flex; gap: 1.25rem; font-size: 0.9rem; }
.pub-nav a { color: var(--subtle); }
.pub-nav a:hover { color: var(--white); text-decoration: none; }
.pub-main { padding-top: 2rem; padding-bottom: 3rem; }

.overall {
  display: flex; align-items: center; gap: 0.9rem;
  padding: 1.1rem 1.25rem; border-radius: var(--radius); border: 1px solid;
  margin-bottom: 2rem; color: var(--white);
}
.overall-dot { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; background: currentColor; }
.overall-text { font-size: 1.15rem; font-weight: 700; color: var(--white); }
.overall-sub { font-size: 0.85rem; color: var(--subtle); }
.overall-up       { color: var(--up);       border-color: rgba(60,179,113,0.5);  background: rgba(60,179,113,0.1); }
.overall-degraded { color: var(--degraded); border-color: rgba(224,180,60,0.5);  background: rgba(224,180,60,0.1); }
.overall-partial  { color: var(--partial);  border-color: rgba(240,138,60,0.5);  background: rgba(240,138,60,0.1); }
.overall-down     { color: var(--down);     border-color: rgba(232,66,58,0.5);   background: rgba(232,66,58,0.12); }
.overall-unknown  { color: var(--muted);    border-color: var(--border);         background: var(--deep); }

.section-title {
  font-size: 0.78rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted); margin: 2rem 0 0.8rem;
}
.section-title:first-child { margin-top: 0; }

/* Active incident cards */
.incident-card {
  background: var(--panel); border: 1px solid var(--border); border-left: 4px solid var(--down);
  border-radius: var(--radius); padding: 1rem 1.15rem; margin-bottom: 0.9rem;
}
.incident-card.impact-degraded { border-left-color: var(--degraded); }
.incident-card.impact-info     { border-left-color: var(--info); }
.incident-card.status-monitoring { border-left-color: var(--info); }
.incident-card-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; }
.incident-title { font-size: 1.02rem; font-weight: 700; color: var(--white); }
.incident-title a { color: var(--white); }
.incident-meta { font-size: 0.8rem; color: var(--muted); margin-top: 0.15rem; }
.incident-body { margin-top: 0.55rem; color: var(--body); white-space: pre-line; }

/* Projects and components */
.project { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 1rem; }
.project-head {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  padding: 0.9rem 1.15rem; border-bottom: 1px solid var(--border);
}
.project-name { font-size: 1.05rem; font-weight: 700; color: var(--white); }
.component { padding: 0.85rem 1.15rem 0.9rem; }
.component + .component { border-top: 1px solid var(--border); }
.component-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.55rem; }
.component-name { font-weight: 600; color: var(--light); }
.component-state { font-size: 0.82rem; font-weight: 600; }
.state-up { color: var(--up); }  .state-degraded { color: var(--degraded); }
.state-down { color: var(--down); }  .state-unknown { color: var(--muted); }

/* 30-day bar strip. Each bar is one day; hover shows the day's numbers. */
.bars { display: flex; gap: 2px; height: 34px; align-items: stretch; }
.bar { flex: 1 1 0; min-width: 3px; border-radius: 2px; position: relative; background: var(--nodata); }
.bar-up       { background: var(--up); }
.bar-degraded { background: var(--degraded); }
.bar-partial  { background: var(--partial); }
.bar-down     { background: var(--down); }
.bar-nodata   { background: var(--nodata); }
.bar:hover { filter: brightness(1.25); }
.bar[data-tip]:hover::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  background: var(--black); color: var(--light); border: 1px solid var(--border); border-radius: 4px;
  padding: 0.35rem 0.6rem; font-size: 0.75rem; white-space: nowrap; z-index: 10; pointer-events: none;
}
.bars > .bar:nth-child(-n+5)[data-tip]:hover::after { left: 0; transform: none; }
.bars > .bar:nth-last-child(-n+5)[data-tip]:hover::after { left: auto; right: 0; transform: none; }
.bars-legend { display: flex; justify-content: space-between; gap: 0.5rem; font-size: 0.75rem; color: var(--muted); margin-top: 0.35rem; }
.bars-legend .uptime { color: var(--subtle); font-weight: 600; }

.key { display: flex; flex-wrap: wrap; gap: 1rem; font-size: 0.78rem; color: var(--muted); margin: -0.25rem 0 1rem; }
.key span { display: inline-flex; align-items: center; gap: 0.35rem; }
.key i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

/* Incident history list */
.past-item { padding: 0.8rem 0; border-bottom: 1px solid var(--border); }
.past-item:last-child { border-bottom: none; }
.past-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; }
.past-title { font-weight: 600; color: var(--light); }
.past-meta { font-size: 0.8rem; color: var(--muted); }
.empty { color: var(--muted); padding: 0.5rem 0; }

/* Incident timeline */
.timeline { list-style: none; border-left: 2px solid var(--border); margin-left: 0.4rem; }
.timeline-item { position: relative; padding: 0 0 1.25rem 1.25rem; }
.timeline-item::before {
  content: ""; position: absolute; left: -7px; top: 0.35rem; width: 12px; height: 12px; border-radius: 50%;
  background: var(--panel); border: 2px solid var(--muted);
}
.timeline-item.st-investigating::before { border-color: var(--down); }
.timeline-item.st-identified::before    { border-color: var(--degraded); }
.timeline-item.st-monitoring::before    { border-color: var(--info); }
.timeline-item.st-resolved::before      { border-color: var(--up); background: var(--up); }
.timeline-head { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.timeline-time { font-size: 0.8rem; color: var(--muted); }
.timeline-body { margin-top: 0.35rem; white-space: pre-line; }

.page-head { margin-bottom: 1.5rem; }
.page-head h1 { font-size: 1.45rem; margin: 0.35rem 0; }
.facts { display: flex; flex-wrap: wrap; gap: 0.4rem 1.5rem; font-size: 0.85rem; color: var(--subtle); margin-top: 0.5rem; }
.facts strong { color: var(--light); font-weight: 600; }

.pagination { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 1.25rem; }
.pagination a, .pagination span {
  padding: 0.3rem 0.7rem; border: 1px solid var(--border); border-radius: 4px; font-size: 0.82rem; color: var(--subtle);
}
.pagination .current { border-color: var(--accent); color: var(--white); background: rgba(91,141,239,0.15); }

.pub-footer { border-top: 1px solid var(--border); color: var(--muted); font-size: 0.8rem; }
.pub-footer-inner { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding-top: 1.1rem; padding-bottom: 1.5rem; }

/* ══ Signed-out auth pages ══════════════════════════════ */
.auth-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem 16px; }
.auth-card { width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem; }
.auth-card.wide { max-width: 520px; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 0.6rem; color: var(--subtle); font-size: 0.85rem; margin-bottom: 1.25rem; }
.auth-title { text-align: center; font-size: 1.35rem; margin-bottom: 1.25rem; }
.auth-links { text-align: center; margin-top: 1.25rem; font-size: 0.85rem; }
.auth-links a { color: var(--muted); }
.auth-links a:hover { color: var(--white); }

.qr-box { display: flex; justify-content: center; margin: 1rem 0; }
.qr-box svg { border-radius: 4px; max-width: 100%; height: auto; }
.secret-key { font-family: var(--mono); font-size: 0.95rem; letter-spacing: 0.08em; text-align: center; color: var(--white); background: var(--deep); border: 1px solid var(--border); border-radius: 4px; padding: 0.5rem; word-break: break-all; }
.codes-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin: 1rem 0; }
.codes-grid code { display: block; text-align: center; background: var(--deep); border: 1px solid var(--border); border-radius: 4px; padding: 0.45rem; color: var(--white); font-size: 0.9rem; }
.code-input { font-family: var(--mono); font-size: 1.4rem !important; letter-spacing: 0.3em; text-align: center; }

/* ══ Admin shell ════════════════════════════════════════ */
body.admin { display: flex; min-height: 100vh; background: var(--deep); }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: var(--sidebar); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; overflow-y: auto; z-index: 50;
}
.sidebar-logo { display: flex; align-items: center; gap: 0.6rem; padding: 1.1rem 1.1rem 1rem; border-bottom: 1px solid var(--border); color: var(--white); font-weight: 700; }
.sidebar-logo em { color: var(--accent); font-style: normal; }
.sidebar-section { padding: 1rem 1.1rem 0.35rem; font-size: 0.64rem; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); }
.nav-item { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.5rem 0.9rem; margin: 0 0.5rem; border-radius: 4px; font-size: 0.9rem; color: var(--subtle); }
.nav-item:hover { background: var(--panel); color: var(--light); text-decoration: none; }
.nav-item.active { background: rgba(91,141,239,0.14); color: var(--white); }
.nav-count { background: var(--down); color: #fff; font-size: 0.68rem; font-weight: 700; border-radius: 999px; padding: 0.05rem 0.45rem; }
.sidebar-footer { margin-top: auto; padding: 1rem 1.1rem; border-top: 1px solid var(--border); font-size: 0.8rem; color: var(--muted); }
.sidebar-footer strong { color: var(--subtle); display: block; }
.sidebar-footer form { margin-top: 0.6rem; }

.main { margin-left: var(--sidebar-w); flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  background: var(--panel); border-bottom: 1px solid var(--border); padding: 0 1.75rem; min-height: 56px;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; position: sticky; top: 0; z-index: 40;
}
.topbar-title { font-size: 1.05rem; font-weight: 700; color: var(--white); }
.topbar-right { display: flex; align-items: center; gap: 1rem; font-size: 0.82rem; }
.env-badge { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--white); background: rgba(91,141,239,0.2); border: 1px solid var(--accent); border-radius: 3px; padding: 0.1rem 0.5rem; }
.content { padding: 2rem 1.75rem; flex: 1; }
.admin-footer { padding: 1rem 1.75rem; font-size: 0.78rem; color: var(--muted); border-top: 1px solid var(--border); }

/* ── UI kit ─────────────────────────────────────────────── */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; }
.card + .card { margin-top: 1.5rem; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.15rem; padding-bottom: 0.85rem; border-bottom: 1px solid var(--border); }
.card-title { font-size: 0.95rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--white); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; align-items: start; }
.grid-2 > .card + .card { margin-top: 0; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--panel); border: 1px solid var(--border); border-top: 3px solid var(--muted); border-radius: var(--radius); padding: 1rem 1.1rem; }
.stat-card.stat-up { border-top-color: var(--up); }       .stat-card.stat-degraded { border-top-color: var(--degraded); }
.stat-card.stat-down { border-top-color: var(--down); }   .stat-card.stat-info { border-top-color: var(--info); }
.stat-num { font-size: 2rem; font-weight: 800; color: var(--white); line-height: 1; }
.stat-label { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--subtle); margin-top: 0.35rem; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; }
.form-group { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 1.1rem; }
.form-grid .form-group { margin-bottom: 0; }
.form-group.full { grid-column: 1 / -1; }
label, .form-label { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--subtle); }
input[type="text"], input[type="email"], input[type="password"], input[type="url"], input[type="number"],
input[type="datetime-local"], input[type="search"], textarea, select {
  width: 100%; background: var(--deep); border: 1px solid var(--border); border-radius: 4px; color: var(--white);
  font-family: var(--font); font-size: 0.95rem; padding: 0.6rem 0.8rem; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 110px; }
select option { background: var(--panel); }
.form-hint { font-size: 0.8rem; color: var(--muted); text-transform: none; letter-spacing: normal; font-weight: 400; }
.check-row { display: flex; align-items: center; gap: 0.55rem; font-size: 0.92rem; color: var(--body); text-transform: none; letter-spacing: normal; font-weight: 400; margin-bottom: 0.45rem; }
.check-row input { width: 16px; height: 16px; accent-color: var(--accent); }
.check-group { margin-bottom: 1.1rem; }
.check-group .form-label { display: block; margin-bottom: 0.5rem; }
.form-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; margin-top: 0.25rem; }
.inline-form { display: inline; }
.filters { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1.25rem; }
.filters input, .filters select { width: auto; padding: 0.45rem 0.7rem; font-size: 0.85rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  font-family: var(--font); font-weight: 700; font-size: 0.85rem; letter-spacing: 0.04em;
  padding: 0.6rem 1.2rem; border-radius: 4px; border: 1px solid transparent; cursor: pointer; text-decoration: none; line-height: 1.2;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--body); }
.btn-ghost:hover { border-color: var(--light); color: var(--white); }
.btn-danger { background: #6e1f1f; color: #ffb4ae; border-color: #8c2b2b; }
.btn-danger:hover { background: #8c2525; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.76rem; }
.btn-block { width: 100%; }

.alert { padding: 0.8rem 1rem; border-radius: 4px; font-size: 0.9rem; margin-bottom: 1.25rem; border: 1px solid; }
.alert-success { background: rgba(60,179,113,0.1);  border-color: rgba(60,179,113,0.5);  color: #8fe0b0; }
.alert-error   { background: rgba(232,66,58,0.1);   border-color: rgba(232,66,58,0.5);   color: #ffa39d; }
.alert-warn    { background: rgba(224,180,60,0.1);  border-color: rgba(224,180,60,0.5);  color: #f0d080; }
.alert-info    { background: rgba(122,176,255,0.1); border-color: rgba(122,176,255,0.5); color: #b6d2ff; }
.alert-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.alert a { color: var(--white); font-weight: 600; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
thead th { background: var(--deep); color: var(--subtle); font-size: 0.68rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; padding: 0.65rem 0.85rem; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,0.03); }
tbody td { padding: 0.65rem 0.85rem; vertical-align: top; }
.td-strong { color: var(--white); font-weight: 600; }
.td-error { color: #ffa39d; font-size: 0.8rem; max-width: 320px; }

.result-box { background: var(--deep); border: 1px solid var(--border); border-radius: 4px; padding: 0.85rem 1rem; margin-top: 1rem; font-size: 0.88rem; }
.result-box dl { display: grid; grid-template-columns: max-content 1fr; gap: 0.25rem 1rem; }
.result-box dt { color: var(--muted); }
.result-box dd { color: var(--light); word-break: break-all; }

.log-view { background: var(--black); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; overflow-x: auto; font-family: var(--mono); font-size: 0.78rem; line-height: 1.55; white-space: pre-wrap; word-break: break-word; max-height: 600px; overflow-y: auto; }

.changelog h3 { font-size: 1rem; margin-bottom: 0.2rem; }
.changelog ul { margin: 0.5rem 0 1.5rem 1.2rem; }
.changelog li { margin-bottom: 0.3rem; }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 900px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .grid-2, .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  body.admin { display: block; }
  .sidebar { position: static; width: auto; border-right: none; border-bottom: 1px solid var(--border); }
  .sidebar nav { display: flex; flex-wrap: wrap; padding-bottom: 0.6rem; }
  .sidebar-section { width: 100%; }
  .nav-item { margin: 0 0.25rem; }
  .main { margin-left: 0; min-height: 0; }
  .topbar { position: static; padding: 0.6rem 16px; }
  .content { padding: 1.25rem 16px; }
  .admin-footer { padding: 1rem 16px; }
  .bars { gap: 1px; height: 30px; }
  .pub-nav { gap: 1rem; }
}
@media print {
  .sidebar, .topbar, .admin-footer, .no-print { display: none !important; }
  .main { margin-left: 0; }
  body, .card { background: #fff; color: #000; }
}
