/* ============================================================
   Cabinet — Suivi des demandes
   Direction : instrument financier. Rail encre-navy, accent teal
   discipliné, références & dates en mono (écritures de grand livre),
   chiffres tabulaires partout.
   ============================================================ */

:root {
  /* Encre & papier */
  --ink-900: #0e1524;   /* rail, texte fort */
  --ink-800: #16203a;
  --ink-700: #1e2b45;
  --ink-500: #43506b;
  --ink-400: #6b7690;
  --ink-300: #9aa3b8;

  --paper:    #f5f6f8;  /* canvas (froid, pas crème) */
  --surface:  #ffffff;
  --line:     #e4e7ec;
  --line-strong: #d3d8e0;

  /* Accent — teal discipliné (héritage "vert du comptable") */
  --teal-700: #0b5c54;
  --teal-600: #0f766e;
  --teal-500: #14907f;
  --teal-050: #e6f2f0;

  /* Sémantique statut */
  --gray-600: #64748b;  --gray-050: #eef1f5;
  --blue-600: #2563eb;  --blue-050: #e8effd;
  --amber-700:#b45309;  --amber-050:#fbf0dc;
  --red-600:  #c2321f;  --red-050:  #fbe9e6;
  --green-700:#15803d;  --green-050:#e5f4ea;

  --text:    #111726;
  --text-dim:#5a6478;

  --radius: 9px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(14,21,36,.05), 0 1px 3px rgba(14,21,36,.04);
  --shadow-md: 0 4px 14px rgba(14,21,36,.08);

  --font-display: "Space Grotesk", "Segoe UI", system-ui, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", ui-monospace, Menlo, monospace;

  --rail-w: 244px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--paper);
  font-feature-settings: "tnum" 1, "cv05" 1;  /* chiffres tabulaires */
  -webkit-font-smoothing: antialiased;
}

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

.mono { font-family: var(--font-mono); font-feature-settings: "tnum" 1; }
.num  { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ Layout */
.app { display: flex; min-height: 100vh; }

.rail {
  width: var(--rail-w);
  flex: 0 0 var(--rail-w);
  background: var(--ink-900);
  color: #c7cee0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.rail__brand {
  padding: 20px 20px 16px;
  display: flex;
  align-items: center;
  gap: 11px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.rail__mark {
  width: 30px; height: 30px; border-radius: 7px;
  background: linear-gradient(150deg, var(--teal-500), var(--teal-700));
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; color: #fff;
  font-size: 15px; letter-spacing: .5px;
}
.rail__title {
  font-family: var(--font-display);
  font-weight: 600; font-size: 14.5px; color: #fff; line-height: 1.15;
}
.rail__title small { display: block; font-weight: 400; font-size: 11px; color: var(--ink-300); letter-spacing: .3px; }

.rail__nav { padding: 12px 12px; flex: 1; overflow-y: auto; }
.rail__section {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .11em;
  color: var(--ink-400); padding: 14px 10px 6px; font-weight: 600;
}
.rail__link {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 11px; border-radius: var(--radius-sm);
  color: #c7cee0; font-size: 13.5px; font-weight: 500;
  margin-bottom: 1px;
}
.rail__link:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.rail__link.is-active { background: var(--teal-600); color: #fff; }
.rail__link.is-active svg { color: #fff; }
.rail__link svg { width: 17px; height: 17px; color: var(--ink-300); flex: 0 0 17px; }
.rail__badge {
  margin-left: auto; background: var(--red-600); color: #fff;
  font-size: 11px; font-weight: 600; border-radius: 20px;
  padding: 1px 7px; min-width: 20px; text-align: center;
}
.rail__link.is-active .rail__badge { background: rgba(255,255,255,.25); }

.rail__user {
  padding: 12px 14px; border-top: 1px solid rgba(255,255,255,.07);
  display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 32px; height: 32px; border-radius: 8px; flex: 0 0 32px;
  background: var(--teal-600); color: #fff;
  display: grid; place-items: center;
  font-weight: 600; font-size: 12px; font-family: var(--font-display);
}
.rail__user .meta { min-width: 0; }
.rail__user .meta b { color: #fff; font-size: 13px; font-weight: 600; display: block;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail__user .meta span { color: var(--ink-300); font-size: 11px; }
.rail__logout { margin-left: auto; color: var(--ink-300); display: grid; place-items: center; }
.rail__logout:hover { color: #fff; }

/* ------------------------------------------------------------ Main */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 60px; background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 16px;
  padding: 0 28px; position: sticky; top: 0; z-index: 20;
}
.topbar h1 {
  font-family: var(--font-display); font-size: 17px; font-weight: 600;
  margin: 0; color: var(--ink-900); letter-spacing: -.01em;
}
.topbar .spacer { flex: 1; }

.content { padding: 26px 28px 48px; max-width: 1320px; width: 100%; }

/* ------------------------------------------------------------ Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font-body); font-size: 13.5px; font-weight: 600;
  padding: 8px 15px; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: pointer; background: none;
  line-height: 1.2; transition: background .12s, border-color .12s;
}
.btn svg { width: 16px; height: 16px; }
.btn--primary { background: var(--teal-600); color: #fff; }
.btn--primary:hover { background: var(--teal-700); text-decoration: none; }
.btn--ghost { background: var(--surface); color: var(--ink-700); border-color: var(--line-strong); }
.btn--ghost:hover { background: var(--paper); text-decoration: none; }
.btn--subtle { color: var(--ink-500); }
.btn--subtle:hover { background: var(--gray-050); text-decoration: none; }
.btn--sm { padding: 5px 10px; font-size: 12.5px; }
.btn--danger { background: var(--red-600); color: #fff; }

/* ------------------------------------------------------------ Cards / panels */
.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.panel__head {
  padding: 14px 18px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
}
.panel__head h2 {
  font-family: var(--font-display); font-size: 14px; font-weight: 600;
  margin: 0; color: var(--ink-900);
}
.panel__head .spacer { flex: 1; }
.panel__body { padding: 18px; }
.panel__body--flush { padding: 0; }

/* ------------------------------------------------------------ KPI strip */
.kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 22px; }
.kpi {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 15px 16px; box-shadow: var(--shadow-sm);
  position: relative; overflow: hidden;
}
.kpi::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--ink-300);
}
.kpi--total::before  { background: var(--ink-700); }
.kpi--ouvert::before { background: var(--blue-600); }
.kpi--retard::before { background: var(--red-600); }
.kpi--bientot::before{ background: var(--amber-700); }
.kpi--sla::before    { background: var(--green-700); }
.kpi__label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-dim); font-weight: 600; margin-bottom: 8px;
}
.kpi__value {
  font-family: var(--font-display); font-size: 27px; font-weight: 600;
  color: var(--ink-900); line-height: 1; font-variant-numeric: tabular-nums;
}
.kpi__value small { font-size: 15px; color: var(--ink-400); font-weight: 500; }
.kpi__sub { font-size: 11.5px; color: var(--text-dim); margin-top: 5px; }

/* ------------------------------------------------------------ Tables */
.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.grid th {
  text-align: left; font-size: 11px; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-dim); font-weight: 600;
  padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap;
  background: #fafbfc;
}
table.grid td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.grid tr:last-child td { border-bottom: none; }
table.grid tbody tr:hover { background: #fafbfd; }
table.grid tr.row-link { cursor: pointer; }
.ref { font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-700); font-weight: 500; }
.subj { font-weight: 500; color: var(--ink-900); }
.muted { color: var(--text-dim); }
.due-cell { font-family: var(--font-mono); font-size: 12.5px; white-space: nowrap; }

/* ------------------------------------------------------------ Badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600; padding: 2px 9px;
  border-radius: 20px; line-height: 1.5; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; }
.badge--nouveau { background: var(--gray-050); color: var(--gray-600); }
.badge--nouveau::before { background: var(--gray-600); }
.badge--en_cours { background: var(--blue-050); color: var(--blue-600); }
.badge--en_cours::before { background: var(--blue-600); }
.badge--en_attente { background: var(--amber-050); color: var(--amber-700); }
.badge--en_attente::before { background: var(--amber-700); }
.badge--resolu { background: var(--green-050); color: var(--green-700); }
.badge--resolu::before { background: var(--green-700); }
.badge--cloture { background: var(--gray-050); color: var(--ink-500); }
.badge--cloture::before { background: var(--ink-500); }

/* SLA chip */
.sla {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-mono); font-size: 12px; font-weight: 500;
  padding: 2px 8px; border-radius: 5px;
}
.sla--en_retard { background: var(--red-050); color: var(--red-600); }
.sla--bientot   { background: var(--amber-050); color: var(--amber-700); }
.sla--dans_les_temps { background: var(--green-050); color: var(--green-700); }
.sla--retard_resolu  { background: var(--red-050); color: var(--red-600); }
.sla--ouvert { background: var(--gray-050); color: var(--gray-600); }

/* Priority ticks */
.prio { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; }
.prio__dot { width: 8px; height: 8px; border-radius: 2px; }
.prio--BASSE   .prio__dot { background: var(--ink-300); }
.prio--NORMALE .prio__dot { background: var(--blue-600); }
.prio--HAUTE   .prio__dot { background: var(--amber-700); }
.prio--URGENTE .prio__dot { background: var(--red-600); }

.domain-tag {
  font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 5px;
  letter-spacing: .02em;
}
.domain-tag--client { background: var(--teal-050); color: var(--teal-700); }
.domain-tag--rh { background: #efe9fb; color: #6d28d9; }

/* ------------------------------------------------------------ Forms */
.field { margin-bottom: 16px; }
.field label {
  display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-700);
  margin-bottom: 6px;
}
.field .hint { font-size: 11.5px; color: var(--text-dim); margin-top: 5px; }
input[type=text], input[type=email], input[type=password], input[type=number],
select, textarea {
  width: 100%; font-family: var(--font-body); font-size: 14px;
  padding: 9px 11px; border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
}
textarea { resize: vertical; min-height: 92px; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--teal-500);
  box-shadow: 0 0 0 3px rgba(15,118,110,.13);
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.form-row { display: flex; gap: 10px; align-items: flex-end; }

/* ------------------------------------------------------------ Toolbar / filters */
.toolbar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin-bottom: 18px;
}
.toolbar select, .toolbar input[type=text] { width: auto; min-width: 150px; }
.toolbar .search { min-width: 230px; }

/* ------------------------------------------------------------ Detail */
.detail-grid { display: grid; grid-template-columns: 1fr 320px; gap: 22px; align-items: start; }
.meta-list { display: grid; grid-template-columns: auto 1fr; gap: 11px 16px; font-size: 13px; }
.meta-list dt { color: var(--text-dim); font-weight: 500; }
.meta-list dd { margin: 0; font-weight: 500; color: var(--ink-900); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  position: relative; padding: 0 0 16px 22px; font-size: 13px;
}
.timeline li::before {
  content: ""; position: absolute; left: 4px; top: 4px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--teal-500);
  box-shadow: 0 0 0 3px var(--teal-050);
}
.timeline li::after {
  content: ""; position: absolute; left: 7.5px; top: 14px; bottom: 0;
  width: 1px; background: var(--line);
}
.timeline li:last-child::after { display: none; }
.timeline .t-msg { color: var(--ink-800); }
.timeline .t-meta { color: var(--text-dim); font-size: 11.5px; margin-top: 2px; }
.timeline li.k-escalated::before { background: var(--red-600); box-shadow: 0 0 0 3px var(--red-050); }
.timeline li.k-reminder::before  { background: var(--amber-700); box-shadow: 0 0 0 3px var(--amber-050); }
.timeline li.k-status::before    { background: var(--blue-600); box-shadow: 0 0 0 3px var(--blue-050); }

.comment {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 11px 13px; margin-bottom: 10px;
}
.comment .c-head { display: flex; gap: 8px; align-items: center; margin-bottom: 5px; }
.comment .c-head b { font-size: 12.5px; }
.comment .c-head span { font-size: 11.5px; color: var(--text-dim); }

/* ------------------------------------------------------------ Progress / SLA bar */
.slabar { height: 4px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 8px; }
.slabar > span { display: block; height: 100%; border-radius: 3px; }

/* ------------------------------------------------------------ Flash */
.flashes { margin-bottom: 18px; display: flex; flex-direction: column; gap: 8px; }
.flash {
  padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13.5px;
  border: 1px solid; display: flex; align-items: center; gap: 9px;
}
.flash--success { background: var(--green-050); border-color: #bfe3cb; color: var(--green-700); }
.flash--danger  { background: var(--red-050);   border-color: #f0c4bd; color: var(--red-600); }
.flash--warning { background: var(--amber-050); border-color: #edd6a8; color: var(--amber-700); }

/* ------------------------------------------------------------ Empty state */
.empty { text-align: center; padding: 46px 20px; color: var(--text-dim); }
.empty svg { width: 34px; height: 34px; color: var(--line-strong); margin-bottom: 10px; }
.empty h3 { font-family: var(--font-display); font-size: 15px; color: var(--ink-700); margin: 0 0 4px; }

/* ------------------------------------------------------------ Split status bars (dashboard) */
.stack { display: flex; flex-direction: column; gap: 10px; }
.statrow { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.statrow .lbl { width: 110px; color: var(--ink-700); font-weight: 500; }
.statrow .bar { flex: 1; height: 8px; background: var(--gray-050); border-radius: 4px; overflow: hidden; }
.statrow .bar > span { display: block; height: 100%; }
.statrow .val { width: 32px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink-900); }

.two-col { display: grid; grid-template-columns: 1.5fr 1fr; gap: 22px; align-items: start; }

.section-title {
  font-family: var(--font-display); font-size: 12px; text-transform: uppercase;
  letter-spacing: .08em; color: var(--text-dim); font-weight: 600; margin: 26px 0 12px;
}

/* ------------------------------------------------------------ Login */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-aside {
  background: var(--ink-900); color: #fff; padding: 54px 52px;
  display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.login-aside::after {
  content: ""; position: absolute; right: -120px; bottom: -120px;
  width: 360px; height: 360px; border-radius: 50%;
  background: radial-gradient(circle, rgba(20,144,127,.35), transparent 70%);
}
.login-aside .brand { display: flex; align-items: center; gap: 12px; }
.login-aside h2 {
  font-family: var(--font-display); font-size: 30px; font-weight: 600;
  line-height: 1.2; margin: 0 0 12px; letter-spacing: -.02em; max-width: 440px;
}
.login-aside p { color: var(--ink-300); font-size: 14.5px; max-width: 420px; line-height: 1.6; }
.login-aside .ledger {
  font-family: var(--font-mono); font-size: 12px; color: var(--ink-400);
  display: flex; flex-direction: column; gap: 4px;
}
.login-aside .ledger span { display: flex; justify-content: space-between; max-width: 300px;
  border-bottom: 1px dotted rgba(255,255,255,.12); padding-bottom: 3px; }

.login-main { display: grid; place-items: center; padding: 40px; background: var(--surface); }
.login-card { width: 100%; max-width: 360px; }
.login-card h1 { font-family: var(--font-display); font-size: 22px; margin: 0 0 6px; color: var(--ink-900); }
.login-card > p { color: var(--text-dim); margin: 0 0 26px; font-size: 13.5px; }
.demo-hint {
  margin-top: 22px; padding: 12px 14px; background: var(--paper);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: 12px; color: var(--text-dim); font-family: var(--font-mono); line-height: 1.7;
}
.demo-hint b { color: var(--ink-700); }

/* ------------------------------------------------------------ Responsive */
@media (max-width: 1000px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .detail-grid, .two-col { grid-template-columns: 1fr; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-aside { display: none; }
}
@media (max-width: 720px) {
  .rail { position: fixed; z-index: 100; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-md); }
  .rail.open { transform: none; }
  .form-grid { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .content { padding: 18px 16px 40px; }
  .topbar { padding: 0 16px; }
  .menu-toggle { display: inline-grid !important; }
}
.menu-toggle { display: none; }
