:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e2e5ea;
  --border-strong: #cfd4dc;
  --text: #12151b;
  --text-dim: #5c6472;
  --text-faint: #8a92a0;
  --accent: #2f6df6;
  --accent-weak: #e8f0ff;
  --green: #1a9d54;
  --green-bg: #e3f6ea;
  --red: #d63030;
  --red-bg: #fbe6e6;
  --amber: #b5820a;
  --amber-bg: #fdf1d6;
  --grey: #6b7280;
  --grey-bg: #eceef1;
  --shadow: 0 8px 30px rgba(15, 20, 30, .12);
  --radius: 10px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --surface: #161a21;
    --surface-2: #1d222b;
    --border: #262c37;
    --border-strong: #333a47;
    --text: #e7eaef;
    --text-dim: #9aa3b2;
    --text-faint: #6a7383;
    --accent: #5a8cff;
    --accent-weak: #1a2740;
    --green: #3ecf7c;
    --green-bg: #123021;
    --red: #ff6b6b;
    --red-bg: #3a1717;
    --amber: #e8b64c;
    --amber-bg: #37290d;
    --grey: #9aa3b2;
    --grey-bg: #232833;
    --shadow: 0 10px 40px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Error banner ---------- */
.banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 200;
  background: var(--red); color: #fff;
  padding: .55rem 1rem; font-weight: 600; text-align: center;
  box-shadow: 0 2px 10px rgba(0,0,0,.2);
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 1.5rem;
  padding: .7rem 1.25rem;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .55rem; flex-shrink: 0; }
.brand .logo { color: var(--accent); font-size: 1.2rem; }
.brand h1 { font-size: 1.05rem; font-weight: 700; margin: 0; letter-spacing: -.01em; }

.search-wrap {
  position: relative; flex: 1; max-width: 720px;
  display: flex; align-items: center;
}
.search-ico {
  position: absolute; left: .85rem; color: var(--text-faint);
  font-size: 1.1rem; pointer-events: none;
}
#search {
  width: 100%; font-size: .95rem; font-family: var(--sans);
  padding: .6rem .9rem .6rem 2.3rem;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  outline: none; transition: border-color .12s, box-shadow .12s;
}
#search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-weak);
}
.search-count {
  position: absolute; right: .85rem; color: var(--text-faint);
  font-size: .78rem; font-variant-numeric: tabular-nums;
}

/* ---------- Main ---------- */
main { max-width: 1440px; margin: 0 auto; padding: 1.25rem; }

/* ---------- Tiles ---------- */
.tiles {
  display: grid; gap: .75rem;
  grid-template-columns: repeat(6, 1fr);
  margin-bottom: 1.1rem;
}
.tile {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .8rem .9rem;
  display: flex; flex-direction: column; gap: .15rem;
}
.tile .val {
  font-size: 1.55rem; font-weight: 700; line-height: 1.1;
  font-variant-numeric: tabular-nums; letter-spacing: -.02em;
}
.tile .lbl { font-size: .72rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em; }
.tile.warn { border-color: color-mix(in srgb, var(--red) 45%, var(--border)); background: var(--red-bg); }
.tile.warn .val { color: var(--red); }
.tile.good .val { color: var(--green); }
.tile.amber .val { color: var(--amber); }

/* ---------- Filters ---------- */
.filters {
  display: flex; flex-wrap: wrap; gap: 1.25rem;
  margin-bottom: .9rem;
}
.chip-group { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.chip-label { font-size: .72rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: .05em; margin-right: .15rem; }
.chip {
  font-family: var(--sans); font-size: .82rem; font-weight: 500;
  padding: .32rem .7rem; border-radius: 999px; cursor: pointer;
  background: var(--surface); color: var(--text-dim);
  border: 1px solid var(--border); transition: all .1s;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.is-active {
  background: var(--accent); border-color: var(--accent); color: #fff;
}

/* ---------- Table ---------- */
.table-wrap {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; min-width: 780px; }
thead th {
  text-align: left; font-size: .72rem; font-weight: 600;
  color: var(--text-faint); text-transform: uppercase; letter-spacing: .04em;
  padding: .6rem .9rem; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface); z-index: 1;
}
tbody tr {
  border-bottom: 1px solid var(--border); cursor: pointer;
  transition: background .08s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
tbody tr.is-open { background: var(--accent-weak); }
tbody td { padding: .55rem .9rem; vertical-align: middle; }
td.domain { font-family: var(--mono); font-weight: 600; color: var(--accent); font-size: .86rem; }
td.dim { color: var(--text-dim); }
td.mono { font-family: var(--mono); font-size: .82rem; color: var(--text-dim); }
td.exp-soon { color: var(--amber); font-weight: 600; }
.abuse-tag {
  font-size: .62rem; font-weight: 700; color: var(--red);
  border: 1px solid var(--red); border-radius: 4px; padding: 0 .25rem;
  margin-left: .4rem; text-transform: uppercase;
}

/* ---------- Badges ---------- */
.badge {
  display: inline-block; font-size: .7rem; font-weight: 600;
  padding: .12rem .5rem; border-radius: 999px; text-transform: capitalize;
  white-space: nowrap;
}
.badge.fleet { background: var(--surface-2); color: var(--text-dim); border: 1px solid var(--border); }
.badge.st-live { background: var(--green-bg); color: var(--green); }
.badge.st-down { background: var(--red-bg); color: var(--red); }
.badge.st-degraded, .badge.st-expiring { background: var(--amber-bg); color: var(--amber); }
.badge.st-abuse { background: var(--red-bg); color: var(--red); }
.badge.st-retired { background: var(--grey-bg); color: var(--grey); }

.empty { padding: 2.5rem; text-align: center; color: var(--text-faint); }
.more-wrap { padding: .75rem; text-align: center; }
.btn-more {
  font-family: var(--sans); font-size: .85rem; font-weight: 600;
  padding: .5rem 1.4rem; border-radius: var(--radius); cursor: pointer;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
}
.btn-more:hover { border-color: var(--border-strong); }

/* ---------- Drawer ---------- */
.scrim {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(8, 11, 16, .45);
  animation: fade .12s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 100;
  width: min(560px, 94vw);
  background: var(--surface); border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  transform: translateX(100%); transition: transform .2s cubic-bezier(.2,.7,.2,1);
  overflow-y: auto;
}
.drawer.is-open { transform: translateX(0); }
#drawer-body { padding: 1.25rem 1.4rem 3rem; }

.d-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.d-title { font-family: var(--mono); font-size: 1.2rem; font-weight: 700; word-break: break-all; }
.d-sub { display: flex; gap: .4rem; margin-top: .4rem; flex-wrap: wrap; }
.d-close {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-dim);
  width: 2rem; height: 2rem; border-radius: 8px; cursor: pointer; font-size: 1.1rem;
  flex-shrink: 0; line-height: 1;
}
.d-close:hover { color: var(--text); border-color: var(--border-strong); }

.d-section { margin-top: 1.4rem; }
.d-section > h3 {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-faint); margin: 0 0 .55rem; font-weight: 700;
}
.kv { display: grid; grid-template-columns: 42% 58%; gap: .3rem .5rem; }
.kv dt { color: var(--text-dim); font-size: .82rem; }
.kv dd { margin: 0; font-size: .85rem; word-break: break-word; }
.kv dd.mono { font-family: var(--mono); font-size: .8rem; }

.ns-flag {
  font-size: .7rem; font-weight: 700; color: var(--amber);
  background: var(--amber-bg); padding: .05rem .4rem; border-radius: 4px;
  margin-left: .4rem;
}
.ns-ok { color: var(--green); font-size: .7rem; font-weight: 700; margin-left: .4rem; }

/* Health dots */
.health { display: flex; flex-wrap: wrap; gap: .5rem; }
.hdot {
  display: flex; align-items: center; gap: .4rem;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: .35rem .6rem; font-size: .8rem;
}
.dot { width: .65rem; height: .65rem; border-radius: 50%; flex-shrink: 0; background: var(--grey); }
.dot.ok { background: var(--green); }
.dot.bad { background: var(--red); }
.dot.unk { background: var(--grey); }
.checked-at { font-size: .75rem; color: var(--text-faint); margin-top: .5rem; }

/* Project + conflict cards */
.card {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: .7rem .8rem; margin-bottom: .6rem; background: var(--surface-2);
}
.card .c-title { font-weight: 600; font-size: .9rem; margin-bottom: .3rem; }
.card .c-meta { display: flex; flex-wrap: wrap; gap: .3rem .8rem; font-size: .78rem; color: var(--text-dim); }
.conflict { border-color: color-mix(in srgb, var(--amber) 50%, var(--border)); background: var(--amber-bg); }
.muted { color: var(--text-faint); font-size: .82rem; font-style: italic; }

.d-loading { padding: 2rem; text-align: center; color: var(--text-faint); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) { .tiles { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: .6rem; }
  .search-wrap { max-width: none; order: 3; flex-basis: 100%; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .kv { grid-template-columns: 45% 55%; }
}

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px 26px; box-shadow: var(--shadow); display: flex; flex-direction: column;
}
.login-brand { display: flex; align-items: center; gap: 8px; }
.login-brand .logo { color: var(--accent); font-size: 18px; }
.login-brand h1 { font-size: 17px; margin: 0; }
.login-sub { color: var(--text-dim); margin: 4px 0 20px; font-size: 13px; }
.login-label { font-size: 12px; color: var(--text-dim); margin: 10px 0 4px; }
.login-card input {
  padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface-2); color: var(--text); font-size: 14px; font-family: var(--sans);
}
.login-card input:focus { outline: 2px solid var(--accent-weak); border-color: var(--accent); }
.login-btn {
  margin-top: 18px; padding: 10px 12px; border: none; border-radius: 8px; background: var(--accent);
  color: #fff; font-size: 14px; font-weight: 600; cursor: pointer;
}
.login-btn:disabled { opacity: .6; cursor: default; }
.login-error { margin-top: 12px; color: var(--red); font-size: 13px; }

/* ---------- Logout button ---------- */
.btn-logout {
  margin-left: 12px; padding: 7px 12px; border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface); color: var(--text-dim); font-size: 13px; cursor: pointer; white-space: nowrap;
}
.btn-logout:hover { color: var(--text); border-color: var(--accent); }

/* ---------- Credentials ---------- */
.btn-creds {
  padding: 8px 14px; border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface-2); color: var(--text); font-size: 13px; cursor: pointer; font-weight: 600;
}
.btn-creds:hover { border-color: var(--accent); }
.btn-creds:disabled { opacity: .6; cursor: default; }
.creds-box { margin-top: 8px; }
.creds-h { margin: 14px 0 6px; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--text-dim); }
.creds-val { user-select: all; word-break: break-all; }
