/* Police Philosopher (licence OFL) pour les états et rapports */
@font-face { font-family: "Philosopher"; font-style: normal; font-weight: 400; src: local("Philosopher"), local("Philosopher-Regular"), url("fonts/Philosopher-Regular.ttf") format("truetype"); }
@font-face { font-family: "Philosopher"; font-style: normal; font-weight: 700; src: local("Philosopher Bold"), local("Philosopher-Bold"), url("fonts/Philosopher-Bold.ttf") format("truetype"); }
@font-face { font-family: "Philosopher"; font-style: italic; font-weight: 400; src: local("Philosopher Italic"), local("Philosopher-Italic"), url("fonts/Philosopher-Italic.ttf") format("truetype"); }
@font-face { font-family: "Philosopher"; font-style: italic; font-weight: 700; src: local("Philosopher Bold Italic"), local("Philosopher-BoldItalic"), url("fonts/Philosopher-BoldItalic.ttf") format("truetype"); }

/* SEB - style de l'application */
:root {
  --brand: #0f4c5c;
  --brand-dark: color-mix(in srgb, var(--brand) 80%, #000);
  --brand-soft: color-mix(in srgb, var(--brand) 10%, #fff);
  --ink: #1d2733;
  --muted: #667085;
  --line: #e4e7ec;
  --bg: #f4f6f8;
  --card: #fff;
  --ok: #12805c;
  --ok-soft: #e3f5ee;
  --bad: #b42318;
  --bad-soft: #fdebea;
  --warn: #b25e09;
  --warn-soft: #fdf1e0;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 14px rgba(16, 24, 40, .05);
}
* { box-sizing: border-box; }
html { font-size: 16px; }
body { margin: 0; font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; color: var(--ink); background: var(--bg); line-height: 1.5; }
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }
small, .muted { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.center { text-align: center; }

/* Mise en page */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 262px; background: var(--brand); color: #fff; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; flex-shrink: 0; }
.brand { display: flex; align-items: center; gap: 12px; padding: 22px 20px; font-size: 1.25rem; font-weight: 700; letter-spacing: .02em; }
.brand-mark { width: 40px; height: 40px; border-radius: 10px; background: rgba(255,255,255,.16); display: grid; place-items: center; font-size: 1.3rem; }
.sidebar nav { flex: 1; overflow-y: auto; padding: 4px 12px; }
.sidebar nav a { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 10px; color: rgba(255,255,255,.88); text-decoration: none; font-size: 1.02rem; margin-bottom: 2px; }
.sidebar nav a .ico { width: 24px; text-align: center; }
.sidebar nav a:hover { background: rgba(255,255,255,.1); color: #fff; }
.sidebar nav a.active { background: #fff; color: var(--brand); font-weight: 600; }
.side-user { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 16px 20px; border-top: 1px solid rgba(255,255,255,.15); font-size: .92rem; }
.side-user small { color: rgba(255,255,255,.7); }
.logout { color: #fff; border: 1px solid rgba(255,255,255,.4); border-radius: 8px; padding: 6px 12px; text-decoration: none; font-size: .9rem; }
.logout:hover { background: rgba(255,255,255,.14); }
.content { flex: 1; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 18px 28px 0; }
.topbar h1 { font-size: 1.55rem; margin: 0; }
.ex-sel { margin-left: auto; display: flex; align-items: center; gap: 8px; background: var(--card); padding: 6px 12px; border-radius: 10px; box-shadow: var(--shadow); }
.ex-sel label { margin: 0; font-size: .85rem; color: var(--muted); font-weight: 600; }
.ex-sel select { width: auto; padding: 5px 8px; font-size: .95rem; font-weight: 700; }
.burger { display: none; border: 0; background: var(--card); box-shadow: var(--shadow); border-radius: 10px; width: 44px; height: 44px; font-size: 1.3rem; cursor: pointer; }
.page { padding: 18px 28px 48px; max-width: 1180px; }

/* Cartes et blocs */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 20px; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(2, 1fr); }
.grid.c3 { grid-template-columns: repeat(3, 1fr); }
.grid.c4 { grid-template-columns: repeat(4, 1fr); }
.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; border-left: 5px solid var(--brand); }
.stat .label { color: var(--muted); font-size: .92rem; }
.stat .value { font-size: 1.6rem; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat.good { border-left-color: var(--ok); }
.stat.bad { border-left-color: var(--bad); }
.stat.warn { border-left-color: var(--warn); }
.stat small { display: block; }

/* Grandes tuiles d'action */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.tile { display: flex; align-items: center; gap: 14px; background: var(--card); border: 2px solid transparent; border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; text-decoration: none; color: var(--ink); cursor: pointer; transition: .15s; font-size: 1.05rem; font-weight: 600; text-align: left; font-family: inherit; width: 100%; }
.tile:hover { border-color: var(--brand); transform: translateY(-1px); }
.tile .emo { font-size: 1.9rem; width: 52px; height: 52px; border-radius: 12px; background: var(--brand-soft); display: grid; place-items: center; flex-shrink: 0; }
.tile small { display: block; font-weight: 400; color: var(--muted); font-size: .86rem; line-height: 1.3; }
.tile.in .emo { background: var(--ok-soft); }
.tile.out .emo { background: var(--bad-soft); }
.tile.mv .emo { background: var(--warn-soft); }

/* Boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 20px; background: var(--brand); color: #fff; border: 0; border-radius: 10px; font-size: 1rem; font-weight: 600; text-decoration: none; cursor: pointer; font-family: inherit; }
.btn:hover { background: var(--brand-dark); }
.btn.secondary { background: #fff; color: var(--brand); border: 1.5px solid var(--brand); }
.btn.secondary:hover { background: var(--brand-soft); }
.btn.danger { background: var(--bad); }
.btn.ghost { background: transparent; color: var(--brand); padding: 6px 10px; }
.btn.ghost:hover { background: var(--brand-soft); }
.btn.big { padding: 15px 28px; font-size: 1.12rem; }
.btn.small { padding: 6px 12px; font-size: .88rem; border-radius: 8px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 16px; }

/* Formulaires */
label { display: block; font-weight: 600; margin-bottom: 6px; }
.field { margin-bottom: 18px; }
.field .hint { color: var(--muted); font-size: .88rem; font-weight: 400; margin-top: 4px; }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: 12px 14px; font-size: 1.05rem; border: 1.5px solid #cfd4dc; border-radius: 10px; background: #fff; color: var(--ink); font-family: inherit; }
input:focus, select:focus, textarea:focus { outline: 3px solid color-mix(in srgb, var(--brand) 25%, transparent); border-color: var(--brand); }
textarea { min-height: 84px; resize: vertical; }
.amount-input { font-size: 1.6rem !important; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 18px; }
.date-wrap { position: relative; }
.date-wrap .date-input { padding-right: 46px; }
.date-pick { position: absolute; right: 4px; top: 4px; bottom: 4px; width: 38px; border: 0; background: transparent; cursor: pointer; font-size: 1.15rem; border-radius: 8px; }
.date-pick:hover { background: var(--brand-soft); }
.date-native { position: absolute; right: 0; bottom: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; border: 0; padding: 0; }
.choice { display: flex; gap: 10px; flex-wrap: wrap; }
.choice label { display: inline-flex; align-items: center; gap: 8px; border: 2px solid var(--line); border-radius: 10px; padding: 10px 18px; cursor: pointer; font-weight: 600; margin: 0; background: #fff; }
.choice input { width: auto; accent-color: var(--brand); transform: scale(1.2); }
.choice label:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.words { margin-top: 6px; color: var(--muted); font-size: .92rem; min-height: 1.4em; font-style: italic; }

/* Tableaux */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: .97rem; }
table.t th { text-align: left; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 10px 12px; border-bottom: 2px solid var(--line); background: #fafbfc; white-space: nowrap; }
table.t td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t tr:hover td { background: #fafcfc; }
table.t tr.annule td { color: #98a2b3; text-decoration: line-through; }
table.t tfoot td { font-weight: 700; background: #fafbfc; border-top: 2px solid var(--line); }
td.in { color: var(--ok); font-weight: 600; }
td.out { color: var(--bad); font-weight: 600; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }

/* Étiquettes et messages */
.badge { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: .8rem; font-weight: 600; background: #eef0f3; color: #475467; white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.brand { background: var(--brand-soft); color: var(--brand); }
.alert { padding: 13px 16px; border-radius: 10px; margin-bottom: 16px; border: 1px solid; }
.alert-success { background: var(--ok-soft); border-color: #a6dcc6; color: #0b5e43; }
.alert-danger { background: var(--bad-soft); border-color: #f3b4ae; color: #8a1a11; }
.alert-warning { background: var(--warn-soft); border-color: #f1cf9c; color: #7d4306; }
.alert-info { background: var(--brand-soft); border-color: #bcd2d8; color: var(--brand-dark); }
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin-bottom: 16px; }
.filters .field { margin: 0; min-width: 150px; }
.filters input, .filters select { padding: 9px 12px; font-size: .98rem; }
.pager { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 16px; }
.pager a, .pager span { padding: 6px 12px; border-radius: 8px; background: #fff; border: 1px solid var(--line); text-decoration: none; }
.pager span.cur { background: var(--brand); color: #fff; border-color: var(--brand); }
.steps { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.steps span { background: #fff; border: 1px solid var(--line); padding: 4px 14px; border-radius: 99px; font-size: .9rem; color: var(--muted); }
.steps span.on { background: var(--brand); color: #fff; border-color: var(--brand); }
details.more { margin-top: 12px; }
details.more summary { cursor: pointer; color: var(--brand); font-weight: 600; }

/* Pages sans menu (connexion) */
body.bare { background: linear-gradient(135deg, var(--brand), var(--brand-dark)); }
.bare-main { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-box { background: #fff; border-radius: 16px; padding: 34px; width: 100%; max-width: 420px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.login-box h1 { font-size: 1.5rem; text-align: center; margin-bottom: 4px; }
.login-box .sub { text-align: center; color: var(--muted); margin-bottom: 22px; }
.login-box .btn { width: 100%; }
.login-logo { display: block; margin: 0 auto 14px; max-height: 70px; max-width: 200px; }

/* Lignes de facture */
.lines td { padding: 6px 6px; border: 0; }
.lines input { padding: 9px 10px; font-size: 1rem; }
.lines .del { background: none; border: 0; color: var(--bad); font-size: 1.3rem; cursor: pointer; }
.totals { margin-left: auto; width: 320px; max-width: 100%; }
.totals div { display: flex; justify-content: space-between; padding: 6px 0; }
.totals .grand { font-size: 1.3rem; font-weight: 700; border-top: 2px solid var(--ink); margin-top: 6px; padding-top: 10px; }

/* Adaptation téléphone / tablette */
@media (max-width: 960px) {
  .grid.c4, .grid.c3 { grid-template-columns: repeat(2, 1fr); }
  .sidebar { position: fixed; left: -280px; top: 0; z-index: 50; transition: left .2s; }
  .sidebar.open { left: 0; box-shadow: 0 0 0 100vmax rgba(0,0,0,.4); }
  .burger { display: block; }
  .topbar, .page { padding-left: 16px; padding-right: 16px; }
}
@media (max-width: 620px) {
  .grid.c2, .grid.c3, .grid.c4, .row2, .row3 { grid-template-columns: 1fr; }
  .topbar h1 { font-size: 1.25rem; }
  .card { padding: 16px; }
}

.checks { display: grid; gap: 10px; }
.chk { display: flex; gap: 10px; align-items: flex-start; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.chk small { font-size: .85rem; }

/* Impression générale */
@media print {
  .sidebar, .topbar, .no-print, .btn-row, .filters, .pager, .alert { display: none !important; }
  body { background: #fff; }
  .layout { display: block; }
  .page { padding: 0; max-width: none; }
  .card { box-shadow: none; padding: 0; }
  .table-wrap { overflow: visible; }
}
