/* Ted Portal — thème « fintech clair & pro ». 100 % maison, zéro dépendance. */

:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --fg: #1b2330;
  --muted: #68717f;
  --border: #e5e9f0;
  --primary: #4f46e5;        /* indigo */
  --primary-600: #4338ca;
  --primary-050: #eef1ff;    /* tint indigo clair */
  --accent: #0ea5a4;         /* teal (accents secondaires) */
  --danger: #dc2626;
  --ok: #15803d;
  --ok-bg: #e9f8ef;
  --warn-bg: #fff8e6;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-md: 0 4px 14px rgba(16, 24, 40, .08);
  --radius: 12px;
}

/* Accordeon conso API : chaque type se deroule pour montrer ses appels (zero JS). */
.usage-acc-head,
.usage-acc > summary {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: .5rem;
  padding: .55rem .75rem;
  align-items: center;
}
.usage-acc-head {
  font-weight: 600;
  color: var(--fg);
  background: var(--primary-050);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
}
.usage-acc { border: 1px solid var(--border); border-top: none; }
.usage-acc:last-of-type { border-radius: 0 0 var(--radius) var(--radius); }
.usage-acc > summary { cursor: pointer; list-style: none; }
.usage-acc > summary::-webkit-details-marker { display: none; }
.usage-acc > summary .ua-type::before {
  content: "\25B8";                 /* triangle de deroulage */
  display: inline-block;
  width: 1em;
  color: var(--primary);
  transition: transform .15s ease;
}
.usage-acc[open] > summary .ua-type::before { transform: rotate(90deg); }
.usage-acc > summary:hover { background: #f3f6fa; }
.usage-acc[open] > summary { background: var(--primary-050); font-weight: 600; }
.usage-detail { width: auto; margin: .25rem .75rem .75rem; }
.ua-empty { margin: .4rem .75rem .75rem; color: var(--muted); }
/* Colonnes numeriques alignees a DROITE + chiffres tabulaires (lecture / controle). */
.usage-acc-head span:not(:first-child),
.usage-acc > summary span:not(.ua-type) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.usage-detail th:nth-child(6), .usage-detail td:nth-child(6),
.usage-detail th:nth-child(7), .usage-detail td:nth-child(7) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
/* Sections repliables Spot Data / EcoData (details natif, triangle du navigateur). */
details.data-fold > summary {
  cursor: pointer;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--fg);
  padding: .1rem 0;
}
details.data-fold > summary .muted { font-weight: 400; font-size: .85rem; color: var(--muted); }
details.data-fold[open] > summary { margin-bottom: .7rem; }

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--fg);
  background:
    radial-gradient(1200px 400px at 100% -10%, #eaeefc 0%, transparent 60%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- En-tête + nav --------------------------------------------------------- */
header {
  display: flex; align-items: center; gap: 1.2rem;
  padding: .75rem 1.4rem;
  background: rgba(255, 255, 255, .85);
  backdrop-filter: saturate(1.4) blur(6px);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: sticky; top: 0; z-index: 50;
}
header .brand {
  display: inline-flex; align-items: center; gap: .55rem;
  font-weight: 700; letter-spacing: -.01em; color: var(--fg); text-decoration: none;
}
header .brand::before {
  content: ""; width: .62rem; height: .62rem; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 0 0 3px var(--primary-050);
}
header nav { display: flex; gap: .25rem; }
header nav a {
  color: var(--muted); text-decoration: none; font-weight: 500;
  padding: .35rem .7rem; border-radius: 8px; transition: all .15s ease;
}
header nav a:hover { color: var(--fg); background: var(--primary-050); text-decoration: none; }
header nav a.active { color: var(--primary-600); background: var(--primary-050); font-weight: 600; }
header .session { margin-left: auto; color: var(--muted); font-size: .85rem; }
header .session a { color: var(--muted); }
header .session a:hover { color: var(--primary); }

main { max-width: 960px; margin: 2rem auto; padding: 0 1.4rem; }

h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -.015em; margin: .2rem 0 1rem; }
h2 { font-size: 1.12rem; font-weight: 650; margin: 0 0 .6rem; }
h3 { font-size: .98rem; font-weight: 600; margin: 1.1rem 0 .4rem; color: var(--fg); }

/* --- Login : surface minimale --------------------------------------------- */
.login { display: flex; justify-content: center; margin-top: 18vh; }
.btn-google {
  display: inline-block; padding: .8rem 1.6rem; border: 1px solid var(--border);
  border-radius: 10px; background: #fff; color: var(--fg); text-decoration: none;
  font-weight: 600; box-shadow: var(--shadow-sm); transition: all .15s ease;
}
.btn-google:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); text-decoration: none; }

/* --- Cartes ---------------------------------------------------------------- */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.15rem 1.35rem; margin: 1.15rem 0; box-shadow: var(--shadow-sm);
  transition: box-shadow .18s ease;
}
.card:hover { box-shadow: var(--shadow-md); }
.card.placeholder { border-style: dashed; box-shadow: none; background: #fcfdff; }
.card.empty { background: #f7f9fc; box-shadow: none; }
.todo { color: var(--muted); font-size: .9rem; }

.access-hint {
  display: inline-block; margin: -.5rem 0 1rem; padding: .18rem .65rem;
  background: var(--primary-050); color: var(--primary-600); border: 1px solid #dfe3fb;
  border-radius: 999px; font-size: .8rem; font-weight: 500;
}

code {
  background: var(--primary-050); color: var(--primary-600);
  padding: .1rem .35rem; border-radius: 5px; font-size: .88em;
  font-family: ui-monospace, "SF Mono", "Cascadia Code", Menlo, monospace;
}

/* --- Bannières statut ------------------------------------------------------ */
.ok {
  color: var(--ok); font-weight: 600; background: var(--ok-bg);
  border: 1px solid #bfe9cd; border-radius: 10px; padding: .6rem .85rem;
}
.error { color: var(--danger); font-weight: 600; }

/* --- Tables ---------------------------------------------------------------- */
table.usage {
  width: 100%; border-collapse: separate; border-spacing: 0; font-size: .92rem;
  border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
  background: #fff;
}
table.usage th, table.usage td { text-align: left; padding: .6rem .8rem; }
table.usage thead th {
  background: #f3f5fb; color: var(--muted); font-weight: 600;
  letter-spacing: .01em; text-transform: uppercase; font-size: .76rem;
  border-bottom: 1px solid var(--border); position: relative;
}
table.usage tbody tr:nth-child(even) { background: #fafbfe; }
table.usage tbody tr:hover { background: var(--primary-050); }
table.usage tbody td { border-bottom: 1px solid #eef1f6; }
table.usage tbody tr:last-child td { border-bottom: none; }
table.usage tbody tr.empty-row:hover { background: none; }
table.usage tbody tr.empty-row td { text-align: center; color: var(--muted); padding: 1.2rem; }

/* --- Formulaires ----------------------------------------------------------- */
form label { display: block; margin: .6rem 0; font-size: .9rem; color: var(--fg); }
form label small { color: var(--muted); font-weight: 400; font-size: .82em; }
form.inline { display: inline; margin: 0; }
form input[type="text"], form input[type="number"], form select {
  display: block; margin-top: .25rem; width: 100%; max-width: 360px;
  padding: .5rem .65rem; border: 1px solid var(--border); border-radius: 8px;
  font-size: .95rem; background: #fff; color: var(--fg); transition: all .15s ease;
}
form input[type="text"]:focus, form input[type="number"]:focus, form select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .15);
}
form button {
  margin-top: .5rem; padding: .55rem 1.1rem; border: none; border-radius: 9px;
  background: var(--primary); color: #fff; font-weight: 600; font-size: .92rem;
  cursor: pointer; box-shadow: var(--shadow-sm); transition: all .15s ease;
}
form button:hover { background: var(--primary-600); transform: translateY(-1px); box-shadow: var(--shadow-md); }
button.link-danger {
  background: none; border: none; color: var(--danger); cursor: pointer;
  font: inherit; padding: 0; text-decoration: underline; box-shadow: none; margin: 0;
}
button.link-danger:hover { color: #991b1b; background: none; transform: none; box-shadow: none; }

fieldset { border: 1px solid var(--border); border-radius: 9px; margin: .6rem 0; padding: .5rem .9rem; }
fieldset legend { font-size: .82rem; color: var(--muted); padding: 0 .35rem; }
label.inline { display: inline-flex; align-items: center; gap: .35rem; margin-right: 1.1rem; }

/* --- Clés API : révélation du secret --------------------------------------- */
.key-reveal {
  background: var(--warn-bg); border: 1px solid #f0d98a; border-radius: 10px;
  padding: .8rem 1rem; margin: .9rem 0;
}
.key-reveal .secret {
  display: block; margin-top: .45rem; padding: .55rem .7rem; background: #fff;
  border: 1px dashed #c9a94a; border-radius: 6px; word-break: break-all;
  font-family: ui-monospace, monospace; color: #7a5c00;
}
.secret-row { display: flex; align-items: stretch; gap: .5rem; margin-top: .45rem; }
.secret-row .secret { flex: 1; margin-top: 0; }
.copy-icon {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 36px; padding: 0; border: 1px solid #c9a94a; border-radius: 6px;
  background: #fff; color: #7a5c00; cursor: pointer; transition: all .15s ease;
}
.copy-icon:hover { background: #fff3d6; }
.copy-icon.copied { color: var(--ok); border-color: var(--ok); background: var(--ok-bg); }

/* --- Chips de statut ------------------------------------------------------- */
.status {
  display: inline-block; padding: .14rem .6rem; border-radius: 999px;
  font-size: .78rem; font-weight: 600; letter-spacing: .01em;
}
.status-pending { background: #fff3cd; color: #8a6d00; }
.status-approved { background: var(--primary-050); color: var(--primary-600); }
.status-rejected { background: #fde2e2; color: #9b1c1c; }
.status-executed { background: var(--ok-bg); color: var(--ok); }

/* Pastille « owner » a cote d'une liste de diffusion. */
/* QR d'enrolement 2FA + codes de secours. */
.qr { display: inline-block; padding: .6rem; background: #fff; border: 1px solid var(--border);
      border-radius: 8px; margin: .4rem 0; }
.qr svg { width: 220px; height: 220px; display: block; shape-rendering: crispEdges; }
ul.backup-codes { list-style: none; padding: 0; margin: .5rem 0 0;
      display: grid; grid-template-columns: repeat(2, max-content); gap: .3rem 1.4rem; }
ul.backup-codes code { font-size: .95rem; }

.badge-owner {
  display: inline-block; padding: .08rem .5rem; margin-left: .3rem; border-radius: 999px;
  font-size: .72rem; font-weight: 700; letter-spacing: .02em; text-transform: uppercase;
  background: #e8f6f5; color: #0b7d7b; border: 1px solid #b9e3e1;
}

/* --- Blocs de code copier-coller (how-to API) ------------------------------ */
.code-block { position: relative; margin: .6rem 0; }
.code-block pre {
  margin: 0; padding: .9rem 1.05rem; background: #0f1724; color: #e6edf3;
  border-radius: 10px; overflow-x: auto; box-shadow: var(--shadow-sm);
  font-family: ui-monospace, "SF Mono", "Cascadia Code", Menlo, monospace;
  font-size: .85rem; line-height: 1.5;
}
.code-block pre code { background: none; padding: 0; color: inherit; }
.code-block .copy-btn {
  position: absolute; top: .45rem; right: .45rem; padding: .22rem .65rem;
  font-size: .76rem; border: 1px solid #2a3647; border-radius: 6px;
  background: #1b2636; color: #cdd6e4; cursor: pointer; transition: all .15s ease;
}
.code-block .copy-btn:hover { background: #26344a; color: #fff; }

/* --- Entonnoir de filtre (table filterable) -------------------------------- */
.filter-btn {
  float: right; margin-left: .4rem; padding: 0; cursor: pointer;
  background: none; border: none; line-height: 0; color: #a9b2c3;
}
.filter-btn:hover { color: var(--primary); }
.filter-btn.active { color: var(--primary); }

.filter-popup {
  position: absolute; z-index: 1000; min-width: 180px; max-width: 260px;
  background: #fff; color: var(--fg); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: var(--shadow-md); padding: .5rem;
}
.filter-popup .filter-search {
  width: 100%; box-sizing: border-box; margin-bottom: .4rem; padding: .3rem .45rem;
  font-size: .85rem; border: 1px solid var(--border); border-radius: 6px;
}
.filter-popup .filter-all {
  display: flex; align-items: center; gap: .4rem; font-weight: 600;
  padding: .2rem 0; border-bottom: 1px solid #eef1f6; margin-bottom: .3rem;
}
.filter-popup .filter-list { max-height: 220px; overflow-y: auto; }
.filter-popup .filter-list label {
  display: flex; align-items: center; gap: .4rem; padding: .18rem 0;
  font-size: .88rem; font-weight: 400; cursor: pointer;
}
.filter-popup .filter-list label:hover { background: #f3f6fa; }
