/* JONSEN · Encaissements boutiques */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e2e5ea;
  --text: #1c2330;
  --muted: #6b7482;
  --primary: #1f3a5f;
  --primary-2: #2c5282;
  --primary-soft: #e6edf6;
  --ok: #1e7b4f;
  --ok-soft: #e3f4ea;
  --warn: #9a6200;
  --warn-soft: #fdf2d8;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --info: #1d5fa8;
  --info-soft: #e5f0fb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151b;
    --surface: #1a2029;
    --surface-2: #222a35;
    --border: #2e3744;
    --text: #e6e9ee;
    --muted: #97a1b0;
    --primary: #7aa7e0;
    --primary-2: #9cc0ef;
    --primary-soft: #1f2e44;
    --ok: #5fcf95;
    --ok-soft: #173326;
    --warn: #f0b851;
    --warn-soft: #3a2d12;
    --danger: #f08a80;
    --danger-soft: #3d1d1a;
    --info: #86b6ef;
    --info-soft: #1b2c42;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 var(--font); font-variant-numeric: tabular-nums;
}
a { color: var(--primary-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.55rem; margin: 0 0 .15rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0; }
h3 { font-size: .95rem; margin: 1.2rem 0 .5rem; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: .85em; }
.strong { font-weight: 600; }
.mono { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: .9em; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.text-due { color: var(--danger); }
.text-credit { color: var(--info); }
.text-ok { color: var(--ok); }

/* ---------------------------------------------------------------- barre haute */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
  padding: .6rem 1.5rem; background: var(--primary); color: #fff;
}
@media (prefers-color-scheme: dark) { .topbar { background: #0c1f36; } }
.brand { display: flex; align-items: center; gap: .6rem; color: #fff; font-weight: 700; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.logo, .login-logo {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
  background: #fff; color: #1f3a5f; font-weight: 800;
}
.mainnav { display: flex; gap: .25rem; flex-wrap: wrap; }
.mainnav a { color: rgba(255,255,255,.8); padding: .4rem .75rem; border-radius: 7px; }
.mainnav a:hover { background: rgba(255,255,255,.1); text-decoration: none; color: #fff; }
.mainnav a.active { background: rgba(255,255,255,.18); color: #fff; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 1rem; }
.season-form select { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.25); }
.season-form option { color: #000; }
.user { display: flex; align-items: center; gap: .5rem; }
.user img { width: 28px; height: 28px; border-radius: 50%; }
.user-name { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user .btn-ghost { color: #fff; border-color: rgba(255,255,255,.35); }

.container { max-width: 1480px; margin: 0 auto; padding: 1.5rem; }

/* ---------------------------------------------------------------- entête page */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head p { margin: 0; }
.actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.crumbs { margin: 0 0 .5rem; font-size: .9em; }

/* ------------------------------------------------------------------- boutons */
.btn {
  display: inline-flex; align-items: center; gap: .35rem; justify-content: center;
  padding: .5rem .9rem; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600;
  cursor: pointer; white-space: nowrap; line-height: 1.2;
}
.btn:hover { text-decoration: none; background: var(--surface-2); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-2); }
@media (prefers-color-scheme: dark) { .btn-primary { color: #0c1624; } }
.btn-ghost { background: transparent; }
.btn-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.btn-danger-ghost { background: transparent; color: var(--danger); border-color: var(--danger-soft); }
.btn-sm { padding: .35rem .7rem; font-size: .9em; }
.btn-xs { padding: .2rem .5rem; font-size: .8em; border-radius: 6px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 6px;
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
form.inline { display: inline; margin: 0; }

.btn-google {
  display: inline-flex; align-items: center; gap: .75rem; justify-content: center; width: 100%;
  padding: .8rem 1rem; border-radius: 8px; border: 1px solid var(--border);
  background: #fff; color: #1f1f1f; font-weight: 600; font-size: 1rem; margin: 1rem 0 .75rem;
}
.btn-google:hover { text-decoration: none; background: #f7f8f8; box-shadow: var(--shadow); }

/* ---------------------------------------------------------------- menu export */
details.menu { position: relative; }
details.menu summary { list-style: none; }
details.menu summary::-webkit-details-marker { display: none; }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 10; min-width: 260px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); padding: .3rem;
}
.menu-list a { display: block; padding: .5rem .7rem; border-radius: 6px; color: var(--text); }
.menu-list a:hover { background: var(--surface-2); text-decoration: none; }

/* ------------------------------------------------------------------------ KPI */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: .9rem; margin-bottom: 1rem; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .9rem 1rem; display: flex; flex-direction: column; gap: .25rem; box-shadow: var(--shadow);
}
.kpi-accent { border-top: 3px solid var(--primary); }
.kpi-label { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.kpi-value { font-size: 1.35rem; font-weight: 700; letter-spacing: -.01em; }
.kpi-sub { color: var(--muted); font-size: .82rem; }
.kpis-6 .kpi-value { font-size: 1.15rem; }

.bar { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; width: var(--w, 0%); background: var(--ok); border-radius: 99px; }
.bar-sm { width: 90px; height: 5px; }

.checks { display: grid; gap: .5rem; margin-bottom: 1rem; }
.check { padding: .6rem .9rem; border-radius: 8px; font-size: .92em; margin: .5rem 0; }
.check-warn { background: var(--warn-soft); color: var(--warn); }
.check-warn a { color: inherit; text-decoration: underline; }

/* -------------------------------------------------------------------- flash */
.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-weight: 500; }
.flash-success { background: var(--ok-soft); color: var(--ok); }
.flash-error { background: var(--danger-soft); color: var(--danger); }
.flash-warning { background: var(--warn-soft); color: var(--warn); }

/* ------------------------------------------------------------------ filtres */
.filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: .8rem; }
.filters input[type=search] { min-width: 280px; flex: 1 1 280px; max-width: 420px; }
.filters .count { margin-left: auto; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: .45rem .65rem; min-height: 36px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary-2); }
textarea { resize: vertical; width: 100%; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 3px; flex-wrap: wrap; }
.seg a { padding: .35rem .75rem; border-radius: 6px; color: var(--muted); font-weight: 500; }
.seg a:hover { text-decoration: none; color: var(--text); }
.seg a.active { background: var(--primary); color: #fff; }

/* ------------------------------------------------------------------ tableaux */
.table-wrap {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow-x: auto; box-shadow: var(--shadow);
}
.table-scroll { max-height: 520px; overflow-y: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { padding: .5rem .7rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
table.data thead th {
  position: sticky; top: 0; background: var(--surface-2); color: var(--muted);
  font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; font-weight: 700; white-space: nowrap;
}
table.data tbody tr:hover { background: var(--surface-2); }
table.data tfoot th { background: var(--surface-2); font-weight: 700; border-bottom: 0; }
table.data .num { text-align: right; white-space: nowrap; }
table.data td.empty { text-align: center; color: var(--muted); padding: 1.5rem; }
th.sort { cursor: pointer; user-select: none; }
th.sort:hover { color: var(--text); }
th[aria-sort=ascending]::after { content: " ▲"; font-size: .7em; }
th[aria-sort=descending]::after { content: " ▼"; font-size: .7em; }
.row-actions { white-space: nowrap; text-align: right; width: 1%; }
.row-actions > * { vertical-align: middle; }
.row-late td { background: color-mix(in srgb, var(--danger-soft) 50%, transparent); }
.row-muted td { opacity: .55; }
td.details { max-width: 520px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }

.badge {
  display: inline-block; padding: .12rem .5rem; border-radius: 99px; font-size: .78rem; font-weight: 600; white-space: nowrap;
}
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-neutral { background: var(--surface-2); color: var(--text); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-muted { background: var(--surface-2); color: var(--muted); }
.count-pill { display: inline-block; min-width: 1.6em; padding: 0 .45em; border-radius: 99px; background: var(--surface-2); color: var(--muted); font-size: .8rem; text-align: center; margin-left: .3rem; }

/* ------------------------------------------------------------------- blocs */
.block { margin: 1.75rem 0; scroll-margin-top: 70px; }
.block-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .6rem; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: .9rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.card h2 { margin-bottom: .7rem; }
.card.empty { text-align: center; color: var(--muted); padding: 2rem; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.note { white-space: normal; max-height: 220px; overflow: auto; }
.roles-help { margin-top: .8rem; }
.empty { text-align: center; color: var(--muted); }

/* ---------------------------------------------------------------- dialogues */
dialog.dlg {
  border: 0; border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 32px));
  background: var(--surface); color: var(--text); box-shadow: 0 20px 50px rgba(0,0,0,.3);
}
dialog.dlg-wide { width: min(860px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(15, 23, 35, .45); }
dialog form { padding: 1.3rem 1.4rem; display: grid; gap: .8rem; }
dialog h2 { font-size: 1.15rem; }
dialog label { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; color: var(--muted); font-weight: 600; }
dialog label input, dialog label select, dialog label textarea { color: var(--text); font-weight: 400; font-size: .95rem; }
dialog .check-label { flex-direction: row; align-items: center; gap: .5rem; align-self: end; min-height: 36px; }
dialog .check-label input { min-height: auto; width: 18px; height: 18px; }
.hint { font-weight: 400; font-size: .8rem; }
.grid2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: .8rem; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; }
.span2 { grid-column: span 2; }
.span3 { grid-column: 1 / -1; }
.dlg-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .4rem; }

/* -------------------------------------------------------------------- login */
.login-wrap { min-height: calc(100vh - 3rem); display: grid; place-items: center; }
.login-card {
  width: min(420px, 100%); background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 2.2rem 2rem; text-align: center; box-shadow: var(--shadow);
}
.login-logo { width: 52px; height: 52px; font-size: 1.5rem; background: var(--primary); color: #fff; border-radius: 12px; margin-bottom: 1rem; }
.login-card h1 { font-size: 1.3rem; }

/* ------------------------------------------------------------------- mobile */
@media (max-width: 760px) {
  .topbar { padding: .6rem 1rem; gap: .6rem; }
  .topbar-right { margin-left: 0; width: 100%; justify-content: space-between; }
  .user-name { display: none; }
  .container { padding: 1rem; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .span2, .span3 { grid-column: auto; }
  .filters input[type=search] { min-width: 0; max-width: none; }
  .kpis { grid-template-columns: 1fr 1fr; }
}
