/* =========================================================
   SiteWatch — admin theme
   ========================================================= */

:root {
  --bg:        #f6f7f9;
  --panel:     #ffffff;
  --panel-2:   #fbfcfd;
  --line:      #e3e7ec;
  --line-2:    #eef1f4;
  --text:      #16202e;
  --text-2:    #5b6878;
  --muted:     #8c98a8;

  --brand:     #2f6feb;
  --brand-dk:  #1f57c4;
  --brand-bg:  #eaf1fe;

  --up:        #16855c;
  --up-bg:     #e6f5ef;
  --warn:      #b4690e;
  --warn-bg:   #fdf3e4;
  --down:      #c0392b;
  --down-bg:   #fdeceb;
  --info:      #2f6feb;
  --info-bg:   #eaf1fe;
  --idle:      #8c98a8;
  --idle-bg:   #eff1f4;

  --radius:    10px;
  --radius-sm: 7px;
  --shadow:    0 1px 2px rgba(16,32,46,.06), 0 1px 3px rgba(16,32,46,.04);
  --shadow-lg: 0 4px 16px rgba(16,32,46,.10);
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:      #0f151d;
    --panel:   #161d27;
    --panel-2: #1b2430;
    --line:    #263141;
    --line-2:  #1f2a38;
    --text:    #e6edf5;
    --text-2:  #9dabbd;
    --muted:   #74839a;

    --brand:   #5b93ff;
    --brand-dk:#4a80ea;
    --brand-bg:#1a2740;

    --up:      #38d39f; --up-bg:  #11302a;
    --warn:    #f0b23c; --warn-bg:#332715;
    --down:    #ff6b5e; --down-bg:#3a1c1c;
    --info:    #5b93ff; --info-bg:#1a2740;
    --idle:    #74839a; --idle-bg:#1d2531;
    --shadow:  0 1px 2px rgba(0,0,0,.3);
    --shadow-lg: 0 8px 28px rgba(0,0,0,.45);
  }
}

* { box-sizing: border-box; }

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

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

h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.25; font-weight: 620; letter-spacing: -.01em; }
h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p  { margin: 0 0 1em; }
code, pre, .mono { font-family: var(--mono); font-size: 13px; }

/* ---------- layout ---------- */
.shell { display: flex; min-height: 100vh; }

.side {
  width: 232px;
  flex: 0 0 232px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.side .brand {
  padding: 18px 18px 14px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--line);
}
.side .brand .logo {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), #7b4dff);
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 15px;
  flex: 0 0 30px;
}
.side .brand b { font-size: 15px; letter-spacing: -.01em; }
.side nav { padding: 10px; flex: 1; overflow-y: auto; }
.side nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; margin-bottom: 2px;
  border-radius: var(--radius-sm);
  color: var(--text-2); font-size: 14.5px; font-weight: 500;
  text-decoration: none;
}
.side nav a:hover { background: var(--panel-2); color: var(--text); }
.side nav a.on { background: var(--brand-bg); color: var(--brand); font-weight: 600; }
.side nav a .ic { width: 17px; text-align: center; flex: 0 0 17px; opacity: .85; }
.side nav .pill {
  margin-left: auto; background: var(--down); color: #fff;
  font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 10px;
}
.side nav .sep { height: 1px; background: var(--line); margin: 10px 4px; }
.side nav .cap {
  font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); padding: 12px 11px 5px;
}
.side .foot {
  padding: 12px 14px; border-top: 1px solid var(--line);
  font-size: 12.5px; color: var(--muted);
}
.side .foot a { color: var(--text-2); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 58px; display: flex; align-items: center; gap: 14px;
  padding: 0 24px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { margin: 0; font-size: 17px; font-weight: 620; }
.topbar .sp { flex: 1; }
.wrap { padding: 22px 24px 60px; max-width: 1440px; width: 100%; }

/* ---------- cards ---------- */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.card > .hd {
  padding: 14px 18px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px;
}
.card > .hd h2 { margin: 0; font-size: 15px; font-weight: 620; }
.card > .hd .sp { flex: 1; }
.card > .bd { padding: 18px; }
.card > .bd.tight { padding: 0; }

.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.g-2-1 { grid-template-columns: 2fr 1fr; }
@media (max-width: 1080px) { .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); } .g-2-1, .g3 { grid-template-columns: 1fr; } }
@media (max-width: 720px)  { .g2, .g4 { grid-template-columns: 1fr; } }

/* ---------- stat tiles ---------- */
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 15px 17px; box-shadow: var(--shadow);
}
.stat .k { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.stat .v { font-size: 27px; font-weight: 640; letter-spacing: -.02em; margin-top: 3px; line-height: 1.15; }
.stat .s { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }
.stat.ok  .v { color: var(--up); }
.stat.bad .v { color: var(--down); }
.stat.warn .v { color: var(--warn); }

/* ---------- badges & status ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2.5px 9px; border-radius: 20px;
  font-size: 12px; font-weight: 640; letter-spacing: .01em; white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: 0 0 6px; }
.b-up   { background: var(--up-bg);   color: var(--up); }
.b-slow { background: var(--warn-bg); color: var(--warn); }
.b-down { background: var(--down-bg); color: var(--down); }
.b-idle { background: var(--idle-bg); color: var(--idle); }
.b-info { background: var(--info-bg); color: var(--info); }
.b-crit { background: var(--down-bg); color: var(--down); }
.b-warn { background: var(--warn-bg); color: var(--warn); }

.sev-critical { color: var(--down); font-weight: 700; }
.sev-high     { color: var(--down); font-weight: 640; }
.sev-medium   { color: var(--warn); font-weight: 640; }
.sev-low      { color: var(--text-2); font-weight: 600; }
.sev-info     { color: var(--muted); }

/* ---------- tables ---------- */
table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th {
  text-align: left; font-size: 11.5px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted);
  padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--panel-2);
  white-space: nowrap;
}
table.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; font-size: 14px; }
table.tbl tr:last-child td { border-bottom: 0; }
table.tbl tbody tr:hover { background: var(--panel-2); }
table.tbl td.num, table.tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl .sub { font-size: 12.5px; color: var(--muted); }
.tbl-wrap { overflow-x: auto; }

/* ---------- forms ---------- */
label { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 5px; }
input[type=text], input[type=url], input[type=email], input[type=password],
input[type=number], input[type=search], select, textarea {
  width: 100%; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--panel); color: var(--text);
  font: inherit; font-size: 14px;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 16%, transparent);
}
textarea { min-height: 84px; resize: vertical; line-height: 1.5; }
select { appearance: none; background-image: none; padding-right: 30px; }
.field { margin-bottom: 15px; }
.field .hint { font-size: 12.5px; color: var(--muted); margin-top: 5px; line-height: 1.5; }
.field-row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

.check { display: flex; align-items: flex-start; gap: 9px; margin-bottom: 11px; }
.check input[type=checkbox] { width: 17px; height: 17px; margin: 2px 0 0; accent-color: var(--brand); flex: 0 0 17px; }
.check label { margin: 0; font-weight: 500; color: var(--text); font-size: 14px; }
.check .hint { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

fieldset { border: 0; padding: 0; margin: 0 0 26px; }
fieldset > legend {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); padding: 0; margin-bottom: 12px;
  width: 100%; border-bottom: 1px solid var(--line); padding-bottom: 8px;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8.5px 15px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  font: inherit; font-size: 14px; font-weight: 570; cursor: pointer;
  text-decoration: none; white-space: nowrap;
  transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: var(--panel-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-p { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-p:hover { background: var(--brand-dk); border-color: var(--brand-dk); }
.btn-d { color: var(--down); border-color: color-mix(in srgb, var(--down) 35%, var(--line)); }
.btn-d:hover { background: var(--down-bg); }
.btn-sm { padding: 5.5px 11px; font-size: 13px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btns { display: flex; flex-wrap: wrap; gap: 9px; }

/* ---------- alerts ---------- */
.alert {
  padding: 12px 15px; border-radius: var(--radius-sm); margin-bottom: 14px;
  font-size: 14px; border: 1px solid transparent; white-space: pre-line;
}
.alert-success { background: var(--up-bg);   color: var(--up);   border-color: color-mix(in srgb, var(--up) 25%, transparent); }
.alert-error   { background: var(--down-bg); color: var(--down); border-color: color-mix(in srgb, var(--down) 25%, transparent); }
.alert-warning { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.alert-info    { background: var(--info-bg); color: var(--info); border-color: color-mix(in srgb, var(--info) 25%, transparent); }

/* ---------- misc ---------- */
.muted { color: var(--muted); }
.small { font-size: 13px; }
.xs    { font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mt0 { margin-top: 0; } .mb0 { margin-bottom: 0; }
.mt16 { margin-top: 16px; } .mb16 { margin-bottom: 16px; }
.flex { display: flex; align-items: center; gap: 10px; }
.flex-wrap { flex-wrap: wrap; }
.sp { flex: 1; }
.divider { height: 1px; background: var(--line); margin: 18px 0; }

.empty { padding: 42px 20px; text-align: center; color: var(--muted); }
.empty .big { font-size: 30px; margin-bottom: 6px; opacity: .5; }

.kv { display: grid; grid-template-columns: minmax(120px, 38%) 1fr; gap: 0; }
.kv > div { padding: 8px 0; border-bottom: 1px solid var(--line-2); font-size: 14px; }
.kv > div:nth-child(odd) { color: var(--muted); font-size: 13px; padding-right: 12px; }
.kv > div:last-child, .kv > div:nth-last-child(2) { border-bottom: 0; }

.tag {
  display: inline-block; padding: 1.5px 8px; border-radius: 5px;
  background: var(--panel-2); border: 1px solid var(--line);
  font-size: 12px; color: var(--text-2);
}

/* ---------- site cards on the dashboard ---------- */
.site-card {
  display: block; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 15px 16px; box-shadow: var(--shadow);
  text-decoration: none; color: inherit; transition: border-color .12s, box-shadow .12s, transform .08s;
}
.site-card:hover { text-decoration: none; border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.site-card.is-down { border-left: 3px solid var(--down); }
.site-card.is-slow { border-left: 3px solid var(--warn); }
.site-card.is-up   { border-left: 3px solid var(--up); }
.site-card.is-idle { border-left: 3px solid var(--idle); }
.site-card .nm { font-weight: 620; font-size: 15px; letter-spacing: -.01em; }
.site-card .ur { font-size: 12.5px; color: var(--muted); word-break: break-all; }
.site-card .row { display: flex; align-items: center; gap: 10px; margin-top: 11px; }
.site-card .met { font-size: 12.5px; color: var(--text-2); }
.site-card .met b { color: var(--text); font-weight: 640; }

/* ---------- sparkline / bars ---------- */
.spark { display: flex; align-items: flex-end; gap: 1.5px; height: 26px; }
.spark i {
  display: block; width: 4px; border-radius: 1.5px;
  background: color-mix(in srgb, var(--brand) 55%, transparent); min-height: 2px;
}
.spark i.dn { background: var(--down); }

.uptime-bars { display: flex; gap: 2px; align-items: stretch; height: 30px; }
.uptime-bars i { flex: 1; border-radius: 2px; background: var(--up); min-width: 2px; }
.uptime-bars i.p { background: var(--warn); }
.uptime-bars i.d { background: var(--down); }
.uptime-bars i.n { background: var(--line); }

/* ---------- chart ---------- */
.chart { width: 100%; height: 210px; display: block; }
.chart-legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); margin-top: 8px; flex-wrap: wrap; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 3px; border-radius: 2px; display: inline-block; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a, .tabs button {
  padding: 10px 15px; font-size: 14px; font-weight: 570; color: var(--text-2);
  border: 0; border-bottom: 2px solid transparent; background: none; cursor: pointer;
  text-decoration: none; white-space: nowrap; font-family: inherit;
}
.tabs a:hover, .tabs button:hover { color: var(--text); text-decoration: none; }
.tabs a.on, .tabs button.on { color: var(--brand); border-bottom-color: var(--brand); }

/* ---------- login ---------- */
.login-page {
  min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1100px 500px at 50% -10%, color-mix(in srgb, var(--brand) 12%, var(--bg)), var(--bg));
}
.login-box {
  width: 100%; max-width: 392px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 14px; padding: 32px;
  box-shadow: var(--shadow-lg);
}
.login-box .logo-lg {
  width: 46px; height: 46px; border-radius: 12px; margin: 0 auto 16px;
  background: linear-gradient(135deg, var(--brand), #7b4dff);
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 21px;
}

/* ---------- findings ---------- */
.finding { padding: 13px 0; border-bottom: 1px solid var(--line-2); }
.finding:last-child { border-bottom: 0; }
.finding .t { font-weight: 600; font-size: 14.5px; }
.finding .d { font-size: 13.5px; color: var(--text-2); margin-top: 3px; }
.finding .e {
  font-family: var(--mono); font-size: 12px; color: var(--muted);
  background: var(--panel-2); border: 1px solid var(--line);
  padding: 6px 9px; border-radius: 5px; margin-top: 7px;
  word-break: break-all; max-height: 88px; overflow: auto;
}

/* ---------- meter ---------- */
.meter { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 3px; background: var(--brand); }
.meter.ok > i   { background: var(--up); }
.meter.warn > i { background: var(--warn); }
.meter.bad > i  { background: var(--down); }

/* ---------- status page ---------- */
.status-page { max-width: 880px; margin: 0 auto; padding: 46px 20px 70px; }
.status-hero { text-align: center; margin-bottom: 34px; }
.status-hero .big {
  font-size: 26px; font-weight: 650; letter-spacing: -.02em; margin: 14px 0 6px;
}
.status-row {
  display: flex; align-items: center; gap: 14px; padding: 15px 0;
  border-bottom: 1px solid var(--line-2);
}
.status-row:last-child { border-bottom: 0; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .side { width: 100%; flex: none; height: auto; position: static; border-right: 0; border-bottom: 1px solid var(--line); }
  .side nav { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px; }
  .side nav a { flex: none; }
  .side nav .sep, .side nav .cap, .side .foot { display: none; }
  .wrap { padding: 16px 14px 50px; }
  .topbar { padding: 0 14px; }
}

@media print {
  .side, .topbar, .btns, .btn { display: none !important; }
  .card { break-inside: avoid; box-shadow: none; }
}
