@import url("./fonts/fonts.css");

:root {
  --navy:       #123B6E;
  --navy-deep:  #0C2A50;
  --navy-soft:  #3D6293;
  --green:      #2FA36B;
  --green-deep: #1E7A4E;
  --green-pale: #EAF6F0;
  --amber:      #B8791F;
  --amber-pale: #FBF2E3;
  --red:        #B3392F;
  --red-pale:   #FBECEA;
  --ink:        #16233A;
  --ink-soft:   #4A5A72;
  --ink-mute:   #7B8899;
  --line:       #DFE5EC;
  --line-soft:  #EDF1F6;
  --paper:      #FFFFFF;
  --paper-cool: #F6F8FB;
  --paper-blue: #EEF3F9;
  --radius:     8px;
  --shadow:     0 1px 2px rgba(18,59,110,0.05), 0 8px 24px rgba(18,59,110,0.06);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

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

body {
  font-family: "Hanken Grotesk", system-ui, -apple-system, sans-serif;
  background: var(--paper-cool);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.serif { font-family: "Instrument Serif", Georgia, serif; font-weight: 400; }

a { color: var(--navy); }

/* ============================ chrome ============================ */

.wordmark {
  font-family: "Instrument Serif", Georgia, serif;
  font-size: 26px; color: var(--navy); line-height: 1; letter-spacing: 0.02em;
  white-space: nowrap;
}
.wordmark .plus { color: var(--green); }

.stickyhead { position: sticky; top: 0; z-index: 40; }
.topbar {
  background: rgba(255,255,255,0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-in {
  max-width: 1280px; margin: 0 auto; padding: 14px 24px;
  display: flex; align-items: center; gap: 18px;
}
.topbar .title {
  font-size: 14px; font-weight: 600; color: var(--ink-soft);
  padding-left: 18px; border-left: 1px solid var(--line);
  line-height: 1.3;
}
.topbar .spacer { margin-left: auto; }

.tabs {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.tabs-in {
  max-width: 1280px; margin: 0 auto; padding: 0 24px;
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
}
.tabs-in::-webkit-scrollbar { display: none; }
.tab {
  appearance: none; background: none; border: 0; cursor: pointer;
  font: inherit; font-size: 15px; font-weight: 600; color: var(--ink-mute);
  padding: 15px 16px; white-space: nowrap;
  border-bottom: 2.5px solid transparent;
  transition: color .12s;
}
.tab:hover { color: var(--navy); }
.tab[aria-selected="true"] { color: var(--navy-deep); border-bottom-color: var(--green); }

main { max-width: 1280px; margin: 0 auto; padding: 30px 24px 80px; }

.page-head { margin-bottom: 24px; }
.page-head h1 {
  font-family: "Instrument Serif", Georgia, serif;
  font-weight: 400; font-size: 34px; line-height: 1.15; color: var(--navy-deep);
  letter-spacing: -0.008em;
}
.page-head p { margin-top: 8px; color: var(--ink-soft); font-size: 15.5px; max-width: 760px; }

/* ============================ boutons ============================ */

.btn {
  appearance: none; cursor: pointer; font: inherit;
  font-size: 15px; font-weight: 600;
  padding: 10px 18px; border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--paper); color: var(--navy-deep);
  display: inline-flex; align-items: center; gap: 8px;
  transition: background .12s, border-color .12s;
  min-height: 42px;
}
.btn:hover { background: var(--paper-blue); border-color: #C9D6E6; }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-deep); border-color: var(--navy-deep); }
.btn-green { background: var(--green); border-color: var(--green); color: #fff; }
.btn-green:hover { background: var(--green-deep); border-color: var(--green-deep); }
.btn-danger { color: var(--red); }
.btn-danger:hover { background: var(--red-pale); border-color: #EFC9C4; }
.btn-sm { font-size: 14px; padding: 7px 12px; min-height: 36px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-icon {
  appearance: none; cursor: pointer; background: none; border: 0;
  color: var(--ink-mute); padding: 6px; border-radius: 5px; line-height: 0;
  min-width: 34px; min-height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn-icon:hover { background: var(--paper-blue); color: var(--navy); }
.btn-icon.danger:hover { background: var(--red-pale); color: var(--red); }

/* ============================ cartes ============================ */

.card {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-pad { padding: 22px 24px; }

.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* carte agence */
.agency { padding: 24px; display: flex; flex-direction: column; }
.agency-head { display: flex; align-items: flex-start; gap: 18px; min-height: 124px; }
.agency h2 {
  font-size: 20px; font-weight: 700; color: var(--navy-deep);
  letter-spacing: -0.012em; line-height: 1.25;
}
.agency .meta { margin-top: 6px; font-size: 14px; color: var(--ink-mute); line-height: 1.45; }

.ring { position: relative; width: 88px; height: 88px; flex: none; }
.ring svg { transform: rotate(-90deg); display: block; }
.ring .val {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 21px; font-weight: 700; color: var(--navy-deep); font-variant-numeric: tabular-nums;
}
.ring .val.empty { font-size: 22px; color: var(--ink-mute); }

.score-row {
  margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line-soft);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.score-row .lbl { font-size: 13px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-mute); }
.score-hint { margin-top: 10px; font-size: 13.5px; color: var(--amber); }

.counts { display: flex; gap: 10px; margin-top: 18px; }
.count {
  flex: 1; background: var(--paper-cool); border-radius: 6px; padding: 11px 12px; text-align: center;
}
.count b { display: block; font-size: 21px; font-weight: 700; color: var(--navy-deep); font-variant-numeric: tabular-nums; }
.count span { font-size: 12.5px; color: var(--ink-mute); }

.next-due {
  margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line-soft);
  font-size: 14px; color: var(--ink-soft); line-height: 1.45;
}
.next-due b { color: var(--navy-deep); font-weight: 700; }
.next-due .k { font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-mute); display: block; margin-bottom: 5px; }

/* barre consolidée */
.consolidated { margin-top: 20px; padding: 22px 24px; }
.consolidated h3 {
  font-size: 13px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-mute);
  margin-bottom: 14px;
}
.stackbar { height: 18px; border-radius: 4px; overflow: hidden; display: flex; background: var(--line-soft); }
.stackbar i { display: block; height: 100%; }
.sb-done { background: var(--green); }
.sb-wip  { background: #8FC9AC; }
.sb-todo { background: #DCE3EC; }
.legend { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 13px; }
.legend span { display: flex; align-items: center; gap: 7px; font-size: 13.5px; color: var(--ink-mute); }
.legend i { width: 11px; height: 11px; border-radius: 2px; display: block; }

/* ============================ tags ============================ */

.tag {
  display: inline-block; white-space: nowrap;
  font-size: 12px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 999px;
}
.tag-green  { background: var(--green-pale); color: var(--green-deep); }
.tag-blue   { background: #E7F0FA; color: var(--navy); }
.tag-grey   { background: #F1F4F8; color: var(--ink-mute); }
.tag-amber  { background: var(--amber-pale); color: var(--amber); }
.tag-red    { background: var(--red-pale); color: var(--red); }

/* ============================ tableaux ============================ */

.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  margin-bottom: 18px;
}
.toolbar .spacer { margin-left: auto; }

.chipset { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  appearance: none; cursor: pointer; font: inherit; font-size: 14px; font-weight: 600;
  padding: 7px 14px; border-radius: 999px; min-height: 36px;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink-soft);
}
.chip:hover { border-color: #C9D6E6; }
.chip[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }

table.list { width: 100%; border-collapse: collapse; }
table.list th {
  text-align: left; font-size: 12px; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: var(--ink-mute);
  padding: 14px 14px; border-bottom: 1px solid var(--line);
  background: var(--paper-cool);
}
table.list td {
  padding: 15px 14px; border-bottom: 1px solid var(--line-soft);
  font-size: 15px; color: var(--ink-soft); vertical-align: top;
}
table.list tr:last-child td { border-bottom: 0; }
table.list tr:hover td { background: #FBFCFE; }
table.list .t-title { color: var(--navy-deep); font-weight: 600; font-size: 15.5px; }
table.list .t-note { margin-top: 5px; font-size: 13.5px; color: var(--ink-mute); line-height: 1.45; }
table.list td.actions { text-align: right; white-space: nowrap; }
.overdue { color: var(--red); font-weight: 700; }
.nowrap { white-space: nowrap; }

.empty {
  padding: 46px 24px; text-align: center; color: var(--ink-mute); font-size: 15px;
}
.empty b { display: block; color: var(--navy-deep); font-size: 17px; margin-bottom: 6px; font-weight: 700; }

/* ============================ formulaires ============================ */

label.field { display: block; margin-bottom: 16px; }
label.field > span {
  display: block; font-size: 13px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-mute); margin-bottom: 7px;
}
input[type=text], input[type=date], input[type=number], input[type=password], select, textarea {
  width: 100%; font: inherit; font-size: 15.5px; color: var(--ink);
  padding: 11px 13px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--paper); min-height: 44px;
}
textarea { min-height: 84px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--navy-soft); box-shadow: 0 0 0 3px rgba(61,98,147,0.15);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
input.score-input { width: 92px; min-width: 92px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ============================ modale ============================ */

dialog.modal {
  border: 0; padding: 0; border-radius: 10px; width: min(600px, calc(100vw - 32px));
  box-shadow: 0 24px 70px rgba(12,42,80,0.28);
  color: var(--ink);
}
dialog.modal::backdrop { background: rgba(12,42,80,0.42); }
.modal-head {
  padding: 22px 26px 18px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px;
}
.modal-head h2 {
  font-family: "Instrument Serif", Georgia, serif; font-weight: 400;
  font-size: 26px; color: var(--navy-deep); line-height: 1.2;
}
.modal-body { padding: 24px 26px; max-height: min(62vh, 560px); overflow-y: auto; }
.modal-foot {
  padding: 18px 26px; border-top: 1px solid var(--line); background: var(--paper-cool);
  display: flex; gap: 10px; align-items: center;
  border-radius: 0 0 10px 10px;
}
.modal-foot .spacer { margin-left: auto; }

.error-msg {
  background: var(--red-pale); border: 1px solid #EFC9C4; color: var(--red);
  padding: 11px 14px; border-radius: 6px; font-size: 14.5px; margin-bottom: 16px;
}

/* ============================ notes de suivi ============================ */

.notes-agency { padding: 22px 24px; }
.notes-agency h3 {
  font-size: 17px; font-weight: 700; color: var(--navy-deep); margin-bottom: 4px;
}
.notes-agency .sub { font-size: 13.5px; color: var(--ink-mute); margin-bottom: 16px; }
.note-list { list-style: none; margin-top: 16px; }
.note-list li { padding: 13px 0; border-top: 1px solid var(--line-soft); }
.note-list .d {
  font-size: 12.5px; font-weight: 700; letter-spacing: .08em; color: var(--navy);
  font-variant-numeric: tabular-nums; margin-bottom: 4px;
}
.note-list .x { font-size: 14.5px; color: var(--ink-soft); line-height: 1.5; white-space: pre-wrap; }
.note-empty { font-size: 14px; color: var(--ink-mute); padding-top: 12px; border-top: 1px solid var(--line-soft); }

/* ============================ échéances ============================ */

.ms-group { margin-bottom: 26px; }
.ms-group > h3 {
  font-size: 13px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-mute); margin-bottom: 12px;
}
.ms-list { list-style: none; }
.ms-list li {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 15px 20px; border-bottom: 1px solid var(--line-soft);
}
.ms-list li:last-child { border-bottom: 0; }
.ms-date {
  width: 112px; flex: none; font-size: 14px; font-weight: 700; color: var(--navy);
  font-variant-numeric: tabular-nums;
}
.ms-date.none { color: var(--ink-mute); font-weight: 400; }
.ms-body { flex: 1; min-width: 200px; }
.ms-body b { display: block; font-size: 15.5px; color: var(--navy-deep); font-weight: 600; }
.ms-body span { font-size: 13.5px; color: var(--ink-mute); }
.ms-tags { display: flex; gap: 8px; align-items: center; }

/* ============================ connexion ============================ */

.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1000px 600px at 80% 10%, #EAF6F0 0%, rgba(234,246,240,0) 60%),
    radial-gradient(900px 600px at 10% 90%, #EEF3F9 0%, rgba(238,243,249,0) 60%),
    var(--paper-cool);
}
.login-card {
  background: var(--paper); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 20px 60px rgba(18,59,110,0.10);
  width: min(430px, 100%); padding: 40px 38px 34px;
}
.login-card .wordmark { font-size: 34px; }
.login-card h1 {
  font-family: "Instrument Serif", Georgia, serif; font-weight: 400;
  font-size: 30px; color: var(--navy-deep); margin-top: 22px; line-height: 1.2;
}
.login-card p.sub { color: var(--ink-soft); font-size: 15px; margin-top: 8px; margin-bottom: 26px; }
.login-card .btn { width: 100%; justify-content: center; }
.login-foot { margin-top: 22px; font-size: 13px; color: var(--ink-mute); text-align: center; line-height: 1.5; }

/* ============================ divers ============================ */

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
  background: var(--navy-deep); color: #fff; padding: 13px 22px; border-radius: 8px;
  font-size: 15px; font-weight: 600; box-shadow: 0 12px 34px rgba(12,42,80,0.30);
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 100;
  max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--red); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

.updated { font-size: 13px; color: var(--ink-mute); }

/* ============================ mobile ============================ */

@media (max-width: 900px) {
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  main { padding: 22px 16px 90px; }
  .agency-head { min-height: 0; }
  .topbar-in { padding: 12px 16px; gap: 12px; }
  .topbar .title { display: none; }
  .tabs-in { padding: 0 16px; }
  .tab { padding: 14px 12px; font-size: 14.5px; }
  .page-head h1 { font-size: 27px; }
  .field-row { grid-template-columns: 1fr; }

  /* le tableau du plan d'action devient une pile de fiches */
  table.list thead { display: none; }
  table.list, table.list tbody, table.list tr, table.list td { display: block; width: 100%; }
  table.list tr {
    border: 1px solid var(--line); border-radius: 8px; margin-bottom: 12px;
    background: var(--paper); overflow: hidden;
  }
  table.list tr:hover td { background: none; }
  table.list td { border-bottom: 0; padding: 4px 16px; }
  table.list td:first-child { padding-top: 16px; }
  table.list td.actions { text-align: left; padding: 12px 16px 14px; border-top: 1px solid var(--line-soft); margin-top: 12px; }
  table.list td[data-l]::before {
    content: attr(data-l);
    display: block; font-size: 11.5px; font-weight: 700; letter-spacing: .1em;
    text-transform: uppercase; color: var(--ink-mute); margin-bottom: 3px;
  }
  .ms-date { width: 100%; }
  .modal-body { max-height: 58vh; }
}
