:root {
  --brand: #722F37;
  --brand-dark: #59242b;
  --ok: #15803d;
  --ok-soft: #16a34a;
  --ok-bg: #ecfdf5;
  --warn: #b45309;
  --warn-soft: #d97706;
  --warn-bg: #fffbeb;
  --down: #b91c1c;
  --down-soft: #dc2626;
  --down-bg: #fef2f2;
  --info: #1d4ed8;
  --info-bg: #eff6ff;
  --bg: #f4f1f2;
  --card: #ffffff;
  --text: #1c1618;
  --muted: #6b6164;
  --line: #e8e1e3;
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Inter, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

header { background: var(--brand); color: #fff; }
.header-inner, .wrap {
  max-width: 840px;
  margin: 0 auto;
  padding: 0 20px;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  gap: 12px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}
.brand img {
  width: 40px;
  height: 40px;
  border-radius: 10px;
}
.brand strong { display: block; font-size: 18px; letter-spacing: .04em; }
.brand small { display: block; opacity: .72; font-size: 12px; font-weight: 500; }
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.btn-ghost {
  background: rgba(255,255,255,.12);
  color: #fff;
  border: 1px solid rgba(255,255,255,.22);
}
.btn-ghost:hover { background: rgba(255,255,255,.2); }
.btn-primary { background: var(--brand); color: #fff; border-radius: 10px; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-light { background: #f3f0f1; color: var(--text); border-radius: 10px; }
.btn-danger { background: var(--down-bg); color: var(--down); border-radius: 10px; }

main.wrap { padding-bottom: 80px; }

.banner {
  margin-top: 28px;
  border-radius: var(--radius);
  padding: 26px 28px;
  border: 1px solid transparent;
}
.banner.operational { background: var(--ok-bg); border-color: #bbf7d0; }
.banner.degraded { background: var(--warn-bg); border-color: #fde68a; }
.banner.major { background: var(--down-bg); border-color: #fecaca; }
.banner.maintenance { background: var(--info-bg); border-color: #bfdbfe; }
.banner-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: currentColor;
}
.banner h1 { margin: 0 0 6px; font-size: 28px; letter-spacing: -.02em; }
.banner p { margin: 0; color: var(--muted); font-size: 14px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-top: 20px;
  overflow: hidden;
}
.card-h {
  padding: 14px 20px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.component {
  display: grid;
  grid-template-columns: 1fr auto 6px;
  align-items: center;
  min-height: 56px;
  border-bottom: 1px solid var(--line);
}
.component:last-child { border-bottom: 0; }
.component button.expand {
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: 0;
  text-align: left;
  padding: 16px 18px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  color: inherit;
}
.component .name { padding: 16px 18px; font-weight: 600; }
.chevron {
  width: 16px; height: 16px; color: var(--muted);
  transition: transform .15s ease;
}
.component.open .chevron { transform: rotate(90deg); }
.status-label { padding-right: 14px; font-size: 13px; font-weight: 650; }
.rail { align-self: stretch; }
.status-ok { color: var(--ok); }
.status-degraded { color: var(--warn); }
.status-major { color: var(--down); }
.status-maintenance { color: var(--info); }
.rail-ok { background: var(--ok-soft); }
.rail-degraded { background: var(--warn-soft); }
.rail-major { background: var(--down-soft); }
.rail-maintenance { background: var(--info); }

.children { display: none; background: #faf8f9; border-bottom: 1px solid var(--line); }
.component.open + .children { display: block; }
.child {
  display: grid;
  grid-template-columns: 1fr auto 6px;
  align-items: center;
  padding-left: 44px;
  min-height: 46px;
  border-top: 1px solid var(--line);
  font-size: 14px;
}

.incident { padding: 20px 22px 8px; }
.incident + .incident { border-top: 1px solid var(--line); }
.incident h3 { margin: 0 0 4px; font-size: 18px; }
.meta { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.timeline { border-left: 2px solid var(--line); margin: 0 0 16px 8px; padding-left: 16px; }
.timeline article { margin-bottom: 16px; }
.timeline time {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 4px;
}
.timeline p { margin: 0; font-size: 14px; line-height: 1.5; }

.maint {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 16px 20px;
}
.maint p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.badge {
  flex-shrink: 0;
  background: var(--info-bg);
  color: var(--info);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 999px;
}

.uptime-wrap { padding: 8px 20px 18px; }
.uptime { display: flex; gap: 2px; height: 34px; margin: 8px 0 10px; }
.uptime i { flex: 1; border-radius: 2px; background: var(--ok-soft); }
.uptime i.warn, .uptime i.degraded { background: var(--warn-soft); }
.uptime i.down, .uptime i.major { background: var(--down-soft); }
.uptime-legend {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  gap: 8px;
  flex-wrap: wrap;
}
.legend-keys { display: flex; gap: 12px; }
.legend-keys b { font-weight: 600; }
.legend-keys b.ok { color: var(--ok); }
.legend-keys b.warn { color: var(--warn); }
.legend-keys b.down { color: var(--down); }

footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 28px;
  color: var(--muted);
  font-size: 13px;
}
footer a { color: var(--brand); font-weight: 600; text-decoration: none; }

dialog {
  border: 0;
  border-radius: 16px;
  padding: 0;
  width: min(460px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(28, 22, 24, .45); }
.modal { padding: 24px; }
.modal h2 { margin: 0 0 8px; font-size: 18px; }
.modal p { margin: 0 0 16px; color: var(--muted); font-size: 14px; }
.modal label { display: block; font-size: 12px; font-weight: 700; margin: 0 0 6px; }
.modal input, .modal textarea, .modal select, .field {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  font: inherit;
  margin-bottom: 12px;
  background: #fff;
}
.modal textarea { min-height: 110px; resize: vertical; }
.hp { position: absolute; left: -9999px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.flash { margin: 0 0 12px; padding: 10px 12px; border-radius: 10px; font-size: 13px; }
.flash-ok { background: var(--ok-bg); color: var(--ok); }
.flash-err { background: var(--down-bg); color: var(--down); }
.hidden { display: none !important; }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.login-hero {
  background: var(--brand);
  color: #fff;
  text-align: center;
  padding: 32px 24px;
}
.login-hero img {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  margin-bottom: 12px;
}
.login-hero p { margin: 6px 0 0; opacity: .75; font-size: 14px; }
.login-form {
  padding: 28px 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.login-field { display: block; width: 100%; }
.login-form label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  margin: 0 0 8px;
  color: var(--text);
}
.login-form input {
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  font: inherit;
  background: #fff;
  color: var(--text);
}
.login-form input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(114, 47, 55, .15);
}
.password-wrap { position: relative; display: block; width: 100%; }
.password-wrap input { padding-right: 46px; }
.password-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  border-radius: 8px;
  padding: 0;
}
.password-toggle:hover {
  color: var(--brand);
  background: rgba(114, 47, 55, .08);
}
.login-submit {
  width: 100%;
  margin-top: 4px;
  padding: 12px 14px;
  font-size: 15px;
}
.hint { font-size: 12px; color: var(--muted); margin-top: 12px; }

.admin-shell header .header-inner { max-width: 1080px; }
.admin-shell .wrap { max-width: 1080px; }
.tabs {
  display: flex;
  gap: 6px;
  margin-top: 24px;
  flex-wrap: wrap;
}
.tabs button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.tabs button.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.admin-row {
  display: grid;
  grid-template-columns: 1fr 180px;
  gap: 12px;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
}
.admin-row.child { padding-left: 40px; background: #faf8f9; font-size: 14px; }
.admin-row select { margin: 0; }
.stack { padding: 16px 20px; display: grid; gap: 10px; }
.report {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.report h3 { margin: 0 0 4px; font-size: 15px; }
.report .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.table th, .table td {
  text-align: left;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.table th { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }

@media (max-width: 640px) {
  .banner h1 { font-size: 22px; }
  .admin-row { grid-template-columns: 1fr; }
}
