:root {
  --bg: #07080c;
  --bg-2: #0c0e15;
  --surface: rgba(255, 255, 255, 0.035);
  --surface-hi: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.09);
  --border-hi: rgba(255, 255, 255, 0.16);
  --text: #eef1f7;
  --muted: #8b93a7;
  --faint: #5c6478;
  --accent: #6c8cff;
  --accent-2: #a76cff;
  --ok: #3ddc97;
  --warn: #ffb648;
  --bad: #ff5f6d;
  --radius: 16px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  --font: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

/* Ambient background wash */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 600px at 12% -10%, rgba(108, 140, 255, 0.16), transparent 60%),
    radial-gradient(800px 500px at 88% 8%, rgba(167, 108, 255, 0.13), transparent 60%),
    linear-gradient(180deg, var(--bg-2), var(--bg) 55%);
}

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

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.gate-card {
  width: 100%;
  max-width: 420px;
  background: linear-gradient(180deg, rgba(255,255,255,0.055), rgba(255,255,255,0.02));
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 40px 34px 32px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
  text-align: center;
  animation: rise 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

.keymark {
  width: 76px;
  height: 76px;
  margin: 0 auto 22px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  box-shadow: 0 12px 34px rgba(108, 140, 255, 0.36);
  position: relative;
}

.keymark svg { width: 38px; height: 38px; stroke: #fff; }

.keymark.waiting { animation: pulse 1.5s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 12px 34px rgba(108, 140, 255, 0.36); }
  50%      { box-shadow: 0 12px 52px rgba(108, 140, 255, 0.85); transform: scale(1.04); }
}

.gate h1 {
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.gate .lede {
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 14.5px;
}

.field {
  width: 100%;
  padding: 13px 15px;
  margin-bottom: 12px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  transition: border-color 0.18s, box-shadow 0.18s;
}

.field:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108, 140, 255, 0.16);
}

.field::placeholder { color: var(--faint); }

.btn {
  width: 100%;
  padding: 13px 18px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  transition: transform 0.15s, filter 0.15s, opacity 0.15s;
}

.btn:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.1); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn.ghost {
  background: var(--surface-hi);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 500;
}

.btn.small { width: auto; padding: 8px 14px; font-size: 13.5px; }

.linkbtn {
  background: none;
  border: none;
  color: var(--muted);
  font-family: var(--font);
  font-size: 13.5px;
  cursor: pointer;
  padding: 10px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.linkbtn:hover { color: var(--text); }

.msg {
  margin-top: 16px;
  padding: 11px 14px;
  border-radius: 11px;
  font-size: 13.5px;
  display: none;
  text-align: left;
}

.msg.show { display: block; animation: rise 0.3s ease; }
.msg.err { background: rgba(255, 95, 109, 0.12); border: 1px solid rgba(255,95,109,0.3); color: #ffb3b8; }
.msg.ok  { background: rgba(61, 220, 151, 0.12); border: 1px solid rgba(61,220,151,0.3); color: #94f0c6; }
.msg.info{ background: rgba(108, 140, 255, 0.11); border: 1px solid rgba(108,140,255,0.28); color: #bcc9ff; }

.foot {
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--faint);
  font-family: var(--mono);
}

/* --------------------------------------------------------------- dashboard */

.shell { max-width: 1240px; margin: 0 auto; padding: 28px 24px 60px; }

header.top {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 0 26px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 13px; margin-right: auto; }

.brand-mark {
  width: 42px; height: 42px;
  border-radius: 13px;
  display: grid; place-items: center;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 22px rgba(108, 140, 255, 0.32);
}
.brand-mark svg { width: 21px; height: 21px; stroke: #fff; }

.brand h1 { margin: 0; font-size: 19px; font-weight: 650; letter-spacing: -0.02em; }
.brand p { margin: 0; font-size: 12.5px; color: var(--muted); font-family: var(--mono); }

.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12.5px;
  color: var(--muted);
}

.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 9px var(--ok); }

section { margin-bottom: 34px; animation: rise 0.5s cubic-bezier(0.22,1,0.36,1) backwards; }
section:nth-of-type(2) { animation-delay: 0.06s; }
section:nth-of-type(3) { animation-delay: 0.12s; }
section:nth-of-type(4) { animation-delay: 0.18s; }

.sec-head {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 14px;
}

.sec-head h2 {
  margin: 0;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
}

.sec-head .rule { flex: 1; height: 1px; background: var(--border); }

.grid { display: grid; gap: 14px; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid.tiles { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.grid.keys  { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  backdrop-filter: blur(14px);
  transition: border-color 0.2s, transform 0.2s, background 0.2s;
}

.card:hover { border-color: var(--border-hi); }

/* stat cards */
.stat .label {
  font-size: 11.5px; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--faint); margin-bottom: 8px;
}
.stat .value { font-size: 27px; font-weight: 650; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.stat .value small { font-size: 14px; color: var(--muted); font-weight: 500; margin-left: 3px; }
.stat .sub { font-size: 12.5px; color: var(--muted); margin-top: 3px; font-family: var(--mono); }

.meter { height: 5px; border-radius: 3px; background: rgba(255,255,255,0.07); margin-top: 12px; overflow: hidden; }
.meter i {
  display: block; height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}
.meter i.hot  { background: linear-gradient(90deg, var(--warn), var(--bad)); }

/* service / link tiles */
a.tile, div.tile {
  display: block;
  position: relative;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

a.tile:hover, div.tile:hover { transform: translateY(-3px); background: var(--surface-hi); }

.tile .icon { font-size: 25px; line-height: 1; margin-bottom: 12px; display: block; }
.tile .name { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
.tile .desc { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.tile .state {
  position: absolute; top: 16px; right: 16px;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--muted); font-family: var(--mono);
}
.tile .state .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); transition: background 0.3s; }
.tile .state.up   .dot { background: var(--ok);  box-shadow: 0 0 8px var(--ok); }
.tile .state.down .dot { background: var(--bad); }

.tile .kill {
  position: absolute; bottom: 14px; right: 14px;
  opacity: 0; transition: opacity 0.18s;
  background: none; border: none; color: var(--faint);
  cursor: pointer; font-size: 15px; padding: 4px;
}
.tile:hover .kill { opacity: 1; }
.tile .kill:hover { color: var(--bad); }

.tile.add {
  display: grid; place-items: center;
  border-style: dashed;
  color: var(--faint);
  min-height: 118px;
  font-size: 14px;
}
.tile.add:hover { color: var(--accent); border-color: var(--accent); }

/* key cards */
.key .row { display: flex; align-items: center; gap: 11px; }
.key .kicon {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(140deg, rgba(108,140,255,0.28), rgba(167,108,255,0.28));
  border: 1px solid var(--border);
}
.key .kicon svg { width: 18px; height: 18px; stroke: var(--accent); }
.key .kname { font-weight: 600; font-size: 14.5px; }
.key .kmeta { font-size: 11.5px; color: var(--faint); font-family: var(--mono); margin-top: 1px; }
.key .badge {
  margin-left: auto; font-size: 10.5px; padding: 3px 8px; border-radius: 999px;
  background: rgba(61,220,151,0.14); color: var(--ok); border: 1px solid rgba(61,220,151,0.28);
  font-family: var(--mono); white-space: nowrap;
}
.key .acts { display: flex; gap: 8px; margin-top: 14px; }

/* modal */
.scrim {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(3, 4, 8, 0.72);
  backdrop-filter: blur(7px);
  display: none; place-items: center;
  padding: 24px;
}
.scrim.show { display: grid; }

.modal {
  width: 100%; max-width: 400px;
  background: linear-gradient(180deg, #14171f, #0e1017);
  border: 1px solid var(--border-hi);
  border-radius: 20px;
  padding: 28px;
  box-shadow: var(--shadow);
  animation: rise 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
.modal h3 { margin: 0 0 6px; font-size: 18px; font-weight: 650; letter-spacing: -0.02em; }
.modal p  { margin: 0 0 20px; font-size: 13.5px; color: var(--muted); }
.modal .acts { display: flex; gap: 10px; margin-top: 8px; }
.modal .acts .btn { flex: 1; }

.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #171a23; border: 1px solid var(--border-hi);
  padding: 12px 20px; border-radius: 12px; font-size: 14px;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none;
  transition: opacity 0.25s, transform 0.25s; z-index: 60;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: rgba(255,95,109,0.45); color: #ffb3b8; }

.empty { color: var(--faint); font-size: 13.5px; padding: 18px 2px; }

@media (max-width: 620px) {
  .shell { padding: 20px 16px 48px; }
  .grid.stats { grid-template-columns: repeat(2, 1fr); }
  .stat .value { font-size: 22px; }
}
