/* SiteGuardian Cloud — plain CSS, no build step. */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #111827;
  --text-2: #4b5563;
  --muted: #6b7280;
  --line: #e5e7eb;
  --line-2: #d1d5db;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --ok: #15803d;
  --ok-bg: #dcfce7;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --bad: #b91c1c;
  --bad-bg: #fee2e2;
  --info: #1d4ed8;
  --info-bg: #dbeafe;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(17, 24, 39, 0.05);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 4px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h2 { font-size: 1.05rem; margin: 0 0 12px; }
h3 { font-size: 0.95rem; margin: 16px 0 8px; }
code { background: #f3f4f6; padding: 1px 5px; border-radius: 4px; font-size: 0.9em; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; }
.mt { margin-top: 16px; }
.text-ok { color: var(--ok); }
.text-warn { color: var(--warn); }
.text-bad { color: var(--bad); }

/* ---------- App shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: #0f172a; color: #cbd5e1; padding: 20px 14px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 1.05rem; padding: 0 8px; }
.brand:hover { text-decoration: none; }
.agency-name { color: #94a3b8; font-size: 0.82rem; padding: 4px 8px 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a { color: #cbd5e1; padding: 8px 10px; border-radius: 7px; font-weight: 500; }
.sidebar nav a:hover { background: #1e293b; color: #fff; text-decoration: none; }
.sidebar nav a.active { background: #1e293b; color: #fff; box-shadow: inset 3px 0 0 #60a5fa; }
.sidebar-foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid #1e293b; font-size: 0.85rem; }
.me { color: #e2e8f0; margin-bottom: 6px; }
.me span { display: block; color: #94a3b8; font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; }
.sidebar .link { color: #94a3b8; }
.main { padding: 28px 32px 48px; max-width: 1240px; width: 100%; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 0; }
.crumbs { font-size: 0.85rem; color: var(--muted); margin: 0 0 4px !important; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions form { margin: 0; }
.section-title { margin: 24px 0 12px; }

/* ---------- Cards, grids ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; box-shadow: var(--shadow); }
.card-alert { border-color: #fecaca; box-shadow: inset 4px 0 0 var(--bad); }
.card-danger { border-color: #fecaca; }
.card.empty ol { padding-left: 20px; color: var(--text-2); }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 + .card, .grid-2 + .grid-2, .grid-2 + section { margin-top: 18px; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi span { display: block; color: var(--muted); font-size: 0.82rem; }
.kpi strong { font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.kpi .small-strong { font-size: 1rem; display: block; margin-top: 4px; }
.kpi-bad { border-color: #fecaca; background: #fff7f7; }
.kpi-bad strong { color: var(--bad); }
.kpi-warn strong { color: var(--warn); }
.kpi-ok strong { color: var(--ok); }

.client-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin-bottom: 18px; }
.client-card { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; color: var(--text); box-shadow: var(--shadow); transition: border-color .15s, transform .15s; }
.client-card:hover { text-decoration: none; border-color: var(--line-2); transform: translateY(-1px); }
.client-card.is-down { border-color: #fca5a5; box-shadow: inset 4px 0 0 var(--bad); }
.client-card.is-warn { box-shadow: inset 4px 0 0 #f59e0b; }
.client-card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.client-card-head strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.client-card-uptime { font-size: 1.5rem; font-weight: 700; margin: 10px 0 4px; font-variant-numeric: tabular-nums; }
.client-card-uptime span { display: block; font-size: 0.78rem; font-weight: 400; color: var(--muted); }
.client-card-meta { display: flex; gap: 10px; font-size: 0.85rem; color: var(--text-2); }
.dots { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px; }
.dots span { width: 10px; height: 10px; border-radius: 3px; background: #d1d5db; }
.dots .dot-up { background: #22c55e; }
.dots .dot-down { background: #ef4444; }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table th { text-align: left; color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: .03em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table.compact td { padding: 6px 10px; }
.sub { color: var(--muted); font-size: 0.82rem; word-break: break-all; }
.spark-cell { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.spark-cell span { color: var(--text-2); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.spark-line { fill: none; stroke: var(--primary); stroke-width: 1.5; }
.spark-fail { stroke: #ef4444; stroke-width: 1.5; opacity: .6; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 0.78rem; font-weight: 600; white-space: nowrap; line-height: 1.6; }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-ok { color: var(--ok); background: var(--ok-bg); }
.badge-warn { color: var(--warn); background: var(--warn-bg); }
.badge-bad { color: var(--bad); background: var(--bad-bg); }
.badge-info { color: var(--info); background: var(--info-bg); }
.badge-muted { color: var(--text-2); background: #f3f4f6; }
h1 .badge { font-size: 0.8rem; }

/* ---------- Forms ---------- */
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack > .btn:not(.btn-block) { align-self: flex-start; }
label > .label-text { display: block; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > label { flex: 1 1 180px; }
.row.inline { align-items: center; }
.row.inline input { flex: 1 1 240px; }
label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 0.88rem; color: var(--text); }
label small { font-weight: 400; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
input, select, textarea { font: inherit; font-weight: 400; color: var(--text); background: #fff; border: 1px solid var(--line-2); border-radius: 7px; padding: 8px 10px; width: 100%; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); }
input[type=color] { padding: 2px; height: 38px; }
input:focus, select:focus, textarea:focus { outline: 2px solid #93c5fd; outline-offset: 0; border-color: var(--primary); }
textarea { resize: vertical; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; font-size: 0.9rem; padding: 8px 14px; border-radius: 7px; border: 1px solid var(--line-2); background: #fff; color: var(--text); cursor: pointer; text-decoration: none; }
.btn:hover { background: #f9fafb; text-decoration: none; }
.btn:disabled { opacity: .6; cursor: wait; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: #fff; border-color: #fca5a5; color: var(--bad); }
.btn-danger:hover { background: var(--bad-bg); }
.btn-block { width: 100%; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--primary); cursor: pointer; }
.link:hover { text-decoration: underline; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid; font-size: 0.92rem; }
.flash ul { margin: 6px 0 0; padding-left: 18px; }
.flash-success { background: var(--ok-bg); border-color: #86efac; color: #14532d; }
.flash-error { background: var(--bad-bg); border-color: #fca5a5; color: #7f1d1d; }
.flash-warn { background: var(--warn-bg); border-color: #fcd34d; color: #78350f; }

.tabs { display: flex; gap: 4px; background: #e5e7eb; padding: 3px; border-radius: 8px; }
.tabs a { padding: 6px 12px; border-radius: 6px; color: var(--text-2); font-weight: 600; font-size: 0.88rem; }
.tabs a.active { background: #fff; color: var(--text); box-shadow: var(--shadow); }
.tabs a:hover { text-decoration: none; }

/* ---------- Charts ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .line { fill: none; stroke: var(--primary); stroke-width: 1.6; }
.chart .fail { stroke: #ef4444; stroke-width: 2; opacity: .55; }
.legend { font-size: 0.8rem; color: var(--muted); display: flex; gap: 8px; align-items: center; margin: 8px 0 0; }
.lg-line { width: 16px; height: 2px; background: var(--primary); display: inline-block; }
.lg-fail { width: 2px; height: 12px; background: #ef4444; display: inline-block; margin-left: 10px; }

.facts { display: grid; grid-template-columns: 120px 1fr; gap: 8px 12px; margin: 0 0 10px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

.timeline { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--line); }
.timeline li { padding: 0 0 14px 16px; position: relative; font-size: 0.9rem; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--line-2); }
.timeline .ev-opened::before { background: #ef4444; }
.timeline .ev-resolved::before { background: #22c55e; }
.timeline .ev-acknowledged::before { background: #f59e0b; }
.timeline time { display: block; color: var(--muted); font-size: 0.8rem; }

/* ---------- Auth pages ---------- */
.bare-main { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 16px; }
.auth-card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 32px; width: 100%; max-width: 420px; box-shadow: 0 10px 30px rgba(15, 23, 42, .06); }
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; margin-bottom: 20px; }
.auth-card h1 { font-size: 1.35rem; }

/* ---------- Reports ---------- */
.report-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.report-frame { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.report { --brand: #2563eb; padding: 32px; border-top: 6px solid var(--brand); }
.report h1 { font-size: 1.5rem; margin-top: 12px; }
.report h2 { margin-top: 26px; font-size: 1rem; color: var(--brand); text-transform: uppercase; letter-spacing: .04em; }
.report-sub { color: var(--text-2); margin: 0; }
.report-logo { max-height: 44px; max-width: 220px; }
.report-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 22px; }
.report-kpis div { border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.report-kpis span { display: block; color: var(--muted); font-size: 0.8rem; }
.report-kpis strong { font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.prose { white-space: pre-wrap; }
.report-foot { margin-top: 32px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.82rem; }
.public-report { background: var(--bg); }
.report-public-wrap { max-width: 900px; margin: 32px auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.report-public-actions { display: flex; justify-content: flex-end; padding: 12px 16px 0; }

/* ---------- Responsive & print ---------- */
@media (max-width: 1000px) {
  .grid-2, .report-layout { grid-template-columns: 1fr; }
  .kpis, .report-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; }
  .agency-name, .sidebar-foot .me { display: none; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-foot { margin: 0 0 0 auto; border: 0; padding: 0; }
  .main { padding: 18px 14px 40px; }
  .table { display: block; overflow-x: auto; }
}
@media print {
  .sidebar, .page-head .actions, .report-layout > aside, .report-public-actions { display: none !important; }
  .shell, .report-layout { display: block; }
  body, .public-report { background: #fff; }
  .report-public-wrap, .report-frame { border: 0; margin: 0; }
}
