/* ============================================================
   App Séchage — thème ardoise / braise (Weber) / luxe
   ============================================================ */
:root {
  --bg: #14161a;
  --bg-grad: radial-gradient(120% 80% at 50% -10%, #1d2128 0%, #14161a 55%, #101216 100%);
  --surface: #1e222a;
  --surface-2: #252a33;
  --surface-3: #2c313b;
  --border: #333a45;
  --border-soft: #2a303a;
  --text: #f1ede6;
  --muted: #98a0ac;
  --muted-2: #6c7581;
  --accent: #d98a4e;      /* braise / cuivre */
  --accent-2: #c0703a;
  --accent-soft: rgba(217, 138, 78, 0.14);
  --gold: #d9b26a;        /* touche luxe */
  --bordeaux: #8a3b46;    /* charcuterie */
  --bordeaux-soft: rgba(138, 59, 70, 0.18);
  --success: #6fae6a;
  --success-soft: rgba(111, 174, 106, 0.15);
  --warning: #e2a94e;
  --warning-soft: rgba(226, 169, 78, 0.15);
  --danger: #d0573f;
  --danger-soft: rgba(208, 87, 63, 0.16);
  --info: #6ea0c8;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-soft: 0 4px 14px rgba(0, 0, 0, 0.25);
  --maxw: 480px;
  --nav-h: 80px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  /* Bandes noires sur les côtés en desktop (letterbox) */
  background: #000;
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 16px; }

/* ---------- Shell ---------- */
/* Colonne d'app : fond ardoise (plein écran sur smartphone) avec repli ardoise unie */
#app {
  max-width: var(--maxw); margin: 0 auto; min-height: 100vh; position: relative;
  background-color: #1a1d22;
  /* voile sombre léger (lisibilité + profondeur) par-dessus la texture ardoise */
  background-image: linear-gradient(rgba(16, 18, 22, 0.35), rgba(16, 18, 22, 0.42)), url("/img/ardoise.jpg");
  background-repeat: no-repeat, no-repeat;
  background-position: center, center;
  background-size: cover, cover;
  background-attachment: fixed, fixed;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.6);
}

.appbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 14px) 18px 14px;
  background: rgba(20, 22, 26, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-soft);
}
.appbar h1 { font-size: 19px; font-weight: 700; margin: 0; letter-spacing: 0.2px; flex: 1; }
.appbar .sub { font-size: 12px; color: var(--muted); font-weight: 500; }
.appbar .iconbtn { background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 18px; }
.appbar .back { background: transparent; border: none; color: var(--accent); font-size: 22px; width: 34px; height: 40px; padding: 0; }

.content { padding: 18px 18px calc(var(--nav-h) + env(safe-area-inset-bottom) + 26px); }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted);
  margin: 22px 4px 12px; font-weight: 700; }
.section-title:first-child { margin-top: 6px; }

/* ---------- Bottom nav ---------- */
.bottomnav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: var(--maxw); z-index: 50;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(22, 24, 29, 0.94);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-soft);
  padding-bottom: env(safe-area-inset-bottom);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
}
.bottomnav button {
  background: none; border: none; color: var(--muted-2);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 10.5px; font-weight: 600; padding-top: 8px;
}
.bottomnav button .ic { font-size: 24px; line-height: 1; display: grid; place-items: center; height: 38px; }
.bottomnav button .ic img { width: 38px; height: 38px; object-fit: contain; display: block;
  opacity: 0.85; transition: opacity 0.15s, filter 0.15s; }
.bottomnav button.active .ic img { opacity: 1; filter: drop-shadow(0 0 8px var(--accent-soft)); }
.bottomnav button.active { color: var(--accent); }
.bottomnav button.active .ic { filter: drop-shadow(0 0 8px var(--accent-soft)); }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-soft);
  margin-bottom: 14px;
}
.card.tap { transition: transform 0.08s ease, border-color 0.15s; }
.card.tap:active { transform: scale(0.985); border-color: var(--border); }
.card-row { display: flex; align-items: center; gap: 12px; }
.card h3 { margin: 0 0 4px; font-size: 16px; font-weight: 700; }
.card .meta { color: var(--muted); font-size: 13px; }

.hero {
  background: linear-gradient(150deg, #262a32 0%, #1c2028 60%, #1a1d24 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
  margin-bottom: 16px; position: relative; overflow: hidden;
}
.hero::after { content: ""; position: absolute; right: -40px; top: -40px; width: 140px; height: 140px;
  background: radial-gradient(circle, var(--accent-soft), transparent 70%); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 14px; padding: 13px 18px;
  font-size: 15px; font-weight: 700; color: #fff; width: 100%;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 18px rgba(217, 138, 78, 0.28);
}
.btn:active { transform: translateY(1px); }
.btn.secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); box-shadow: none; }
.btn.ghost { background: transparent; color: var(--accent); border-color: var(--border); box-shadow: none; }
.btn.danger { background: transparent; color: var(--danger); border-color: rgba(208,87,63,0.5); box-shadow: none; }
.btn.sm { width: auto; padding: 9px 14px; font-size: 13px; border-radius: 11px; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { width: 100%; }
.fab-space { height: 8px; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 0 2px 7px; }
.field .hint { font-size: 12px; color: var(--muted-2); margin: 6px 2px 0; }
input, select, textarea {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); border-radius: 12px; padding: 13px 14px; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input::placeholder, textarea::placeholder { color: var(--muted-2); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 84px; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2398a0ac'%3E%3Cpath d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Segmented (perte cible, etc.) */
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
.segmented.wrap { grid-auto-flow: row; grid-template-columns: repeat(3, 1fr); }
.seg {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--muted);
  border-radius: 12px; padding: 12px 4px; font-weight: 700; font-size: 15px; text-align: center;
}
.seg.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.slider-row { display: flex; align-items: center; gap: 12px; }
input[type=range] { -webkit-appearance: none; appearance: none; height: 6px; border-radius: 6px;
  background: var(--surface-3); padding: 0; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; border-radius: 50%;
  background: linear-gradient(180deg, var(--accent), var(--accent-2)); border: 2px solid #fff2; box-shadow: 0 2px 8px rgba(0,0,0,.4); }
input[type=range]::-moz-range-thumb { width: 24px; height: 24px; border-radius: 50%; border: none;
  background: var(--accent); }

/* ---------- Chips / badges ---------- */
.chip { display: inline-flex; align-items: center; gap: 5px; background: var(--surface-2);
  border: 1px solid var(--border); color: var(--muted); border-radius: 999px; padding: 5px 11px;
  font-size: 12px; font-weight: 600; }
.chip.accent { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 4px 10px;
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.3px; }
.badge.preparation { background: var(--surface-3); color: var(--muted); }
.badge.salage { background: var(--bordeaux-soft); color: #e0899a; }
.badge.rincage { background: rgba(110,160,200,0.16); color: #8fb8d8; }
.badge.fumage { background: rgba(160,120,80,0.2); color: #d0a878; }
.badge.sechage { background: var(--accent-soft); color: var(--accent); }
.badge.termine { background: var(--success-soft); color: var(--success); }
.badge.abandonne { background: var(--surface-3); color: var(--muted-2); }

/* ---------- Progress ---------- */
.progress { height: 10px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--bordeaux), var(--accent), var(--gold)); transition: width 0.4s ease; }
.progress.done > span { background: linear-gradient(90deg, var(--success), #8fce88); }
.progress.over > span { background: linear-gradient(90deg, var(--warning), var(--danger)); }

.ring-wrap { display: flex; align-items: center; gap: 16px; }
.ring { --p: 0; width: 92px; height: 92px; border-radius: 50%; flex: 0 0 auto;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--surface-3) 0);
  display: grid; place-items: center; position: relative; }
.ring::before { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: var(--surface); }
.ring .val { position: relative; font-size: 20px; font-weight: 800; }
.ring .val small { display: block; font-size: 10px; color: var(--muted); font-weight: 600; letter-spacing: 0.5px; }

/* ---------- Stat grid ---------- */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); padding: 12px 13px; }
.stat .k { font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.stat .v { font-size: 19px; font-weight: 800; margin-top: 3px; }
.stat .v small { font-size: 12px; color: var(--muted); font-weight: 600; }

/* ---------- Alerts ---------- */
.alert-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border-soft); margin-bottom: 8px; }
.alert-item .dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.alert-item .dot.attention { background: var(--warning); box-shadow: 0 0 10px var(--warning-soft); }
.alert-item .dot.danger { background: var(--danger); box-shadow: 0 0 10px var(--danger-soft); }
.alert-item .dot.info { background: var(--info); }
.alert-item .grow { flex: 1; }
.alert-item .grow b { display: block; font-size: 14px; }
.alert-item .grow span { font-size: 12px; color: var(--muted); }

.callout { border-radius: var(--radius-sm); padding: 13px 15px; font-size: 13.5px; margin-bottom: 12px; border: 1px solid; }
.callout.warn { background: var(--warning-soft); border-color: rgba(226,169,78,0.4); color: #f0cf95; }
.callout.danger { background: var(--danger-soft); border-color: rgba(208,87,63,0.45); color: #f0a493; }
.callout.info { background: var(--surface-2); border-color: var(--border); color: var(--muted); }

/* ---------- Lists ---------- */
.list-item { display: flex; align-items: center; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--border-soft); }
.list-item:last-child { border-bottom: none; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .grow b { font-size: 15px; display: block; }
.list-item .grow span { font-size: 12.5px; color: var(--muted); }
.list-item .chev { color: var(--muted-2); font-size: 18px; }
.avatar { width: 44px; height: 44px; border-radius: 13px; flex: 0 0 auto; display: grid; place-items: center;
  font-size: 20px; background: var(--surface-3); border: 1px solid var(--border-soft); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 6px; background: var(--surface-2); border: 1px solid var(--border-soft);
  border-radius: 14px; padding: 5px; margin-bottom: 16px; }
.tabs button { flex: 1; background: none; border: none; color: var(--muted); font-weight: 700; font-size: 13.5px;
  padding: 10px 6px; border-radius: 10px; }
.tabs button.on { background: var(--surface-3); color: var(--text); box-shadow: var(--shadow-soft); }

/* ---------- Chart ---------- */
.chart-card { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius);
  padding: 14px; margin-bottom: 14px; }
.chart-card .lbl { font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 8px; }
svg.chart { width: 100%; height: auto; display: block; }

/* ---------- Sheet / modal ---------- */
.sheet-back { position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 60; display: flex; align-items: flex-end;
  animation: fade 0.2s ease; }
.sheet { background: var(--surface); width: 100%; max-width: var(--maxw); margin: 0 auto;
  border-radius: 22px 22px 0 0; border-top: 1px solid var(--border); padding: 8px 18px calc(env(safe-area-inset-bottom) + 22px);
  max-height: 90vh; overflow-y: auto; animation: up 0.26s cubic-bezier(.2,.8,.2,1); }
.sheet .grab { width: 44px; height: 5px; background: var(--border); border-radius: 3px; margin: 10px auto 14px; }
.sheet h2 { font-size: 18px; margin: 0 0 14px; }
@keyframes up { from { transform: translateY(30px); opacity: 0.6; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Auth ---------- */
.auth { padding: 0 22px; min-height: 100vh; display: flex; flex-direction: column; justify-content: center; }
.brand { text-align: center; margin-bottom: 30px; }
.brand-logo { display: block; width: min(78%, 300px); height: auto; margin: 0 auto;
  border-radius: 24px; box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55); }
.auth-switch { text-align: center; margin-top: 18px; color: var(--muted); font-size: 14px; }

/* ---------- Misc ---------- */
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.empty .ic { font-size: 40px; margin-bottom: 12px; opacity: 0.7; }
.rating { color: var(--gold); letter-spacing: 2px; font-size: 16px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.center { text-align: center; }
.spacer { height: 10px; }
.divider { height: 1px; background: var(--border-soft); margin: 16px 0; }
pre.pre { white-space: pre-wrap; font-family: inherit; margin: 0; color: var(--text); font-size: 14px; }

.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 24px); transform: translateX(-50%) translateY(20px);
  background: #2a2f38; color: var(--text); border: 1px solid var(--border); padding: 12px 18px; border-radius: 12px;
  font-size: 14px; font-weight: 600; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: all 0.25s; z-index: 100; max-width: 90%; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: var(--danger); }

.loader { display: grid; place-items: center; padding: 60px; }
.spin { width: 34px; height: 34px; border: 3px solid var(--surface-3); border-top-color: var(--accent); border-radius: 50%;
  animation: rot 0.8s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }
