@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap");

:root {
  color-scheme: light;
  --ink: #171719;
  --ink-soft: #4f5056;
  --muted: #85868d;
  --stroke: #e7e5e2;
  --canvas: #fbfbfc;
  --paper: #ffffff;
  --blush: #ffe7ee;
  --sky: #eaf3ff;
  --mint: #e4f8ef;
  --lemon: #fff4c9;
  --lilac: #f0e9ff;
  --peach: #ffe8d5;
  --sage: #4b7d63;
  --danger: #b63c5c;
  --shadow: 0 14px 36px rgba(23, 23, 25, 0.07);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--canvas);
  color: var(--ink);
  font-family: Manrope, ui-sans-serif, system-ui, sans-serif;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 26px 18px 20px;
  background: var(--paper);
  border-right: 1px solid var(--stroke);
  display: flex;
  flex-direction: column;
  gap: 34px;
}

.brand {
  padding: 0 10px;
  display: flex;
  align-items: center;
  gap: 11px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: var(--blush);
  border: 1px solid rgba(0, 0, 0, 0.05);
  display: grid;
  place-items: center;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0;
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 16px; font-weight: 800; }
.brand small { margin-top: 1px; color: var(--muted); font-size: 12px; font-weight: 600; }

.nav { display: grid; gap: 5px; }
.nav-label {
  margin: 18px 12px 5px;
  color: #a0a1a7;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}
.nav-label:first-child { margin-top: 0; }

.nav-link {
  min-height: 43px;
  padding: 11px 13px;
  border-radius: 12px;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
}
.nav-link:hover { background: #f5f5f7; color: var(--ink); }
.nav-link.active { background: var(--ink); color: #fff; }

.sidebar-footer {
  margin-top: auto;
  padding: 14px 10px 0;
  border-top: 1px solid var(--stroke);
  display: grid;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.main {
  width: 100%;
  max-width: 1500px;
  margin: 0 auto;
  padding: 34px clamp(24px, 4vw, 62px) 60px;
  display: grid;
  gap: 30px;
  align-content: start;
}

.topbar, .section-heading, .panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--sage);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 30px; line-height: 1.12; font-weight: 800; }
h2 { margin-bottom: 0; font-size: 24px; line-height: 1.18; font-weight: 800; }
h3 { margin-bottom: 0; font-size: 15px; font-weight: 800; }

.api-control {
  min-width: min(330px, 100%);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 5px 12px;
  align-items: center;
}
.api-control label { grid-column: 1 / -1; color: var(--muted); font-size: 11px; font-weight: 700; }
.api-control a { color: var(--ink-soft); font-size: 12px; font-weight: 700; text-decoration: none; }
.api-control a:hover { text-decoration: underline; }

input, select {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  background: #f7f7f9;
  color: var(--ink);
  outline: none;
}
input:focus, select:focus {
  border-color: #aaa8a5;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(23, 23, 25, 0.05);
}

.login-panel {
  min-height: 540px;
  border: 1px solid var(--stroke);
  border-radius: 20px;
  overflow: hidden;
  background: var(--paper);
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(350px, 0.8fr);
}

.login-copy {
  min-height: 540px;
  padding: clamp(38px, 6vw, 76px);
  background: var(--lemon) url("./assets/tira-world-map.png") center / cover no-repeat;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.login-copy h2 { max-width: 560px; font-size: clamp(32px, 4vw, 50px); }
.login-copy p:last-child { max-width: 560px; margin: 18px 0 0; color: var(--ink-soft); line-height: 1.6; }

.login-form {
  padding: clamp(32px, 5vw, 58px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
}
.login-form > div { margin-bottom: 8px; }
.login-form > div p { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.login-form label, .business-form label, .status-control {
  display: grid;
  gap: 7px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
}

.primary-button, .secondary-button, .ghost-button {
  min-height: 42px;
  border: 0;
  border-radius: 12px;
  padding: 10px 15px;
  font-weight: 800;
}
.primary-button { background: var(--ink); color: #fff; }
.primary-button:hover { background: #303034; }
.secondary-button { background: var(--mint); color: #315f4a; }
.secondary-button:hover { background: #d8f2e6; }
.ghost-button { border: 1px solid var(--stroke); background: #fff; color: var(--ink); }

.form-message { min-height: 20px; margin-bottom: 0; color: var(--danger); font-size: 13px; }
.operation-message { min-height: 0; margin: 0; color: #315f4a; font-size: 13px; font-weight: 700; }
.operation-message:not(:empty) {
  min-height: 42px; padding: 11px 14px; border: 1px solid #c8e7d8;
  border-radius: 12px; background: var(--mint);
}
.operation-message.error:not(:empty) { color: var(--danger); border-color: #f1c7d2; background: #fff0f4; }

.workspace { display: grid; gap: 23px; }

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric-card {
  min-height: 132px;
  padding: 19px;
  border: 1px solid rgba(0, 0, 0, 0.045);
  border-radius: 16px;
  background: var(--sky);
  display: flex;
  flex-direction: column;
}
.metric-card:nth-child(2), .metric-card:nth-child(6) { background: var(--mint); }
.metric-card:nth-child(3), .metric-card:nth-child(7) { background: var(--lilac); }
.metric-card:nth-child(4), .metric-card:nth-child(8) { background: var(--lemon); }
.metric-card:nth-child(5) { background: var(--blush); }
.metric-card span { color: var(--ink-soft); font-size: 12px; font-weight: 700; }
.metric-card strong { margin-top: auto; font-size: 29px; line-height: 1; }
.metric-card small { margin-top: 7px; color: var(--muted); font-size: 11px; font-weight: 600; }

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 15px;
}

.panel {
  padding: 20px;
  border: 1px solid var(--stroke);
  border-radius: 16px;
  background: var(--paper);
}
.panel-heading { padding-bottom: 16px; border-bottom: 1px solid var(--stroke); }
.panel-heading p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.panel-heading > span { color: var(--muted); font-size: 11px; font-weight: 700; }

.module-list, .user-list, .records-list { display: grid; gap: 8px; padding-top: 14px; }
.module-item, .user-item, .record-row {
  border: 1px solid var(--stroke);
  border-radius: 14px;
  padding: 14px;
  background: #fff;
}
.module-item { display: grid; gap: 7px; }
.module-title, .user-main { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.module-item p, .user-item p { margin-bottom: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.user-item strong { display: block; font-size: 13px; }
.user-main span { color: var(--muted); font-size: 11px; }

.status {
  padding: 5px 9px;
  border-radius: 999px;
  color: #315f4a;
  background: var(--mint);
  font-size: 10px;
  font-weight: 800;
}
.status.planned { color: #7a5a00; background: var(--lemon); }

.create-panel { margin-bottom: 15px; }
.business-form {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1.4fr 1fr auto;
  gap: 11px;
  align-items: end;
  padding-top: 16px;
}
.business-form button { white-space: nowrap; }

.record-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) minmax(240px, 1.7fr) minmax(150px, .7fr);
  gap: 18px;
  align-items: center;
}
.record-primary, .record-meta { min-width: 0; }
.record-primary strong, .record-primary span, .record-meta span { display: block; overflow-wrap: anywhere; }
.record-primary strong { font-size: 13px; }
.record-primary span, .record-meta { color: var(--muted); font-size: 11px; }
.record-primary span { margin-top: 4px; }
.record-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.status-control select { min-width: 145px; }
.empty-state {
  padding: 24px; border: 1px dashed #d8d6d3; border-radius: 14px;
  background: #fafafa; color: var(--muted); font-size: 13px; text-align: center;
}

@media (max-width: 1050px) {
  .app-shell { grid-template-columns: 210px minmax(0, 1fr); }
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content-grid { grid-template-columns: 1fr; }
  .business-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .record-row { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    padding: 14px 16px 12px;
    gap: 12px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }
  .brand { padding: 0; }
  .nav {
    grid-column: 1 / -1;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav-link { min-height: 38px; padding: 9px 12px; white-space: nowrap; }
  .nav-label { display: none; }
  .sidebar-footer {
    margin: 0;
    padding: 0;
    border: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
  }
  .sidebar-footer #sessionLabel { display: none; }
  .main { padding: 24px 16px 48px; }
  .topbar, .section-heading { align-items: stretch; flex-direction: column; }
  .api-control { min-width: 0; }
  .login-panel { grid-template-columns: 1fr; }
  .login-copy { min-height: 310px; padding: 30px; }
  .login-form { padding: 30px; }
}

@media (max-width: 520px) {
  .metrics-grid, .business-form { grid-template-columns: 1fr; }
  .metric-card { min-height: 112px; }
  h1 { font-size: 27px; }
}

/* ---------- Moderation ----------
   La pastille dit s'il y a du travail sans avoir a ouvrir l'onglet :
   une file de signalements qu'on doit penser a consulter n'est jamais
   consultee. */
.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  margin-left: 8px;
  padding: 0 5px;
  border-radius: 9px;
  background: #ff4f62;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.report-row .report-actions {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.report-row .report-details {
  font-style: italic;
  max-width: 44ch;
}
