:root {
  --bg: #f3f6f4;
  --panel: #ffffff;
  --ink: #17201d;
  --muted: #6e7d77;
  --line: #dfe7e3;
  --green: #0d7657;
  --green-dark: #07553f;
  --green-soft: #e8f5ef;
  --amber: #b86c09;
  --amber-soft: #fff4dc;
  --shadow: 0 18px 50px rgba(22, 48, 39, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; color: var(--ink); background: var(--bg); }
body { font-size: 15px; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 250px 1fr; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 250px;
  display: flex;
  flex-direction: column;
  padding: 26px 18px;
  color: #eaf7f1;
  background:
    radial-gradient(circle at 10% 10%, rgba(86, 193, 148, .22), transparent 32%),
    linear-gradient(165deg, #103d30 0%, #09251e 100%);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  color: #083b2b;
  background: #71d4aa;
  font-weight: 900;
  font-size: 21px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.3);
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 19px; letter-spacing: .01em; }
.brand small { margin-top: 2px; color: #a8c6bb; font-size: 11px; }
.sidebar nav { display: grid; gap: 7px; margin-top: 42px; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  color: #bcd0c9;
  transition: .18s ease;
}
.sidebar nav a:hover, .sidebar nav a.active { color: #fff; background: rgba(255,255,255,.1); }
.sidebar nav a.active { box-shadow: inset 3px 0 #6ed6a9; }
.nav-icon { width: 22px; text-align: center; color: #74d9ad; font-size: 19px; }
.sidebar-footer {
  margin-top: auto;
  padding: 16px 14px 0;
  border-top: 1px solid rgba(255,255,255,.1);
  color: #a8c6bb;
}
.sidebar-footer span { display: block; margin-bottom: 5px; }
.sidebar-footer small { display: block; margin-bottom: 10px; color: #77a293; }

.main { grid-column: 2; min-width: 0; padding: 30px 40px 60px; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 28px; }
.topbar h1, .login-box h1 { margin: 3px 0 0; font-size: 34px; line-height: 1.1; letter-spacing: -.035em; }
.eyebrow { margin: 0; color: var(--green); text-transform: uppercase; letter-spacing: .14em; font-weight: 800; font-size: 11px; }
.timezone { padding: 9px 12px; border-radius: 99px; color: var(--muted); background: #e6ece9; font-size: 12px; }

.hero-line { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 18px; }
.hero-line h2, .card h2 { margin: 0; font-size: 19px; letter-spacing: -.015em; }
.hero-line p, .card-header p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; margin-bottom: 20px; }
.stat-card {
  position: relative;
  overflow: hidden;
  min-height: 148px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 8px 30px rgba(22, 48, 39, .04);
}
.stat-card::after {
  content: "";
  position: absolute;
  width: 75px; height: 75px;
  right: -25px; bottom: -30px;
  border-radius: 50%;
  background: #edf2f0;
}
.stat-card.accent { color: #fff; border-color: transparent; background: linear-gradient(145deg, #138361, #075b43); }
.stat-card.accent::after { background: rgba(255,255,255,.1); }
.stat-card.warning::after { background: var(--amber-soft); }
.stat-card.success::after { background: var(--green-soft); }
.stat-label { display: block; color: var(--muted); font-size: 12px; font-weight: 700; }
.stat-card.accent .stat-label, .stat-card.accent small { color: #c3e7d8; }
.stat-card strong { display: block; margin: 13px 0 8px; font-size: 38px; line-height: 1; letter-spacing: -.04em; }
.stat-card small { color: var(--muted); }

.card {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 8px 30px rgba(22, 48, 39, .04);
}
.card + .card { margin-top: 18px; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.count-pill { padding: 7px 11px; border-radius: 99px; color: var(--green); background: var(--green-soft); font-weight: 800; }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  padding: 11px 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  text-align: left;
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
  font-size: 10px;
}
td { padding: 14px 12px; border-bottom: 1px solid #edf1ef; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafcfb; }
.cell-subtitle { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.empty { padding: 38px 20px; color: var(--muted); text-align: center; }
.actions { text-align: right; }

.badge { display: inline-flex; align-items: center; padding: 6px 9px; border-radius: 99px; white-space: nowrap; font-size: 11px; font-weight: 800; }
.badge.success { color: #086044; background: var(--green-soft); }
.badge.warning { color: #915506; background: var(--amber-soft); }
.badge.neutral { color: #61706a; background: #edf1ef; }
.badge.danger { color: #8a2f22; background: #ffebe7; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 11px;
  cursor: pointer;
  font-weight: 800;
  font-size: 13px;
}
.button.primary { color: #fff; background: var(--green); }
.button.primary:hover { background: var(--green-dark); }
.button.secondary { color: var(--green); border-color: #bdd7cc; background: #fff; }
.button.secondary:hover { background: var(--green-soft); }
.button.danger { color: #9a3326; border-color: #efc4bd; background: #fff; }
.button.danger:hover { background: #ffebe7; }
.button:disabled { opacity: .45; cursor: not-allowed; }
.button.wide { width: 100%; }
.link-button { padding: 0; border: 0; color: #72d3aa; background: transparent; cursor: pointer; font-size: 13px; }
.danger-link { display: block; margin-top: 7px; color: #a13e31; font-size: 12px; }
.actions > form { margin-top: 7px; }
.small-button { min-height: 32px; padding: 6px 10px; }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; }
.enrollment-card { max-width: 920px; }
.danger-card { max-width: 820px; border-color: #efc4bd; }
.solid-danger { color: #fff !important; border-color: #a13e31 !important; background: #a13e31 !important; }
.delete-mapping-list { display: grid; gap: 9px; margin-bottom: 16px; }
.delete-mapping-list > div {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fafcfb;
}
.delete-mapping-list > div > span:not(.badge) { color: var(--muted); }
.enrollment-note { padding: 13px 15px; color: #6e580c; border-radius: 11px; background: var(--amber-soft); line-height: 1.5; }

.stack-form { display: grid; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
label { display: grid; gap: 7px; color: #4c5b56; font-size: 12px; font-weight: 750; }
input, select {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  color: var(--ink);
  border: 1px solid #cad6d1;
  border-radius: 10px;
  outline: none;
  background: #fff;
}
input:focus, select:focus { border-color: #4eac87; box-shadow: 0 0 0 3px rgba(78,172,135,.12); }
.split-grid { display: grid; margin-bottom: 18px; }
.form-card .button { justify-self: start; }
.filters-card { margin-bottom: 18px; }
.filter-form { display: flex; align-items: end; gap: 12px; }
.filter-form label { min-width: 170px; }
.check-label { display: flex; align-items: center; gap: 9px; }
.check-label input { width: 17px; min-height: 17px; accent-color: var(--green); }

.device-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.device-card { margin: 0 !important; }
.device-title { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 13px; }
.device-glyph {
  display: grid;
  place-items: center;
  width: 44px; height: 44px;
  border-radius: 13px;
  color: var(--green);
  background: var(--green-soft);
  font-size: 22px;
}
.device-title h2 { margin-bottom: 4px; }
.device-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; margin: 20px 0; padding: 16px; border-radius: 13px; background: #f6f9f7; }
.device-meta div { min-width: 0; }
.device-meta dt { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .06em; }
.device-meta dd { margin: 5px 0 0; overflow: hidden; text-overflow: ellipsis; }
.compact-form { padding-top: 4px; }

.login-body { min-height: 100vh; display: grid; grid-template-columns: 1.08fr .92fr; background: #0b3025; }
.login-visual {
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
  min-height: 100vh;
  background:
    radial-gradient(circle at 25% 15%, rgba(80, 196, 146, .28), transparent 26%),
    linear-gradient(140deg, #0b4b37, #061c17);
}
.login-orbit { position: absolute; border: 1px solid rgba(142, 233, 193, .2); border-radius: 50%; }
.orbit-one { width: 540px; height: 540px; }
.orbit-two { width: 760px; height: 760px; }
.scan-card {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 24px;
  color: #effcf6;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 23px;
  background: rgba(255,255,255,.08);
  box-shadow: 0 30px 80px rgba(0,0,0,.25);
  backdrop-filter: blur(12px);
}
.scan-card strong, .scan-card small { display: block; }
.scan-card small { margin-top: 5px; color: #acd2c3; }
.face-frame {
  position: relative;
  width: 84px; height: 84px;
  border: 2px solid #74d9ad;
  border-radius: 24px;
  box-shadow: 0 0 30px rgba(116,217,173,.2);
}
.face-dot { position: absolute; top: 29px; width: 8px; height: 8px; border-radius: 50%; background: #74d9ad; }
.dot-one { left: 22px; } .dot-two { right: 22px; }
.face-line { position: absolute; left: 24px; right: 24px; bottom: 22px; height: 10px; border-bottom: 3px solid #74d9ad; border-radius: 50%; }
.login-panel { min-height: 100vh; display: grid; place-items: center; padding: 50px; background: #f4f7f5; }
.login-box { width: min(420px, 100%); }
.login-brand { margin-bottom: 56px; color: var(--ink); }
.login-brand .brand small { color: var(--muted); }
.login-box h1 { margin: 10px 0; font-size: 40px; }
.muted { color: var(--muted); line-height: 1.6; }
.login-box .stack-form { margin-top: 28px; }
.alert { margin: 18px 0; padding: 12px 14px; border-radius: 10px; }
.alert-error { color: #8a2f22; background: #ffebe7; }
.alert-success { margin-top: 0; color: #086044; background: var(--green-soft); }
.onboarding-card { margin-bottom: 18px; border-color: #b9dacf; }
.two-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.editor-list { display: grid; gap: 12px; }
.editor-row {
  display: grid;
  grid-template-columns: 1.2fr 1.25fr 1fr 1.25fr auto auto;
  align-items: end;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fafcfb;
}
.editor-identity { align-self: center; min-width: 0; }
.editor-identity strong, .editor-identity span { display: block; }
.editor-identity .badge { display: inline-flex; margin-top: 7px; }
.site-editor { grid-template-columns: 1.1fr 1fr 2fr auto auto; }
.site-view { grid-template-columns: 2fr 1fr auto; align-items: center; }

@media (max-width: 1080px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .editor-row, .site-editor { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 800px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: auto; padding: 16px; }
  .sidebar nav { grid-auto-flow: column; grid-auto-columns: minmax(110px, 1fr); overflow-x: auto; margin-top: 20px; }
  .sidebar nav a { justify-content: center; }
  .sidebar-footer { display: none; }
  .main { padding: 24px 16px 50px; }
  .device-grid, .login-body { grid-template-columns: 1fr; }
  .login-visual { display: none; }
  .login-panel { min-height: 100vh; padding: 30px 20px; }
  .login-brand { margin-bottom: 38px; }
}

@media (max-width: 560px) {
  .stats-grid, .form-grid, .device-grid, .two-cols, .editor-row, .site-editor, .site-view { grid-template-columns: 1fr; }
  .hero-line, .filter-form { align-items: stretch; flex-direction: column; }
  .topbar { align-items: flex-start; }
  .timezone { display: none; }
  .main { padding-inline: 12px; }
  .card { padding: 16px; border-radius: 15px; }
}
