/* ============================================================
   Sunscreensaver — Operations dashboard
   Light theme; solar accents borrowed from the landing page.
   ============================================================ */

:root {
  --bg: #f5f5f7;
  --bg-alt: #ffffff;
  --card: #ffffff;
  --card-2: #f0f0f3;
  --border: #e4e4e9;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --accent: #ff6b35;
  --gold: #e0922a;
  --green: #28a745;
  --amber: #d98e00;
  --red: #e5484d;
  --blue: #2f7ed8;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "DM Sans", Roboto, sans-serif;
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: radial-gradient(1200px 600px at 70% -10%, rgba(255, 107, 53, 0.07), transparent 60%), var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { font-size: 16px; font-weight: 600; letter-spacing: 0.2px; }
.dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--gold), var(--accent));
  box-shadow: 0 0 12px var(--accent);
}
.topbar-actions { display: flex; align-items: center; gap: 14px; }
#updatedAt { font-size: 13px; }

.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 980px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}
.btn:hover { background: #e55a28; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: default; }

main { max-width: 1200px; margin: 0 auto; padding: 28px; }

.banner {
  background: rgba(229, 72, 77, 0.1);
  border: 1px solid rgba(229, 72, 77, 0.35);
  color: #b42318;
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 14px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* KPI grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}
.kpi-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); }
.kpi-value { font-size: 32px; font-weight: 700; margin: 6px 0 2px; }
.kpi-sub { font-size: 13px; color: var(--muted); }
/* 24h movement badge on the KPI cards. Empty (no text) when there's no change. */
.kpi-delta { font-size: 12px; font-weight: 600; min-height: 16px; margin-bottom: 2px; color: var(--muted); }
.kpi-delta.up { color: var(--green); }
.kpi-delta.down { color: var(--red); }

/* Controls */
.control-card { margin-bottom: 22px; }
.control-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.config-editor {
  width: 100%;
  box-sizing: border-box;
  margin-top: 12px;
  min-height: 110px;
  resize: vertical;
  background: var(--card-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
}
.config-editor:focus { outline: none; border-color: var(--accent); }
#configEffective { margin-top: 8px; word-break: break-word; }
.field-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
}
.field-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}
.field-grid input[type="text"], .field-grid input[type="url"] {
  background: var(--card-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.field-grid input:focus { outline: none; border-color: var(--accent); }
.field-grid .checkbox-row {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  align-self: end;
  font-size: 13px;
  color: var(--text);
}
.field-grid .checkbox-row input { width: auto; }
@media (max-width: 640px) { .field-grid { grid-template-columns: 1fr; } }

/* App-update form: full-width URL inputs, inline validation, mandatory guardrail */
.field-stack { margin-top: 12px; display: flex; flex-direction: column; gap: 12px; }
.field-stack label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.field-stack input[type="url"] {
  width: 100%;
  background: var(--card-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.field-stack input:focus { outline: none; border-color: var(--accent); }
.field-error { color: var(--red); font-size: 11px; }
.field-error:empty { display: none; }
.field-grid input.invalid, .field-stack input.invalid { border-color: var(--red); }
.field-opt { color: var(--muted); font-weight: 400; text-transform: none; opacity: 0.75; }
.au-mandatory { margin-top: 14px; display: flex; align-items: flex-start; gap: 8px; font-size: 13px; color: var(--text); cursor: pointer; }
.au-mandatory input { width: auto; margin-top: 2px; flex: none; }
.au-validation { margin-top: 12px; font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.au-validation.ok { color: var(--green); }
.au-validation.error { color: var(--red); }

/* Release-notes editor */
.btn-secondary { background: var(--card-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #e8e8ec; }
.rn-actions { display: flex; gap: 8px; }
.rn-list { margin-top: 14px; display: flex; flex-direction: column; gap: 14px; }
.rn-entry { border: 1px solid var(--border); border-radius: 10px; padding: 12px; background: var(--card-2); }
.rn-entry-head { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.rn-entry input, .rn-body {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 9px;
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.rn-version { width: 110px; }
.rn-date { width: 160px; }
.rn-entry input:focus, .rn-body:focus { outline: none; border-color: var(--accent); }
.rn-entry input.invalid { border-color: var(--red); }
.rn-remove { margin-left: auto; background: transparent; border: none; color: var(--muted); font-size: 15px; line-height: 1; cursor: pointer; padding: 6px 9px; border-radius: 6px; }
.rn-remove:hover { color: var(--red); background: rgba(229, 72, 77, 0.1); }
.rn-body { width: 100%; min-height: 92px; resize: vertical; line-height: 1.5; }
.rn-help { margin-top: 12px; font-size: 12px; color: var(--muted); line-height: 1.5; }
.rn-help code { background: var(--card-2); padding: 1px 5px; border-radius: 4px; font-size: 11px; }
.segmented { display: inline-flex; background: var(--card-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.segmented button {
  background: transparent;
  color: var(--muted);
  border: none;
  border-radius: 8px;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.segmented button:hover:not(.active) { color: var(--text); }
.segmented button.active { background: var(--accent); color: #fff; }
.segmented button:disabled { opacity: 0.5; cursor: default; }
/* Compact variant for the top-bar granularity switch. */
.segmented.sm button { padding: 5px 12px; font-size: 12px; }

/* Charts */
.chart-grid {
  display: grid;
  /* minmax(0,1fr) (not 1fr) prevents the canvas from blowing the track out wider
     than the viewport — the classic Chart.js + CSS grid overflow. */
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}
.chart-card { display: flex; flex-direction: column; min-width: 0; }
/* Fixed-height, relatively-positioned box so the responsive canvas has a bounded
   area to fill (paired with maintainAspectRatio:false in app.js). */
.chart-box { position: relative; width: 100%; height: 260px; }
.chart-box canvas { display: block; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-head h2 { font-size: 15px; font-weight: 600; }

.range { display: flex; gap: 4px; }
.range button {
  background: var(--card-2);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}
.range button.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Table */
.table-card { overflow: hidden; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; }
td.error { white-space: normal; color: #ffb4ae; max-width: 320px; }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 980px;
  font-size: 11px;
  font-weight: 600;
  text-transform: capitalize;
}
.badge.healthy { background: rgba(52, 199, 89, 0.15); color: var(--green); }
.badge.stale { background: rgba(255, 179, 71, 0.15); color: var(--gold); }
.badge.failing { background: rgba(255, 69, 58, 0.15); color: var(--red); }
.badge.unknown { background: rgba(139, 139, 149, 0.15); color: var(--muted); }
.badge.upstream { background: rgba(47, 126, 216, 0.15); color: var(--blue); }
.oom { color: var(--red); font-weight: 600; margin-left: 6px; }

@media (max-width: 760px) {
  .chart-grid { grid-template-columns: 1fr; }
  main { padding: 18px; }
}
