/* Front CLIENT TC Tontine — consultation lecture seule (§21). Mobile-first, thème auto. */

:root {
  --tc-bg: #f5f6f8;
  --tc-surface: #ffffff;
  --tc-surface-2: #f0f2f5;
  --tc-border: #e2e5ea;
  --tc-text: #1a1d21;
  --tc-muted: #6b7280;
  --tc-primary: #0f6e4f;
  --tc-primary-ink: #ffffff;
  --tc-accent: #12805c;
  --tc-danger: #b42318;
  --tc-danger-bg: #fdecea;
  --tc-radius: 14px;
  --tc-shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --tc-bg: #0f1216;
    --tc-surface: #171b21;
    --tc-surface-2: #1f242c;
    --tc-border: #2a3038;
    --tc-text: #e7eaee;
    --tc-muted: #9aa3af;
    --tc-primary: #2ea37b;
    --tc-primary-ink: #04120c;
    --tc-accent: #34b98c;
    --tc-danger: #f0736a;
    --tc-danger-bg: #2a1613;
    --tc-shadow: 0 1px 3px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--tc-bg);
  color: var(--tc-text);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--tc-primary); text-decoration: none; }
h1 { font-size: 1.45rem; margin: 0; }
h2 { font-size: 1.1rem; }

/* --- Coque appli --------------------------------------------------------- */
.tc-app { min-height: 100vh; display: flex; flex-direction: column; }

.tc-topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem; padding: .85rem 1rem;
  background: var(--tc-surface); border-bottom: 1px solid var(--tc-border);
  position: sticky; top: 0; z-index: 10;
}
.tc-brand { font-weight: 700; color: var(--tc-text); }
.tc-brand span { color: var(--tc-muted); font-weight: 500; font-size: .8rem; }
.tc-topbar-user { display: flex; align-items: center; gap: .6rem; }
.tc-user-name { font-size: .9rem; color: var(--tc-muted); max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tc-nav {
  display: flex; gap: .25rem; padding: .4rem .6rem; overflow-x: auto;
  background: var(--tc-surface); border-bottom: 1px solid var(--tc-border);
}
.tc-nav-link {
  padding: .5rem .8rem; border-radius: 999px; color: var(--tc-muted);
  font-size: .9rem; white-space: nowrap;
}
.tc-nav-link.active { background: var(--tc-surface-2); color: var(--tc-text); font-weight: 600; }
.tc-nav-ico { opacity: .7; margin-right: .25rem; }

.tc-main { flex: 1; width: 100%; max-width: 780px; margin: 0 auto; padding: 1rem; }
.tc-footer { text-align: center; color: var(--tc-muted); font-size: .75rem; padding: 1rem; }

.tc-page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.tc-back { color: var(--tc-muted); font-size: .9rem; }

/* --- Boutons / formulaires ---------------------------------------------- */
.tc-btn {
  appearance: none; border: 1px solid var(--tc-border); background: var(--tc-surface);
  color: var(--tc-text); padding: .6rem 1rem; border-radius: 10px; font-size: .95rem;
  cursor: pointer; font-weight: 600;
}
.tc-btn:disabled { opacity: .6; cursor: default; }
.tc-btn-primary { background: var(--tc-primary); border-color: var(--tc-primary); color: var(--tc-primary-ink); width: 100%; }
.tc-btn-ghost { background: transparent; border-color: transparent; color: var(--tc-muted); }

.tc-form { display: flex; flex-direction: column; gap: .5rem; }
.tc-label { font-size: .85rem; color: var(--tc-muted); margin-top: .4rem; }
.tc-input {
  width: 100%; padding: .7rem .8rem; border: 1px solid var(--tc-border);
  border-radius: 10px; background: var(--tc-surface); color: var(--tc-text); font-size: 1rem;
}
.tc-input-code { letter-spacing: .4em; text-align: center; font-size: 1.4rem; font-weight: 700; }

/* --- Auth ---------------------------------------------------------------- */
.tc-auth { max-width: 380px; margin: 2rem auto; background: var(--tc-surface); padding: 1.5rem; border-radius: var(--tc-radius); box-shadow: var(--tc-shadow); }
.tc-auth-sub { color: var(--tc-muted); margin-top: .25rem; }
.tc-auth-info, .tc-auth-code { font-size: .9rem; }

/* --- Cartes tontines ----------------------------------------------------- */
.tc-cards { list-style: none; margin: 0; padding: 0; display: grid; gap: .8rem; }
.tc-card { background: var(--tc-surface); border: 1px solid var(--tc-border); border-radius: var(--tc-radius); box-shadow: var(--tc-shadow); }
.tc-card-link { display: block; padding: 1rem; color: var(--tc-text); }
.tc-card-top { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.tc-card-title { font-weight: 700; }
.tc-card-progress { margin: .8rem 0 .6rem; }
.tc-progress { height: 8px; background: var(--tc-surface-2); border-radius: 999px; overflow: hidden; }
.tc-progress-bar { height: 100%; background: var(--tc-accent); border-radius: 999px; }
.tc-progress-label { display: block; margin-top: .3rem; font-size: .8rem; color: var(--tc-muted); }
.tc-card-facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin: .6rem 0; }
.tc-card-facts dt { font-size: .72rem; color: var(--tc-muted); }
.tc-card-facts dd { margin: .1rem 0 0; font-size: .85rem; font-weight: 600; }
.tc-card-cta { color: var(--tc-primary); font-size: .85rem; font-weight: 600; }

/* --- Badges / tags ------------------------------------------------------- */
.tc-badge { font-size: .72rem; font-weight: 700; padding: .2rem .55rem; border-radius: 999px; background: var(--tc-surface-2); color: var(--tc-muted); white-space: nowrap; }
.tc-badge-active { background: rgba(46, 163, 123, .15); color: var(--tc-accent); }
.tc-badge-ok { background: rgba(46, 163, 123, .18); color: var(--tc-accent); }
.tc-badge-warn { background: rgba(180, 130, 0, .16); color: #b47a00; }
.tc-tag { display: inline-block; margin-top: .5rem; font-size: .72rem; padding: .15rem .5rem; border-radius: 6px; background: var(--tc-surface-2); color: var(--tc-muted); }

/* --- Tableau relevé ------------------------------------------------------ */
.tc-table-wrap { overflow-x: auto; background: var(--tc-surface); border: 1px solid var(--tc-border); border-radius: var(--tc-radius); }
.tc-table { width: 100%; border-collapse: collapse; font-size: .88rem; min-width: 520px; }
.tc-table th, .tc-table td { padding: .6rem .7rem; text-align: left; border-bottom: 1px solid var(--tc-border); }
.tc-table th { color: var(--tc-muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; }
.tc-num { text-align: right; font-variant-numeric: tabular-nums; }
.tc-in { color: var(--tc-accent); }
.tc-out { color: var(--tc-danger); }
.tc-solde { font-weight: 700; }

/* --- Liste dépendants ---------------------------------------------------- */
.tc-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.tc-list-item { display: flex; align-items: center; gap: .7rem; background: var(--tc-surface); border: 1px solid var(--tc-border); border-radius: 10px; padding: .7rem .9rem; }
.tc-avatar { width: 34px; height: 34px; border-radius: 999px; background: var(--tc-primary); color: var(--tc-primary-ink); display: grid; place-items: center; font-weight: 700; }
.tc-list-name { font-weight: 600; }
.tc-hint { color: var(--tc-muted); font-size: .85rem; margin-bottom: .8rem; }

/* --- Carnet drill-down --------------------------------------------------- */
.tc-carnet { background: var(--tc-surface); border: 1px solid var(--tc-border); border-radius: var(--tc-radius); padding: 1rem; box-shadow: var(--tc-shadow); }
.tc-carnet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.tc-carnet-client { color: var(--tc-muted); margin: .3rem 0 0; }
.tc-adherent { margin-left: .5rem; font-size: .8rem; padding: .1rem .45rem; border-radius: 6px; background: var(--tc-surface-2); }
.tc-carnet-facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; margin: 1rem 0; }
.tc-carnet-facts dt { font-size: .72rem; color: var(--tc-muted); }
.tc-carnet-facts dd { margin: .1rem 0 0; font-weight: 700; }
.tc-carnet-subtitle { margin: 1rem 0 .3rem; }
.tc-legend { display: flex; align-items: center; gap: .4rem; color: var(--tc-muted); font-size: .8rem; flex-wrap: wrap; }
.tc-legend-swatch { width: 20px; height: 20px; padding: 0; }

.tc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: .4rem; margin-top: .6rem; }
.tc-cell { position: relative; aspect-ratio: 1; display: grid; place-items: center; border: 1px solid var(--tc-border); border-radius: 8px; background: var(--tc-surface-2); font-size: .8rem; color: var(--tc-muted); }
.tc-cell-on { background: var(--tc-accent); border-color: var(--tc-accent); color: #fff; }
.tc-cell-num { font-weight: 600; }
.tc-cell-check { position: absolute; bottom: 2px; right: 4px; font-size: .7rem; }

/* --- États --------------------------------------------------------------- */
.tc-loading { display: flex; align-items: center; gap: .6rem; color: var(--tc-muted); padding: 2rem 1rem; justify-content: center; }
.tc-spinner { width: 18px; height: 18px; border: 2px solid var(--tc-border); border-top-color: var(--tc-primary); border-radius: 999px; animation: tc-spin .8s linear infinite; }
@keyframes tc-spin { to { transform: rotate(360deg); } }
.tc-error { background: var(--tc-danger-bg); color: var(--tc-danger); border-radius: 10px; padding: .8rem 1rem; font-size: .9rem; display: grid; gap: .6rem; }
.tc-empty { text-align: center; color: var(--tc-muted); padding: 2.5rem 1rem; }

.tc-switch { display: flex; align-items: center; gap: .4rem; font-size: .85rem; color: var(--tc-muted); cursor: pointer; }

/* --- Encart d'information (session expirée…) ----------------------------- */
.tc-notice {
  background: var(--tc-surface-2); color: var(--tc-text); border: 1px solid var(--tc-border);
  border-left: 3px solid var(--tc-primary); border-radius: 10px; padding: .7rem .9rem;
  font-size: .88rem; margin: .8rem 0;
}

/* --- Accueil / synthèse -------------------------------------------------- */
.tc-hero { margin-bottom: 1.1rem; }
.tc-hero-hi { color: var(--tc-muted); margin: 0; font-size: .9rem; }
.tc-hero-name { margin: .1rem 0 .2rem; word-break: break-word; }
.tc-hero-sub { color: var(--tc-muted); margin: 0; font-size: .9rem; }

.tc-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; margin: 1rem 0; }
.tc-stat {
  background: var(--tc-surface); border: 1px solid var(--tc-border); border-radius: var(--tc-radius);
  box-shadow: var(--tc-shadow); padding: .9rem .6rem; text-align: center;
}
.tc-stat-val { display: block; font-size: 1.5rem; font-weight: 700; color: var(--tc-primary); font-variant-numeric: tabular-nums; }
.tc-stat-lbl { display: block; margin-top: .2rem; font-size: .72rem; color: var(--tc-muted); }
.tc-hero-progress { margin: .2rem 0 .4rem; }

.tc-quick-title { margin: 1.4rem 0 .6rem; }
.tc-quick { display: grid; gap: .6rem; }
.tc-quick-card {
  display: flex; align-items: center; gap: .8rem; padding: .9rem 1rem; color: var(--tc-text);
  background: var(--tc-surface); border: 1px solid var(--tc-border); border-radius: var(--tc-radius);
  box-shadow: var(--tc-shadow);
}
.tc-quick-ico {
  width: 38px; height: 38px; flex: none; display: grid; place-items: center; border-radius: 10px;
  background: var(--tc-surface-2); color: var(--tc-primary); font-size: 1.1rem;
}
.tc-quick-txt { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.tc-quick-txt strong { font-size: .95rem; }
.tc-quick-txt small { color: var(--tc-muted); font-size: .78rem; }
.tc-quick-cta { color: var(--tc-primary); font-size: 1.1rem; font-weight: 700; }

@media (max-width: 380px) {
  .tc-stat-val { font-size: 1.25rem; }
  .tc-stat-lbl { font-size: .68rem; }
}
