@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=Source+Sans+3:ital,wght@0,400;0,600;0,700;1,400&family=Syne:wght@600;700;800&display=swap");

:root {
  --paper: #eef2f6;
  --paper-2: #e4ebf3;
  --surface: #ffffff;
  --ink: #142033;
  --mute: #5a6b7d;
  --line: #c8d0db;
  --line-strong: #9aabbc;
  --brand: #1e3a5f;
  --teal: #0f7a5a;
  --teal-soft: #d8f3ea;
  --amber: #b86e00;
  --amber-soft: #fff1d6;
  --coral: #c23b22;
  --coral-soft: #fde4df;
  --slate: #6b7c8f;
  --slate-soft: #e8edf2;
  --focus: #2563a8;
  --shadow: 0 1px 0 rgba(20, 32, 51, 0.04), 0 12px 32px rgba(30, 58, 95, 0.06);
  --radius: 14px;
  --font-display: "Syne", sans-serif;
  --font-body: "Source Sans 3", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(15, 122, 90, 0.08), transparent 55%),
    radial-gradient(900px 420px at 100% 0%, rgba(184, 110, 0, 0.07), transparent 50%),
    linear-gradient(180deg, var(--paper) 0%, var(--paper-2) 100%);
  line-height: 1.45;
}

a {
  color: var(--brand);
  text-decoration: none;
  font-weight: 600;
}
a:hover { text-decoration: underline; text-underline-offset: 3px; }

code, .mono {
  font-family: var(--font-mono);
  font-size: 0.86em;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.5rem;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.03em;
  color: var(--brand);
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.85rem;
  align-items: center;
}
.nav a {
  color: var(--mute);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.25rem 0.15rem;
}
.nav a:hover { color: var(--ink); text-decoration: none; }
.nav .who {
  color: var(--mute);
  font-size: 0.9rem;
  margin-left: 0.5rem;
}

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 3rem;
}

.eyebrow {
  margin: 0 0 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mute);
}

h1 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.7rem, 3vw, 2.25rem);
  letter-spacing: -0.04em;
  line-height: 1.1;
  margin: 0 0 0.45rem;
  color: var(--ink);
}

.lede {
  margin: 0 0 1.5rem;
  color: var(--mute);
  max-width: 42rem;
  font-size: 1.05rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.15rem 1.25rem 1.25rem;
  margin-bottom: 1.15rem;
}

.panel-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 0.85rem;
}

/* Signature: presence rail */
.presence-rail {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  margin: 0 0 1.25rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.presence-seg {
  padding: 1rem 1.1rem 0.95rem;
  border-right: 1px solid var(--line);
  position: relative;
}
.presence-seg:last-child { border-right: 0; }
.presence-seg::before {
  content: "";
  position: absolute;
  left: 0; top: 0; right: 0;
  height: 4px;
}
.presence-seg.active::before { background: var(--teal); }
.presence-seg.idle::before { background: var(--amber); }
.presence-seg.suspicious::before { background: var(--coral); }
.presence-seg.offline::before { background: var(--slate); }
.presence-seg .n {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.85rem;
  letter-spacing: -0.04em;
  line-height: 1;
}
.presence-seg .l {
  margin-top: 0.35rem;
  font-size: 0.82rem;
  color: var(--mute);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  text-align: left;
  padding: 0.75rem 0.55rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th {
  color: var(--mute);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
tr:last-child td { border-bottom: 0; }
.empty { color: var(--mute); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
}
.badge::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: currentColor;
}
.badge.Active { background: var(--teal-soft); color: var(--teal); }
.badge.Idle { background: var(--amber-soft); color: var(--amber); }
.badge.Suspicious { background: var(--coral-soft); color: var(--coral); }
.badge.Offline { background: var(--slate-soft); color: var(--slate); }
.badge.tracking { background: var(--teal-soft); color: var(--teal); }
.badge.stopped { background: var(--amber-soft); color: var(--amber); }
.badge.retired { background: var(--slate-soft); color: var(--slate); }
.badge.Stopped, .badge.Retired { background: var(--slate-soft); color: var(--slate); }

.form-grid, .filters {
  display: grid;
  gap: 0.85rem;
}
.form-grid {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.filters {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  align-items: end;
}
label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--mute);
}
input, select, textarea, button, .btn {
  font: inherit;
}
input, select, textarea {
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--focus) 35%, white);
  border-color: var(--focus);
}
.btn, button[type="submit"], .filters button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.7rem 1rem;
  border-radius: 10px;
  border: 0;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover, button[type="submit"]:hover, .filters button:hover {
  filter: brightness(1.06);
  text-decoration: none;
}
.btn-ghost, .filters button.btn-ghost {
  background: transparent;
  color: var(--brand);
  border: 1px solid var(--line-strong);
}
.btn-warn, .filters button.btn-warn {
  background: var(--amber);
}
.btn-danger, .filters button.btn-danger {
  background: var(--coral);
}
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: end;
  grid-column: 1 / -1;
}

.install-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  font-size: 0.9rem;
  color: var(--mute);
  margin-bottom: 1rem;
}
.install-chip code {
  color: var(--ink);
  font-weight: 500;
}

.sub {
  font-size: 0.85rem;
  color: var(--mute);
  margin-top: 0.15rem;
}

/* Login — daylight floor */
.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
}
.login-hero {
  padding: clamp(2rem, 5vw, 4rem);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background:
    linear-gradient(145deg, rgba(30, 58, 95, 0.92), rgba(15, 122, 90, 0.78)),
    repeating-linear-gradient(
      -18deg,
      transparent,
      transparent 18px,
      rgba(255, 255, 255, 0.04) 18px,
      rgba(255, 255, 255, 0.04) 19px
    );
  color: #fff;
  position: relative;
  overflow: hidden;
}
.login-hero::after {
  content: "";
  position: absolute;
  width: 280px;
  height: 280px;
  border-radius: 40% 60% 55% 45%;
  right: -40px;
  top: 12%;
  background: rgba(255, 255, 255, 0.08);
}
.login-kicker {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.8;
  margin-bottom: 0.75rem;
  position: relative;
  z-index: 1;
}
.login-hero h1 {
  color: #fff;
  font-size: clamp(2.4rem, 5vw, 3.6rem);
  max-width: 10ch;
  position: relative;
  z-index: 1;
}
.login-hero p {
  position: relative;
  z-index: 1;
  max-width: 28rem;
  font-size: 1.1rem;
  opacity: 0.9;
  margin: 0.75rem 0 0;
}
.login-panel {
  display: grid;
  place-items: center;
  padding: 2rem 1.25rem;
  background: var(--paper);
}
.login-card {
  width: min(400px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 2px);
  box-shadow: var(--shadow);
  padding: 1.5rem 1.4rem 1.6rem;
}
.login-card h2 {
  font-family: var(--font-display);
  margin: 0 0 0.25rem;
  letter-spacing: -0.03em;
}
.login-card .hint {
  color: var(--mute);
  margin: 0 0 1.15rem;
}
.login-card label { margin-bottom: 0.75rem; }
.login-card .btn { width: 100%; margin-top: 0.5rem; }
.error {
  color: var(--coral);
  background: var(--coral-soft);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  margin: 0.5rem 0 0.75rem;
  font-size: 0.92rem;
  font-weight: 600;
}

@media (max-width: 860px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-hero { min-height: 38vh; justify-content: center; }
  .presence-rail { grid-template-columns: 1fr 1fr; }
  .presence-seg:nth-child(2) { border-right: 0; }
  .presence-seg:nth-child(1),
  .presence-seg:nth-child(2) { border-bottom: 1px solid var(--line); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
