:root {
  --ink: #11152a;
  --ink-2: #2a3052;
  --muted: #6b7390;
  --line: #e7eaf3;
  --line-2: #d9deec;
  --bg: #f1f3fa;
  --surface: #ffffff;
  --surface-2: #f8f9fd;

  --brand: #3b46d6;
  --brand-ink: #2a32a8;
  --brand-soft: #eef0ff;
  --accent: #08b3c7;

  --ok: #0f9d6b;
  --ok-bg: #e6f7ef;
  --off: #e0455e;
  --off-bg: #fdecef;
  --warn: #b9740c;
  --warn-bg: #fbf0df;
  --mute-bg: #eef0f6;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16, 21, 42, .05), 0 10px 30px -16px rgba(16, 21, 42, .25);
  --shadow-lift: 0 2px 4px rgba(16, 21, 42, .06), 0 18px 40px -18px rgba(16, 21, 42, .32);

  --font: "Hanken Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: "Bricolage Grotesque", var(--font);
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 85% -10%, #e9ecfb 0%, transparent 60%),
    radial-gradient(900px 400px at -5% 0%, #e6f7fa 0%, transparent 55%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

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

h1 { font-family: var(--font-display); font-weight: 800; font-size: 1.75rem; letter-spacing: -.02em; margin: 0; }
h2 { font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; letter-spacing: -.01em; margin: 0 0 14px; }
h3 { margin: 0; }

.mono { font-family: var(--mono); font-size: .86em; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; height: 64px;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: linear-gradient(90deg, var(--brand), var(--accent));
  opacity: .9;
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-logo {
  display: block;
  width: 32px;
  height: 32px;
  object-fit: contain;
  flex: 0 0 32px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-name { font-family: var(--font-display); font-weight: 800; letter-spacing: -.02em; }
.brand-sub { font-size: .68rem; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); }

.nav { display: flex; align-items: center; gap: 6px; }
.nav > a {
  color: var(--ink-2); font-weight: 600; font-size: .92rem; padding: 8px 12px;
  border-radius: 8px; transition: background .15s, color .15s;
}
.nav > a:hover { background: var(--surface-2); text-decoration: none; }
.nav > a.active { color: var(--brand-ink); background: var(--brand-soft); }
.who { display: inline-flex; align-items: center; gap: 7px; margin-left: 10px; color: var(--muted); font-size: .88rem; font-weight: 600; }
.who-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); }
.inline { display: inline; margin: 0; }

/* ---------- Layout ---------- */
.wrap { max-width: 1120px; margin: 0 auto; padding: 30px 28px 60px; }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 22px; flex-wrap: wrap;
}
.page-head .muted { margin: 4px 0 0; font-size: .92rem; }
.page-actions { display: flex; gap: 10px; align-items: center; }
.crumb { margin: 0 0 6px; font-size: .9rem; }

/* ---------- Buttons ---------- */
.btn {
  --bg-btn: var(--surface); --fg-btn: var(--ink);
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font); font-weight: 600; font-size: .92rem;
  padding: 9px 15px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line-2); background: var(--bg-btn); color: var(--fg-btn);
  transition: transform .08s, box-shadow .15s, background .15s, border-color .15s;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .6; cursor: default; transform: none; }
.btn-sm { font-size: .84rem; padding: 7px 11px; border-radius: 9px; }
.btn-block { width: 100%; justify-content: center; padding: 12px; }
.btn-primary {
  border-color: transparent; color: #fff;
  background: linear-gradient(135deg, var(--brand), #4b56e6);
  box-shadow: 0 8px 18px -8px rgba(59, 70, 214, .55);
}
.btn-primary:hover { box-shadow: 0 12px 24px -10px rgba(59, 70, 214, .65); }
.btn-soft { background: var(--brand-soft); border-color: transparent; color: var(--brand-ink); }
.btn-soft:hover { background: #e4e7ff; }
.btn-ghost { background: transparent; border-color: var(--line-2); color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: transparent; border-color: var(--line-2); color: var(--off); }
.btn-danger:hover { background: var(--off-bg); border-color: var(--off); }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow);
  margin-bottom: 18px;
}

/* ---------- Add panel ---------- */
.add-panel[hidden] { display: none; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.field-wide { grid-column: 1 / -1; }
.form-row-actions { grid-column: 1 / -1; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: .82rem; font-weight: 600; color: var(--ink-2); }
.field input, .field select, .field textarea {
  font-family: var(--font); font-size: .95rem; color: var(--ink);
  padding: 11px 13px; border: 1px solid var(--line-2); border-radius: 10px;
  background: var(--surface-2); transition: border-color .15s, box-shadow .15s, background .15s;
}
.field textarea { font-family: var(--mono); font-size: .86rem; resize: vertical; min-height: 96px; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--brand); background: #fff;
  box-shadow: 0 0 0 4px rgba(59, 70, 214, .12);
}
.field-hint { font-size: .78rem; color: var(--muted); }
.inline-form { display: inline-flex; gap: 6px; align-items: center; margin: 0; flex-wrap: wrap; }
.inline-form select, .inline-form input {
  font-family: var(--font); font-size: .84rem; color: var(--ink);
  padding: 6px 9px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface-2);
}
.row-actions { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.self-tag { font-size: .7rem; font-weight: 700; padding: 2px 7px; border-radius: 6px; color: var(--brand-ink); background: var(--brand-soft); margin-left: 6px; }
.note-warn { padding: 11px 14px; border-radius: 11px; margin-bottom: 14px; font-size: .88rem; font-weight: 600; color: var(--warn); background: var(--warn-bg); border: 1px solid #f0dcb8; }

/* ---------- Grid of sites ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 18px; }
.site {
  margin: 0; display: flex; flex-direction: column; gap: 14px;
  animation: rise .4s both; animation-delay: calc(var(--i, 0) * 45ms);
  transition: box-shadow .2s, transform .2s, border-color .2s;
}
.site:hover { box-shadow: var(--shadow-lift); transform: translateY(-2px); border-color: var(--line-2); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.site-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.site-name { font-family: var(--font-display); font-weight: 700; font-size: 1.12rem; letter-spacing: -.01em; }
.site-name a { color: var(--ink); }
.site-name a:hover { color: var(--brand); text-decoration: none; }
.site-url { display: block; font-size: .82rem; color: var(--muted); margin-top: 2px; }

/* status dot */
.dot {
  display: inline-flex; align-items: center; gap: 7px; flex: none;
  font-size: .76rem; font-weight: 700; padding: 5px 10px 5px 8px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: .03em;
}
.dot i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-online { color: var(--ok); background: var(--ok-bg); }
.dot-online i { background: var(--ok); box-shadow: 0 0 0 0 rgba(15, 157, 107, .5); animation: pulse 2s infinite; }
.dot-offline { color: var(--off); background: var(--off-bg); }
.dot-offline i { background: var(--off); }
.dot-unknown { color: var(--muted); background: var(--mute-bg); }
.dot-unknown i { background: var(--muted); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(15,157,107,.45); } 70% { box-shadow: 0 0 0 6px rgba(15,157,107,0); } 100% { box-shadow: 0 0 0 0 rgba(15,157,107,0); } }

.site-meta {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1px;
  background: var(--line); border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden;
}
.site-meta > div { background: var(--surface-2); padding: 9px 12px; display: flex; flex-direction: column; gap: 1px; }
.site-meta span { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.site-meta b { font-weight: 700; font-size: .95rem; }

.updates { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pill { font-size: .78rem; font-weight: 700; padding: 4px 11px; border-radius: 999px; }
.pill-warn { color: var(--warn); background: var(--warn-bg); }
.pill-ok { color: var(--ok); background: var(--ok-bg); }
.pill-mute { color: var(--muted); background: var(--mute-bg); }
.tag { font-family: var(--mono); font-size: .72rem; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); padding: 3px 8px; border-radius: 7px; }

.site-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding-top: 4px; border-top: 1px solid var(--line); }
.site-actions .push { margin-left: auto; }
.detail-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }

.site-foot { font-size: .74rem; color: var(--muted); }

/* ---------- Detail ---------- */
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.cols .card { margin-bottom: 0; }
.kv { width: 100%; border-collapse: collapse; }
.kv th { text-align: left; font-weight: 600; color: var(--muted); font-size: .85rem; padding: 8px 0; width: 40%; vertical-align: top; }
.kv td { padding: 8px 0; border-bottom: 1px solid var(--line); }
.kv tr:last-child td { border-bottom: none; }
.ul { margin: 6px 0 12px; padding-left: 18px; }
.ul li { margin: 2px 0; font-size: .85rem; }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table thead th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line-2); }
.table tbody td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: none; }
.table code { font-family: var(--mono); font-size: .82em; color: var(--ink-2); background: var(--surface-2); padding: 2px 6px; border-radius: 6px; }
.table-log td { font-size: .85rem; }
.lvl-warning td { background: #fffaf2; }
.badge { font-size: .72rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.badge-on { color: var(--ok); background: var(--ok-bg); }
.badge-off { color: var(--muted); background: var(--mute-bg); }
.lvl-tag { font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 6px; text-transform: uppercase; }
.lvl-tag-info { color: var(--brand-ink); background: var(--brand-soft); }
.lvl-tag-warning { color: var(--warn); background: var(--warn-bg); }
.lvl-tag-notice { color: var(--ok); background: var(--ok-bg); }

/* ---------- Empty / flash ---------- */
.empty { text-align: center; padding: 70px 20px; }
.empty-logo { display: block; width: 64px; height: 64px; object-fit: contain; margin: 0 auto; }
.empty h2 { font-size: 1.3rem; margin: 12px 0 6px; }

.flash { padding: 12px 16px; border-radius: 11px; margin-bottom: 18px; font-weight: 600; font-size: .92rem; border: 1px solid transparent; }
.flash-success { color: var(--ok); background: var(--ok-bg); border-color: #bfead7; }
.flash-error { color: var(--off); background: var(--off-bg); border-color: #f6cdd5; }

/* ---------- Login ---------- */
.login-shell { min-height: 100vh; display: grid; place-content: center; gap: 14px; padding: 24px; }
.login-card {
  width: 340px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; padding: 32px 28px; box-shadow: var(--shadow-lift);
  position: relative; overflow: hidden;
}
.login-card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--brand), var(--accent));
}
.login-brand { font-family: var(--font-display); font-weight: 800; font-size: 1.4rem; display: flex; align-items: center; gap: 10px; letter-spacing: -.02em; }
.login-tag { color: var(--muted); font-size: .85rem; margin: 4px 0 22px; }
.form { display: flex; flex-direction: column; gap: 14px; }
.login-note { text-align: center; color: var(--muted); font-size: .78rem; }

/* ---------- Footer ---------- */
.foot { margin-top: 40px; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: .8rem; display: flex; gap: 8px; }
.foot-sep { opacity: .5; }

@media (max-width: 760px) {
  .form-grid, .cols { grid-template-columns: 1fr; }
  .wrap { padding: 22px 16px 50px; }
  .topbar { padding: 0 16px; }
  .brand-sub { display: none; }
}
