*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
  --bg: #0b0f14;
  --panel: #121820;
  --panel-2: #1a2230;
  --border: #243044;
  --text: #e8eef7;
  --muted: #8b98ab;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.hidden {
  display: none !important;
}

#login-screen {
  min-height: 100vh;
  display: grid;
  /* Anchored low and right on purpose. The ParkEZ wordmark spans the middle
     ~30% of the backdrop and stays horizontally centred, so a right-aligned
     card only clears it above ~1350px — but the wordmark is confined to the
     top half, so biasing the form downwards keeps the branding fully visible
     at every width. */
  place-items: end end;
  padding: 24px clamp(24px, 5vw, 72px) clamp(32px, 9vh, 96px);
  background-image: url("/parkez.webp");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.login-card {
  width: min(420px, 100%);
  /* Slightly translucent over the photo so the backdrop reads through
     without costing form legibility. */
  background: rgba(18, 24, 32, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

/* Narrow screens crop the backdrop hard, often cutting the wordmark out of
   frame entirely — so centre the form again and lay a scrim over the busy
   photo to keep the fields readable. */
@media (max-width: 720px) {
  #login-screen {
    place-items: center;
    padding: 24px;
    background-image: linear-gradient(
        rgba(11, 15, 20, 0.74),
        rgba(11, 15, 20, 0.74)
      ),
      url("/parkez.webp");
  }
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 1.5rem;
}

.login-card p {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 0.95rem;
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 6px;
}

input,
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
}

input:focus,
select:focus {
  outline: 2px solid var(--accent);
  border-color: transparent;
}

button {
  font: inherit;
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 600;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.35);
}

#app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.brand {
  padding: 0 12px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.brand strong {
  display: block;
  font-size: 1.1rem;
}

.brand span {
  color: var(--muted);
  font-size: 0.8rem;
}

.nav-btn {
  text-align: left;
  padding: 12px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text);
}

.nav-btn.active,
.nav-btn:hover {
  background: var(--panel-2);
}

.nav-btn.active {
  color: var(--accent);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.main {
  padding: 24px 28px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.page-header h2 {
  margin: 0;
  font-size: 1.5rem;
}

.page-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.stat-card span {
  color: var(--muted);
  font-size: 0.85rem;
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: 1.8rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}

th {
  color: var(--muted);
  font-weight: 600;
  background: var(--panel-2);
}

tr:last-child td {
  border-bottom: none;
}

.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success {
  background: rgba(34, 197, 94, 0.15);
  color: #86efac;
}

.badge-muted {
  background: rgba(139, 152, 171, 0.15);
  color: var(--muted);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 100;
}

.modal {
  width: min(560px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
}

.modal h3 {
  margin: 0 0 16px;
}

.key-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.key-cell code {
  font-size: 0.8rem;
  color: var(--muted);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.error-banner {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fecaca;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
}

.empty-state {
  padding: 40px;
  text-align: center;
  color: var(--muted);
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  padding: 0;
  font-weight: 600;
}

@media (max-width: 900px) {
  #app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }

  .sidebar-footer {
    margin-top: 0;
    border-top: none;
  }
}
