/* Charte « La Maison des Fragrances by Leyla » : crème, doré, noir profond, Cormorant Garamond */
@font-face { font-family: "Cormorant Garamond"; font-weight: 500; font-style: normal; font-display: swap; src: url("fonts/cormorant-garamond-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Cormorant Garamond"; font-weight: 600; font-style: normal; font-display: swap; src: url("fonts/cormorant-garamond-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Cormorant Garamond"; font-weight: 700; font-style: normal; font-display: swap; src: url("fonts/cormorant-garamond-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Cormorant Garamond"; font-weight: 500; font-style: italic; font-display: swap; src: url("fonts/cormorant-garamond-latin-500-italic.woff2") format("woff2"); }
@font-face { font-family: "Cormorant Garamond"; font-weight: 600; font-style: italic; font-display: swap; src: url("fonts/cormorant-garamond-latin-600-italic.woff2") format("woff2"); }

:root {
  --primary: #9a7339;        /* doré du logo */
  --primary-dark: #7a5a2a;
  --primary-light: #f4ecdf;
  --ink: #1f1a17;            /* noir profond du logo */
  --ink-soft: #2c2520;
  --bg: #fbf6ef;             /* crème du logo */
  --surface: #ffffff;
  --text: #1f1a17;
  --muted: #7d7166;
  --border: #ebe1d3;
  --success: #3f7a52;
  --success-bg: #e8f2ea;
  --danger: #a8402f;
  --danger-bg: #f8e8e4;
  --warning: #a8741c;
  --warning-bg: #f8eedb;
  --radius: 10px;
  --serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 14px; color: var(--text); background: var(--bg); line-height: 1.45;
}
a { color: var(--primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: .01em; }
h1 { font-size: 30px; margin: 0; line-height: 1.15; }
h2 { font-size: 21px; margin: 0 0 12px; }
h3 { font-size: 18px; margin: 0 0 10px; }

/* ---------- layout */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; flex-shrink: 0; background: var(--ink); color: #d9cbb6;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; padding-bottom: 24px;
}
.sidebar .brand { display: block; padding: 22px 18px 18px; text-align: center; border-bottom: 1px solid rgba(154,115,57,.35); text-decoration: none !important; }
.sidebar .brand img { width: 78px; height: auto; display: block; margin: 0 auto 10px; }
.sidebar .brand .b1 { display: block; font-family: var(--serif); font-size: 12px; letter-spacing: .32em; color: #e9dcc8; text-transform: uppercase; }
.sidebar .brand .b2 { display: block; font-family: var(--serif); font-size: 27px; font-weight: 600; color: #fbf6ef; line-height: 1.1; }
.sidebar .brand .b3 { display: block; font-family: var(--serif); font-style: italic; font-size: 19px; color: #c39a5c; }
.sidebar .section { padding: 16px 18px 5px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .18em; color: #a8875a; }
.sidebar a { display: flex; align-items: center; justify-content: space-between; padding: 7px 18px; color: #e6dccd; font-size: 13.5px; border-left: 3px solid transparent; }
.sidebar a:hover { background: rgba(154,115,57,.14); text-decoration: none; }
.sidebar a.active { background: rgba(154,115,57,.22); color: #fff; border-left-color: #c39a5c; padding-left: 18px; }
.badge-count { background: var(--danger); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 7px; font-weight: 600; }
.main { flex: 1; min-width: 0; }
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: var(--surface); border-bottom: 1px solid var(--border); padding: 10px 24px; position: sticky; top: 0; z-index: 5;
}
.topbar .quick { display: flex; gap: 6px; flex-wrap: wrap; }
.topbar .user { color: var(--muted); font-size: 13px; white-space: nowrap; }
.content { padding: 22px 24px 40px; max-width: 1400px; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.subtitle { color: var(--muted); margin-top: 3px; }

/* ---------- cards / grid */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > h2, .card.flush > .card-head { padding: 14px 18px 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 10px; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.kpi { border-top: 3px solid var(--primary); }
.kpi .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.kpi .value { font-family: var(--serif); font-size: 28px; font-weight: 700; margin-top: 2px; white-space: nowrap; }
.kpi .value small { font-size: 12px; font-weight: 500; color: var(--muted); }
.kpi.good .value { color: var(--success); }
.kpi.bad .value { color: var(--danger); }
.kpi.warn .value { color: var(--warning); }
@media (max-width: 1000px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ---------- tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
table.data th { background: #f8f2e8; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: #6b5a44; font-weight: 600; white-space: nowrap; }
table.data tbody tr:hover { background: #fdfaf5; }
table.data tfoot td { font-weight: 700; background: #f8f2e8; }
table.data .num, .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.data .center { text-align: center; }
table.data.compact th, table.data.compact td { padding: 6px 8px; }
table.data input, table.data select { width: 100%; }
.empty { text-align: center; color: var(--muted); padding: 22px !important; }
tr.muted td { color: var(--muted); text-decoration: line-through; }
.totals { margin-left: auto; width: 340px; max-width: 100%; }
.totals td { padding: 5px 10px; }
.totals tr.grand td { font-family: var(--serif); font-size: 21px; font-weight: 700; border-top: 2px solid var(--primary); }

/* ---------- forms */
label { display: block; font-weight: 600; font-size: 12.5px; margin-bottom: 4px; color: #35424f; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=email], input[type=search], select, textarea {
  width: 100%; padding: 7px 9px; border: 1px solid #c9d2dc; border-radius: 6px; font: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #e2cda8; border-color: var(--primary); }
textarea { min-height: 70px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.field { margin-bottom: 12px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 3px; font-weight: 400; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: auto; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filters .field { margin: 0; }
.filters input, .filters select { width: auto; min-width: 140px; }
.inline-form { display: inline; }
.form-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

/* ---------- buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 6px; border: 1px solid var(--primary);
  background: var(--primary); color: #fff; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none !important;
}
.btn:hover { background: var(--primary-dark); }
.btn.secondary { background: #fff; color: var(--primary); }
.btn.secondary:hover { background: var(--primary-light); }
.btn.danger { background: var(--danger); border-color: var(--danger); }
.btn.danger.secondary { background: #fff; color: var(--danger); }
.btn.success { background: var(--success); border-color: var(--success); }
.btn.small { padding: 4px 10px; font-size: 12.5px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- badges / flashes */
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11.5px; font-weight: 600; background: #eef1f4; color: #4a5664; white-space: nowrap; }
.badge.P { background: var(--primary-light); color: var(--primary-dark); }
.badge.F { background: var(--success-bg); color: var(--success); }
.badge.FC { background: var(--warning-bg); color: var(--warning); }
.badge.FA { background: var(--danger-bg); color: var(--danger); }
.badge.BL { background: #ece6df; color: var(--ink-soft); }
.badge.ok { background: var(--success-bg); color: var(--success); }
.badge.warn { background: var(--warning-bg); color: var(--warning); }
.badge.bad { background: var(--danger-bg); color: var(--danger); }
.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; border: 1px solid; }
.flash.success { background: var(--success-bg); color: var(--success); border-color: #b7dfc6; }
.flash.error { background: var(--danger-bg); color: var(--danger); border-color: #f1c2bb; }
.flash.info { background: var(--primary-light); color: var(--primary-dark); border-color: #e2cda8; }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-muted { color: var(--muted); }
.strong { font-weight: 700; }

/* ---------- details */
.dl { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; font-weight: 500; }
.history { font-size: 12.5px; color: var(--muted); }
.history li { margin-bottom: 4px; word-break: break-word; }

/* ---------- line editor */
#lines td { padding: 5px 6px; }
#lines .col-des { min-width: 260px; }
#lines .col-qty { width: 90px; }
#lines .col-price { width: 120px; }
#lines .col-dtype { width: 80px; }
#lines .col-dval { width: 95px; }
#lines .col-total { width: 120px; }
#lines .stock-info { font-size: 11.5px; color: var(--muted); }
#lines .stock-info.low { color: var(--danger); }

/* ---------- charts */
.chart { width: 100%; height: 260px; }
.chart text { font-size: 11px; fill: var(--muted); }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; background: var(--c); }

/* ---------- auth */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: var(--bg); }
.auth-box { width: 400px; max-width: 100%; }
.auth-logo { display: block; width: 230px; max-width: 70%; margin: 0 auto 22px; }
.auth-box .card { padding: 28px; border-top: 3px solid var(--primary); box-shadow: 0 10px 30px rgba(122,90,42,.08); }
.auth-box h1 { text-align: center; margin-bottom: 4px; font-size: 28px; }
.auth-box .subtitle { text-align: center; margin-bottom: 20px; }

@media (max-width: 800px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .content { padding: 16px; }
  .topbar { position: static; flex-wrap: wrap; }
}
