@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

/* ==========================================================================
   WC Monitor - Western Cloud
   Brand: cyan #26A5E0 / charcoal #1E1E1E, taken from the westerncloud.co.za
   wordmark. Dense by design: the dashboard is an instrument panel, not a
   marketing page, so rows are tight and numbers are tabular.
   ========================================================================== */

:root {
  --brand:        #26a5e0;
  --brand-dark:   #1b8ec4;
  --brand-tint:   #e8f5fc;
  --ink:          #1e1e1e;
  --ink-2:        #4a4f55;
  --muted:        #7b8288;

  --bg:           #f7f8f9;
  --surface:      #ffffff;
  --surface-2:    #fbfcfc;
  --line:         #e3e7ea;
  --line-strong:  #cfd5da;

  --up:           #12924c;
  --up-bg:        #e8f6ee;
  --warn:         #e07c00;
  --warn-bg:      #fdf2e3;
  --down:         #d32f2f;
  --down-bg:      #fdecec;
  --idle:         #98a1a8;
  --idle-bg:      #f0f2f4;

  --r:            5px;
  --row-h:        32px;
  --shadow:       0 1px 2px rgba(20,30,40,.05);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 14px/1.45 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

.mono, td.num, .num {
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------- top bar --- */

.topbar {
  display: flex; align-items: center; gap: 22px;
  height: 52px; padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}

.brand-lockup { display: flex; align-items: center; gap: 9px; white-space: nowrap; }
.brand-lockup:hover { text-decoration: none; }
.brand-lockup img { width: 26px; height: 26px; border-radius: 50%; display: block; }
.brand-lockup .wm {
  font-weight: 700; font-size: 16px; letter-spacing: -.015em; color: var(--ink);
}
.brand-lockup .wm b { color: var(--brand); font-weight: 700; }
.brand-lockup .sub {
  font-size: 10px; letter-spacing: .09em; text-transform: uppercase;
  color: var(--muted); font-weight: 600; border-left: 1px solid var(--line-strong);
  padding-left: 9px; margin-left: 2px;
}

.topbar nav { display: flex; gap: 2px; margin-right: auto; }
.topbar nav a {
  padding: 6px 11px; border-radius: var(--r); color: var(--ink-2);
  font-weight: 500; font-size: 13.5px;
}
.topbar nav a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.topbar nav a.active { background: var(--brand-tint); color: var(--brand-dark); font-weight: 600; }

.who { display: flex; align-items: center; gap: 9px; font-size: 12.5px; color: var(--muted); }
.who .email { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role {
  font-size: 10px; text-transform: uppercase; letter-spacing: .06em;
  padding: 2px 6px; border-radius: 3px; font-weight: 700;
  background: var(--idle-bg); color: var(--ink-2);
}
.role.admin { background: var(--brand-tint); color: var(--brand-dark); }

main { max-width: 1680px; margin: 0 auto; padding: 16px; }

/* ------------------------------------------------------------- headings -- */

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 14px; flex-wrap: wrap;
}
.page-head h1 { font-size: 19px; margin: 0; font-weight: 650; letter-spacing: -.01em; }
.page-head .sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; }

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

/* --------------------------------------------------------------- buttons - */

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: var(--r); border: 1px solid transparent;
  background: var(--brand); color: #fff; font-weight: 600; font-size: 13.5px;
  cursor: pointer; font-family: inherit; line-height: 1.2;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn.ghost { background: var(--surface); color: var(--ink-2); border-color: var(--line-strong); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.danger { background: var(--down); }
.btn.danger:hover { background: #b62222; }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }

/* ----------------------------------------------------------- stat strip -- */

.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 8px; margin-bottom: 12px;
}
.stat {
  padding: 9px 12px; border-left: 3px solid var(--line-strong);
  display: flex; flex-direction: column; justify-content: center;
}
.stat .n {
  font-size: 22px; font-weight: 650; line-height: 1.1;
  font-family: 'IBM Plex Mono', monospace; font-variant-numeric: tabular-nums;
}
.stat .l {
  font-size: 10.5px; color: var(--muted); text-transform: uppercase;
  letter-spacing: .07em; margin-top: 2px; font-weight: 600;
}
.stat.s-up      { border-left-color: var(--up); }    .stat.s-up .n      { color: var(--up); }
.stat.s-warn    { border-left-color: var(--warn); }  .stat.s-warn .n    { color: var(--warn); }
.stat.s-down    { border-left-color: var(--down); }  .stat.s-down .n    { color: var(--down); }
.stat.s-brand   { border-left-color: var(--brand); } .stat.s-brand .n   { color: var(--brand-dark); }

/* ------------------------------------------------------------- toolbar --- */

.toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 10px; margin-bottom: 10px;
}
.chips { display: flex; gap: 4px; flex-wrap: wrap; }
.chip {
  padding: 4px 10px; border-radius: 20px; font-size: 12.5px; font-weight: 600;
  border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--ink-2); cursor: pointer; font-family: inherit; line-height: 1.3;
}
.chip:hover { background: var(--surface-2); }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip .c { opacity: .65; margin-left: 3px; font-family: 'IBM Plex Mono', monospace; }
.chip.on .c { opacity: .8; }
.chip.k-down.on  { background: var(--down); border-color: var(--down); }
.chip.k-warn.on  { background: var(--warn); border-color: var(--warn); }

.search {
  flex: 1; min-width: 160px; max-width: 320px; margin-left: auto;
  padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: var(--r);
  font: inherit; font-size: 13px; background: var(--surface); color: var(--ink);
}
.search:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }

/* ========================================================== monitor grid == */
/* The density target: ~30 sites legible without scrolling.                  */

.grid-wrap { overflow-x: auto; }

table.mon { width: 100%; border-collapse: collapse; font-size: 13px; }

table.mon thead th {
  text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); font-weight: 700; padding: 7px 8px;
  border-bottom: 1px solid var(--line-strong); background: var(--surface-2);
  position: sticky; top: 52px; z-index: 10; white-space: nowrap;
}
table.mon thead th.r, table.mon td.r { text-align: right; }
table.mon thead th.c, table.mon td.c { text-align: center; }

table.mon tbody tr {
  height: var(--row-h); border-bottom: 1px solid var(--line);
  border-left: 3px solid transparent;
}
table.mon tbody tr:hover { background: var(--surface-2); }
table.mon td { padding: 3px 8px; white-space: nowrap; }

/* Problem rows carry a wash so they read instantly in a wall of green. */
tr.r-down     { background: var(--down-bg); border-left-color: var(--down); }
tr.r-down:hover { background: #fbe2e2; }
tr.r-degraded { background: var(--warn-bg); border-left-color: var(--warn); }
tr.r-degraded:hover { background: #fbeacf; }
tr.r-up       { border-left-color: var(--up); }
tr.r-paused   { border-left-color: var(--idle); opacity: .6; }
tr.r-unknown  { border-left-color: var(--line-strong); }

.dot {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  background: var(--idle); flex: none;
}
.dot.up { background: var(--up); }
.dot.down { background: var(--down); box-shadow: 0 0 0 3px rgba(211,47,47,.18); }
.dot.degraded { background: var(--warn); box-shadow: 0 0 0 3px rgba(224,124,0,.16); }
.dot.paused { background: var(--idle); }

.site { display: flex; align-items: center; gap: 8px; min-width: 0; }
.site .name {
  font-weight: 600; color: var(--ink); max-width: 320px;
  overflow: hidden; text-overflow: ellipsis;
}
.site .name:hover { color: var(--brand-dark); }
.site .path { color: var(--muted); font-size: 11.5px; }

.tag {
  display: inline-block; padding: 1px 6px; border-radius: 3px; font-size: 11px;
  background: var(--idle-bg); color: var(--ink-2); font-weight: 500;
  max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  vertical-align: middle;
}

.code { font-weight: 600; font-family: 'IBM Plex Mono', monospace; font-size: 12.5px; }
.code.ok { color: var(--up); }
.code.bad { color: var(--down); }
.code.none { color: var(--muted); }

.ssl { font-family: 'IBM Plex Mono', monospace; font-size: 12.5px; font-weight: 500; }
.ssl.ok { color: var(--ink-2); }
.ssl.soon { color: var(--warn); font-weight: 700; }
.ssl.crit { color: var(--down); font-weight: 700; }
.ssl.none { color: var(--muted); }

.why {
  color: var(--down); font-size: 11.5px; max-width: 360px;
  overflow: hidden; text-overflow: ellipsis; display: inline-block;
  vertical-align: middle;
}
tr.r-degraded .why { color: var(--warn); }

/* Inline 24h bar - one mark per check, newest right. */
.bars { display: inline-flex; align-items: flex-end; gap: 1px; height: 16px; }
.bars i { width: 3px; border-radius: .5px; background: var(--up); }
.bars i.f { background: var(--down); }
.bars i.w { background: var(--warn); }

.pct { font-size: 12px; font-family: 'IBM Plex Mono', monospace; color: var(--ink-2); }
.pct.low { color: var(--down); font-weight: 600; }

/* ----------------------------------------------------------- pills ------- */

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  padding: 2px 7px; border-radius: 3px; white-space: nowrap;
}
.pill.ok { background: var(--up-bg); color: var(--up); }
.pill.bad { background: var(--down-bg); color: var(--down); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.muted, .pill.unknown { background: var(--idle-bg); color: var(--muted); }

/* ----------------------------------------------------------- tables ------ */

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); font-weight: 700; padding: 9px 12px;
  border-bottom: 1px solid var(--line-strong); background: var(--surface-2);
}
td { padding: 9px 12px; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: none; }
td.num { text-align: right; }
.table-wrap { overflow-x: auto; }

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

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 13px; }
label.field { display: block; }
label.field > span {
  display: block; font-size: 11px; color: var(--ink-2); margin-bottom: 4px;
  font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
}
input[type=text], input[type=url], input[type=email], input[type=password],
input[type=number], select, textarea {
  width: 100%; padding: 7px 10px; border-radius: var(--r);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font: inherit; font-size: 13.5px;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint);
}
textarea { min-height: 66px; resize: vertical; font-size: 13px; }
.hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; line-height: 1.4; }
.form-actions { display: flex; gap: 9px; align-items: center; margin-top: 16px; flex-wrap: wrap; }

fieldset { border: none; padding: 0; margin: 0 0 20px; }
fieldset > legend {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--brand-dark); font-weight: 700; padding: 0 0 9px;
  width: 100%; border-bottom: 1px solid var(--line); margin-bottom: 13px;
}

/* Check toggles - a monitor runs several checks at once, so these read as a
   list of switches rather than scattered checkboxes. */
.toggles { display: grid; grid-template-columns: repeat(auto-fit, minmax(255px, 1fr)); gap: 8px; }
.toggle {
  display: flex; align-items: flex-start; gap: 9px; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2);
  cursor: pointer;
}
.toggle:hover { border-color: var(--line-strong); }
.toggle input { width: 16px; height: 16px; margin: 1px 0 0; accent-color: var(--brand); flex: none; }
.toggle .t { font-weight: 600; font-size: 13px; display: block; }
.toggle .d { font-size: 11.5px; color: var(--muted); display: block; margin-top: 1px; line-height: 1.35; }
.toggle:has(input:checked) { background: var(--brand-tint); border-color: #b9e0f3; }

.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.check input { width: 15px; height: 15px; accent-color: var(--brand); }

.pad { padding: 14px; }
.split { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; align-items: start; }
@media (max-width: 980px) { .split { grid-template-columns: 1fr; } }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty h3 { margin: 0 0 6px; color: var(--ink); font-size: 15px; }

.flash {
  max-width: 1680px; margin: 12px auto 0; padding: 9px 13px; border-radius: var(--r);
  background: var(--up-bg); color: var(--up); font-weight: 500; font-size: 13.5px;
  border-left: 3px solid var(--up);
}
.flash.bad { background: var(--down-bg); color: var(--down); border-left-color: var(--down); }

.foot { text-align: center; color: var(--muted); font-size: 11.5px; padding: 18px; }

/* -------------------------------------------------------------- login ---- */

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--bg); }
.login { width: 100%; max-width: 360px; padding: 26px; }
.login .lock { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 4px; }
.login .lock img { width: 34px; height: 34px; border-radius: 50%; }
.login .lock .wm { font-weight: 700; font-size: 19px; letter-spacing: -.015em; }
.login .lock .wm b { color: var(--brand); }
.login .sub { text-align: center; color: var(--muted); font-size: 12px; margin: 0 0 20px;
              text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.login label.field { margin-bottom: 13px; }
.login .btn { width: 100%; justify-content: center; padding: 9px; }
.err {
  background: var(--down-bg); color: var(--down); padding: 9px 12px; border-radius: var(--r);
  font-size: 13px; margin-bottom: 14px; border-left: 3px solid var(--down);
}

/* Rows are already tight; on a narrow screen drop the optional columns. */
@media (max-width: 1100px) { .opt-1 { display: none; } }
@media (max-width: 860px)  { .opt-2 { display: none; } }
