/* CranL status page — light/dark theme in the spirit of a classic status page. */

:root {
  color-scheme: light;
  --bg: #ffffff;
  --bg-soft: #fafbfc;
  --text: #2f3a44;
  --text-strong: #16202a;
  --muted: #7b8a97;
  --border: #e3e6e9;
  --border-strong: #d4d9de;

  --green: #2f9e44;
  --green-bar: #62bd62;
  --yellow: #e0a800;
  --yellow-bar: #e8c14a;
  --orange: #e2761b;
  --red: #cf4646;
  --red-bar: #e05252;
  --blue: #1f6fd0;
  --gray-bar: #e6e9ec;

  --shadow: 0 1px 2px rgba(16, 32, 48, 0.05);
  --radius: 4px;
  --container: 940px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1419;
  --bg-soft: #151b22;
  --text: #c3cdd7;
  --text-strong: #e8eef4;
  --muted: #7d8a97;
  --border: #232b34;
  --border-strong: #2d3742;
  --green: #35a854;
  --green-bar: #4a9d55;
  --yellow-bar: #b99433;
  --red-bar: #b74a4a;
  --gray-bar: #232b34;
  --shadow: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1419;
    --bg-soft: #151b22;
    --text: #c3cdd7;
    --text-strong: #e8eef4;
    --muted: #7d8a97;
    --border: #232b34;
    --border-strong: #2d3742;
    --green: #35a854;
    --green-bar: #4a9d55;
    --yellow-bar: #b99433;
    --red-bar: #b74a4a;
    --gray-bar: #232b34;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 16px;
}

/* ---------- header ---------- */

.site-header { padding: 28px 0 8px; }

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand { display: inline-flex; align-items: center; }
.brand img { height: 38px; width: auto; display: block; }
.logo-light { display: none; }

:root[data-theme="dark"] .logo-dark { display: none; }
:root[data-theme="dark"] .logo-light { display: block; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-dark { display: none; }
  :root:not([data-theme="light"]) .logo-light { display: block; }
}

.header-actions { display: flex; align-items: center; gap: 10px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 9px 16px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  background: transparent;
  color: var(--text);
  transition: background 120ms ease, border-color 120ms ease, opacity 120ms ease;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { filter: brightness(1.07); }
.btn-secondary { border-color: var(--border-strong); color: var(--text); background: var(--bg); }
.btn-secondary:hover { background: var(--bg-soft); }
.btn-danger { border-color: var(--red); color: var(--red); background: transparent; }
.btn-danger:hover { background: rgba(207, 70, 70, 0.08); }
.btn-sm { padding: 6px 10px; font-size: 11px; letter-spacing: 0.04em; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

.icon-btn {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  border-radius: var(--radius);
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}
.icon-btn:hover { background: var(--bg-soft); color: var(--text); }
.icon-btn svg { display: block; }

/* ---------- status banner ---------- */

.status-banner {
  margin: 26px 0 8px;
  border-radius: var(--radius);
  padding: 18px 20px;
  color: #fff;
  font-size: 20px;
  font-weight: 400;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--green);
  min-height: 62px;
}
.status-banner .banner-meta { font-size: 12px; opacity: 0.9; }
.status-banner.is-operational { background: var(--green); }
.status-banner.is-degraded { background: var(--yellow); }
.status-banner.is-partial_outage { background: var(--orange); }
.status-banner.is-major_outage { background: var(--red); }
.status-banner.is-maintenance { background: var(--blue); }
.status-banner.is-unknown { background: var(--muted); }

/* ---------- sections ---------- */

.section { margin: 40px 0; }
.section-title {
  font-size: 22px;
  font-weight: 400;
  color: var(--text-strong);
  margin: 0 0 6px;
}
.section-body { color: var(--muted); font-size: 14px; margin: 0; }

.uptime-note {
  text-align: right;
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 8px;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: var(--shadow);
}

.card-empty { padding: 28px 20px; text-align: center; color: var(--muted); font-size: 14px; }

/* ---------- component rows ---------- */

.component-group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px 2px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  border-top: 1px solid var(--border);
}
.component-group-head:first-child { border-top: none; }

.component {
  padding: 16px 18px 14px;
  border-top: 1px solid var(--border);
}
.component:first-child { border-top: none; }

.component-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.component-name {
  font-size: 15px;
  color: var(--text-strong);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.component-status { font-size: 13px; white-space: nowrap; }

.status-operational { color: var(--green); }
.status-degraded { color: var(--yellow); }
.status-partial_outage { color: var(--orange); }
.status-major_outage { color: var(--red); }
.status-maintenance { color: var(--blue); }
.status-unknown { color: var(--muted); }

.hint {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  color: var(--muted);
  font-size: 10px;
  cursor: help;
  position: relative;
}

/* ---------- uptime bars ---------- */

.bars {
  display: flex;
  align-items: stretch;
  gap: 2px;
  height: 34px;
  margin-bottom: 6px;
}
.bar {
  flex: 1 1 0;
  min-width: 2px;
  border-radius: 1px;
  background: var(--gray-bar);
  position: relative;
  transition: opacity 120ms ease;
}
.bar:hover { opacity: 0.7; }
.bar.up { background: var(--green-bar); }
.bar.partial { background: var(--yellow-bar); }
.bar.down { background: var(--red-bar); }
.bar.nodata { background: var(--gray-bar); }

.bars-legend {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--muted);
}
.bars-legend .rule { flex: 1; height: 1px; background: var(--border); }

/* ---------- tooltips ---------- */

[data-tip] { position: relative; }
[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%);
  background: #16202a;
  color: #fff;
  font-size: 11px;
  font-weight: 400;
  line-height: 1.35;
  letter-spacing: 0;
  text-transform: none;
  white-space: pre-line;
  width: max-content;
  max-width: 230px;
  padding: 6px 9px;
  border-radius: 3px;
  z-index: 20;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(16, 32, 48, 0.25);
}

/* ---------- incidents ---------- */

.incident-day { padding: 18px 0 20px; border-bottom: 1px solid var(--border); }
.incident-day:last-child { border-bottom: none; }
.incident-day-title { font-size: 17px; font-weight: 400; color: var(--text-strong); margin: 0 0 10px; }
.incident-none { color: var(--muted); font-size: 13px; margin: 0; }

.incident { margin: 0 0 20px; }
.incident:last-child { margin-bottom: 0; }
.incident-title {
  font-size: 15px;
  margin: 0 0 8px;
  color: var(--text-strong);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 10px;
  border: 1px solid currentColor;
  line-height: 1.5;
}
.badge.impact-none { color: var(--muted); }
.badge.impact-minor { color: var(--yellow); }
.badge.impact-major { color: var(--orange); }
.badge.impact-critical { color: var(--red); }
.badge.state-resolved, .badge.state-completed { color: var(--green); }
.badge.state-investigating, .badge.state-identified { color: var(--orange); }
.badge.state-monitoring, .badge.state-scheduled, .badge.state-in_progress { color: var(--blue); }

.incident-updates { list-style: none; margin: 0; padding: 0; }
.incident-update { padding: 6px 0 6px 14px; border-left: 2px solid var(--border); margin-left: 2px; }
.incident-update-head { font-size: 13px; font-weight: 600; color: var(--text-strong); }
.incident-update-body { font-size: 14px; margin: 2px 0 2px; white-space: pre-wrap; }
.incident-update-time { font-size: 11px; color: var(--muted); }
.incident-components { font-size: 12px; color: var(--muted); margin-top: 6px; }

.active-incidents { margin: 18px 0 0; }
.active-incident {
  border: 1px solid var(--border);
  border-left: 3px solid var(--orange);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  background: var(--bg-soft);
}
.active-incident.impact-critical { border-left-color: var(--red); }
.active-incident.impact-minor { border-left-color: var(--yellow); }
.active-incident.impact-none { border-left-color: var(--blue); }

/* ---------- footer ---------- */

.site-footer {
  margin-top: 56px;
  padding: 22px 0 40px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
}
.footer-inner { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.footer-links { display: flex; gap: 16px; }

/* ---------- forms ---------- */

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-strong);
  margin-bottom: 5px;
}
.field .help { font-size: 11px; color: var(--muted); margin-top: 4px; }

input[type="text"],
input[type="password"],
input[type="url"],
input[type="number"],
input[type="datetime-local"],
select,
textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}
textarea { min-height: 92px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(31, 111, 208, 0.15);
}
.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.field-row > .field { flex: 1 1 160px; margin-bottom: 14px; }

.checkbox { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.checkbox input { width: auto; }

/* ---------- admin ---------- */

.admin-body { background: var(--bg-soft); min-height: 100vh; }

.login-wrap {
  max-width: 400px;
  margin: 8vh auto;
  padding: 0 16px;
}
.login-card {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  padding: 26px 24px;
  box-shadow: 0 6px 24px rgba(16, 32, 48, 0.07);
}
.login-logo { display: flex; justify-content: center; margin-bottom: 22px; }
.login-logo img { height: 34px; }
.login-card h1 { font-size: 17px; font-weight: 600; color: var(--text-strong); margin: 0 0 4px; text-align: center; }
.login-card .sub { font-size: 13px; color: var(--muted); text-align: center; margin: 0 0 20px; }

.admin-header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
}
.admin-header-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.admin-header-inner .brand img { height: 26px; }
.admin-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-left: 12px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 24px 0 22px; flex-wrap: wrap; }
.tab {
  border: none;
  background: transparent;
  padding: 10px 14px;
  font: inherit;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text-strong); border-bottom-color: var(--blue); font-weight: 600; }

.panel { display: none; }
.panel.active { display: block; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.panel-head h2 { font-size: 18px; font-weight: 500; color: var(--text-strong); margin: 0; }

.admin-card {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  padding: 20px;
  margin-bottom: 18px;
}
.admin-card h3 { margin: 0 0 14px; font-size: 15px; font-weight: 600; color: var(--text-strong); }

.list-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 16px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.list-row:first-child { border-top: none; }
.list-main { flex: 1 1 260px; min-width: 0; }
.list-title { color: var(--text-strong); font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.list-sub { font-size: 12px; color: var(--muted); margin-top: 3px; word-break: break-word; }
.list-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.pill {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--muted);
}
.pill.type-https { color: var(--blue); }
.pill.type-tcp { color: var(--orange); }

.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 32, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 5vh 16px;
  overflow-y: auto;
  z-index: 50;
}
.dialog-backdrop[hidden] { display: none; }
.dialog {
  background: var(--bg);
  border-radius: 6px;
  width: 100%;
  max-width: 560px;
  padding: 22px 24px 20px;
  box-shadow: 0 12px 40px rgba(12, 20, 28, 0.3);
}
.dialog h3 { margin: 0 0 16px; font-size: 17px; font-weight: 600; color: var(--text-strong); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.alert {
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 14px;
  border: 1px solid;
}
.alert.error { color: var(--red); border-color: rgba(207, 70, 70, 0.4); background: rgba(207, 70, 70, 0.08); }
.alert.success { color: var(--green); border-color: rgba(47, 158, 68, 0.4); background: rgba(47, 158, 68, 0.08); }
.alert[hidden] { display: none; }

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: #16202a;
  color: #fff;
  padding: 11px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  box-shadow: 0 6px 20px rgba(12, 20, 28, 0.32);
  z-index: 80;
}
.toast[hidden] { display: none; }
.toast.error { background: var(--red); }

.stat-grid { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.stat {
  flex: 1 1 150px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  padding: 14px 16px;
}
.stat .label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.stat .value { font-size: 22px; color: var(--text-strong); margin-top: 4px; }

.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.nowrap { white-space: nowrap; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

@media (max-width: 620px) {
  .status-banner { font-size: 17px; flex-direction: column; align-items: flex-start; gap: 4px; }
  .bars { height: 28px; gap: 1px; }
  .component-head { flex-direction: column; align-items: flex-start; gap: 2px; }
  .header-inner { gap: 12px; }
}
