:root {
  --bg: #14161b;
  --panel: #1c1f26;
  --panel-raised: #23262f;
  --amber: #e8a33d;
  --amber-dim: #8a6526;
  --text: #eef0f4;
  --text-dim: #8b909c;
  --danger: #e2574c;
  --success: #4caf7d;
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.screen {
  width: 100%;
  display: flex;
  justify-content: center;
}

.hidden {
  display: none !important;
}

.card {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border-radius: var(--radius);
  padding: 20px 24px 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

h1 {
  margin: 0 0 12px;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-align: center;
  color: var(--text);
}

/* --- Login --- */

#login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#login-form input {
  background: var(--panel-raised);
  border: 1px solid #2e323d;
  border-radius: 10px;
  padding: 14px 16px;
  color: var(--text);
  font-size: 1rem;
}

#login-form input:focus {
  outline: 2px solid var(--amber-dim);
  outline-offset: 1px;
}

#login-form button {
  margin-top: 8px;
  background: var(--amber);
  color: #1a1204;
  border: none;
  border-radius: 10px;
  padding: 14px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

#login-form button:active {
  transform: scale(0.98);
}

.error {
  min-height: 1.2em;
  color: var(--danger);
  font-size: 0.9rem;
  text-align: center;
  margin: 4px 0 0;
}

/* --- Keypad --- */

.status {
  min-height: 1.4em;
  text-align: center;
  font-size: 0.95rem;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.status.error { color: var(--danger); }
.status.success { color: var(--success); }

.code-display {
  display: flex;
  justify-content: center;
  gap: 10px;
  height: 18px;
  margin-bottom: 28px;
}

.code-display span {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1.5px solid var(--text-dim);
  background: transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.code-display span.filled {
  background: var(--amber);
  border-color: var(--amber);
}

.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.num {
  aspect-ratio: 1;
  border-radius: 50%;
  border: none;
  background: var(--panel-raised);
  color: var(--text);
  font-size: 1.4rem;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.12s ease;
}

.num:active {
  transform: scale(0.94);
  background: #2b2f3a;
}

.num.action {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-dim);
}

.num.ok {
  background: var(--amber-dim);
  color: var(--amber);
}

.logout {
  margin-top: 12px;
  width: 100%;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.85rem;
  text-align: center;
  cursor: pointer;
}

.bottom-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.bottom-buttons .bottom-btn {
  flex: 1;
}

.bottom-btn {
  flex: 1;
  height: 50px;

  border: none;
  border-radius: 14px;

  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.85);

  font-size: 15px;
  font-weight: 600;

  cursor: pointer;

  transition: .2s ease;
}

.bottom-btn:hover {
  background: rgba(255,255,255,.15);
}

.bottom-btn:active {
  transform: scale(.98);
}
.audit-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
  margin-bottom: 20px;
  max-height: 420px;
  overflow-y: auto;
}

.audit-entry {
  background: rgba(255,255,255,.06);
  border-radius: 16px;
  padding: 14px;
  text-align: left;

  border-left: 4px solid rgba(255,255,255,.12);
}

.audit-entry.success {
  border-left-color: #4CAF50;
}

.audit-entry.mastercode {
  border-left-color: #E3A12B;
}

.audit-entry.lockout {
  border-left-color: #FF5252;
}

.audit-user {
  font-size: 17px;
  font-weight: 600;
}

.audit-date {
  font-size: 13px;
  opacity: .65;
  margin-top: 6px;
}

.audit-type {
  display: none;
}

.audit-user {
  font-size: 16px;
  font-weight: 600;
}

.audit-date {
  font-size: 13px;
  opacity: .7;
  margin-top: 4px;
}

.audit-type {
  font-size: 13px;
  margin-top: 4px;
}

.users-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
  margin-bottom: 20px;
}

.user-entry {
  background: rgba(255,255,255,.06);
  border-radius: 12px;
  padding: 12px;
}

.user-name {
  font-size: 16px;
  font-weight: 600;
}

.user-code {
  opacity: .7;
  font-size: 14px;
  margin-top: 4px;
}

.delete-user-btn {
  margin-top: 10px;
  border: none;
  border-radius: 10px;
  padding: 8px;
  background: rgba(255,80,80,.18);
  color: white;
}

.user-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 20px;
}

.user-form input {
  height: 48px;
  border: none;
  border-radius: 12px;
  padding: 0 14px;
  background: rgba(255,255,255,.08);
  color: white;
  font-size: 15px;
}

.user-form input::placeholder {
  color: rgba(255,255,255,.55);
}

.edit-user-btn,
.delete-user-btn {
  margin-top: 10px;
  border: none;
  border-radius: 10px;
  padding: 8px 12px;
  color: white;
  cursor: pointer;
}

.edit-user-btn {
  background: rgba(80,140,255,.18);
  margin-right: 8px;
}

.delete-user-btn {
  background: rgba(255,80,80,.18);
}
#edit-user-screen input {
  width: 100%;
  height: 48px;

  margin-bottom: 12px;

  border: none;
  border-radius: 12px;

  padding: 0 14px;

  background: rgba(255,255,255,.08);
  color: white;

  font-size: 15px;
  box-sizing: border-box;
}
#save-user-btn,
#cancel-edit-user-btn,
#add-user-btn,
#close-users-btn {
  border: none;
  border-radius: 12px;
  height: 46px;

  background: rgba(255,255,255,.08);
  color: white;

  font-size: 15px;
  font-weight: 600;

  cursor: pointer;
}

#save-user-btn {
  background: rgba(70,170,90,.25);
}

#cancel-edit-user-btn {
  background: rgba(255,255,255,.08);
}
#delete-user-name {
  margin: 25px 0;

  text-align: center;

  font-size: 16px;
  line-height: 1.6;

  color: rgba(255,255,255,.9);
}

#delete-user-name strong {
  display: block;
  font-size: 22px;
  margin-bottom: 10px;
}
#edit-user-screen h1,
#delete-user-screen h1 {
  margin-bottom: 24px;
}

#edit-user-screen input {
  margin-bottom: 14px;
}
#confirm-delete-btn {
  background: rgba(220,60,60,.25);
}

#confirm-delete-btn:hover {
  background: rgba(220,60,60,.35);
}

#save-user-btn {
  background: rgba(76,175,80,.25);
}

#save-user-btn:hover {
  background: rgba(76,175,80,.35);
}

#device-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

#switch-device-btn {
  width: 100%;
  margin-top: 6px;
  margin-bottom: 10px;
}
.last-access-info {
  font-size: 0.82rem;
  line-height: 1.05;
  margin-bottom: 2px;
  color: rgba(255,255,255,.85);
}

.toggle-user-btn {
  background: #444;
  color: white;
}

.audit-entry.wrongpin {
  border-left-color: #ff6b6b;
}
