/* ——— Admin back-office ——— */
body.admin { background: #f7f2ed; font-size: 14px; }

.admin-shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.admin-side {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 28px;
  padding: 28px 22px; background: var(--espresso); color: var(--satin);
}
.admin-side .admin-brand { color: var(--satin); align-items: flex-start; }
.admin-side .admin-brand .brand__maison { color: var(--gold-soft); padding-left: 0; }
.admin-side .admin-brand .brand__name { font-size: 26px; padding-left: 0; }
.admin-nav { display: grid; gap: 2px; }
.admin-nav a {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; border-radius: 6px; font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: rgba(244, 233, 224, .78);
}
.admin-nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.admin-nav a.is-active { background: rgba(191, 151, 96, .22); color: #fff; }
.admin-pill { min-width: 20px; padding: 0 6px; border-radius: var(--pill); background: var(--gold); color: #fff; font-size: 11px; letter-spacing: 0; text-align: center; }
.admin-side__foot { margin-top: auto; display: grid; gap: 10px; font-size: 12px; color: rgba(244, 233, 224, .7); }
.admin-side__foot a:hover { color: #fff; }
.admin-side__foot .link-btn { color: rgba(244, 233, 224, .7); border-color: rgba(244, 233, 224, .3); justify-self: start; }

.admin-main { padding: 32px clamp(16px, 3vw, 44px) 80px; min-width: 0; }
.admin-main > .flash { margin-bottom: 20px; }
.admin-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 26px; }
.admin-head h1 { font-size: 34px; margin: 0; }
.admin-head p { margin: 4px 0 0; color: var(--mocha); }

.panel { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 22px; margin-bottom: 22px; }
.panel h2 { font-size: 22px; margin-bottom: 14px; }
.panel__head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.panel__head h2 { margin: 0; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 22px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; }
.kpi span { display: block; font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--mocha); }
.kpi strong { font-family: var(--serif); font-size: 34px; font-weight: 400; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-weight: 400; font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--mocha); padding: 10px 12px; border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:hover td { background: #fcf9f6; }
.table .num { text-align: right; white-space: nowrap; }
.thumb { width: 46px; height: 60px; object-fit: cover; border-radius: 4px; background: var(--satin); }
.row-title { font-family: var(--serif); font-size: 18px; font-weight: 500; }
.row-sub { font-size: 12px; color: var(--mocha); }

.badge { display: inline-block; padding: 3px 10px; border-radius: var(--pill); font-size: 11px; letter-spacing: .06em; background: var(--satin); color: var(--cocoa); white-space: nowrap; }
.badge--pending { background: #f5e6c8; color: #7a5a1c; }
.badge--paid { background: #dfe9da; color: #3f5a3a; }
.badge--preparing, .badge--ready { background: #e3e4f0; color: #3e4270; }
.badge--shipped, .badge--delivered { background: #dcebe9; color: #2f5a55; }
.badge--cancelled { background: #efdcd9; color: #8a3a31; }
.badge--live { background: #dfe9da; color: #3f5a3a; }
.badge--draft { background: #eee7e1; color: var(--mocha); }
.badge--low { background: #f5e6c8; color: #7a5a1c; }
.badge--out { background: #efdcd9; color: #8a3a31; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 18px; }
.filters .input, .filters select { min-height: 38px; width: auto; padding: 6px 12px; border: 1px solid var(--line-strong); border-radius: 6px; background: #fff; }
.actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.actions form { display: inline; }

.form-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.check { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--cocoa); }

.variant-row { border: 1px solid var(--line); border-radius: 8px; padding: 16px; margin-bottom: 14px; background: #fdfbf9; }
.variant-row__grid { display: grid; grid-template-columns: 1.5fr 90px .8fr .8fr auto; gap: 12px; align-items: end; }
.variant-row .field { margin-bottom: 0; }
.variant-row input[type=color] { width: 100%; height: 46px; padding: 4px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: #fff; }
.variant-images { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; align-items: flex-end; }
.variant-images figure { position: relative; margin: 0; }
.variant-images figure img { width: 70px; height: 92px; object-fit: cover; border-radius: 4px; }
.variant-images figure button { position: absolute; top: -8px; right: -8px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: var(--espresso); color: #fff; cursor: pointer; font-size: 13px; line-height: 1; }
.upload { display: grid; gap: 4px; font-size: 12px; color: var(--mocha); }
.danger-zone { border-color: rgba(164, 70, 60, .3); }
.btn--danger { background: var(--danger); border-color: var(--danger); }
.btn--danger:hover { background: #7f3129; border-color: #7f3129; }

.stock-input { width: 80px; min-height: 36px; padding: 4px 8px; border: 1px solid var(--line-strong); border-radius: 6px; text-align: center; }
.stock-input.is-low { border-color: var(--gold); background: #fbf3e4; }
.stock-input.is-out { border-color: var(--danger); background: #fbeeec; }
.sticky-save { position: sticky; bottom: 0; padding: 14px 0; background: linear-gradient(to top, #f7f2ed 70%, transparent); display: flex; justify-content: flex-end; }

.admin-login { min-height: 100vh; display: grid; place-content: center; gap: 16px; padding: 24px; }
.login-card { width: min(400px, 100vw - 32px); background: rgba(255, 255, 255, .85); padding: 38px 34px; border-radius: 12px; box-shadow: var(--shadow); text-align: center; }
.login-card .brand { margin-bottom: 18px; }
.login-card form { text-align: left; margin-top: 20px; }

dl.details { display: grid; grid-template-columns: 130px 1fr; gap: 8px 14px; margin: 0; }
dl.details dt { color: var(--mocha); font-size: 11px; letter-spacing: .16em; text-transform: uppercase; padding-top: 3px; }
dl.details dd { margin: 0; }

@media (max-width: 1000px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 14px; padding: 16px; }
  .admin-nav { display: flex; flex-wrap: wrap; }
  .admin-side__foot { margin: 0; display: flex; flex-wrap: wrap; gap: 14px; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .variant-row__grid { grid-template-columns: 1fr 1fr; }
}

/* ——— Tour de contrôle ——— */
.admin { --series-human: #8f4a2a; --series-other: #ad7f1f; }
.kpis--5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.kpi small { display: block; font-size: 12px; color: var(--mocha); }
.kpi--accent { border-color: rgba(143, 74, 42, .35); background: #fffaf6; }
.live-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 18px; font-size: 14px; }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: #5f7a5a; box-shadow: 0 0 0 0 rgba(95, 122, 90, .5); animation: pulse 1.8s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(95, 122, 90, 0); } 100% { box-shadow: 0 0 0 0 rgba(95, 122, 90, 0); } }

.legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 12px; color: var(--cocoa); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.traffic-split { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.traffic-split > div { padding: 12px 14px; border-radius: 8px; background: #fbf7f3; }
.traffic-split strong { display: block; font-family: var(--serif); font-size: 28px; font-weight: 400; }
.traffic-split small { font-size: 12px; color: var(--mocha); }

.chart { width: 100%; height: auto; display: block; }
.chart__grid { stroke: rgba(90, 64, 54, .12); stroke-width: 1; }
.chart__tick { font-family: var(--sans); font-size: 13px; fill: var(--mocha); }
.chart__hit { fill: transparent; }
.chart__col:hover .chart__hit { fill: rgba(90, 64, 54, .06); }
.table-toggle { margin-top: 10px; font-size: 13px; }
.table-toggle summary { cursor: pointer; color: var(--mocha); }

.funnel { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 12px; }
.funnel__head { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 4px; }
.funnel__head small { color: var(--mocha); margin-left: 6px; }
.funnel__bar, .share-list__track { height: 10px; border-radius: 5px; background: #f1e8e0; overflow: hidden; }
.funnel__bar span, .share-list__track span { display: block; height: 100%; border-radius: 5px; background: var(--series-human); }

.share-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.share-list__head { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; margin-bottom: 4px; }
.share-list__num small { color: var(--mocha); margin-left: 4px; }
.share-list__track { height: 6px; }

.inline-bar { height: 4px; border-radius: 2px; background: #f1e8e0; margin-top: 6px; max-width: 220px; }
.inline-bar span { display: block; height: 100%; border-radius: 2px; background: var(--series-human); }

.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; }
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.feed { list-style: none; margin: 0; padding: 0; max-height: 460px; overflow-y: auto; }
.feed li { display: grid; grid-template-columns: 82px auto 1fr; gap: 4px 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.feed__time { color: var(--mocha); font-size: 12px; }
.feed__meta { grid-column: 3; font-size: 12px; }

@media (max-width: 1200px) { .kpis--5 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 700px) { .kpis--5, .traffic-split, .grid-3 { grid-template-columns: 1fr; } }

/* ——— Phones ——— */
.stock-variants { display: flex; flex-wrap: wrap; gap: 14px; }
.chart-scroll { overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; }
.chart-scroll::-webkit-scrollbar { display: none; }
.table td:first-child a { white-space: nowrap; }

@media (max-width: 700px) {
  /* Compact top bar: brand and account links, then the sections on one sliding row. */
  .admin-side {
    display: grid; grid-template-columns: auto 1fr; grid-template-areas: "brand foot" "nav nav";
    align-items: center; gap: 10px 12px; padding: 14px 16px 10px;
  }
  .admin-side .admin-brand { grid-area: brand; }
  .admin-side .admin-brand .brand__name { font-size: 22px; }
  .admin-side__foot { grid-area: foot; justify-content: flex-end; gap: 4px 14px; font-size: 11px; text-align: right; }
  .admin-nav {
    grid-area: nav; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain;
    margin-inline: -16px; padding: 2px 16px 4px; scroll-snap-type: x proximity;
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 16px, #000 calc(100% - 16px), transparent);
            mask-image: linear-gradient(90deg, transparent, #000 16px, #000 calc(100% - 16px), transparent);
  }
  .admin-nav::-webkit-scrollbar { display: none; }
  .admin-nav a { flex: none; white-space: nowrap; scroll-snap-align: center; padding: 10px 12px; }

  .admin-main { padding: 22px 16px 70px; }
  .form-grid, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .admin-head h1 { font-size: 28px; }
  .admin-head .actions, .admin-head > .btn { width: 100%; }
  .admin-head .actions { display: flex; gap: 10px; }
  .admin-head .actions .btn { flex: 1; padding-inline: 10px; letter-spacing: .14em; white-space: nowrap; }
  .panel { padding: 18px 16px; }
  .kpis, .kpis--5 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpis--5 > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  .kpi strong { font-size: 26px; }
  .traffic-split { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .chart { min-width: 720px; }
  .filters { display: grid; grid-template-columns: 1fr 1fr; }
  .filters .input { grid-column: 1 / -1; width: 100%; }
  .filters select { width: 100%; }
  .variant-row__grid { grid-template-columns: 1fr 1fr; }

  /* Lists become cards: no sideways scrolling, everything important visible. */
  .table--stack thead { display: none; }
  .table--stack, .table--stack tbody { display: block; }
  .table--stack tbody tr { display: grid; padding: 14px 2px; border-bottom: 1px solid var(--line); gap: 4px 12px; align-items: center; }
  .table--stack tbody tr:last-child { border-bottom: 0; }
  .table--stack td { display: block; padding: 0; border: 0; text-align: left; }
  .table--stack [data-unit] { font-size: 0; }
  .table--stack [data-unit]::after { content: attr(data-unit); font-size: 12px; color: var(--mocha); }

  .table--orders tbody tr { grid-template-columns: minmax(0, 1fr) auto; }
  .table--orders .o-num { grid-area: 1 / 1; }
  .table--orders .o-status { grid-area: 1 / 2; justify-self: end; }
  .table--orders .o-client { grid-area: 2 / 1; }
  .table--orders .o-total { grid-area: 2 / 2; justify-self: end; font-weight: 500; }
  .table--orders .o-meta { font-size: 12px; color: var(--mocha); }
  .table--orders .o-date { grid-area: 3 / 1; }
  .table--orders .o-delivery { grid-area: 3 / 2; justify-self: end; }
  .table--orders .o-payment { grid-area: 4 / 1; }
  .table--orders .o-count { grid-area: 4 / 2; justify-self: end; }

  .table--products tbody tr {
    grid-template-columns: 64px minmax(0, 1fr) auto;
    grid-template-areas: "thumb name status" "thumb category price" "thumb swatches stock" "thumb actions actions";
  }
  .table--products .p-thumb { grid-area: thumb; align-self: start; }
  .table--products .p-thumb .thumb { width: 64px; height: 84px; }
  .table--products .p-name { grid-area: name; }
  .table--products .p-status { grid-area: status; justify-self: end; }
  .table--products .p-category { grid-area: category; font-size: 12px; color: var(--mocha); }
  .table--products .p-price { grid-area: price; justify-self: end; }
  .table--products .p-swatches { grid-area: swatches; }
  .table--products .p-stock { grid-area: stock; justify-self: end; font-size: 12px; }
  .table--products .p-stock::before { content: "Stock "; color: var(--mocha); }
  .table--products .p-actions { grid-area: actions; display: flex; gap: 16px; align-items: center; justify-content: flex-start; margin-top: 4px; }

  .table--categories tbody tr { grid-template-columns: 26px minmax(0, 1fr) auto; grid-template-areas: "pos name count" "pos slug slug" "pos actions actions"; }
  .table--categories .c-position { grid-area: pos; align-self: start; color: var(--mocha); }
  .table--categories .c-name { grid-area: name; }
  .table--categories .c-slug { grid-area: slug; }
  .table--categories .c-count { grid-area: count; justify-self: end; }
  .table--categories .c-actions { grid-area: actions; display: flex; gap: 16px; align-items: center; margin-top: 4px; }

  .table--stock tbody tr { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name total" "category category" "variants variants"; }
  .table--stock .s-name { grid-area: name; }
  .table--stock .s-total { grid-area: total; justify-self: end; }
  .table--stock .s-category { grid-area: category; font-size: 12px; color: var(--mocha); }
  .table--stock .s-variants { grid-area: variants; margin-top: 8px; }
  .stock-variants { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
  .stock-input { width: 100%; min-height: 44px; }
  .sticky-save .btn { width: 100%; }

  /* Comfortable touch targets. */
  .admin-side__foot a, .admin-side__foot .link-btn { display: inline-block; padding: 8px 0; }
  .table--products .p-status .badge { padding: 8px 12px; }
  .table--products .p-actions .link-underline { padding: 10px 0; }
  .variant-images .img-delete { width: 34px !important; height: 34px !important; top: -10px !important; right: -10px !important; font-size: 16px !important; }
  .variant-row .link-btn { padding: 10px 0; }
  .table-toggle summary { padding: 10px 0; }
  .plain-list a { display: inline-block; padding: 6px 0; }
}
