/* Ma Cave — feuille de style unique */
:root {
  --bg: #F6F3EE;
  --surface: #FFFFFF;
  --ink: #221B18;
  --ink-2: #4A403B;
  --muted: #675D57;
  --line: #E4DDD5;
  --line-2: #D9D0C6;
  --soft: #EFE8E0;
  --wine: #7B1E3A;
  --wine-dark: #5A1529;
  --wine-soft: #F3E4E8;
  --warn-bg: #FBEFD9; --warn-ink: #6B4500;
  --ok-bg: #E1F0EE; --ok-ink: #154B45;
  --info-bg: #E5ECF6; --info-ink: #1F3F6B;
  --danger-bg: #F8E1DE; --danger-ink: #8A1F12;
  --side: #2A1F1D;
  --radius: 12px;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans); }
a { color: var(--wine); }
a:hover { color: var(--wine-dark); }
h1, h2, h3 { line-height: 1.2; }
h1 { font-family: var(--serif); font-weight: 600; font-size: 30px; margin: 0; }
h2 { font-size: 17px; font-weight: 600; margin: 0 0 12px; }
h3 { font-size: 15px; font-weight: 600; margin: 0 0 8px; }
img { max-width: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid #1F3F6B; outline-offset: 2px; }

/* Structure */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 236px; flex: 0 0 236px; background: var(--side); color: #F6F3EE; padding: 24px 14px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { font-family: var(--serif); font-size: 22px; font-weight: 600; padding: 0 12px 20px; color: #fff; text-decoration: none; display: block; }
.sidebar a.nav { display: block; padding: 10px 12px; border-radius: 8px; color: #E9E1D8; text-decoration: none; }
.sidebar a.nav:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar a.nav[aria-current="page"] { background: var(--wine); color: #fff; font-weight: 500; }
.sidebar .sep { height: 1px; background: rgba(255,255,255,.12); margin: 14px 8px; }
.sidebar .me { margin-top: auto; padding: 12px; font-size: 13px; color: #D9CFC4; }
.sidebar .me form { margin-top: 8px; }
.sidebar .me button { background: none; border: 1px solid rgba(255,255,255,.25); color: #F6F3EE; border-radius: 8px; padding: 6px 10px; font: inherit; cursor: pointer; }
.main { flex: 1; min-width: 0; padding: 28px 40px 48px; }
.page-head { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-head .sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
.crumbs { font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.tabbar { display: none; }

/* Cartes et grilles */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; }
.card + .card { margin-top: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 20px; }
.grid-kpi { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.cols { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.col-main { flex: 2 1 520px; min-width: 0; display: grid; gap: 20px; }
.col-side { flex: 1 1 300px; min-width: 0; display: grid; gap: 20px; }
.stack { display: grid; gap: 20px; }
/* Grilles à une colonne : la piste ne s'élargit jamais au-delà du conteneur */
.col-main, .col-side, .stack, .wine-list { grid-template-columns: minmax(0, 1fr); }
.card { min-width: 0; }
.kpi .label { font-size: 13px; color: var(--muted); }
.kpi .value { font-family: var(--serif); font-size: 32px; font-weight: 600; margin-top: 4px; }
.kpi .hint { font-size: 13px; color: var(--muted); }
.bar { height: 6px; background: var(--soft); border-radius: 3px; margin-top: 8px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--wine); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mt { margin-top: 16px; }
.empty { text-align: center; color: var(--muted); padding: 24px 12px; }

/* Boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font: inherit; font-weight: 500; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--soft); color: var(--ink); }
.btn-primary { background: var(--wine); border-color: var(--wine); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--wine-dark); color: #fff; }
.btn-danger { color: var(--danger-ink); border-color: #E7B8B1; }
.btn-danger:hover { background: var(--danger-bg); color: var(--danger-ink); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn-block { width: 100%; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--wine); font: inherit; cursor: pointer; text-decoration: underline; }

/* Étiquettes */
.tag { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--soft); color: var(--ink-2); white-space: nowrap; }
.tag-wine { background: var(--wine-soft); color: var(--wine); }
.tag-warn { background: var(--warn-bg); color: var(--warn-ink); }
.tag-ok { background: var(--ok-bg); color: var(--ok-ink); }
.tag-info { background: var(--info-bg); color: var(--info-ink); }
.tag-danger { background: var(--danger-bg); color: var(--danger-ink); }
.tag-muted { background: var(--soft); color: var(--muted); }
.tag-solid { background: var(--wine); color: #fff; }
.dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; vertical-align: -1px; margin-right: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 8px; background: var(--bg); font-size: 14px; }
.chip form { display: inline; }
.chip button { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 0 2px; }

/* Messages */
.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 14px; font-size: 14px; }
.flash-success { background: var(--ok-bg); color: var(--ok-ink); }
.flash-error { background: var(--danger-bg); color: var(--danger-ink); }
.flash-warning { background: var(--warn-bg); color: var(--warn-ink); }
.flash-info { background: var(--info-bg); color: var(--info-ink); }
.alert-line { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; margin: 0 -12px; border-radius: 8px; }
.alert-line.bad { background: var(--warn-bg); color: #5C3B00; }

/* Tableaux */
.table-wrap { overflow-x: auto; position: relative; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; color: var(--muted); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px; white-space: nowrap; }
table.t td { padding: 11px 10px; border-top: 1px solid var(--soft); vertical-align: top; }
table.t th:first-child, table.t td:first-child { padding-left: 0; }
table.t .num { text-align: right; white-space: nowrap; }
table.t tr.off td { color: var(--muted); }
.wname { color: var(--ink); font-weight: 600; text-decoration: none; }
.wname:hover { color: var(--wine); text-decoration: underline; }

/* Liste de vins (cartes mobiles) */
.wine-list { display: grid; gap: 10px; }
.wine-row { display: flex; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; text-decoration: none; color: var(--ink); }
.wine-row:hover { border-color: var(--line-2); color: var(--ink); }
.wine-row .swatch { width: 10px; align-self: stretch; border-radius: 5px; flex: 0 0 10px; }
.wine-row .body { flex: 1; min-width: 0; }
.wine-row .t1 { font-weight: 600; }
.wine-row .t2 { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wine-row .stock { font-family: var(--serif); font-size: 22px; font-weight: 600; color: var(--wine); min-width: 32px; text-align: right; }

/* Formulaires */
form.f { display: grid; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label, .label { font-size: 13px; color: var(--ink-2); font-weight: 500; display: flex; justify-content: space-between; gap: 8px; }
.field .help { font-size: 12px; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local],
input[type=search], input[type=url], input[type=color], select, textarea {
  width: 100%; min-height: 44px; padding: 8px 12px; border: 1px solid var(--line-2); border-radius: 10px; background: #fff; color: var(--ink); font: inherit; font-size: 16px;
}
input[type=color] { padding: 4px; }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--wine); outline: none; box-shadow: 0 0 0 3px var(--wine-soft); }
.row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.row-2 { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px 18px; margin: 0; background: var(--surface); }
legend { font-weight: 600; padding: 0 6px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; }
.check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--wine); }
.choice-group { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; }
.choice span { display: flex; align-items: center; justify-content: center; text-align: center; min-height: 44px; padding: 6px 10px; border: 1px solid var(--line-2); border-radius: 10px; background: #fff; cursor: pointer; }
.choice input:checked + span { border: 2px solid var(--wine); background: var(--wine-soft); color: var(--wine); font-weight: 600; }
.choice input:focus-visible + span { outline: 3px solid #1F3F6B; outline-offset: 2px; }
.conf { font-size: 11px; font-weight: 600; }
.conf-high { color: var(--ok-ink); }
.conf-medium, .conf-low { color: var(--warn-ink); }
.conf-suggested { color: var(--info-ink); }
.field.need-check input, .field.need-check select { border: 2px solid #D9A441; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }

/* Filtres */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 16px; }
.filters .field { flex: 1 1 150px; }
.filters .field.grow { flex: 3 1 260px; }

/* Fiche vin */
.hero { display: flex; flex-wrap: wrap; gap: 24px; }
.hero .pic { flex: 0 0 150px; height: 220px; border-radius: 10px; background: var(--soft); overflow: hidden; display: flex; align-items: center; justify-content: center; }
.hero .pic img { width: 100%; height: 100%; object-fit: cover; }
.hero .info { flex: 1 1 320px; min-width: 0; display: grid; gap: 8px; align-content: start; }
.hero .stockbox { flex: 0 1 160px; text-align: right; }
.hero .stockbox .n { font-family: var(--serif); font-size: 48px; font-weight: 600; color: var(--wine); line-height: 1; margin: 4px 0; }
.bottle-ill { display: flex; flex-direction: column; align-items: center; }
.bottle-ill .neck { width: 16px; height: 46px; border-radius: 4px 4px 0 0; }
.bottle-ill .body { width: 58px; height: 130px; border-radius: 18px 18px 6px 6px; display: flex; align-items: center; justify-content: center; }
.bottle-ill .lbl { width: 46px; height: 48px; background: #F4EBDD; border-radius: 3px; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.facts .k { font-size: 13px; color: var(--muted); }
.facts .v { font-size: 19px; font-weight: 600; }
.facts .v.sm { font-size: 16px; }
.facts .def { font-size: 12px; color: var(--muted); font-weight: 400; }
.aging { position: relative; height: 12px; background: var(--soft); border-radius: 6px; margin: 8px 0 6px; }
.aging .peak { position: absolute; top: 0; height: 12px; background: #E3A3A8; border-radius: 6px; }
.aging .now { position: absolute; top: -6px; width: 4px; height: 24px; background: var(--ink); border-radius: 2px; }
.aging-legend { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-top: 1px solid var(--soft); font-size: 14px; }
.kv:first-child { border-top: 0; }
.photos { display: flex; flex-wrap: wrap; gap: 10px; }
.photos figure { margin: 0; width: 110px; }
.photos img { width: 110px; height: 140px; object-fit: cover; border-radius: 8px; display: block; }
.photos figcaption { font-size: 12px; display: flex; justify-content: space-between; margin-top: 4px; }
details.more summary { cursor: pointer; color: var(--wine); font-weight: 500; min-height: 32px; display: flex; align-items: center; }
details.more[open] summary { margin-bottom: 10px; }
.mv-in { color: #1F6B63; font-weight: 700; }
.mv-out { color: var(--wine); font-weight: 700; }
.mv-move { color: var(--muted); font-weight: 700; }

/* Plan de cave */
.zone-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.zone-tabs a { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line-2); background: #fff; color: var(--ink); text-decoration: none; font-size: 14px; }
.zone-tabs a[aria-current="true"] { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 600; }
.zone-tabs a .alert { color: #B86A00; margin-left: 6px; }
.zone-tabs a[aria-current="true"] .alert { color: #FFC66B; }
.plan { display: grid; gap: 6px; }
.plan .rl { font-size: 12px; color: var(--muted); display: flex; align-items: center; }
.plan .cl { font-size: 12px; color: var(--muted); text-align: center; }
.cell { aspect-ratio: 1; min-width: 22px; border-radius: 50%; display: block; text-decoration: none; }
.cell.free { border: 1.5px dashed #B5A99D; background: transparent; }
.cell.free:hover { background: var(--soft); }
.cell.sel { outline: 3px solid var(--ink); outline-offset: 2px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--ink-2); }

/* Températures */
.spark { width: 100%; height: 120px; display: block; }

/* Authentification */
.guest { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.guest .box { width: 100%; max-width: 400px; }
.guest .brand-big { font-family: var(--serif); font-size: 34px; font-weight: 600; text-align: center; margin-bottom: 20px; color: var(--wine); }

/* Bandeau hors ligne */
.offline-banner { display: none; background: var(--warn-bg); color: #5C3B00; padding: 8px 16px; font-size: 14px; text-align: center; }
body.is-offline .offline-banner { display: block; }

/* Scan */
.scan-drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 40px 20px; border: 2px dashed var(--line-2); border-radius: 16px; background: #fff; text-align: center; cursor: pointer; }
.scan-drop:hover { border-color: var(--wine); }
.scan-preview { max-height: 260px; border-radius: 10px; display: block; margin: 0 auto; }

/* Mobile */
@media (max-width: 860px) {
  .sidebar { display: none; }
  .main { padding: 18px 16px 110px; }
  h1 { font-size: 25px; }
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: #fff; border-top: 1px solid var(--line); justify-content: space-around; align-items: flex-start; padding: 8px 4px calc(10px + env(safe-area-inset-bottom)); }
  .tabbar a { width: 66px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--ink-2); text-decoration: none; min-height: 44px; }
  .tabbar a[aria-current="page"] { color: var(--wine); font-weight: 600; }
  .tabbar a.fab { width: 58px; height: 58px; margin-top: -24px; border-radius: 50%; background: var(--wine); color: #fff; justify-content: center; box-shadow: 0 4px 12px rgba(123,30,58,.35); }
  .tabbar svg { width: 24px; height: 24px; }
  .hero .pic { flex-basis: 96px; height: 150px; }
  .hero .stockbox { text-align: left; }
  .hide-mobile { display: none !important; }
  .card { padding: 16px; }
  .grid-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi .value { font-size: 24px; }
  .kpi .hint { font-size: 12px; }
  .facts .v { font-size: 17px; }
}
@media (min-width: 861px) {
  .show-mobile { display: none !important; }
}
@media print {
  .sidebar, .tabbar, .actions, .btn, form { display: none !important; }
  .main { padding: 0; }
  .card { border: 0; padding: 0; }
}
