:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #131825;
  --bg-tertiary: #1a1f33;
  --accent-primary: #6366f1;
  --accent-secondary: #a855f7;
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --border-color: rgba(255, 255, 255, 0.1);
  --border-radius: 14px;
  --border-radius-lg: 22px;
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 24px rgba(99, 102, 241, 0.25);
  --gradient-primary: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-family);
  background:
    radial-gradient(circle at top right, rgba(99, 102, 241, 0.14), transparent 28%),
    radial-gradient(circle at bottom left, rgba(168, 85, 247, 0.08), transparent 24%),
    var(--bg-primary);
  color: var(--text-primary);
}

h1,
h2,
p {
  margin: 0;
}

.app-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  min-height: 100vh;
  padding: 24px 16px 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
}

.app-shell.panel-open {
  justify-content: flex-start;
  padding-top: 40px;
}

.logout-form {
  display: flex;
  justify-content: flex-end;
}

.logout-button {
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border-radius: 999px;
  min-width: 88px;
  height: 42px;
  padding: 0 14px;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.logout-button:hover {
  transform: translateY(-1px);
  color: var(--text-primary);
  border-color: rgba(99, 102, 241, 0.45);
}

.hero-card {
  background: rgba(19, 24, 37, 0.96);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  padding: 20px;
  box-shadow: var(--shadow-lg);
}

.hero-card h1 {
  font-size: clamp(1.4rem, 3vw, 1.9rem);
}

.hero-card p {
  margin-top: 8px;
  color: var(--text-secondary);
}

.alert {
  border-radius: var(--border-radius);
  padding: 14px 16px;
  border: 1px solid transparent;
  box-shadow: var(--shadow-md);
}

.alert-success {
  background: rgba(255, 255, 255, 0.03);
  color: #f1f5f9;
  border-color: rgba(255, 255, 255, 0.06);
}

.alert-error {
  background: rgba(239, 68, 68, 0.14);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.25);
}

body.login-page {
  background:
    radial-gradient(circle at top center, rgba(109, 99, 242, 0.12), transparent 30%),
    linear-gradient(180deg, #0b1020 0%, #0a0e1a 100%);
}

.login-shell {
  width: min(100%, 920px);
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}

.login-card {
  width: 100%;
  max-width: 760px;
  background:
    radial-gradient(circle at top center, rgba(255, 255, 255, 0.03), transparent 28%),
    linear-gradient(180deg, rgba(28, 33, 52, 0.98), rgba(33, 37, 58, 0.99));
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 32px;
  padding: 50px 34px 34px;
  box-shadow: var(--shadow-lg);
}

.login-brand {
  display: grid;
  justify-items: center;
  text-align: center;
  margin-bottom: 30px;
}

.login-logo {
  width: 168px;
  height: auto;
  margin-bottom: 18px;
  filter: drop-shadow(0 0 20px rgba(255, 212, 79, 0.18));
}

.login-title {
  margin: 0;
  font-size: clamp(2.6rem, 8vw, 4rem);
  line-height: 0.95;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 700;
  background: linear-gradient(135deg, #6d63f2 0%, #9a52ea 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-copy {
  margin-top: 12px;
  color: #8f9ab5;
  font-size: clamp(1rem, 3vw, 1.2rem);
  font-weight: 500;
}

.login-form {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
}

.login-input {
  min-height: 68px;
  border-radius: 18px;
  background: #060b17;
  border: 1px solid rgba(99, 102, 241, 0.18);
  padding: 0 20px;
  font-size: 1.05rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.login-input:focus {
  border-color: #645cf0;
  box-shadow: 0 0 0 4px rgba(100, 92, 240, 0.16);
}

.remember-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  color: var(--text-primary);
  font-size: 1rem;
  line-height: 1.45;
  cursor: pointer;
}

.remember-checkbox {
  width: 22px;
  height: 22px;
  accent-color: #7a5bf2;
  cursor: pointer;
  flex: 0 0 auto;
}

.login-submit {
  margin-top: 8px;
  min-height: 72px;
  font-size: 1.1rem;
  border-radius: 20px;
}

.home-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.home-actions-three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.home-button,
.submit-button {
  width: 100%;
  min-height: 76px;
  border: none;
  border-radius: var(--border-radius-lg);
  font: inherit;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.home-button:hover,
.submit-button:hover {
  transform: translateY(-2px);
}

.home-button-active,
.submit-button {
  color: #fff;
  background: var(--gradient-primary);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.home-button-secondary {
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
}

.home-button.home-button-active {
  color: #fff;
  background: var(--gradient-primary);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  border-color: transparent;
}

.panel-wrap {
  display: grid;
  gap: 18px;
}

.panel-card {
  background: rgba(19, 24, 37, 0.96);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  padding: 20px;
  box-shadow: var(--shadow-lg);
}

.panel-card h2 {
  margin-bottom: 14px;
}

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

.form-stack {
  display: grid;
  gap: 16px;
}

.form-group {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.form-group-full,
.submit-button {
  grid-column: 1 / -1;
}

.form-label {
  color: var(--text-secondary);
  font-size: 0.92rem;
  font-weight: 600;
}

.form-control {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  display: block;
  padding: 0.9rem 1rem;
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-primary);
  font: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.14);
}

input[type="date"].form-control {
  -webkit-appearance: none;
  appearance: none;
  background: var(--bg-tertiary);
  border: 2px solid var(--accent-primary);
}

.filter-form {
  margin-top: 10px;
  display: grid;
  gap: 12px;
}

.range-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.records-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.records-header span,
.empty-text {
  color: var(--text-secondary);
}

.empty-text {
  margin-top: 10px;
}

.records-list {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.record-card {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 12px;
  background: rgba(26, 31, 51, 0.92);
}

.record-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}

.record-date {
  font-weight: 700;
  color: var(--text-secondary);
  font-size: 0.92rem;
}

.record-km {
  font-weight: 800;
  color: #dbe3ff;
}

.record-plate {
  margin-top: 8px;
  font-size: 1.08rem;
  font-weight: 800;
}

.record-meta {
  margin-top: 5px;
  font-size: 0.93rem;
  color: var(--text-secondary);
}

.record-meta strong {
  color: var(--text-primary);
}

.record-actions {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.record-action-button {
  width: 100%;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  color: #fff;
  background: rgba(19, 24, 37, 0.96);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.record-action-button:hover {
  border-color: rgba(99, 102, 241, 0.45);
}

.record-delete-form {
  margin: 0;
}

.record-action-danger {
  color: #fecaca;
  border-color: rgba(239, 68, 68, 0.45);
  background: rgba(64, 16, 16, 0.35);
}

.record-action-danger:hover {
  border-color: rgba(239, 68, 68, 0.7);
}

body.modal-open {
  overflow: hidden;
}

.edit-modal {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: grid;
  align-items: start;
  justify-items: center;
  padding: max(16px, env(safe-area-inset-top, 0px)) 16px max(16px, env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.edit-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 8, 18, 0.82);
  backdrop-filter: blur(8px);
}

.edit-modal-dialog {
  position: relative;
  z-index: 1;
  width: min(100%, 520px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  margin: auto 0;
  padding: 20px;
  border-radius: 24px;
  background: rgba(19, 24, 37, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow-lg);
}

.edit-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

.is-hidden {
  display: none;
}

@media (max-width: 640px) {
  .login-card {
    padding: 36px 18px 24px;
    border-radius: 24px;
  }

  .login-title {
    font-size: 3rem;
  }

  .login-logo {
    width: 132px;
    margin-bottom: 14px;
  }

  .login-copy {
    font-size: 1rem;
  }

  .login-input {
    min-height: 62px;
  }

  .login-submit {
    min-height: 66px;
  }

  .app-shell {
    padding-top: 18px;
    padding-bottom: 24px;
  }

  .app-shell.panel-open {
    padding-top: 22px;
  }

  .panel-card {
    padding: 16px;
    border-radius: 20px;
  }

  .home-button,
  .submit-button {
    min-height: 68px;
    font-size: 0.98rem;
    padding: 10px 8px;
  }

  .form-grid,
  .range-fields {
    grid-template-columns: 1fr;
  }

  .edit-modal {
    padding: max(10px, env(safe-area-inset-top, 0px)) 10px max(10px, env(safe-area-inset-bottom, 0px));
  }

  .edit-modal-dialog {
    width: 100%;
    max-height: calc(100dvh - 20px);
    padding: 16px;
    border-radius: 20px;
  }
}
