/* ─── Bessettes — app stylesheet ─────────────────────────────────
   Outfit only. Cottage palette: cream + deep forest green.
   Designed for phones, scales up cleanly.
   ──────────────────────────────────────────────────────────── */

:root {
  --bg: #F5F0E8;
  --bg-2: #EFE9DC;
  --surface: #FFFFFF;
  --surface-2: #FBFAF5;

  --accent: #2D5016;
  --accent-2: #5C8A2A;
  --accent-3: #A8C97F;
  --accent-soft: #E9F0D9;

  --danger: #C0392B;
  --danger-soft: #FCE7E4;
  --warn: #E67E22;
  --warn-soft: #FCEDD8;
  --info: #3a76d4;

  --text: #14110D;
  --text-2: #564E40;
  --text-3: #8C8473;

  --border: #E5DFCD;
  --border-2: #D4CEBB;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --r-2xl: 28px;
  --r-pill: 99px;

  --shadow-sm: 0 1px 2px rgba(20,17,13,0.04);
  --shadow-md: 0 4px 16px rgba(20,17,13,0.07);
  --shadow-lg: 0 12px 40px rgba(20,17,13,0.12);
  --shadow-xl: 0 24px 60px rgba(20,17,13,0.18);

  --topbar-h: 64px;
  --nav-h: 64px;

  --ease: cubic-bezier(0.32, 0.72, 0, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
*::before, *::after { box-sizing: border-box; }

/* Force the [hidden] attribute to actually hide elements even when a
   class also sets `display`. Without this, .app-shell { display: flex }
   wins over the UA `[hidden] { display: none }` rule and renders the
   "hidden" screen anyway. */
[hidden] { display: none !important; }

/* Auth screen fade transitions */
.page-login, .app-shell {
  transition: opacity 0.28s var(--ease);
}
.page-login.fade-out, .app-shell.fade-out {
  opacity: 0;
  pointer-events: none;
}

html, body {
  height: 100%;
  overscroll-behavior-y: none;
}

body {
  font-family: 'Outfit', system-ui, -apple-system, sans-serif;
  font-feature-settings: 'cv11', 'ss03', 'ss04';
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

iconify-icon {
  display: inline-flex;
  vertical-align: middle;
  flex-shrink: 0;
}

button { font-family: inherit; }
input, textarea { font-family: inherit; font-size: 16px; /* prevent iOS zoom */ }


/* ───────────────────────────  LOGIN  ─────────────────────────── */

.page-login {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px max(20px, env(safe-area-inset-left)) calc(24px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-right));
  background:
    radial-gradient(circle at 20% 14%, rgba(168,201,127,0.40), transparent 55%),
    radial-gradient(circle at 86% 88%, rgba(92,138,42,0.22), transparent 55%),
    var(--bg);
  position: relative;
  overflow: hidden;
}
.page-login::before {
  content: "";
  position: absolute; inset: 0;
  background-image:
    repeating-linear-gradient(0deg, rgba(45,80,22,0.03) 0 1px, transparent 1px 28px),
    repeating-linear-gradient(90deg, rgba(45,80,22,0.03) 0 1px, transparent 1px 28px);
  pointer-events: none;
}

.login-shell {
  position: relative;
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border-radius: var(--r-2xl);
  padding: 36px 28px 22px;
  box-shadow: var(--shadow-xl);
  border: 1px solid rgba(212,206,187,0.5);
  text-align: center;
  animation: rise 0.5s var(--ease);
}
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.login-mark {
  display: inline-flex;
  width: 72px; height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-soft) 0%, #f0e9d8 100%);
  border: 1px solid var(--border);
  align-items: center; justify-content: center;
  color: var(--accent);
  margin-bottom: 18px;
}

.login-eyebrow {
  font-weight: 400;
  font-size: 12px;
  color: var(--text-2);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.login-title {
  font-weight: 700;
  font-size: 38px;
  letter-spacing: -0.025em;
  line-height: 1;
  color: var(--accent);
  margin-bottom: 4px;
}
.login-tag {
  font-size: 13px;
  color: var(--text-3);
  margin-bottom: 26px;
  font-weight: 400;
}
.login-dots {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 18px;
  height: 14px;
  align-items: center;
}
.login-dots .dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--border-2);
  transition: background 0.18s, transform 0.18s var(--ease);
}
.login-dots .dot.filled {
  background: var(--accent);
  transform: scale(1.15);
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-input {
  width: 100%;
  border: 2px solid var(--border-2);
  border-radius: var(--r-lg);
  padding: 14px 18px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 8px;
  text-align: center;
  background: var(--bg);
  color: var(--accent);
  transition: border-color 0.2s, background 0.2s, transform 0.05s;
}
.login-input::placeholder { color: var(--text-3); font-weight: 400; letter-spacing: normal; font-size: 14px; }
.login-input:focus { outline: none; border-color: var(--accent-2); background: white; }
.login-input.has-error { border-color: var(--danger); animation: shake 0.4s; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%,60% { transform: translateX(-6px); }
  40%,80% { transform: translateX(6px); }
}
.login-error {
  font-size: 13px;
  color: var(--danger);
  background: var(--danger-soft);
  padding: 10px 14px;
  border-radius: var(--r-md);
  text-align: center;
  font-weight: 500;
}
.login-btn {
  width: 100%;
  padding: 15px 20px;
  border: none;
  border-radius: var(--r-lg);
  background: var(--accent);
  color: white;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.02em;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: background 0.2s, transform 0.08s;
  margin-top: 2px;
}
.login-btn:hover { background: #234210; }
.login-btn:active { transform: scale(0.98); }
.login-foot {
  margin-top: 22px;
  color: var(--text-3);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}


/* ───────────────────────────  APP SHELL  ─────────────────────────── */

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
}

/* TOPBAR */
.topbar {
  flex: 0 0 auto;
  height: var(--topbar-h);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  padding-top: env(safe-area-inset-top);
  box-sizing: content-box;
}
.topbar-left {
  display: flex; align-items: center; gap: 10px;
  min-width: 0;
}
.topbar-mark {
  width: 38px; height: 38px;
  border-radius: 11px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.topbar-title { line-height: 1.1; min-width: 0; }
.topbar-eyebrow {
  font-size: 11px;
  color: var(--text-3);
  font-weight: 400;
  letter-spacing: 0.04em;
}
.topbar-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}
.topbar-actions { display: flex; gap: 6px; align-items: center; }
.topbar-btn {
  width: 38px; height: 38px;
  border-radius: 11px;
  border: none;
  background: var(--bg-2);
  color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.06s;
}
.topbar-btn:hover { background: var(--border); }
.topbar-btn:active { transform: scale(0.94); }
.topbar-btn-primary {
  background: var(--accent);
  color: white;
}
.topbar-btn-primary:hover { background: #234210; }


/* VIEWPORT */
.viewport {
  flex: 1 1 auto;
  position: relative;
  overflow: hidden;
  min-height: 0;
}

.view {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  opacity: 0;
  transform: translateX(24px);
  pointer-events: none;
  transition: transform 0.32s var(--ease), opacity 0.22s ease;
}
.view.active {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}
.view.exiting {
  transform: translateX(-24px);
  opacity: 0;
  pointer-events: none;
}

.view-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 16px calc(28px + env(safe-area-inset-bottom));
  scroll-behavior: smooth;
}

.view-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.view-head-icon {
  width: 44px; height: 44px;
  border-radius: 13px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.view-head-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.view-head-sub {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
}


/* SUB-HEADER (mode segments + progress) */
.sub-header {
  flex: 0 0 auto;
  padding: 12px 16px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mode-segments {
  position: relative;
  display: flex;
  background: var(--bg-2);
  border-radius: var(--r-pill);
  padding: 4px;
  gap: 0;
}
.seg {
  flex: 1;
  position: relative;
  z-index: 1;
  border: none;
  background: transparent;
  padding: 9px 8px;
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-3);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: color 0.2s ease;
}
.seg.active { color: white; }
.seg-indicator {
  position: absolute;
  top: 4px; bottom: 4px;
  left: 4px;
  width: calc((100% - 8px) / 3);
  background: var(--accent);
  border-radius: var(--r-pill);
  transition: transform 0.34s var(--ease);
  z-index: 0;
}

.progress-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  background: var(--accent-soft);
  border-radius: var(--r-pill);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}
.progress-pct {
  margin-left: auto;
  font-weight: 700;
}
.progress-mini {
  width: 80px;
  height: 4px;
  background: rgba(45,80,22,0.15);
  border-radius: 99px;
  overflow: hidden;
}
.progress-mini-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.4s ease;
}


/* SECTIONS (checklist) */
.section-card {
  background: var(--surface);
  border-radius: var(--r-xl);
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.section-card.complete {
  background: var(--accent-soft);
  border-color: var(--accent-3);
}
.section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
}
.section-icon {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: var(--bg-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.section-card.complete .section-icon {
  background: white;
  color: var(--accent);
}
.section-info { flex: 1; min-width: 0; }
.section-title {
  font-weight: 700;
  font-size: 15.5px;
  letter-spacing: -0.005em;
}
.section-meta {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
  display: flex; align-items: center; gap: 6px;
}
.section-card.complete .section-meta {
  color: var(--accent);
  font-weight: 600;
}
.section-chevron {
  color: var(--text-3);
  transition: transform 0.24s var(--ease);
  display: flex;
}
.section-card.collapsed .section-chevron { transform: rotate(-90deg); }
.section-items {
  border-top: 1px solid var(--border);
  max-height: 9999px;
  transition: max-height 0.4s var(--ease), opacity 0.2s ease;
  overflow: hidden;
}
.section-card.collapsed .section-items {
  max-height: 0;
  border-top-color: transparent;
  opacity: 0;
}

/* CHECKLIST ITEM */
.check-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
  -webkit-user-select: none; user-select: none;
}
.check-item:last-child { border-bottom: none; }
.check-item:active { background: var(--bg-2); }
.check-item.done { background: rgba(168,201,127,0.1); }

.check-box {
  width: 26px; height: 26px;
  border-radius: 9px;
  border: 2px solid var(--border-2);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.22s var(--ease);
  background: white;
}
.check-item.done .check-box {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
.check-box svg { opacity: 0; transition: opacity 0.18s 0.05s; width: 14px; height: 14px; }
.check-item.done .check-box svg { opacity: 1; }
.check-item.just-checked .check-box {
  animation: pop 0.4s var(--ease);
}
@keyframes pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

.item-photo {
  width: 50px; height: 50px;
  border-radius: 11px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-2);
  border: 1px solid var(--border);
}
.item-photo-placeholder {
  width: 50px; height: 50px;
  border-radius: 11px;
  background: var(--bg-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  color: var(--text-3);
}

.item-info { flex: 1; min-width: 0; }
.item-label {
  font-weight: 500;
  font-size: 14.5px;
  line-height: 1.3;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.check-item.done .item-label {
  color: var(--text-3);
  text-decoration: line-through;
}
.item-desc {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
  line-height: 1.4;
}


/* ─── METERS ─── */
.meter-card {
  background: var(--surface);
  border-radius: var(--r-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 12px;
  overflow: hidden;
}
.meter-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px 10px;
}
.meter-card-icon {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.meter-card-title {
  font-weight: 700;
  font-size: 15px;
}
.meter-card-sub {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 2px;
}
.meter-card-stamp {
  margin-left: auto;
  font-size: 10px;
  color: var(--text-3);
  background: var(--bg-2);
  padding: 4px 8px;
  border-radius: var(--r-pill);
  font-weight: 500;
}
.meter-card-stamp:empty { display: none; }

.meter-card-body {
  display: flex;
  gap: 12px;
  padding: 0 16px 14px;
  align-items: stretch;
}
.meter-input-block { flex: 1; }
.meter-input-big {
  width: 100%;
  border: 2px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 14px;
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
  background: var(--bg);
  text-align: center;
  letter-spacing: -0.01em;
  transition: border-color 0.2s, background 0.2s;
}
.meter-input-big:focus { outline: none; border-color: var(--accent-2); background: white; }
.meter-input-big::placeholder { color: var(--border-2); font-weight: 500; font-size: 18px; letter-spacing: 4px; }
.meter-input-big.has-value { border-color: var(--accent-3); background: var(--accent-soft); }
.meter-input-unit {
  text-align: center;
  font-size: 11px;
  color: var(--text-3);
  margin-top: 4px;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.meter-photo-tile {
  width: 84px;
  border: 2px dashed var(--border-2);
  border-radius: var(--r-md);
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-3);
  cursor: pointer;
  font-size: 10px;
  font-weight: 600;
  flex-shrink: 0;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
  position: relative;
  overflow: hidden;
}
.meter-photo-tile:hover { border-color: var(--accent-2); color: var(--accent); }
.meter-photo-tile.has-photo {
  border: none;
  padding: 0;
  background: transparent;
}
.meter-photo-tile.has-photo img {
  width: 100%; height: 100%;
  object-fit: cover;
  cursor: zoom-in;
  display: block;
}
.meter-photo-del {
  position: absolute;
  top: 4px; right: 4px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  color: white;
  border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  z-index: 1;
}
.meter-photo-tile input[type="file"] { display: none; }

.meter-levels {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 0 16px 14px;
}
.level-btn {
  padding: 12px 4px;
  border: 2px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  color: var(--text-3);
  transition: all 0.18s var(--ease);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.level-btn iconify-icon { font-size: 18px; }
.level-btn.sel-vide { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.level-btn.sel-bas { border-color: var(--warn); background: var(--warn-soft); color: var(--warn); }
.level-btn.sel-mi { border-color: #d6ad00; background: #FFF6CC; color: #8a6f00; }
.level-btn.sel-plein { border-color: var(--accent-2); background: var(--accent-soft); color: var(--accent); }


/* ─── NOTES VIEW ─── */
.notes-card {
  background: var(--surface);
  border-radius: var(--r-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  margin-bottom: 12px;
}
.notes-label {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 10px;
  display: flex; align-items: center; gap: 8px;
  color: var(--text);
}
.notes-label iconify-icon { color: var(--accent); }
textarea.notes-textarea {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  resize: none;
  transition: border-color 0.2s;
  min-height: 110px;
  line-height: 1.5;
}
textarea.notes-textarea:focus { outline: none; border-color: var(--accent-2); background: white; }
textarea.notes-textarea::placeholder { color: var(--text-3); }

.bring-list { list-style: none; }
.bring-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.bring-item:last-child { border-bottom: none; }
.bring-bullet {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent-2);
  flex-shrink: 0;
}
.bring-text { flex: 1; font-size: 14px; }
.bring-delete {
  background: transparent; border: none;
  color: var(--danger);
  cursor: pointer; padding: 6px;
  border-radius: 8px;
  display: flex;
  transition: background 0.15s;
}
.bring-delete:hover { background: var(--danger-soft); }
.add-bring-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.add-bring-row input {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  padding: 11px 14px;
  font-size: 14px;
  background: var(--bg);
}
.add-bring-row input:focus { outline: none; border-color: var(--accent-2); }
.btn-add {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--r-md);
  padding: 10px 14px;
  cursor: pointer;
  display: flex; align-items: center;
  transition: background 0.15s, transform 0.06s;
}
.btn-add:active { transform: scale(0.94); background: var(--accent-2); }


/* ─── HISTORY ─── */
.history-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--surface);
  border-radius: var(--r-lg);
  margin-bottom: 8px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s, transform 0.06s;
}
.history-row:active { transform: scale(0.98); background: var(--bg-2); }
.history-icon {
  width: 42px; height: 42px;
  border-radius: 11px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.history-info { flex: 1; min-width: 0; }
.history-title {
  font-weight: 700;
  font-size: 14px;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.history-sub {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
}
.history-empty {
  text-align: center;
  padding: 56px 20px;
  color: var(--text-3);
}
.history-empty iconify-icon {
  font-size: 56px;
  color: var(--border-2);
  margin-bottom: 12px;
}
.history-empty p { font-size: 14px; }

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 700;
}
.badge-arrive { background: var(--accent-soft); color: var(--accent); }
.badge-depart { background: var(--warn-soft); color: var(--warn); }
.badge-tous   { background: #e2e3f3; color: #3a3a8a; }


/* ─── BOTTOM NAV ─── */
.bottom-nav {
  flex: 0 0 auto;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  position: sticky;
  bottom: 0;
  z-index: 50;
  position: relative;
}
.nav-tab {
  flex: 1;
  height: 100%;
  border: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  padding: 6px 4px;
  position: relative;
  color: var(--text-3);
  transition: color 0.2s;
}
.nav-tab.active { color: var(--accent); }
.nav-icon {
  font-size: 24px;
  transition: transform 0.24s var(--ease);
}
.nav-tab.active .nav-icon { transform: translateY(-1px) scale(1.1); }
.nav-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.nav-badge {
  position: absolute;
  top: 6px;
  right: calc(50% - 22px);
  background: var(--accent);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 99px;
  min-width: 16px;
  text-align: center;
  border: 2px solid var(--surface);
  line-height: 1.2;
}
.nav-indicator {
  position: absolute;
  top: 0;
  width: 20%;          /* default for 5 tabs — JS sets exact value */
  height: 3px;
  background: var(--accent);
  border-radius: 0 0 99px 99px;
  transition: transform 0.32s var(--ease), width 0.2s ease;
}


/* ─── TRAVAUX VIEW ─── */
.travaux-section {
  background: var(--surface);
  border-radius: var(--r-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  margin-bottom: 14px;
}
.travaux-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.travaux-section-title {
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.travaux-section-title iconify-icon { color: var(--accent); }

.btn-add-pill {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--r-pill);
  padding: 7px 14px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s, transform 0.06s;
}
.btn-add-pill:active { transform: scale(0.95); background: #234210; }

.travail-row, .materiel-row {
  display: flex;
  align-items: stretch;
  gap: 10px;
  padding: 10px;
  background: var(--bg);
  border-radius: var(--r-md);
  margin-bottom: 8px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s, transform 0.06s;
  position: relative;
  overflow: hidden;
}
.travail-row:active, .materiel-row:active { transform: scale(0.99); background: var(--bg-2); }
.travail-row.is-done, .materiel-row.is-done { opacity: 0.55; }

.priority-bar {
  width: 4px;
  align-self: stretch;
  border-radius: 2px;
  flex-shrink: 0;
  background: var(--text-3);
}
.priority-bar.prio-basse   { background: var(--text-3); }
.priority-bar.prio-moyenne { background: var(--warn); }
.priority-bar.prio-haute   { background: var(--danger); }

.travail-photo, .materiel-photo {
  width: 56px; height: 56px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--border);
}
.travail-photo-placeholder, .materiel-photo-placeholder {
  width: 56px; height: 56px;
  border-radius: 10px;
  background: var(--bg-2);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: var(--text-3);
}

.travail-info, .materiel-info {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  justify-content: center;
  gap: 2px;
}
.travail-title, .materiel-title {
  font-weight: 600;
  font-size: 14.5px;
  line-height: 1.25;
  word-break: break-word;
}
.travail-row.is-done .travail-title,
.materiel-row.is-done .materiel-title {
  text-decoration: line-through;
}
.travail-desc, .materiel-meta {
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.materiel-link {
  font-size: 11px;
  color: var(--info);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-top: 2px;
}
.travail-tags, .materiel-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 4px;
}
.chip {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.chip-prio-basse   { background: var(--bg-2);     color: var(--text-3); }
.chip-prio-moyenne { background: var(--warn-soft); color: var(--warn); }
.chip-prio-haute   { background: var(--danger-soft); color: var(--danger); }

.chip-status-todo     { background: var(--bg-2); color: var(--text-2); }
.chip-status-doing    { background: var(--warn-soft); color: var(--warn); }
.chip-status-done     { background: var(--accent-soft); color: var(--accent); }
.chip-status-ordered  { background: #e2e3f3; color: #3a3a8a; }
.chip-status-received { background: var(--accent-soft); color: var(--accent); }

.travail-quick {
  flex-shrink: 0;
  align-self: center;
  background: transparent;
  border: 2px solid var(--border-2);
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-3);
  transition: all 0.18s var(--ease);
  padding: 0;
}
.travail-quick.st-doing { border-color: var(--warn); color: var(--warn); background: var(--warn-soft); }
.travail-quick.st-done, .travail-quick.st-received {
  border-color: var(--accent); background: var(--accent); color: white;
}
.travail-quick.st-ordered { border-color: #3a3a8a; color: #3a3a8a; background: #e2e3f3; }
.travail-quick:active { transform: scale(0.92); }

.travaux-empty {
  text-align: center;
  padding: 28px 16px;
  color: var(--text-3);
  font-size: 13px;
}
.travaux-empty iconify-icon { font-size: 36px; color: var(--border-2); margin-bottom: 8px; display: block; margin-left: auto; margin-right: auto; }

.travaux-done-toggle {
  margin-top: 8px;
  padding: 9px 12px;
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: var(--r-md);
  color: var(--text-3);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  transition: background 0.15s;
}
.travaux-done-toggle:hover { background: var(--bg-2); }


/* ─── PRIORITY / STATUS PILLS (modal forms) ─── */
.prio-pills, .status-pills {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.prio-pill, .status-pill {
  border: 2px solid var(--border);
  background: var(--surface);
  padding: 9px 6px;
  border-radius: var(--r-md);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-2);
  transition: all 0.18s var(--ease);
}
.prio-pill[data-val="basse"].active   { border-color: var(--text-3); background: var(--bg-2); color: var(--text); }
.prio-pill[data-val="moyenne"].active { border-color: var(--warn); background: var(--warn-soft); color: var(--warn); }
.prio-pill[data-val="haute"].active   { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }

.status-pill[data-val="todo"].active     { border-color: var(--text-2); background: var(--bg-2); color: var(--text); }
.status-pill[data-val="doing"].active    { border-color: var(--warn); background: var(--warn-soft); color: var(--warn); }
.status-pill[data-val="done"].active     { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.status-pill[data-val="ordered"].active  { border-color: #3a3a8a; background: #e2e3f3; color: #3a3a8a; }
.status-pill[data-val="received"].active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }


/* ─── EDIT PHOTO BOX (in modals) ─── */
.edit-photo-box {
  display: flex;
  align-items: center;
  gap: 12px;
}
.edit-photo-thumb {
  width: 80px; height: 80px;
  border-radius: var(--r-md);
  object-fit: cover;
  border: 1px solid var(--border);
}
.edit-photo-empty {
  width: 80px; height: 80px;
  border-radius: var(--r-md);
  background: var(--bg-2);
  border: 2px dashed var(--border-2);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3);
}
.edit-photo-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}
.edit-photo-actions label.upload-label,
.edit-photo-actions button {
  width: 100%;
  justify-content: center;
}


/* ─── TOAST ─── */
.toast {
  position: fixed;
  /* Sits above the bottom nav by default. When a modal is open it floats
     to the top so it never overlaps the modal's Save/Delete buttons. */
  bottom: calc(var(--nav-h) + 18px + env(safe-area-inset-bottom));
  top: auto;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: white;
  padding: 11px 18px;
  border-radius: var(--r-pill);
  font-size: 13.5px;
  font-weight: 500;
  z-index: 600;
  opacity: 0;
  transition: opacity 0.28s var(--ease), transform 0.28s var(--ease);
  white-space: nowrap;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* When any modal is open, anchor the toast at the TOP so it doesn't sit
   behind / on top of the modal's action buttons. */
body:has(.modal-overlay.open) .toast {
  top: calc(env(safe-area-inset-top) + 12px);
  bottom: auto;
  transform: translateX(-50%) translateY(-20px);
}
body:has(.modal-overlay.open) .toast.show {
  transform: translateX(-50%) translateY(0);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.success { background: var(--accent); }
.toast.error { background: var(--danger); }
.toast .toast-icon { color: currentColor; }


/* ─── MODAL ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20,17,13,0.5);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal-sheet {
  background: var(--surface);
  width: 100%;
  max-width: 520px;
  border-radius: var(--r-2xl) var(--r-2xl) 0 0;
  padding: 18px 20px calc(20px + env(safe-area-inset-bottom));
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.34s var(--ease);
  -webkit-overflow-scrolling: touch;
}
.modal-overlay.open .modal-sheet { transform: translateY(0); }
.modal-handle {
  width: 40px; height: 4px;
  background: var(--border-2);
  border-radius: 99px;
  margin: 0 auto 14px;
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 18px;
  gap: 12px;
}
.modal-title {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 10px;
  color: var(--text);
}
.modal-title iconify-icon { color: var(--accent); }
.modal-help { font-size: 14px; color: var(--text-2); margin-bottom: 14px; }
.modal-hint { font-size: 12px; color: var(--text-3); margin-top: 12px; }
.modal-hint code { background: var(--bg-2); padding: 1px 6px; border-radius: 4px; font-family: ui-monospace, Menlo, monospace; font-size: 11.5px; }
.hint-tip {
  background: var(--accent-soft);
  color: var(--text-2);
  padding: 10px 12px;
  border-radius: var(--r-md);
  font-size: 12px;
  display: flex; align-items: flex-start; gap: 8px;
  line-height: 1.45;
}
.hint-tip iconify-icon { color: var(--accent); flex-shrink: 0; margin-top: 2px; }
.modal-row { display: flex; gap: 8px; margin-top: 10px; }


/* ─── BUTTONS ─── */
.btn-main {
  width: auto;
  padding: 13px 16px;
  border: none;
  border-radius: var(--r-md);
  font-family: inherit;
  font-weight: 600;
  font-size: 14.5px;
  cursor: pointer;
  transition: all 0.18s var(--ease);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-main.full { width: 100%; }
.btn-main.half { flex: 1; }
.btn-main:active { transform: scale(0.98); }

.btn-validate { background: var(--accent); color: white; }
.btn-validate:hover { background: #234210; }
.btn-ghost { background: var(--bg-2); color: var(--text); }
.btn-ghost:hover { background: var(--border); }
.btn-danger-outline {
  background: transparent;
  color: var(--danger);
  border: 1.5px solid var(--danger);
}
.btn-danger-outline:hover { background: var(--danger-soft); }


/* ─── CODE INPUT (admin gate) ─── */
.code-input {
  position: relative;
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.code-input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  z-index: 1;
}
.code-input input {
  flex: 1;
  border: 2px solid var(--border-2);
  border-radius: var(--r-md);
  padding: 13px 14px 13px 40px;
  font-size: 18px;
  letter-spacing: 6px;
  text-align: center;
  background: var(--bg);
  font-weight: 600;
  color: var(--accent);
}
.code-input input:focus { outline: none; border-color: var(--accent); background: white; }
.btn-code {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--r-md);
  padding: 0 18px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  display: flex; align-items: center;
  transition: background 0.15s, transform 0.06s;
}
.btn-code:active { transform: scale(0.96); background: #234210; }


/* ─── BACKEND EDITOR ─── */
.backend-panel { display: none; }
.backend-panel.visible { display: block; }
.backend-tabs {
  display: flex; gap: 6px;
  background: var(--bg-2);
  padding: 4px;
  border-radius: var(--r-md);
  margin-bottom: 14px;
}
.backend-tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 9px 4px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-3);
  display: flex; align-items: center; justify-content: center; gap: 5px;
  transition: background 0.15s, color 0.15s;
}
.backend-tab.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.section-editor {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 14px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.section-editor-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.section-editor-title {
  font-weight: 700;
  font-size: 15px;
  flex: 1;
  border: none !important;
  border-bottom: 2px solid var(--border) !important;
  border-radius: 0 !important;
  padding: 4px 0 !important;
  background: transparent !important;
}
.item-editor {
  background: var(--bg);
  border-radius: var(--r-md);
  padding: 12px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
}
.item-editor-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}
.item-editor input[type="text"] {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
  font-family: inherit;
  font-size: 13.5px;
  background: white;
}
.item-editor input:focus { outline: none; border-color: var(--accent-2); }
.tag-mode {
  display: inline-flex;
  background: var(--bg);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.tag-mode-btn {
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 600;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-3);
  font-family: inherit;
}
.tag-mode-btn.active { background: var(--accent); color: white; }

.btn-sm {
  padding: 7px 12px;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex; align-items: center; gap: 5px;
}
.btn-sm.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-sm.btn-ghost { background: var(--bg-2); color: var(--text); }

.photo-upload-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.photo-preview-small {
  width: 36px; height: 36px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border);
}
label.upload-label {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 11px;
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
}
input[type="file"].file-hidden { display: none; }


/* ─── SETTINGS CARDS ─── */
.settings-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px;
  margin-bottom: 12px;
}
.settings-card-danger { border-color: #f5c6c1; background: #fff6f4; }
.settings-label {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 4px;
  display: flex; align-items: center; gap: 7px;
}
.settings-label iconify-icon { color: var(--accent); }
.settings-card-danger .settings-label iconify-icon { color: var(--danger); }
.settings-help {
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 10px;
  line-height: 1.45;
}

.input-field {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 14px;
  font-family: inherit;
  background: var(--surface);
  margin-bottom: 12px;
  font-size: 14px;
}
.input-field:focus { outline: none; border-color: var(--accent-2); }


/* ─── MAIL PREVIEW + REPORT VIEW ─── */
.mail-preview {
  background: var(--bg);
  border-radius: var(--r-md);
  padding: 12px;
  font-size: 12px;
  line-height: 1.55;
  margin-bottom: 14px;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border);
  white-space: pre-wrap;
  font-family: ui-monospace, 'Cascadia Mono', Menlo, monospace;
  color: var(--text-2);
}
.report-view {
  background: var(--bg);
  border-radius: var(--r-md);
  padding: 14px;
  font-family: ui-monospace, 'Cascadia Mono', Menlo, monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  color: var(--text-2);
  max-height: 50vh;
  overflow-y: auto;
  border: 1px solid var(--border);
}
.report-photos {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.report-photos:empty { display: none; margin-bottom: 0; }
.report-photo {
  background: var(--bg);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  overflow: hidden;
}
.report-photo img {
  width: 100%; display: block;
  aspect-ratio: 4/3;
  object-fit: cover;
  cursor: zoom-in;
}
.report-photo-cap {
  font-size: 11px;
  text-align: center;
  padding: 6px 4px;
  color: var(--text-3);
  font-weight: 600;
}


/* ─── EMPTY STATES ─── */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-3);
}
.empty-state iconify-icon {
  font-size: 56px;
  color: var(--border-2);
  margin-bottom: 14px;
}
.empty-state p {
  font-size: 14px;
  margin-bottom: 4px;
}


@media (min-width: 540px) {
  .app-shell { box-shadow: var(--shadow-md); }
}
