:root {
  --primary: #1b4d6e;
  --primary-dark: #12354d;
  --secondary: #2a9d8f;
  --background: #f4f6f8;
  --surface: #ffffff;
  --text-primary: #1a1a1a;
  --text-secondary: #5f6b76;
  --divider: #e2e8ee;
  --overdue: #c62828;
  --white: #ffffff;
  --shadow: 0 1px 3px rgba(18, 53, 77, 0.12);
  --radius: 12px;
  --toolbar-h: 56px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  background: #d9e1e8;
  font-family: "Segoe UI", Roboto, system-ui, sans-serif;
  color: var(--text-primary);
}

body {
  min-height: 100dvh;
}

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

a {
  color: inherit;
}

.shell {
  position: relative;
  min-height: 100dvh;
  max-width: 640px;
  margin: 0 auto;
  background: var(--background);
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 40px rgba(18, 53, 77, 0.12);
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: calc(var(--toolbar-h) + var(--safe-top));
  padding: var(--safe-top) 4px 0;
  background: var(--primary);
  color: var(--white);
  display: flex;
  align-items: center;
  gap: 4px;
}

.toolbar h1 {
  flex: 1;
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.3;
  padding: 12px 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toolbar-end {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: 0;
  padding-right: 2px;
}

.toolbar-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 22px;
  text-decoration: none;
}

.toolbar-logo img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  display: block;
  /* Fond blanc léger : le logo a un fond clair */
  background: #fff;
  border-radius: 8px;
  padding: 2px;
}

.toolbar-logo:hover,
.toolbar-logo:focus-visible {
  background: rgba(255, 255, 255, 0.12);
  outline: none;
}

.menu {
  position: relative;
}

.menu-panel {
  position: absolute;
  top: calc(100% + 4px);
  right: 4px;
  min-width: 180px;
  padding: 6px 0;
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(18, 53, 77, 0.22);
  z-index: 40;
}

.menu-item {
  display: block;
  width: 100%;
  padding: 12px 16px;
  border: 0;
  background: transparent;
  color: var(--primary);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.menu-item:hover,
.menu-item:focus-visible {
  background: rgba(18, 53, 77, 0.08);
  outline: none;
}

.menu-form {
  margin: 0;
}

.menu-item-btn {
  font-family: inherit;
}

.icon-btn {
  border: 0;
  background: transparent;
  color: inherit;
  width: 44px;
  height: 44px;
  border-radius: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  text-decoration: none;
}

.icon-btn svg {
  width: 22px;
  height: 22px;
}

.icon-btn:hover,
.icon-btn:focus-visible {
  background: rgba(255, 255, 255, 0.12);
  outline: none;
}

.icon-btn.muted {
  color: var(--text-secondary);
}

.icon-btn.accent {
  color: var(--secondary);
}

.content {
  flex: 1;
  padding: 12px 16px calc(96px + var(--safe-bottom));
}

.content.form {
  padding-bottom: calc(32px + var(--safe-bottom));
}

.empty {
  color: var(--text-secondary);
  text-align: center;
  padding: 32px 16px;
  white-space: pre-line;
  line-height: 1.5;
}

.empty.inline {
  text-align: left;
  padding: 8px 0;
}

.card,
a.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 10px;
  display: block;
  text-decoration: none;
  color: inherit;
}

a.card {
  cursor: pointer;
}

a.card:hover {
  box-shadow: 0 2px 8px rgba(18, 53, 77, 0.16);
}

.card h2,
.card-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
}

.meta {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-top: 4px;
}

.row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.grow {
  flex: 1;
  min-width: 0;
}

.km {
  color: var(--primary);
  font-weight: 700;
  font-size: 0.875rem;
}

.km.lg {
  font-size: 1.125rem;
}

.updated {
  color: var(--text-secondary);
  font-size: 0.75rem;
  margin-top: 4px;
}

.fab {
  position: fixed;
  right: max(20px, calc(50vw - 320px + 20px));
  bottom: calc(20px + var(--safe-bottom));
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 16px;
  background: var(--secondary);
  color: var(--white);
  box-shadow: 0 4px 12px rgba(42, 157, 143, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  z-index: 15;
}

.fab svg {
  width: 26px;
  height: 26px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.field label {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--divider);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface);
  color: var(--text-primary);
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: 2px solid var(--primary);
  border-color: var(--primary);
}

.field textarea {
  min-height: 88px;
  resize: vertical;
}

.password-wrap {
  position: relative;
  width: 100%;
}

.password-wrap input {
  display: block;
  width: 100%;
  padding-right: 48px;
  box-sizing: border-box;
}

.password-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 40px;
  height: 40px;
  margin: 0;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 8px;
  padding: 0;
  line-height: 0;
  -webkit-appearance: none;
  appearance: none;
}

.password-toggle svg {
  width: 22px;
  height: 22px;
  display: block;
  pointer-events: none;
}

.password-toggle:hover,
.password-toggle:focus-visible {
  color: var(--primary);
  outline: none;
}

.password-toggle:focus-visible {
  box-shadow: 0 0 0 2px var(--primary);
}

.password-toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.password-toggle-icon.hidden {
  display: none !important;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: 28px;
  padding: 0 12px;
  height: 40px;
  margin-bottom: 8px;
}

.search svg {
  width: 18px;
  height: 18px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.search input {
  flex: 1;
  border: 0;
  background: transparent;
  min-width: 0;
  height: 38px;
}

.search input:focus {
  outline: none;
}

.toggle {
  display: flex;
  border: 1px solid var(--primary);
  border-radius: 8px;
  overflow: hidden;
  margin: 8px 0;
}

.toggle a,
.toggle button {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--primary);
  padding: 8px 6px;
  min-height: 40px;
  cursor: pointer;
  font-size: 0.85rem;
  text-align: center;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toggle a + a,
.toggle button + button {
  border-left: 1px solid var(--primary);
}

.toggle a.active,
.toggle button.active {
  background: var(--primary);
  color: var(--white);
}

.item-card {
  background: var(--surface);
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(18, 53, 77, 0.1);
  padding: 14px;
  margin-bottom: 8px;
}

a.item-main {
  display: block;
  text-decoration: none;
  color: inherit;
  flex: 1;
  min-width: 0;
}

.item-head {
  display: flex;
  align-items: center;
  gap: 4px;
}

.item-head h3 {
  flex: 1;
  margin: 0;
  font-size: 1rem;
}

.date-overdue {
  color: var(--overdue);
}

.remaining {
  margin-top: 2px;
  font-size: 0.75rem;
  color: var(--secondary);
}

.remaining.overdue {
  color: var(--overdue);
}

.checklist-box {
  background: var(--surface);
  border-radius: 8px;
  padding: 10px 12px 6px;
  margin: 4px 0 12px;
}

.checklist-box h3 {
  margin: 0 0 6px;
  font-size: 0.9rem;
}

.checklist-box label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  font-size: 0.9rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  max-width: 260px;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 12px 16px;
  background: var(--primary);
  color: var(--white);
  cursor: pointer;
  font-weight: 600;
  margin: 8px auto 0;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(18, 53, 77, 0.18);
  box-sizing: border-box;
}

.btn.outline {
  background: var(--surface);
  color: var(--primary);
  border: 1px solid var(--primary);
  box-shadow: none;
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.btn-stack .btn {
  margin-top: 0;
}

.btn-stack form {
  width: 100%;
  max-width: 260px;
  margin: 0;
  display: flex;
  justify-content: center;
}

.section-title {
  margin: 16px 0 4px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary-dark);
}

.section-subtitle {
  margin: 16px 0 8px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--primary);
}

.help {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.4;
}

.alt-card {
  border: 1px solid var(--divider);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 8px;
  background: var(--surface);
}

.ref {
  color: var(--primary);
  font-weight: 700;
  font-size: 0.875rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-bottom));
  transform: translateX(-50%);
  background: #323232;
  color: white;
  padding: 12px 18px;
  border-radius: 8px;
  z-index: 50;
  max-width: min(92vw, 480px);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(18, 53, 77, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 40;
}

.modal {
  background: var(--surface);
  border-radius: 16px;
  width: min(100%, 480px);
  max-height: min(90dvh, 720px);
  overflow: auto;
  padding: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.modal h2 {
  margin: 0 0 12px;
  font-size: 1.15rem;
}

.modal p {
  white-space: pre-line;
  line-height: 1.45;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.modal-actions button {
  border: 0;
  background: transparent;
  color: var(--primary);
  font-weight: 600;
  padding: 10px 12px;
  cursor: pointer;
  border-radius: 8px;
}

.modal-actions button.primary,
.modal-actions .primary {
  color: var(--white);
  background: var(--primary);
}

.parts-picker-head {
  display: flex;
  align-items: center;
  gap: 4px;
}

.parts-picker-head h2 {
  flex: 1;
  margin: 0;
}

.parts-list {
  max-height: 280px;
  overflow: auto;
}

.part-select {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 4px 0;
}

.part-select label {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.total {
  border-top: 1px solid var(--divider);
  margin-top: 8px;
  padding-top: 10px;
  color: var(--primary);
  font-weight: 700;
}

.inline-form {
  display: inline;
  margin: 0;
}

.share-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.share-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: 8px;
}

.share-item-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  font-size: 0.9rem;
}

.share-item-text span {
  color: var(--text-secondary);
  font-size: 0.82rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-link {
  border: 0;
  background: transparent;
  color: var(--overdue);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 4px;
  flex-shrink: 0;
}

.badge-shared {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(42, 157, 143, 0.15);
  color: var(--secondary);
  font-size: 0.7rem;
  font-weight: 700;
  vertical-align: middle;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
  font-size: 0.95rem;
  color: var(--text-primary);
  cursor: pointer;
}

.check-row input {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.hidden {
  display: none !important;
}

.setup-error {
  background: #fff3f3;
  border: 1px solid #f5c2c2;
  color: #8a1f1f;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 12px;
}

.auth-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
}

.auth-actions .btn {
  margin-top: 0;
}

.auth-link {
  color: var(--primary);
  font-size: 0.92rem;
  font-weight: 600;
  text-decoration: none;
  padding: 4px 8px;
}

.auth-link:hover,
.auth-link:focus-visible {
  text-decoration: underline;
  outline: none;
}

.contact-card {
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  padding: 20px 16px 8px;
  box-shadow: var(--shadow);
}

.faq-card {
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  padding: 20px 16px;
  box-shadow: var(--shadow);
}

.faq-question {
  margin: 0 0 16px;
  font-size: 1.05rem;
  color: var(--primary-dark);
  line-height: 1.35;
}

.faq-platform {
  margin: 16px 0 6px;
  font-size: 0.92rem;
  color: var(--primary);
}

.faq-platform:first-of-type {
  margin-top: 0;
}

.faq-answer {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.5;
}

.contact-lead {
  margin: 0 0 18px;
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.45;
}

.contact-form .field {
  margin-bottom: 14px;
}

.contact-form .field textarea {
  min-height: 140px;
  line-height: 1.45;
}

.field-hint {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.turnstile-wrap {
  display: flex;
  justify-content: center;
  margin: 8px 0 4px;
  min-height: 65px;
}

.turnstile-wrap .cf-turnstile {
  width: 100%;
  max-width: 100%;
}

/* Honeypot : hors écran, inaccessible au clavier */
.hp-field {
  position: absolute;
  left: -10000px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

