* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  background: #0f172a;
  color: #ffffff;
  min-height: 100%;
  overscroll-behavior: none;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  isolation: isolate;
}

body::before {
  content: "";
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: min(48vh, 420px);
  background-image: url('/static/pin-background.svg');
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center bottom;
  opacity: 0.5;
  pointer-events: none;
  z-index: 0;
  -webkit-mask-image: linear-gradient(to top, rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 0.72) 38%, rgba(0, 0, 0, 0.12) 78%, transparent 100%);
  mask-image: linear-gradient(to top, rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 0.72) 38%, rgba(0, 0, 0, 0.12) 78%, transparent 100%);
}

.app {
  position: relative;
  z-index: 1;
  max-width: 520px;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
}

.admin-link {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 46px;
  height: 46px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: #e2e8f0;
  background: #1e293b;
  border: 1.5px solid #475569;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
}

.admin-link:active {
  transform: scale(0.97);
  filter: brightness(1.18);
}

.app-header {
  position: relative;
}

.admin-back {
  position: absolute;
  top: 0;
  left: 0;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 1.5px solid #475569;
  background: #1e293b;
  color: #e2e8f0;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}

.admin-back:active {
  transform: scale(0.97);
  filter: brightness(1.18);
}

h1 {
  margin: 0;
  font-size: 2rem;
  text-align: center;
  letter-spacing: 0.04em;
}

h2 {
  margin: 0 0 10px;
  color: #e2e8f0;
}

.subtitle {
  margin: 0 0 16px;
  text-align: center;
  color: #cbd5e1;
  font-size: 0.95rem;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 12px 0 8px;
}

.brand-logo {
  width: 44px;
  height: 44px;
  object-fit: contain;
  flex: 0 0 auto;
}

.user-info {
  margin: 0 0 20px;
  text-align: center;
  color: #cbd5e1;
  font-size: 1.05rem;
}

.status {
  margin-top: 20px;
  min-height: 24px;
  text-align: center;
  color: #cbd5e1;
  font-size: 0.95rem;
}

.pin-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 24px 0;
  padding: 20px;
  background: linear-gradient(145deg, rgba(30, 41, 59, 0.98) 0%, rgba(15, 23, 42, 0.95) 100%);
  position: relative;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 480px;
  box-sizing: border-box;
  align-items: center;
  overflow: hidden;
}

.pin-section::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.1) 0%, rgba(15, 23, 42, 0.08) 100%);
  pointer-events: none;
  z-index: 0;
}

.pin-section > * {
  position: relative;
  z-index: 1;
}

.pin-section.hidden {
  display: none;
}

.pin-input {
  appearance: none;
  -webkit-appearance: none;
  border: 2px solid #334155;
  background: #0f172a;
  color: #ffffff;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 1.5rem;
  letter-spacing: 0.2em;
  text-align: center;
  font-weight: 600;
  transition: border-color 0.2s ease;
  width: 100%;
  max-width: 300px;
  box-sizing: border-box;
}

.pin-input:focus {
  outline: none;
  border-color: #3b82f6;
}

.pin-input::placeholder {
  color: #64748b;
  letter-spacing: normal;
}

.pin-submit {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  background: #3b82f6;
  color: #fff;
  padding: 16px 20px;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease;
  margin-top: 12px;
  width: 100%;
  max-width: 300px;
  box-sizing: border-box;
}

.passkey-submit,
.passkey-register {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid #334155;
  background: #1e293b;
  color: #e2e8f0;
  padding: 13px 18px;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.2s ease, border-color 0.2s ease;
  width: 100%;
  max-width: 300px;
  box-sizing: border-box;
}

.passkey-submit {
  margin-top: 2px;
  border-color: #3b68a2;
  background: linear-gradient(135deg, #365278, #4a76ad);
  color: #eff6ff;
}

.passkey-register-wrap {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: max(12px, env(safe-area-inset-bottom));
  display: none;
  justify-content: center;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  z-index: 8;
}

.passkey-register-wrap.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.passkey-register {
  border-color: #0f766e;
  background: linear-gradient(135deg, #134e4a, #0f766e);
  color: #ecfeff;
  max-width: 420px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.passkey-register::before {
  content: "";
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  background: center / contain no-repeat url('/static/face-id-icon.svg');
  opacity: 0.95;
}

.passkey-submit:active,
.passkey-register:active {
  transform: scale(0.98);
  filter: brightness(1.12);
}

.pin-submit:active {
  background: #2563eb;
  transform: scale(0.98);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.24);
}

.pin-error {
  margin: 0;
  color: #ef4444;
  font-size: 0.95rem;
  text-align: center;
}

.timer-section {
  margin: 24px 0;
  padding: 20px;
  background: #1e293b;
  border-radius: 16px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  transition: background 0.35s ease, box-shadow 0.35s ease;
}

.timer-section.is-active {
  background: linear-gradient(135deg, #166534, #15803d);
  box-shadow: 0 10px 30px rgba(34, 197, 94, 0.2);
}

.timer-label::before {
  content: "Zugriff frei für";
}

.timer-text {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: #ffffff;
  transition: color 0.35s ease;
}

#timer-value {
  display: inline-block;
  min-width: 2em;
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  font-weight: 700;
}

.actions-card {
  margin-top: 18px;
  padding: 16px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(22, 37, 59, 0.96) 0%, rgba(30, 46, 73, 0.9) 100%);
  border: 1px solid #2c3d59;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
}

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

.row-between {
  justify-content: space-between;
  align-items: center;
}

#refresh-vehicle-btn {
  border: 1px solid #334155;
  background: #1e293b;
  color: #e2e8f0;
  border-radius: 10px;
  min-height: 40px;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 8px 12px;
}

#refresh-vehicle-btn:active {
  transform: scale(0.98);
}

.actions {
  display: grid;
  gap: 8px;
}

.actions button {
  width: 100%;
  border: none;
  background: #3b82f6;
  color: #fff;
  border-radius: 10px;
  min-height: 44px;
  font-size: 0.95rem;
  font-weight: 700;
}

.actions button:active {
  transform: scale(0.98);
  background: #2563eb;
}

.vehicle-status {
  margin: 10px 0 12px;
}

.vs-section {
  margin-bottom: 16px;
}

.vs-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin: 0 0 6px;
  padding: 0 2px;
}

.vs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 8px;
  margin-bottom: 6px;
}

.vs-span2 {
  grid-column: span 2;
}

.vs-item {
  background: #0e1829;
  border: 1px solid #32455f;
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.vs-label {
  font-size: 0.7rem;
  color: #a8bbd2;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.vs-value {
  font-size: 1.05rem;
  font-weight: 600;
}

.vs-good {
  color: #22c55e;
}

.vs-warn {
  color: #f59e0b;
}

.vs-on {
  color: #60a5fa;
}

.vs-muted {
  color: #a8bbd2;
}

.vs-bar {
  height: 6px;
  background: #1e3a5f;
  border-radius: 3px;
  margin-top: 6px;
  overflow: hidden;
}

.vs-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}

.vs-updated {
  font-size: 0.72rem;
  color: #a8bbd2;
  margin: 0;
}

@media (max-width: 640px) {
  .app {
    padding: max(18px, env(safe-area-inset-top)) 12px max(20px, env(safe-area-inset-bottom));
  }

  .pin-section {
    margin: 18px 0;
    padding: 16px;
    border-radius: 14px;
  }

  .actions-card {
    padding: 14px;
  }
}
