/* Polywatch — interface. Couleurs en jetons (clair / sombre), police système, une seule teinte d'accent. */
:root {
  color-scheme: light;
  --page: #f4f5f7; --card: #ffffff; --card-2: #f7f8f9; --line: #e6e7ea; --line-strong: #d4d6db;
  --ink: #0b0b0b; --ink-2: #52514e; --muted: #898781;
  --accent: #2a78d6; --accent-ink: #1c5cab; --accent-soft: #e8f0fb; --on-accent: #ffffff;
  --good: #006300; --good-soft: #e6f4e6; --bad: #c42f2f; --bad-soft: #fbeaea; --warn: #8a5a00; --warn-soft: #fff4dc;
  --grid: #e1e0d9; --axis: #c3c2b7;
  --radius: 14px; --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --sidebar: 236px; --tabbar: 64px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d; --card: #1a1a19; --card-2: #222220; --line: #2c2c2a; --line-strong: #3a3a37;
    --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781;
    --accent: #3987e5; --accent-ink: #86b6ef; --accent-soft: #16273d; --on-accent: #ffffff;
    --good: #0ca30c; --good-soft: #13281a; --bad: #e66767; --bad-soft: #331a1a; --warn: #fab219; --warn-soft: #33270f;
    --grid: #2c2c2a; --axis: #383835; --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --card: #1a1a19; --card-2: #222220; --line: #2c2c2a; --line-strong: #3a3a37;
  --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781;
  --accent: #3987e5; --accent-ink: #86b6ef; --accent-soft: #16273d; --on-accent: #ffffff;
  --good: #0ca30c; --good-soft: #13281a; --bad: #e66767; --bad-soft: #331a1a; --warn: #fab219; --warn-soft: #33270f;
  --grid: #2c2c2a; --axis: #383835; --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--ink); font: 15px/1.5 var(--font);
  padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 16px); }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; line-height: 1.25; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0; letter-spacing: -.005em; }
h3 { font-size: .95rem; margin: 16px 0 8px; }
.icon { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 16px; height: 16px; }

/* ---------- Structure : barre latérale (PC), barre du haut + onglets (téléphone) ---------- */
.sidebar { display: none; }
.mobilebar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 10px 16px; background: var(--page); border-bottom: 1px solid var(--line); }
.mobilebar .actions { display: flex; gap: 4px; }
.mobilebar .actions a { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; color: var(--ink-2); }
.mobilebar .actions a.on, .mobilebar .actions a:hover { background: var(--accent-soft); color: var(--accent-ink); text-decoration: none; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 700; font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.logo { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--accent);
  color: var(--on-accent); font-weight: 800; font-size: .95rem; letter-spacing: -.02em; }
.virtual-chip { font-size: .7rem; font-weight: 650; color: var(--warn); background: var(--warn-soft); border-radius: 99px;
  padding: 2px 8px; white-space: nowrap; }
nav.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; height: calc(var(--tabbar) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); background: var(--card); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr); }
nav.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: .7rem; font-weight: 550; }
nav.tabbar a.on { color: var(--accent-ink); }
nav.tabbar a:hover { text-decoration: none; }
main.content { padding: 16px 16px 0; max-width: 1180px; margin: 0 auto; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 4px 0 18px; }
.page-head .sub { color: var(--muted); font-size: .88rem; margin-top: 4px; }
.back { display: inline-flex; align-items: center; gap: 4px; font-size: .88rem; color: var(--ink-2); margin-bottom: 10px; }

@media (min-width: 1000px) {
  body { padding-bottom: 0; }
  .mobilebar, nav.tabbar { display: none; }
  .sidebar { display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; width: var(--sidebar);
    padding: 20px 14px; background: var(--card); border-right: 1px solid var(--line); z-index: 10; }
  .sidebar .brand { padding: 0 8px 4px; }
  .sidebar .virtual-chip { margin: 6px 8px 22px; align-self: flex-start; }
  .sidebar nav { display: flex; flex-direction: column; gap: 2px; }
  .sidebar nav a { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px;
    color: var(--ink-2); font-weight: 550; font-size: .93rem; }
  .sidebar nav a:hover { background: var(--card-2); color: var(--ink); text-decoration: none; }
  .sidebar nav a.on { background: var(--accent-soft); color: var(--accent-ink); }
  .sidebar .foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 14px 8px 0;
    border-top: 1px solid var(--line); font-size: .8rem; color: var(--ink-2); }
  .sidebar .foot .status { display: flex; align-items: center; gap: 8px; }
  .sidebar .foot button { display: flex; align-items: center; gap: 10px; padding: 8px 0; background: none; border: 0;
    color: var(--ink-2); font: inherit; font-size: .88rem; cursor: pointer; }
  .sidebar .foot button:hover { color: var(--ink); }
  main.content { margin-left: var(--sidebar); padding: 28px 36px 40px; max-width: calc(var(--sidebar) + 1180px); }
}

/* ---------- Cartes, grilles ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow); margin-bottom: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card.flush .card-head { padding: 16px 18px 0; margin-bottom: 10px; }
.card-head .link { font-size: .85rem; }
.grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.grid > .card { margin-bottom: 0; }
@media (min-width: 760px) {
  .grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 1000px) {
  .grid.main-side { grid-template-columns: minmax(0, 1fr) 330px; align-items: start; }
  .grid.detail { grid-template-columns: minmax(0, 1.15fr) minmax(360px, .85fr); align-items: start; }
  .sticky { position: sticky; top: 24px; }
}
.section { margin-top: 22px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.ink-2 { color: var(--ink-2); }
.small { font-size: .86rem; }
.tiny { font-size: .76rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.only-desk { display: none; }
@media (min-width: 1000px) { .only-desk { display: block; } table.only-desk { display: table; } .only-mobile { display: none !important; } }

/* ---------- Chiffres : héros, tuiles, variations ---------- */
.hero .label { color: var(--ink-2); font-size: .9rem; font-weight: 550; }
.hero .figure { font-size: 3rem; line-height: 1.05; font-weight: 700; letter-spacing: -.03em; margin: 6px 0 10px; }
.hero .meta { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; font-size: .88rem; color: var(--ink-2); }
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 760px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.tile .label { color: var(--ink-2); font-size: .8rem; font-weight: 550; }
.tile .value { font-size: 1.45rem; font-weight: 650; letter-spacing: -.02em; margin-top: 4px; line-height: 1.2; }
.tile .hint { color: var(--muted); font-size: .78rem; margin-top: 3px; }
.tiles.compact .tile { padding: 12px 14px; box-shadow: none; background: var(--card-2); border-color: transparent; }
.tiles.compact .value { font-size: 1.15rem; }
.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 650; white-space: nowrap; }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }
.delta.flat { color: var(--muted); }
.delta-chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 99px; font-size: .84rem; font-weight: 650; }
.delta-chip.up { color: var(--good); background: var(--good-soft); }
.delta-chip.down { color: var(--bad); background: var(--bad-soft); }
.delta-chip.flat { color: var(--ink-2); background: var(--card-2); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Pastilles ---------- */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: .74rem;
  font-weight: 650; background: var(--card-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.chip.accent { background: var(--accent-soft); color: var(--accent-ink); border-color: transparent; }
.chip.good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.chip.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.chip.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip.solid { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--muted); flex: none; }
.dot.good { background: #0ca30c; }
.dot.bad { background: #d03b3b; }
.dot.warn { background: #fab219; }

/* ---------- Jauge : chance estimée (remplissage) face à la cote (repère) ---------- */
.edge { margin-top: 12px; }
.edge .legend { display: flex; justify-content: space-between; gap: 8px; font-size: .78rem; color: var(--ink-2); margin-bottom: 6px; }
.edge .legend b { color: var(--ink); font-weight: 650; }
.meter { position: relative; height: 8px; border-radius: 99px; background: var(--accent-soft); }
.meter .fill { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 99px; background: var(--accent); }
.meter .tick { position: absolute; top: -4px; bottom: -4px; width: 3px; margin-left: -1.5px; left: 0; background: var(--ink);
  border-radius: 2px; box-shadow: 0 0 0 2px var(--card); }

/* ---------- Listes d'alertes ---------- */
.alert-item { display: block; padding: 14px 18px; border-top: 1px solid var(--line); color: var(--ink); }
.alert-item:first-child { border-top: 0; }
.alert-item:hover { background: var(--card-2); text-decoration: none; }
.alert-item .top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.alert-item .top .when { color: var(--muted); font-size: .78rem; white-space: nowrap; }
.alert-item .q { font-weight: 600; line-height: 1.35; }
.alert-item .facts { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 8px; font-size: .84rem; color: var(--ink-2); }
.alert-item .facts b { color: var(--ink); font-weight: 650; }
.alert-item.sur { box-shadow: inset 3px 0 0 var(--accent); }
.alert-lines p { margin: 0 0 6px; overflow-wrap: anywhere; }
.auto-status { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; align-items: baseline; padding: 10px 0;
  border-top: 1px solid var(--line); font-size: .88rem; }
.auto-status:first-of-type { border-top: 0; }
.auto-status .why { grid-column: 1 / -1; color: var(--muted); font-size: .8rem; margin-top: -4px; }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th, td { padding: 11px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-weight: 600; color: var(--muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap;
  background: var(--card-2); }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--card-2); }
td .sub { color: var(--muted); font-size: .76rem; margin-top: 2px; }
td.name a { font-weight: 650; color: var(--ink); }
tr.inactive td { opacity: .55; }
.spark { position: relative; height: 34px; width: 130px; }

/* ---------- Formulaires ---------- */
form.inline { display: inline; }
label { display: block; font-size: .84rem; font-weight: 550; color: var(--ink-2); margin: 12px 0 6px; }
label.check { display: flex; align-items: center; gap: 10px; color: var(--ink); font-size: .92rem; font-weight: 450; margin: 8px 0; }
input[type=text], input[type=number], input[type=password], input[type=date], select {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--card);
  color: var(--ink); font: inherit; font-size: 16px; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
@media (min-width: 760px) { .fields.three { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.fields > div, .checks > * { min-width: 0; }
label, code { overflow-wrap: anywhere; }
.checks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
@media (min-width: 760px) { .checks.three { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
fieldset { border: 0; border-top: 1px solid var(--line); padding: 18px 0 6px; margin: 0; min-width: 0; }
fieldset:first-of-type { border-top: 0; padding-top: 0; }
legend { font-weight: 700; font-size: 1rem; padding: 0; float: left; width: 100%; margin-bottom: 2px; }
legend + * { clear: both; }
.help { font-size: .8rem; color: var(--muted); margin: 6px 0 0; }
details > summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 8px; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "›"; display: inline-block; transition: transform .15s; color: var(--muted); font-size: 1.25rem; line-height: 1; }
details[open] > summary::before { transform: rotate(90deg); }
code { background: var(--card-2); padding: 1px 6px; border-radius: 6px; font-size: .84em; }

/* ---------- Boutons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--accent); background: var(--accent); color: var(--on-accent); font: inherit; font-weight: 650;
  font-size: .93rem; cursor: pointer; text-decoration: none; }
.btn:hover { text-decoration: none; filter: brightness(1.06); }
.btn.ghost { background: var(--card); color: var(--ink); border-color: var(--line-strong); }
.btn.ghost:hover { background: var(--card-2); filter: none; }
.btn.danger { background: #d03b3b; border-color: #d03b3b; color: #fff; }
.btn.ghost.danger { background: var(--card); color: var(--bad); border-color: var(--line-strong); }
.btn.small { padding: 6px 11px; font-size: .82rem; }
.btn.block { width: 100%; }
.btn.lg { padding: 13px 18px; font-size: 1rem; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.seg button { padding: 11px 0; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--card);
  color: var(--ink); font: inherit; font-weight: 650; cursor: pointer; }
.seg button:hover { background: var(--card-2); }
.seg button.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }

/* ---------- Filtres en pastilles ---------- */
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; margin-bottom: 14px; scrollbar-width: none; }
.chips a { padding: 7px 14px; border-radius: 99px; border: 1px solid var(--line-strong); background: var(--card);
  color: var(--ink-2); font-size: .86rem; font-weight: 550; white-space: nowrap; }
.chips a:hover { text-decoration: none; background: var(--card-2); }
.chips a.on { background: var(--ink); border-color: var(--ink); color: var(--card); }

/* ---------- Messages ---------- */
.flash { padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; background: var(--good-soft); color: var(--good); font-weight: 550; }
.flash.error { background: var(--bad-soft); color: var(--bad); }
.notice { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--warn-soft); color: var(--warn); margin: 10px 0; font-size: .88rem; }
.empty { padding: 28px 18px; text-align: center; color: var(--muted); }

/* ---------- Aperçu d'une mise ou d'une vente ---------- */
.receipt { margin-top: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card-2); padding: 16px; }
.receipt .big { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 12px; }
.receipt .big .v { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; }
.receipt dl { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; margin: 0; font-size: .9rem; }
.receipt dt { color: var(--ink-2); }
.receipt dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.receipt .source { grid-column: 1 / -1; text-align: right; font-size: .76rem; color: var(--muted); margin-top: -4px; white-space: normal; }
.outcome-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0 4px; }
.outcome { border-radius: var(--radius-sm); padding: 10px 12px; }
.outcome.win { background: var(--good-soft); }
.outcome.lose { background: var(--bad-soft); }
.outcome .l { font-size: .76rem; color: var(--ink-2); font-weight: 550; }
.outcome .v { font-weight: 700; font-size: 1.05rem; }
.outcome.win .v { color: var(--good); }
.outcome.lose .v { color: var(--bad); }

/* ---------- Journal ---------- */
.log-day { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  padding: 14px 18px 6px; background: var(--card-2); border-bottom: 1px solid var(--line); }
.log-row { display: grid; grid-template-columns: 3.4rem 9.8rem minmax(0, 1fr); gap: 4px 12px; align-items: baseline;
  padding: 11px 18px; border-bottom: 1px solid var(--line); font-size: .88rem; }
.log-row:last-child { border-bottom: 0; }
.log-row .time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .8rem; }
.log-row .msg { min-width: 0; overflow-wrap: anywhere; color: var(--ink); }
.log-row .msg a { color: var(--ink); }
.log-row.error .msg { color: var(--bad); }
@media (max-width: 640px) {
  .log-row { grid-template-columns: 3.4rem minmax(0, 1fr); }
  .log-row .msg { grid-column: 1 / -1; }
}

/* ---------- Graphiques ---------- */
.chart { position: relative; height: 260px; }
.chart-note { color: var(--muted); font-size: .78rem; margin-top: 8px; }

/* ---------- Connexion ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; margin: -16px -16px 0; }
.login { width: 100%; max-width: 380px; }
.login .brand { justify-content: center; margin-bottom: 18px; font-size: 1.2rem; }

.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline; }
.hidden { display: none !important; }
.foot-note { color: var(--muted); font-size: .76rem; margin: 24px 0 8px; }
.sell-row td:empty { padding: 0; border: 0; }
.sell-row td { background: var(--card-2); }
.sell-row .receipt { margin: 4px 0 8px; background: var(--card); }
.only-desk-cell { display: none; }
@media (min-width: 1000px) { .only-desk-cell { display: table-cell; } }
.scroll-y { max-height: 460px; overflow-y: auto; }
.grid.top { align-items: start; }
.scroll-y { max-height: 820px; }

/* ---------- Pastilles de nouveauté et cartes cliquables ---------- */
.nav-badge { display: inline-grid; place-items: center; min-width: 19px; height: 19px; padding: 0 6px; border-radius: 99px;
  font-size: .7rem; font-weight: 750; line-height: 1; color: #fff; background: var(--accent); margin-left: auto; }
.nav-badge.soft { background: var(--line-strong); color: var(--ink); }
.nav-badge.bad { background: #d03b3b; }
nav.tabbar a { position: relative; }
nav.tabbar .nav-badge { position: absolute; top: 6px; left: calc(50% + 6px); margin: 0; min-width: 17px; height: 17px; font-size: .64rem;
  box-shadow: 0 0 0 2px var(--card); }
.mobilebar .actions a.has-badge { position: relative; }
.mobilebar .actions .nav-badge { position: absolute; top: 2px; right: 0; min-width: 16px; height: 16px; font-size: .6rem;
  box-shadow: 0 0 0 2px var(--page); }
a.tile.link, a.card.link { display: block; color: inherit; transition: border-color .12s, box-shadow .12s; }
a.tile.link:hover, a.card.link:hover { text-decoration: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
a.tile.link .label { display: flex; justify-content: space-between; gap: 6px; }
a.tile.link .go { color: var(--muted); transition: transform .12s, color .12s; }
a.tile.link:hover .go { color: var(--accent-ink); transform: translateX(2px); }
.log-row.new { box-shadow: inset 3px 0 0 var(--accent); }
