/* FinOps Dash — feuille de style unique, sans build ni dependance externe. */

:root {
  --ink:        #0f1729;
  --ink-soft:   #4a5568;
  --ink-faint:  #8a94a6;
  --line:       #e2e6ec;
  --line-soft:  #eef1f5;
  --surface:    #ffffff;
  --canvas:     #f5f7fa;
  --rail:       #10161f;
  --rail-soft:  #8b96a8;

  --accent:     #0f766e;
  --accent-dim: #0b5d56;
  --accent-wash:#e6f2f1;

  --warn:       #b45309;
  --warn-wash:  #fdf3e3;
  --danger:     #b42318;
  --danger-wash:#fdecea;
  --ok:         #15803d;


  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 41, .04), 0 4px 12px rgba(15, 23, 41, .04);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Tous les chiffres monetaires s'alignent en colonne. */
.num, td.num, .kpi-value, table td.amount { font-variant-numeric: tabular-nums; }

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

/* ---------------------------------------------------------------- layout */

.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--rail);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 22px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 0 10px 22px;
  font-weight: 650; font-size: 15px; letter-spacing: -.01em;
  color: #fff;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px;
  background: linear-gradient(140deg, #14b8a6, #0f766e);
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700; color: #04201d;
}

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 7px;
  color: var(--rail-soft); font-weight: 500; font-size: 13.5px;
}
.nav a:hover { background: rgba(255,255,255,.06); color: #e8ecf2; text-decoration: none; }
.nav a.active { background: rgba(20, 184, 166, .14); color: #5eead4; }
.nav svg { width: 16px; height: 16px; flex: none; }

.rail-foot { margin-top: auto; padding: 0 10px; color: #4c5666; font-size: 11.5px; }

.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 0 28px; height: 60px;
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { margin: 0; font-size: 16px; font-weight: 620; letter-spacing: -.01em; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.who { font-size: 12.5px; color: var(--ink-soft); }
.who b { font-weight: 600; color: var(--ink); }
.role-chip {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em;
  padding: 2px 6px; border-radius: 4px; background: var(--accent-wash); color: var(--accent-dim);
  font-weight: 650; margin-left: 6px;
}

.page { padding: 24px 28px 56px; max-width: 1360px; width: 100%; }

/* ----------------------------------------------------------------- bits */

.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--ink-faint); }
.small { font-size: 12.5px; }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line-soft); }
.panel-title { font-size: 13.5px; font-weight: 620; }
.panel-body { padding: 18px; }
/* Les tableaux denses defilent dans leur panneau plutot que de pousser la
   page entiere en debordement horizontal. */
.panel-body.flush { padding: 0; overflow-x: auto; }

.grid-2 { display: grid; grid-template-columns: 1.45fr 1fr; gap: 18px; }
@media (max-width: 1080px) { .grid-2 { grid-template-columns: 1fr; } }

/* ------------------------------------------------------------------ kpi */

.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; }
@media (max-width: 1080px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 620px) { .kpi-grid { grid-template-columns: 1fr; } }

.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.kpi-label { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-faint); font-weight: 620; }
.kpi-value { font-size: 27px; font-weight: 650; letter-spacing: -.025em; margin-top: 8px; line-height: 1.15; }
.kpi-foot { margin-top: 6px; font-size: 12.5px; color: var(--ink-faint); }
.delta { font-weight: 620; }
.delta.up { color: var(--danger); }     /* depenser plus n'est pas une bonne nouvelle */
.delta.down { color: var(--ok); }
.kpi.attention { border-color: #f0d9b5; background: linear-gradient(180deg, var(--warn-wash), #fff 62%); }
.kpi.attention .kpi-value { color: var(--warn); }

/* --------------------------------------------------------------- charts */

.chart-wrap { position: relative; height: 300px; padding: 6px 4px 0; }
.chart-wrap.short { height: 268px; }

.legend { display: flex; flex-wrap: wrap; gap: 12px; padding: 12px 18px 0; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-soft); }
.dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }

/* ---------------------------------------------------------------- table */

table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-faint); font-weight: 620; padding: 10px 18px;
  border-bottom: 1px solid var(--line); background: #fafbfc; white-space: nowrap;
}
tbody td { padding: 11px 18px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: #f8fafb; }
td.amount, th.amount { text-align: right; white-space: nowrap; }
.cell-strong { font-weight: 570; }

.empty { padding: 44px 18px; text-align: center; color: var(--ink-faint); }
.empty strong { display: block; color: var(--ink-soft); font-weight: 600; margin-bottom: 4px; }

/* --------------------------------------------------------------- badges */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 600; padding: 3px 8px; border-radius: 999px; white-space: nowrap;
}
.badge-pending   { background: var(--warn-wash); color: var(--warn); }
.badge-validated { background: var(--accent-wash); color: var(--accent-dim); }
.badge-error     { background: var(--danger-wash); color: var(--danger); }
.badge-source    { background: #eef2ff; color: #4338ca; font-size: 10.5px; padding: 2px 6px; }

.cat { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-soft); }

/* Deux panneaux empiles dans une colonne de .grid-2, au meme ecart. */
.stack { display: grid; gap: 18px; align-content: start; }

/* Edition d'une categorie : le champ ne se signale qu'au survol, pour que la
   liste se lise comme un tableau et non comme un formulaire. */
.cat-label {
  width: 100%; padding: 5px 8px; font: inherit; font-size: 13px;
  color: var(--ink); background: transparent;
  border: 1px solid transparent; border-radius: 6px;
}
.cat-label:hover { border-color: var(--line); }
.cat-label:focus { border-color: var(--accent); background: var(--surface); outline: none; }

.cat-color {
  width: 34px; height: 26px; padding: 2px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px;
}

/* ----------------------------------------------------------- pagination */

.pager {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
  padding: 12px 18px; border-top: 1px solid var(--line-soft);
}
.pager-count { font-size: 12.5px; color: var(--ink-faint); }
.pager-nav { display: flex; align-items: center; gap: 10px; }
.pager-position { font-size: 12.5px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.pager button[disabled] { opacity: 0.45; cursor: default; }

/* -------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 8px 14px; border-radius: 7px; font-size: 13px; font-weight: 570;
  cursor: pointer; font-family: inherit; white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: #f7f9fa; text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dim); border-color: var(--accent-dim); }
.btn-danger { color: var(--danger); border-color: #f3cfcb; background: #fff; }
.btn-danger:hover { background: var(--danger-wash); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; background: var(--surface); }
.seg button {
  border: 0; background: transparent; padding: 6px 12px; font-size: 12.5px;
  font-family: inherit; color: var(--ink-soft); cursor: pointer; font-weight: 550;
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button.active { background: var(--accent-wash); color: var(--accent-dim); font-weight: 640; }

/* --------------------------------------------------------------- fields */

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label { font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.field .hint { font-size: 11.5px; color: var(--ink-faint); }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=month], input[type=search], select, textarea {
  width: 100%; padding: 8px 10px; font-size: 13.5px; font-family: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 7px;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15, 118, 110, .12);
}
textarea { resize: vertical; min-height: 66px; }

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.form-grid .span-2 { grid-column: 1 / -1; }

.notice { padding: 10px 12px; border-radius: 7px; font-size: 13px; margin-bottom: 14px; }
.notice-warn  { background: var(--warn-wash); color: #7c3d06; border: 1px solid #f0d9b5; }
.notice-error { background: var(--danger-wash); color: #8a1c14; border: 1px solid #f3cfcb; }
.notice-info  { background: var(--accent-wash); color: var(--accent-dim); border: 1px solid #cfe6e4; }

/* ------------------------------------------------------------- dropzone */

.dropzone {
  border: 1.5px dashed #c8d1dc; border-radius: var(--radius); background: var(--surface);
  padding: 30px 20px; text-align: center; cursor: pointer;
  transition: border-color .14s, background .14s;
}
.dropzone:hover { border-color: var(--accent); background: #fbfdfd; }
.dropzone.dragover { border-color: var(--accent); background: var(--accent-wash); }
.dropzone.busy { pointer-events: none; opacity: .65; }
.dropzone-title { font-weight: 600; font-size: 14px; margin-bottom: 3px; }
.dropzone-sub { color: var(--ink-faint); font-size: 12.5px; }
.dz-icon { width: 30px; height: 30px; color: var(--ink-faint); margin-bottom: 8px; }

.queue { margin-top: 12px; display: flex; flex-direction: column; gap: 7px; }
.queue-item {
  display: flex; align-items: center; gap: 10px; font-size: 13px;
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface);
}
.queue-item .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-item.err { border-color: #f3cfcb; background: var(--danger-wash); }
.queue-item.ok { border-color: #cfe6e4; }

.spinner {
  width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .7s linear infinite; flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------- review */

.review { display: grid; grid-template-columns: minmax(0, 1fr) 470px; gap: 18px; align-items: start; }
@media (max-width: 1180px) { .review { grid-template-columns: 1fr; } }

.doc-frame { width: 100%; height: 78vh; min-height: 480px; border: 0; background: #f0f2f5; border-radius: 0 0 var(--radius) var(--radius); display: block; }
.doc-img { width: 100%; display: block; border-radius: 0 0 var(--radius) var(--radius); background: #f0f2f5; }

.lines-editor { display: flex; flex-direction: column; gap: 8px; }
.line-row { display: grid; grid-template-columns: 1fr 88px 30px; gap: 8px; align-items: center; }
.line-row input { font-size: 13px; padding: 6px 9px; }
.icon-btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 6px;
  width: 30px; height: 30px; display: grid; place-items: center; cursor: pointer; color: var(--ink-faint);
}
.icon-btn:hover { background: var(--danger-wash); color: var(--danger); border-color: #f3cfcb; }

.sticky-actions {
  position: sticky; bottom: 0; background: var(--surface);
  border-top: 1px solid var(--line-soft); padding: 14px 18px;
  display: flex; gap: 10px; align-items: center;
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ---------------------------------------------------------------- login */

.login-shell { display: grid; place-items: center; min-height: 100vh; padding: 24px; background: var(--canvas); }
.login-card { width: 100%; max-width: 372px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 30px; box-shadow: var(--shadow); }
.login-card h1 { margin: 14px 0 4px; font-size: 19px; letter-spacing: -.02em; }
.login-card p.sub { margin: 0 0 22px; color: var(--ink-faint); font-size: 13px; }
.login-card .field + .field { margin-top: 14px; }
.login-card .btn { width: 100%; margin-top: 20px; padding: 10px; }

/* --------------------------------------------------------------- toasts */

.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast {
  background: var(--rail); color: #fff; padding: 11px 15px; border-radius: 8px;
  font-size: 13px; max-width: 400px; box-shadow: 0 10px 24px rgba(15, 23, 41, .22);
  animation: rise .18s ease-out;
}
.toast.err { background: var(--danger); }
.toast.ok { background: var(--accent-dim); }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

.hidden { display: none !important; }


/* ------------------------------------------------------------- analyse */

.head-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.inline-label { font-size: 12px; color: var(--ink-faint); }

.seg-sm button { padding: 5px 10px; font-size: 12px; }

/* Trois chiffres cote a cote, sans la boite d'un vrai KPI : ils commentent le
   graphique qui suit, ils ne sont pas la tete de page. */
.kpi-pair {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 18px;
  padding-bottom: 4px;
}
.kpi-mini .kpi-value { font-size: 21px; margin-top: 4px; }
.kpi-mini .kpi-foot { margin-top: 2px; }
.muted-value { color: var(--ink-faint); }

.delta-up { color: var(--danger); }
.delta-down { color: var(--ok); }

.chart-lede { margin: 12px 0 0; font-size: 13px; color: var(--ink-soft); }
.chart-note { margin: 10px 0 0; font-size: 12px; color: var(--ink-faint); }

.badge-up   { background: var(--danger-wash); color: var(--danger); }
.badge-down { background: #e8f5ec; color: var(--ok); }
.badge-new  { background: #eef2ff; color: #4338ca; }
.badge-gone { background: var(--line-soft); color: var(--ink-soft); }
.badge-flat { background: var(--line-soft); color: var(--ink-faint); }
.badge-recurring  { background: var(--accent-wash); color: var(--accent-dim); }
.badge-occasional { background: var(--warn-wash); color: var(--warn); }

/* La grille peut compter vingt-quatre colonnes : la premiere reste visible
   pendant le defilement horizontal, sinon on perd la ligne qu'on lit. */
.matrix { min-width: 100%; }
.matrix th:first-child, .matrix td:first-child {
  position: sticky; left: 0; z-index: 1;
  background: var(--surface); min-width: 190px;
}
.matrix thead th { white-space: nowrap; }
.matrix td.heat { font-variant-numeric: tabular-nums; }
.matrix tfoot td {
  border-top: 1px solid var(--line);
  font-weight: 620;
  background: var(--surface);
}

/* ------------------------------------------------- boite de dialogue */

.dialog {
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 18px 48px rgba(15, 23, 41, .18);
  padding: 0; max-width: 380px; width: calc(100% - 32px);
  color: var(--ink); background: var(--surface);
}
.dialog::backdrop { background: rgba(15, 23, 41, .38); }
.dialog-body { padding: 20px 22px 18px; display: grid; gap: 12px; }
.dialog-body h2 { margin: 0; font-size: 15px; font-weight: 620; }
.dialog-body p { margin: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
