:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  background: #0d100e;
  color: #f2f5ef;
  --lime: #b8f34a;
  --panel: #171c18;
  --line: #303832;
  --muted: #929b94;
}

* { box-sizing: border-box; }
body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 80% 4%, rgba(184, 243, 74, 0.09), transparent 28rem),
    linear-gradient(180deg, #101411 0%, #0b0e0c 100%);
}
button { font: inherit; }
.hidden { display: none !important; }

.login-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(420px, 100%);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(23, 28, 24, 0.96);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.36);
}
.login-card .brand-mark { margin-bottom: 24px; }
.login-card h1 { margin-top: 8px; font-size: 2rem; }
.login-copy { margin: 10px 0 26px; color: var(--muted); }
.login-card label { display: grid; gap: 8px; margin-top: 16px; color: #cbd2cc; font-size: 0.8rem; font-weight: 700; }
.login-card input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 14px;
  background: #101411;
  color: #fff;
  font: inherit;
}
.login-card input:focus { border-color: var(--lime); outline: 2px solid rgba(184, 243, 74, 0.16); }
.primary-button {
  width: 100%;
  margin-top: 22px;
  border: 0;
  border-radius: 12px;
  padding: 13px;
  background: var(--lime);
  color: #11170d;
  font-weight: 850;
  cursor: pointer;
}
.primary-button:disabled { cursor: wait; opacity: 0.55; }
.login-error { min-height: 20px; margin: 12px 0 0; color: #ff8b83; font-size: 0.8rem; }

.shell {
  width: min(1180px, calc(100% - 40px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 0 22px;
}

.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 14px;
  padding-bottom: 26px;
  border-bottom: 1px solid var(--line);
}
.user-menu { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 0.78rem; }
.user-menu button { border: 1px solid var(--line); border-radius: 999px; padding: 7px 11px; background: transparent; color: #dce3dd; cursor: pointer; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid #405036;
  border-radius: 14px;
  background: #1b2319;
}
.brand-mark::before, .brand-mark::after, .brand-mark span {
  content: "";
  grid-area: 1 / 1;
  width: 5px;
  height: 22px;
  border-radius: 4px;
  background: var(--lime);
}
.brand-mark::before { transform: translateX(-8px); }
.brand-mark::after { transform: translateX(8px); }

.eyebrow, .kicker {
  margin: 0 0 4px;
  color: var(--lime);
  font-size: 0.69rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}
h1 { margin: 0; font-size: 1rem; font-weight: 650; }

.badge, .device-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #687169; }
.badge-online, .device-status.online { color: #dfffb2; border-color: #496028; }
.badge-online .status-dot, .device-status.online .status-dot {
  background: var(--lime);
  box-shadow: 0 0 12px rgba(184, 243, 74, 0.8);
}

.intro {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 28px;
  padding: 58px 0 40px;
}
.intro h2 {
  max-width: 780px;
  margin: 0;
  font-size: clamp(2.7rem, 7vw, 5.8rem);
  line-height: 0.94;
  letter-spacing: -0.06em;
}
.subtitle { max-width: 620px; margin: 18px 0 0; color: var(--muted); font-size: 1.02rem; }
.system-status { display: grid; justify-items: end; gap: 9px; }
.system-status small { color: #687169; font-family: ui-monospace, monospace; }

.section-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}
.section-title h3 { margin: 0; font-size: 1.15rem; }
.section-title span { color: var(--muted); font-size: 0.77rem; }

.locks-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.lock-button {
  position: relative;
  min-height: 145px;
  overflow: hidden;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(145deg, #1a201b, #141815);
  color: #f2f5ef;
  text-align: left;
  cursor: pointer;
  transition: border-color 140ms ease, transform 140ms ease, background 140ms ease;
}
.lock-button:not(:disabled):hover {
  transform: translateY(-3px);
  border-color: #718d43;
  background: linear-gradient(145deg, #20291d, #171d18);
}
.lock-button:not(:disabled):active { transform: translateY(0) scale(0.98); }
.lock-button:focus-visible { outline: 3px solid var(--lime); outline-offset: 3px; }
.lock-button:disabled { cursor: not-allowed; opacity: 0.42; }
.lock-button.pending { border-color: var(--lime); }
.lock-button.complete { animation: confirm 900ms ease; }

.lock-index {
  display: block;
  margin-bottom: 32px;
  color: var(--lime);
  font-family: ui-monospace, monospace;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.13em;
}
.lock-name { display: block; font-size: 1.05rem; font-weight: 800; }
.lock-state { display: block; margin-top: 5px; color: var(--muted); font-size: 0.72rem; }
.lock-arrow { position: absolute; right: 17px; top: 15px; color: #687169; font-size: 1.3rem; }
.lock-button:hover .lock-arrow { color: var(--lime); }

.activity {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 50px;
  margin-top: 18px;
  padding: 12px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #121613;
  color: var(--muted);
  font-size: 0.8rem;
}
.activity-dot { width: 6px; height: 6px; border-radius: 50%; background: #687169; }
.activity.success .activity-dot { background: var(--lime); }
.activity.error .activity-dot { background: #ff6b61; }

footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 4px 0;
  color: #687169;
  font-size: 0.72rem;
}

@keyframes confirm {
  0%, 100% { box-shadow: none; }
  40% { box-shadow: 0 0 0 3px var(--lime), 0 0 35px rgba(184, 243, 74, 0.18); }
}

@media (max-width: 900px) { .locks-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 620px) {
  .shell { width: min(100% - 24px, 1180px); padding-top: 16px; }
  .topbar { grid-template-columns: auto 1fr; }
  .topbar .badge { grid-column: 1 / -1; justify-self: stretch; justify-content: center; }
  .user-menu { grid-column: 1 / -1; justify-content: space-between; }
  .intro { grid-template-columns: 1fr; padding-top: 42px; }
  .system-status { justify-items: start; }
  .locks-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section-title { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 390px) { .locks-grid { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
