/* TITO Finance — administration. Palette de la marque : noir et or (logo), moutarde et brun (application). */
:root {
  --bg: #F6F2E9;
  --surface: #FFFFFF;
  --line: #E9DFC9;
  --line-soft: #F1EADA;
  --ink: #1B1810;
  --muted: #7A7261;
  --brand: #9B6A29;
  --brand-dark: #7E5320;
  --gold: #F1C40F;
  --gold-soft: #FFF4C7;
  --mustard: #CDA650;
  --cream: #FEF7E8;
  --ok: #2E7D43;
  --ok-soft: #E2F3E6;
  --danger: #B3402A;
  --danger-soft: #FBE4DE;
  --side: #0B0A08;
  --side-ink: #CFC7B2;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(27, 24, 16, .04), 0 6px 20px rgba(27, 24, 16, .06);
  --sidebar-w: 252px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.ico { width: 20px; height: 20px; flex: none; }
.mono, code { font-family: ui-monospace, "SF Mono", Consolas, monospace; }
.muted { color: var(--muted); font-size: 13px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ───────── Structure : barre latérale + contenu ───────── */
.side {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: var(--side); color: var(--side-ink);
  display: flex; flex-direction: column; padding: 18px 14px; z-index: 30; overflow-y: auto;
}
.brand { display: block; padding: 6px 8px 22px; }
.brand img { display: block; height: 78px; width: auto; }
.side nav { display: flex; flex-direction: column; gap: 3px; }
.side nav a {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  color: var(--side-ink); font-weight: 600; font-size: 14.5px; text-decoration: none;
}
.side nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.side nav a.on { background: rgba(241, 196, 15, .13); color: var(--gold); }
.side nav a.on::before { content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 4px; border-radius: 0 4px 4px 0; background: var(--gold); }
.side nav .badge { margin-left: auto; background: var(--gold); color: #1B1810; font-size: 12px; font-weight: 800; border-radius: 20px; padding: 1px 8px; }
.side-foot { margin-top: auto; padding: 14px 8px 4px; border-top: 1px solid rgba(255, 255, 255, .08); }
.side-foot .who { font-size: 12.5px; color: #8F8776; word-break: break-all; margin-bottom: 8px; }
.side-foot button { background: none; border: 0; padding: 0; color: var(--side-ink); font: inherit; font-weight: 600; font-size: 13.5px; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.side-foot button:hover { color: #fff; }
.main-wrap { margin-left: var(--sidebar-w); min-height: 100vh; }
.topbar { display: none; }
.scrim { display: none; }
main { max-width: 1120px; margin: 0 auto; padding: 34px 32px 80px; }

/* ───────── En-tête de page ───────── */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
h1 { font-size: 27px; line-height: 1.2; margin: 0; color: var(--ink); letter-spacing: -.01em; }
.page-head .sub, main > p.muted { margin: 6px 0 0; color: var(--muted); }
main > h1 { margin-bottom: 8px; }
main > h1 + p.muted { margin-top: 0; margin-bottom: 20px; max-width: 760px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 30px 0 12px; font-weight: 700; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ───────── Cartes et indicateurs ───────── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 18px; }
.card > h2:first-child, .card h2.t { margin-top: 0; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 14px; }
.card-title h3 { margin: 0; font-size: 16px; }
.card-title a { font-size: 13.5px; font-weight: 600; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 18px; }
.kpi { position: relative; display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 18px 16px; color: var(--ink); text-decoration: none; }
a.kpi:hover { border-color: var(--mustard); text-decoration: none; transform: translateY(-1px); transition: .15s; }
.kpi .chip { width: 38px; height: 38px; border-radius: 11px; background: var(--cream); color: var(--brand); display: grid; place-items: center; margin-bottom: 14px; }
.kpi b { display: block; font-size: 32px; line-height: 1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi span { display: block; margin-top: 8px; font-weight: 600; font-size: 14px; }
.kpi small { display: block; margin-top: 2px; color: var(--muted); font-size: 12.5px; }
.kpi.alert { background: linear-gradient(180deg, #FFFAE3, #fff 70%); border-color: var(--gold); }
.kpi.alert .chip { background: var(--gold); color: #1B1810; }
.cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.cols > .card { margin-bottom: 0; }
.stack { display: grid; gap: 18px; }
.stack > .card { margin-bottom: 0; }
.cols + .card, .cols + .cols { margin-top: 18px; }

/* ───────── Listes (tableau de bord) ───────── */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line-soft); }
.list li:first-child { border-top: 0; padding-top: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .t1 { font-weight: 650; }
.list .t2 { color: var(--muted); font-size: 13px; }
.dot { width: 34px; height: 34px; border-radius: 10px; background: var(--cream); color: var(--brand); display: grid; place-items: center; flex: none; }
.bars { display: grid; gap: 12px; }
.bar-row .bar-top { display: flex; justify-content: space-between; font-size: 13.5px; font-weight: 600; margin-bottom: 5px; }
.bar { height: 8px; border-radius: 8px; background: var(--line-soft); overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--mustard), var(--gold)); border-radius: 8px; }
.empty { text-align: center; padding: 22px 10px; color: var(--muted); }
.empty .ico { width: 30px; height: 30px; color: var(--mustard); margin-bottom: 6px; }

/* ───────── Tableaux ───────── */
table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 18px; }
th { background: #FBF6EA; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); }
td { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td, tr:hover > td { background: #FFFDF7; }
th.num { text-align: right; }
td form { margin: 0; }

/* ───────── Formulaires ───────── */
label { display: block; font-size: 13px; font-weight: 650; color: #4a4435; margin: 14px 0 6px; }
.card label:first-child, .row > div > label { margin-top: 0; }
input, select, textarea {
  font: inherit; color: var(--ink); background: #fff; border: 1px solid #DCCFB0; border-radius: 10px; padding: 9px 12px; max-width: 100%;
  transition: border-color .12s, box-shadow .12s;
}
/* Même hauteur pour tous les champs d'une ligne (liste déroulante, date, texte). */
input:not([type=checkbox]):not([type=hidden]), select { height: 44px; }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--mustard); box-shadow: 0 0 0 3px rgba(241, 196, 15, .25); }
input[type=checkbox] { width: 17px; height: 17px; padding: 0; accent-color: var(--brand); }
textarea { width: 100%; min-height: 84px; resize: vertical; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.field { flex: 1; min-width: 160px; }
.field input, .field select { width: 100%; }
.hint { color: var(--muted); font-size: 12.5px; margin-top: 5px; }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 700; font-size: 14px;
  padding: 10px 16px; border: 1px solid transparent; border-radius: 10px; background: var(--brand); color: #fff; cursor: pointer; text-decoration: none;
  transition: background .12s, transform .05s;
}
button:hover, .btn:hover { background: var(--brand-dark); text-decoration: none; }
button:active, .btn:active { transform: translateY(1px); }
button.gold, .btn.gold { background: var(--gold); color: #1B1810; }
button.gold:hover, .btn.gold:hover { background: #E2B70C; }
button.light, .btn.light { background: #fff; color: var(--brand); border-color: #DCCFB0; }
button.light:hover, .btn.light:hover { background: var(--cream); }
button.danger, .btn.danger { background: var(--danger); }
button.danger:hover { background: #962F1C; }
button.sm, .btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
button:disabled { opacity: .45; cursor: not-allowed; }

/* ───────── Pastilles, alertes ───────── */
.pill { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 12px; font-weight: 700; background: #F1EADA; color: var(--brand); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.bad { background: var(--danger-soft); color: var(--danger); }
.pill.gold { background: var(--gold-soft); color: #7a5c00; }
.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; font-size: 14px; }
.alert.error { background: var(--danger-soft); color: var(--danger); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.info { background: var(--gold-soft); color: #6b5200; }

/* ───────── Clé générée ───────── */
.issued { border: 2px solid var(--gold); background: linear-gradient(180deg, #FFFBEA, #fff 60%); }
.issued h2 { margin: 0 0 6px; color: var(--brand); text-transform: none; letter-spacing: 0; font-size: 16px; }
.key { font: 800 28px/1.25 ui-monospace, "SF Mono", Consolas, monospace; letter-spacing: 2px; color: var(--ink); word-break: break-all; margin: 8px 0 12px; }
pre.msg { white-space: pre-wrap; background: var(--cream); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font: 14px/1.55 inherit; margin: 12px 0 0; }

/* ───────── Connexion ───────── */
body.guest { background: var(--side); }
.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.login-art { background: radial-gradient(900px 500px at 20% 10%, rgba(241, 196, 15, .16), transparent 60%), #000; display: grid; place-items: center; padding: 40px; }
.login-art img { width: min(340px, 70%); height: auto; }
.login-form { background: var(--bg); display: grid; place-items: center; padding: 40px 28px; }
.login-box { width: 100%; max-width: 380px; }
.login-box h1 { font-size: 26px; margin-bottom: 4px; }
.login-box input { width: 100%; }
.login-box button { width: 100%; margin-top: 20px; padding: 12px; }

/* ───────── Mobile ───────── */
@media (max-width: 900px) {
  .side { transform: translateX(-100%); transition: transform .2s; width: 270px; }
  body.nav-open .side { transform: none; box-shadow: 0 0 60px rgba(0, 0, 0, .5); }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 25; }
  .main-wrap { margin-left: 0; }
  .topbar { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 20; background: var(--side); padding: 10px 14px; }
  .topbar button { background: none; border: 0; color: var(--gold); padding: 6px; }
  .topbar img { height: 36px; display: block; }
  main { padding: 22px 16px 70px; }
  .cols { grid-template-columns: 1fr; }
  /* Indicateurs en 2×2 : quatre grandes cartes empilées occuperaient tout l'écran. */
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .kpi { padding: 14px; }
  .kpi .chip { width: 32px; height: 32px; margin-bottom: 10px; }
  .kpi b { font-size: 26px; }
  .kpi span { font-size: 13px; margin-top: 6px; }
  .kpi small { font-size: 12px; }
  .login-shell { grid-template-columns: 1fr; }
  .login-art { padding: 28px; min-height: 190px; }
  .login-art img { width: 150px; }
  table { display: block; overflow-x: auto; }
  h1 { font-size: 23px; }
}
