:root {
  --primary: #0d47a1;
  --primary-light: #1976d2;
  --primary-bright: #2196f3;
  --primary-dark: #08306b;
  --primary-soft: #eaf4ff;
  --primary-soft-2: #dbeafe;

  --orange: #1976d2;
  --orange-dark: #0d47a1;

  --green: #2e7d32;
  --red: #d93025;

  --yellow-bg: #eaf4ff;
  --red-bg: #fdecea;
  --green-bg: #e8f5e9;

  --bg: #f4f8fc;
  --surface: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;

  --shadow: 0 10px 30px rgba(13, 71, 161, 0.10);
  --shadow-soft: 0 6px 18px rgba(13, 71, 161, 0.08);

  --radius-lg: 22px;
  --radius-md: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(25, 118, 210, 0.16), transparent 28rem),
    linear-gradient(180deg, #f4f8fc 0%, #eef5ff 100%);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.hidden {
  display: none !important;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(244, 248, 252, 0.90);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(229, 231, 235, 0.85);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.brand-icon,
.auth-logo {
  display: grid;
  place-items: center;
  background: var(--surface);
  border-radius: 18px;
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.brand-icon {
  width: 44px;
  height: 44px;
  font-size: 1.45rem;
}

.brand-icon img,
.auth-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.auth-logo {
  width: 64px;
  height: 64px;
  font-size: 2rem;
  margin-bottom: 16px;
}

.brand h1 {
  margin: 0;
  font-size: 1.18rem;
  line-height: 1.1;
}

.brand p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button {
  border: 0;
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  min-height: 38px;
  padding: 0 12px;
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  font-weight: 700;
}

.install-button {
  color: var(--primary);
}

.app-main {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 18px 14px calc(116px + var(--safe-bottom));
}

.auth-section {
  min-height: calc(100dvh - 90px);
  display: grid;
  place-items: center;
}

.auth-card,
.welcome-card,
.card-form,
.deadline-home-alert,
.stat-card,
.deadline-card,
.vehicle-card,
.archive-card,
.empty-state {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(229, 231, 235, 0.92);
  box-shadow: var(--shadow);
}

.auth-card {
  width: min(100%, 430px);
  border-radius: 28px;
  padding: 24px;
}

.auth-card h2,
.page-header h2,
.welcome-card h2 {
  margin: 0;
  font-size: clamp(1.35rem, 5vw, 2rem);
}

.auth-card p,
.page-header p,
.welcome-card p {
  color: var(--muted);
}

.form-grid {
  display: grid;
  gap: 13px;
}

.two-columns {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 6px;
  color: var(--text);
  font-weight: 700;
  font-size: 0.9rem;
}

label span {
  padding-left: 2px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 14px;
  padding: 12px 13px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 4px rgba(25, 118, 210, 0.14);
}

textarea {
  resize: vertical;
}

.primary-button,
.secondary-button,
.google-button,
.text-button,
.round-action,
.danger-button,
.small-button {
  border: 0;
  cursor: pointer;
  font-weight: 800;
}

.primary-button,
.secondary-button,
.google-button,
.danger-button {
  border-radius: 16px;
  padding: 12px 16px;
  min-height: 46px;
}

.primary-button {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
}

.primary-button:hover {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
}

.secondary-button {
  background: #f3f4f6;
  color: var(--text);
}

.danger-button {
  background: var(--red-bg);
  color: var(--red);
}

.google-button {
  width: 100%;
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: #111827;
  color: white;
}

.google-button span {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  color: #111827;
}

.register-box {
  margin-top: 14px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  padding: 12px;
}

.register-box summary {
  cursor: pointer;
  color: var(--primary);
  font-weight: 800;
}

.register-box form {
  margin-top: 13px;
}

.app-section {
  display: block;
}

.page-section {
  animation: fadeIn 0.18s ease-out;
}

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

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.welcome-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-radius: var(--radius-lg);
  padding: 18px;
}

.eyebrow {
  margin: 0 0 6px !important;
  color: var(--primary) !important;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 900;
}

.round-action {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-bright));
  color: #fff;
  font-size: 1.7rem;
  line-height: 1;
  box-shadow: 0 8px 20px rgba(25, 118, 210, 0.22);
}

.deadline-home-alert {
  margin: 16px 0;
  padding: 16px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  border-left: 6px solid var(--green);
}

.deadline-home-alert.has-alerts {
  border-left-color: var(--primary-light);
}

.deadline-home-alert.has-expired {
  border-left-color: var(--red);
}

.deadline-home-alert p {
  margin: 5px 0 0;
  font-size: 0.95rem;
  color: var(--muted);
}

.deadline-home-arrow {
  font-size: 2rem;
  color: var(--primary);
  padding-left: 12px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0 18px;
}

.stat-card {
  border-radius: 18px;
  padding: 14px;
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

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

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 20px 0 10px;
}

.section-heading h3 {
  margin: 0;
}

.text-button {
  background: transparent;
  color: var(--primary);
  padding: 8px;
}

.page-header {
  margin: 4px 0 16px;
}

.card-form {
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 18px;
}

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.cards-list,
.compact-list,
.deadlines-list,
.archive-list {
  display: grid;
  gap: 12px;
}

.vehicle-card,
.deadline-card,
.archive-card,
.empty-state {
  border-radius: var(--radius-lg);
  padding: 15px;
}

.vehicle-card-header,
.deadline-card-header,
.archive-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.vehicle-card h3,
.deadline-card h3,
.archive-card h3 {
  margin: 0;
  font-size: 1.05rem;
}

.vehicle-card p,
.deadline-card p,
.archive-card p,
.empty-state p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.vehicle-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
}

.meta-pill {
  background: #f3f4f6;
  color: #374151;
  border-radius: 999px;
  padding: 6px 9px;
  font-size: 0.78rem;
  font-weight: 800;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.small-button {
  border-radius: 999px;
  padding: 8px 12px;
  background: #f3f4f6;
  color: var(--text);
}

.small-button.danger {
  background: var(--red-bg);
  color: var(--red);
}

.deadline-filters {
  display: flex;
  gap: 8px;
  margin: 16px 0;
  overflow-x: auto;
  padding-bottom: 3px;
}

.deadline-filter,
.archive-filter {
  border: 0;
  border-radius: 999px;
  padding: 9px 16px;
  background: #f1f1f1;
  color: #333;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.deadline-filter.active,
.archive-filter.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
}

.deadline-card {
  border-left: 6px solid var(--line);
}

.deadline-card.expired {
  border-left-color: var(--red);
}

.deadline-card.urgent {
  border-left-color: var(--primary-light);
}

.deadline-card.ok {
  border-left-color: var(--green);
}

.deadline-badge,
.archive-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.76rem;
  font-weight: 900;
  border-radius: 999px;
  padding: 6px 10px;
  white-space: nowrap;
}

.deadline-badge.expired {
  background: var(--red-bg);
  color: var(--red);
}

.deadline-badge.urgent {
  background: var(--primary-soft);
  color: var(--primary);
}

.deadline-badge.ok {
  background: var(--green-bg);
  color: var(--green);
}

.archive-badge.fuel {
  background: #e0f2fe;
  color: #0369a1;
}

.archive-badge.maintenance {
  background: #f3e8ff;
  color: #7e22ce;
}

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

/* Barra inferiore ottimizzata per smartphone */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  gap: 4px;
  overflow-x: hidden;
  padding: 8px 7px calc(8px + var(--safe-bottom));
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid rgba(229, 231, 235, 0.95);
  box-shadow: 0 -10px 30px rgba(13, 71, 161, 0.10);
  backdrop-filter: blur(16px);
}

.nav-btn {
  flex: 1 1 0;
  min-width: 0;
  min-height: 70px;
  display: grid;
  grid-template-rows: 28px auto;
  align-items: center;
  justify-items: center;
  gap: 3px;
  padding: 8px 3px 7px;
  border: 0;
  border-radius: 17px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 850;
  font-size: 1.45rem;
  line-height: 1;
  text-align: center;
}

.nav-btn span {
  display: block;
  width: 100%;
  font-size: 0.68rem;
  line-height: 1.05;
  text-align: center;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
}

.nav-btn.active {
  background: var(--primary-soft);
  color: var(--primary);
  box-shadow: inset 0 0 0 1px rgba(25, 118, 210, 0.08);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(104px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 50;
  width: min(calc(100% - 28px), 480px);
  padding: 13px 16px;
  border-radius: 16px;
  background: #111827;
  color: white;
  font-weight: 800;
  box-shadow: var(--shadow);
}

.toast.error {
  background: var(--red);
}

@media (max-width: 720px) {
  .two-columns {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .stat-card {
    padding: 12px 10px;
  }

  .stat-card strong {
    font-size: 1.35rem;
  }

  .app-header {
    padding: 12px;
  }

  .brand p {
    display: none;
  }

  .icon-button {
    padding: 0 10px;
  }

  .install-button {
    display: none !important;
  }
}

@media (max-width: 430px) {
  .app-main {
    padding-left: 14px;
    padding-right: 14px;
    padding-bottom: calc(120px + var(--safe-bottom));
  }

  .bottom-nav {
    gap: 3px;
    padding-left: 6px;
    padding-right: 6px;
  }

  .nav-btn {
    min-height: 72px;
    grid-template-rows: 29px auto;
    padding: 8px 2px 7px;
    font-size: 1.48rem;
  }

  .nav-btn span {
    font-size: 0.66rem;
    line-height: 1.05;
  }
}

@media (max-width: 380px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .vehicle-card-header,
  .deadline-card-header,
  .archive-card-header {
    flex-direction: column;
  }

  .bottom-nav {
    overflow-x: auto;
    padding-left: 8px;
    padding-right: 8px;
  }

  .nav-btn {
    flex: 0 0 62px;
    min-height: 70px;
    font-size: 1.38rem;
  }

  .nav-btn span {
    font-size: 0.63rem;
  }
}