:root {
  --bg: #14110f;
  --panel: #1d1a17;
  --panel2: #24201c;
  --gold: #e8a33d;
  --green: #62a981;
  --text: #f6f1e8;
  --muted: #a79c8d;
  --dim: #9c9183;
  --danger: #d96c62;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: #0d0b0a;
  color: var(--text);
  font: 15px/1.45 'Figtree', system-ui, -apple-system, Segoe UI, sans-serif;
}

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

/* ---------- App shell ---------- */

#app {
  width: min(100%, 720px);
  min-height: 100dvh;
  margin: auto;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 45px #0008;
}

header {
  height: 78px;
  padding: 17px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--panel2);
}

.eyebrow { font-size: 10px; letter-spacing: .2em; color: var(--gold); font-weight: 800; }
h1 { font-size: 20px; margin: 1px 0; letter-spacing: .03em; }
h2 { font-size: 26px; margin: 0; letter-spacing: -.02em; }
h3 { margin: 0; font-size: 17px; }
.sub { color: var(--muted); font-size: 13px; }

.icon {
  border: 0; background: var(--panel2); border-radius: 50%;
  width: 42px; height: 42px; display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}

main { flex: 1; padding: 20px 20px 105px; overflow: auto; }

/* ---------- Hero / avatar ---------- */

.hero { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 20px; }

.avatar {
  width: 40px; height: 40px; border-radius: 20px; flex: none;
  background: var(--panel2); color: var(--gold);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; cursor: pointer;
}

/* ---------- Quick action tiles ---------- */

.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }

.quick-tile {
  border: 0; border-radius: 18px; padding: 14px 12px; min-height: 96px;
  display: flex; flex-direction: column; justify-content: space-between; gap: 18px;
  background: var(--panel2); color: var(--text); cursor: pointer; text-align: left;
}
.quick-tile.primary { background: var(--gold); color: var(--bg); }
.quick-tile svg { stroke: currentColor; }
.quick-tile strong { font-size: 14px; font-weight: 700; line-height: 1.15; }
.quick-tile.locked { opacity: .55; position: relative; }
.quick-tile .lock { position: absolute; top: 8px; right: 10px; font-size: 10px; font-weight: 800; color: var(--gold); letter-spacing: .04em; }

/* ---------- Stats ---------- */

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 18px 0; }
.stat, .card { background: var(--panel); border: 1px solid #2b2722; border-radius: 18px; padding: 16px; }
.stat { cursor: pointer; }
.stat strong { font-size: 28px; color: var(--gold); display: block; }
.stat span { color: var(--muted); font-size: 12px; }

/* ---------- Section / lists ---------- */

.section-title { display: flex; justify-content: space-between; align-items: center; margin: 22px 0 10px; }
.section-title h3 { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.section-title small, .section-title a { color: var(--gold); font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none; }

.list { display: flex; flex-direction: column; gap: 9px; }

.row {
  width: 100%; text-align: left; background: var(--panel); border: 1px solid #2b2722;
  border-radius: 15px; padding: 14px; display: flex; gap: 12px; align-items: center; cursor: pointer;
}
.row .grow { flex: 1; min-width: 0; }
.row strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row small { color: var(--muted); }

.nfc-chip { display: inline-flex; vertical-align: middle; margin-left: 5px; color: var(--gold); }
.nfc-chip svg { width: 13px; height: 13px; display: block; }

.row.selected { border-color: var(--gold); background: #e8a33d1a; }
.apiary-card.selected { background: #e8a33d1a; box-shadow: inset 0 0 0 1.5px var(--gold); }

/* ---------- Journal du site (groupes dépliables) ---------- */

.journal-group { display: flex; flex-direction: column; }
.journal-chevron { transition: transform .15s; color: var(--dim); flex: none; }
.journal-toggle.expanded .journal-chevron { transform: rotate(90deg); }
.journal-items { display: flex; flex-direction: column; padding-left: 12px; border-left: 2px solid var(--panel2); margin: 2px 0 2px 21px; }
.journal-items[hidden] { display: none; }
.journal-subitem { padding: 8px 0 8px 12px; border-bottom: 1px solid var(--panel2); }
.journal-subitem:last-child { border-bottom: 0; }
.journal-subitem small { color: var(--muted); font-size: 13px; }
.journal-day .journal-items { margin-left: 8px; padding-left: 8px; }
.journal-day .journal-subitem { padding: 8px 0 8px 10px; margin: 2px 0; display: flex; flex-direction: column; gap: 2px; }
.journal-cat { font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--text); }

/* ---------- Barre d'actions groupées ---------- */

.bulk-bar {
  position: sticky; bottom: 14px; margin-top: 14px; display: flex; gap: 8px;
  background: var(--panel); border: 1px solid #2b2722; border-radius: 16px; padding: 10px;
  box-shadow: 0 10px 24px -8px #000a;
}
.bulk-bar button {
  flex: 1; border: 0; border-radius: 12px; padding: 10px 4px; font-size: 11px; font-weight: 700;
  background: var(--panel2); color: var(--text); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.bulk-bar button svg { stroke: var(--gold); }
.bulk-bar .cancel { background: none; color: var(--dim); }
.bulk-bar .cancel svg { stroke: var(--dim); }
.bulk-bar .cancel span { font-size: 16px; font-weight: 800; color: var(--gold); }

.badge { padding: 4px 8px; border-radius: 99px; background: var(--panel2); color: var(--muted); font-size: 11px; font-weight: 800; }
.badge.alert { background: #e8a33d22; color: var(--gold); }

.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); flex: none; }
.dot.alert { background: var(--gold); }

.empty { text-align: center; color: var(--muted); padding: 40px 12px; }


/* ---------- Search + filter pills ---------- */

.search-wrap { position: relative; margin: 4px 0; }
.search-wrap svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); pointer-events: none; stroke: var(--dim); }
.search {
  width: 100%; background: var(--panel); border: 1px solid #373129; border-radius: 13px;
  color: var(--text); padding: 12px 14px 12px 40px;
}

/* ---------- Cartes rucher (écran Ruchers) ---------- */

.apiary-card {
  width: 100%; text-align: left; border: 0; cursor: pointer;
  background: var(--panel); border-radius: 16px; padding: 15px 16px;
  display: flex; align-items: center; gap: 14px;
}
.apiary-card .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.apiary-name { font-size: 17px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.apiary-sub { font-size: 13px; color: var(--muted); }
.apiary-side { text-align: right; flex: none; display: flex; flex-direction: column; gap: 3px; }
.apiary-trend { font-size: 15px; font-weight: 700; }
.apiary-last { font-size: 12px; color: var(--dim); }

.todo-badge {
  display: inline-flex; align-items: center; gap: 3px; flex: none;
  background: #e8a33d22; color: var(--gold); border-radius: 999px;
  padding: 3px 8px 3px 6px; font-size: 11px; font-weight: 800;
}

.pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  border: 0; background: var(--panel2); color: var(--muted); border-radius: 999px;
  padding: 8px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.pill.active { background: var(--gold); color: var(--bg); font-weight: 700; }

/* ---------- Segmented control (force, population…) ---------- */

.seg { display: flex; gap: 8px; }
.seg button {
  flex: 1; border: 0; background: var(--panel2); border-radius: 14px; padding: 15px 4px;
  text-align: center; font-size: 14px; font-weight: 700; color: var(--muted); cursor: pointer;
}
.seg button.active { background: var(--gold); color: var(--bg); font-weight: 800; }

/* ---------- Stepper (+/-) ---------- */

.stepper {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--panel); border-radius: 16px; padding: 8px 12px;
}
.stepper button {
  width: 40px; height: 40px; border-radius: 20px; border: 0;
  background: var(--panel2); color: var(--text); font-size: 22px; font-weight: 700; cursor: pointer;
}
.stepper button.inc { background: var(--gold); color: var(--bg); }
.stepper .val { font-size: 24px; font-weight: 800; color: var(--text); }

/* Steppers pleine largeur avec de gros boutons : utilisables avec des gants. */
.steppers-lg .stepper { padding: 10px 16px; }
.steppers-lg .stepper button { width: 56px; height: 56px; border-radius: 28px; font-size: 30px; }
.steppers-lg .stepper .val { font-size: 28px; }

/* ---------- Chips (observations) ---------- */

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; background: var(--panel2); color: #d8cfc2;
  border-radius: 999px; padding: 11px 16px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.chip input { position: absolute; opacity: 0; width: 0; height: 0; }
.chip:has(input:checked) { background: var(--gold); color: var(--bg); font-weight: 700; }

/* ---------- Strength banner (fiche ruche) ---------- */

.banner { background: var(--gold); border-radius: 20px; padding: 18px; display: flex; flex-direction: column; gap: 14px; color: var(--bg); }
.banner .row-between { display: flex; align-items: center; justify-content: space-between; }
.banner .label { font-size: 13px; font-weight: 700; opacity: .7; letter-spacing: .1em; text-transform: uppercase; }
.banner .meta { font-size: 13px; font-weight: 700; }
.bars { display: flex; gap: 8px; align-items: flex-end; height: 44px; }
.bars > div { flex: 1; border-radius: 4px; background: rgba(20, 17, 15, .25); }
.bars > div.filled { background: var(--bg); }

/* ---------- Tile grid + rows ("Plus") ---------- */

.tile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile {
  background: var(--panel); border-radius: 18px; padding: 16px; display: flex; flex-direction: column; gap: 24px;
  border: 0; text-align: left; width: 100%; cursor: pointer; color: inherit;
}
.tile svg { stroke: var(--gold); }
.tile strong { font-size: 16px; font-weight: 700; color: var(--text); }
.tile small { color: var(--muted); font-size: 12px; }

.more-rows { display: flex; flex-direction: column; }
.more-rows .row-item { display: flex; align-items: center; gap: 12px; padding: 15px 0; border-bottom: 1px solid var(--panel2); }
.more-rows .row-item strong { flex: 1; font-size: 15px; font-weight: 600; color: var(--text); }
.more-rows .row-item span { font-size: 13px; color: var(--dim); }

.account-card { display: flex; align-items: center; justify-content: space-between; }
.account-card a { color: var(--gold); font-weight: 700; font-size: 13px; text-decoration: none; }

/* ---------- Sticky bottom CTA ---------- */

.cta-sticky {
  position: sticky; bottom: 14px; margin-top: 18px; display: block; width: 100%; border: 0;
  background: var(--gold); border-radius: 16px; padding: 16px; text-align: center;
  font-size: 16px; font-weight: 800; color: var(--bg); cursor: pointer; text-decoration: none;
  box-shadow: 0 10px 24px -8px #000a;
}
.btn-row { display: flex; gap: 10px; }
.btn-row button {
  flex: 1; border: 0; border-radius: 14px; padding: 14px 8px; text-align: center;
  font-size: 15px; font-weight: 800; cursor: pointer;
}
.btn-row .primary-btn { background: var(--gold); color: var(--bg); }
.btn-row .secondary-btn { background: var(--panel2); color: var(--text); font-weight: 700; }

/* ---------- Nav ---------- */

nav {
  position: fixed; z-index: 5; bottom: 0; width: min(100%, 720px);
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 8px 8px calc(10px + env(safe-area-inset-bottom));
  background: #1a1714; border-top: 1px solid var(--panel2);
}
nav button { border: 0; background: none; color: var(--dim); padding: 6px 2px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; }
nav button svg { stroke: currentColor; }
nav span { font-size: 10px; font-weight: 600; }
nav button.active { color: var(--gold); }

/* ---------- Dialog / modal ---------- */

dialog {
  width: min(92%, 560px); max-height: min(85vh, 720px); overflow-y: auto; -webkit-overflow-scrolling: touch;
  border: 1px solid #39322a; border-radius: 20px; background: var(--panel); color: var(--text); padding: 22px;
}
dialog::backdrop { background: #000a; }
.close { position: sticky; top: 0; float: right; border: 0; background: none; color: var(--muted); font-size: 26px; cursor: pointer; }

/* ---------- Forms ---------- */

form { display: grid; gap: 14px; margin-top: 18px; }
label, .field { display: grid; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
input, select, textarea {
  width: 100%; border: 1px solid #423a31; background: var(--bg); color: var(--text);
  border-radius: 10px; padding: 11px; font-weight: 400; text-transform: none; letter-spacing: normal;
}
textarea { min-height: 80px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.primary { border: 0; border-radius: 12px; background: var(--gold); color: #17120d; font-weight: 800; padding: 13px; cursor: pointer; }

/* ---------- Toast ---------- */

#toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 20;
}
#toast.show { opacity: 1; }

.loading { text-align: center; color: var(--muted); padding-top: 80px; }

/* ---------- Auth pages (login / install) ---------- */

.auth-page { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card {
  width: 100%; max-width: 380px; background: var(--panel); border: 1px solid #2b2722;
  border-radius: 20px; padding: 30px 26px; display: flex; flex-direction: column; gap: 6px;
}
.auth-card h1 { margin: 0 0 8px; }
.auth-card .sub { margin-bottom: 10px; }
.auth-card form { margin-top: 8px; }
.auth-submit { display: block; margin-top: 10px; text-align: center; text-decoration: none; }
.field-error { color: var(--danger); font-size: 13px; margin: 0 0 4px; }
.field-success { color: var(--green); font-size: 13px; margin: 0 0 4px; }

/* ---------- Progress steps (greffages) ---------- */

.steps { display: flex; gap: 6px; align-items: center; }
.steps > div { flex: 1; height: 6px; border-radius: 3px; background: var(--panel2); }
.steps > div.done { background: var(--gold); }
.step-labels { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }

/* ---------- Scan NFC ---------- */

.nfc-target { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 26px; padding: 30px 0; }
.nfc-rings { width: 200px; height: 200px; border-radius: 100px; border: 1px solid var(--panel2); display: flex; align-items: center; justify-content: center; }
.nfc-rings .ring2 { width: 148px; height: 148px; border-radius: 74px; border: 1px solid #2e2925; display: flex; align-items: center; justify-content: center; }
.nfc-rings .core { width: 94px; height: 94px; border-radius: 47px; background: var(--gold); color: var(--bg); display: flex; align-items: center; justify-content: center; }
.nfc-rings.scanning .core { animation: nfc-pulse 1.4s ease-in-out infinite; }
@keyframes nfc-pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.08); opacity: .85; } }

/* ---------- Calendrier ---------- */

.month-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.month-grid .wd { text-align: center; font-size: 11px; font-weight: 700; color: var(--dim); padding-bottom: 4px; }
.month-grid .day { aspect-ratio: 1; border-radius: 11px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; background: transparent; color: var(--text); font-size: 13px; font-weight: 600; cursor: default; }
.month-grid .day.has-event { background: var(--panel); }
.month-grid .day.today { background: var(--gold); color: var(--bg); font-weight: 800; }
.month-grid .day .dot { width: 4px; height: 4px; border-radius: 2px; background: transparent; }

.legend { display: flex; flex-wrap: wrap; gap: 12px; }
.legend .item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.legend .swatch { width: 7px; height: 7px; border-radius: 4px; flex: none; }

@media (min-width: 700px) {
  .stats { grid-template-columns: repeat(4, 1fr); }
}

/* ---------- Comptes / formules ---------- */
.tile.locked { opacity: .55; position: relative; }
.tile .lock { position: absolute; top: 8px; right: 10px; font-size: 10px; font-weight: 800; color: var(--gold); letter-spacing: .04em; }
.upsell { text-align: center; padding: 28px 8px; display: flex; flex-direction: column; gap: 14px; align-items: center; }
.upsell p { margin: 0; color: var(--muted); }
