/* ===================================================================
   Grille de notation — design system
   Palette "registre de jury" : papier crème, encre brune, accent or.
   =================================================================== */

:root {
  --bg: #f6f3ea;
  --surface: #ffffff;
  --surface-2: #eee8d8;
  --surface-3: #e5dec8;
  --border: #ddd3b8;
  --ink: #221d14;
  --ink-muted: #6b6252;
  --accent: #b8863b;
  --accent-strong: #8f6425;
  --accent-bg: #f2e5c8;
  --accent-contrast: #ffffff;
  --positive: #3c6e4f;
  --positive-bg: #e4eee1;
  --negative: #a8412f;
  --negative-bg: #f4e3dd;
  --shadow: 0 1px 2px rgba(34, 29, 20, 0.06), 0 8px 24px -12px rgba(34, 29, 20, 0.18);

  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-body: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #17140f;
    --surface: #211c15;
    --surface-2: #2b251b;
    --surface-3: #362e21;
    --border: #3d3526;
    --ink: #f3efe3;
    --ink-muted: #b3a890;
    --accent: #e0a94e;
    --accent-strong: #f2c572;
    --accent-bg: #3a2f14;
    --accent-contrast: #221802;
    --positive: #6fbe8c;
    --positive-bg: #1e3327;
    --negative: #e08a76;
    --negative-bg: #3a241e;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
  }
}

:root[data-theme='dark'] {
  --bg: #17140f;
  --surface: #211c15;
  --surface-2: #2b251b;
  --surface-3: #362e21;
  --border: #3d3526;
  --ink: #f3efe3;
  --ink-muted: #b3a890;
  --accent: #e0a94e;
  --accent-strong: #f2c572;
  --accent-bg: #3a2f14;
  --accent-contrast: #221802;
  --positive: #6fbe8c;
  --positive-bg: #1e3327;
  --negative: #e08a76;
  --negative-bg: #3a241e;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100vh; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  margin: 0;
  text-wrap: balance;
  color: var(--ink);
}

p { margin: 0; }

a { color: var(--accent-strong); }

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- boot */

.boot-loader {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.boot-mark {
  font-family: var(--font-display);
  font-size: 15px;
  color: var(--ink-muted);
}

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

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 36px 32px 32px;
}

.login-eyebrow {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-strong);
  font-weight: 600;
  margin-bottom: 10px;
}

.login-card h1 {
  font-size: 26px;
  margin-bottom: 6px;
}

.login-sub {
  color: var(--ink-muted);
  font-size: 13.5px;
  margin-bottom: 26px;
}

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--ink-muted); }

.input, select.input {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--ink);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 15px;
  width: 100%;
}
.input:focus { border-color: var(--accent); }


.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.12s ease, transform 0.05s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-contrast); width: 100%; }
.btn-primary:hover { filter: brightness(1.06); }
.btn-secondary { background: var(--surface-2); color: var(--ink); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-3); }
.btn-ghost { background: transparent; color: var(--ink-muted); }
.btn-ghost:hover { color: var(--ink); background: var(--surface-2); }
.btn-danger { background: var(--negative-bg); color: var(--negative); }
.btn-danger:hover { filter: brightness(0.97); }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.form-error {
  background: var(--negative-bg);
  color: var(--negative);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13.5px;
  margin-bottom: 16px;
}
.form-note {
  background: var(--accent-bg);
  color: var(--accent-strong);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  margin-top: 16px;
}

/* ---------------------------------------------------------------- shell */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  gap: 4px;
}

.brand {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  padding: 6px 10px 18px;
}
.brand span { color: var(--accent-strong); }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--ink-muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: none;
  text-align: left;
  width: 100%;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--accent-bg); color: var(--accent-strong); font-weight: 600; }

.sidebar-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  font-size: 13px;
}
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: var(--accent-contrast);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; flex-shrink: 0;
}
.user-name { font-weight: 600; }
.user-role { color: var(--ink-muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; }

.main {
  flex: 1;
  min-width: 0;
  padding: 32px 40px 60px;
}

.topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.page-header h1 { font-size: 26px; }
.page-header .sub { color: var(--ink-muted); font-size: 14px; margin-top: 4px; }
.page-actions { display: flex; gap: 10px; flex-shrink: 0; }

/* ---------------------------------------------------------------- cards */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.card + .card { margin-top: 16px; }

.card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.survey-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  cursor: pointer;
  transition: border-color 0.12s ease, transform 0.05s ease;
}
.survey-card:hover { border-color: var(--accent); }
.survey-card h3 { font-size: 17px; }
.survey-card .desc { color: var(--ink-muted); font-size: 13px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  width: fit-content;
}
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-open { background: var(--positive-bg); color: var(--positive); }
.badge-closed { background: var(--negative-bg); color: var(--negative); }
.badge-admin { background: var(--accent-bg); color: var(--accent-strong); }
.badge-participant { background: var(--surface-2); color: var(--ink-muted); }

.progress-track {
  height: 6px;
  border-radius: 100px;
  background: var(--surface-2);
  overflow: hidden;
}
.progress-fill { height: 100%; background: var(--accent); border-radius: 100px; }

/* ---------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
  font-weight: 600;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.rank-pill {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%;
  font-family: var(--font-mono); font-size: 12px; font-weight: 600;
  background: var(--surface-2); color: var(--ink-muted);
}
.rank-pill.first { background: var(--accent); color: var(--accent-contrast); }

/* ---------------------------------------------------------------- rating grid */

.rating-grid-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.rating-grid { border-collapse: separate; border-spacing: 0; width: 100%; }
.rating-grid th, .rating-grid td { border-bottom: 1px solid var(--border); }
.rating-grid thead th {
  position: sticky; top: 0; background: var(--surface); z-index: 2;
  padding: 14px; font-family: var(--font-display); font-size: 14px;
  text-transform: none; letter-spacing: 0; color: var(--ink); font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.rating-grid tbody th {
  position: sticky; left: 0; background: var(--surface); z-index: 1;
  text-align: left; font-weight: 500; font-size: 13.5px; color: var(--ink);
  padding: 12px 16px; max-width: 260px; border-right: 1px solid var(--border);
}
.rating-grid thead th:first-child { position: sticky; left: 0; z-index: 3; background: var(--surface); border-right: 1px solid var(--border); }
.rating-grid td { padding: 10px 12px; text-align: center; }

.score-picker { display: inline-flex; gap: 4px; }
.score-btn {
  width: 30px; height: 30px; border-radius: 7px;
  border: 1px solid var(--border); background: var(--bg); color: var(--ink-muted);
  font-family: var(--font-mono); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all 0.1s ease;
}
.score-btn:hover { border-color: var(--accent); color: var(--ink); }
.score-btn.selected { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }

.rating-toolbar {
  position: sticky; bottom: 0;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 20px; margin-top: 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow);
}
.rating-toolbar .status { font-size: 13px; color: var(--ink-muted); }

.confirmation-panel {
  text-align: center; padding: 60px 20px; display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.confirmation-mark {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--positive-bg); color: var(--positive);
  display: flex; align-items: center; justify-content: center; font-size: 26px;
}

/* ---------------------------------------------------------------- forms / modals */

.overlay {
  position: fixed; inset: 0; background: rgba(20, 16, 8, 0.45);
  display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 50;
}
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto;
  padding: 26px 28px; box-shadow: var(--shadow);
}
.modal h2 { font-size: 20px; margin-bottom: 4px; }
.modal .modal-sub { color: var(--ink-muted); font-size: 13px; margin-bottom: 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

.repeater-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.repeater-row .input { flex: 1; }
.repeater-row .weight-input { width: 76px; flex: none; }
.icon-btn {
  width: 32px; height: 32px; flex-shrink: 0; border-radius: 7px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink-muted); cursor: pointer; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--negative-bg); color: var(--negative); border-color: var(--negative-bg); }

.checkbox-row { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--border); }
.checkbox-row:last-child { border-bottom: none; }
.checkbox-row input { width: 16px; height: 16px; accent-color: var(--accent); }

.empty-state {
  text-align: center; padding: 50px 20px; color: var(--ink-muted);
  border: 1px dashed var(--border); border-radius: 12px; background: var(--surface);
}
.empty-state h3 { color: var(--ink); margin-bottom: 6px; font-size: 17px; }

.section-title {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-muted); font-weight: 600; margin: 24px 0 10px;
}
.section-title:first-child { margin-top: 0; }

.credential-toast {
  background: var(--accent-bg); border: 1px solid var(--accent); border-radius: 10px;
  padding: 14px 16px; margin-bottom: 18px; font-size: 13.5px;
}
.credential-toast .code { font-family: var(--font-mono); font-weight: 700; font-size: 15px; letter-spacing: 0.05em; }

.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { background: var(--surface-2); border-radius: 100px; padding: 3px 10px; font-size: 12px; color: var(--ink-muted); }

.stat-row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 24px; }
.stat-tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 18px; min-width: 140px; flex: 1;
}
.stat-tile .label { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-muted); font-weight: 600; }
.stat-tile .value { font-family: var(--font-mono); font-size: 24px; font-weight: 600; margin-top: 4px; }

.warning-box {
  background: var(--negative-bg); color: var(--negative); border-radius: 10px;
  padding: 12px 14px; font-size: 13px; margin-bottom: 18px;
}

.score-chart {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px 18px; margin-bottom: 24px; display: flex; flex-direction: column; gap: 10px;
}
.score-chart-row { display: grid; grid-template-columns: 140px 1fr 46px; align-items: center; gap: 10px; }
.score-chart-label {
  font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.score-chart-track {
  background: var(--surface-2); border-radius: 100px; height: 12px; overflow: hidden;
}
.score-chart-fill {
  background: var(--accent); height: 100%; border-radius: 100px; transition: width 0.2s ease;
}
.score-chart-fill.first { background: var(--accent-strong); }
.score-chart-value {
  font-family: var(--font-mono); font-size: 13px; font-weight: 600; text-align: right;
}

.juror-detail-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 24px; }
.juror-detail {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px;
}
.juror-detail summary {
  cursor: pointer; font-weight: 600; font-size: 14px; list-style: none;
}
.juror-detail summary::-webkit-details-marker { display: none; }
.juror-detail summary::before {
  content: '▸'; display: inline-block; margin-right: 8px; color: var(--accent); transition: transform 0.15s ease;
}
.juror-detail[open] summary::before { transform: rotate(90deg); }

/* ---------------------------------------------------------------- responsive */

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar { display: none; }
  .topbar { display: flex; }
  .main { padding: 20px 16px 60px; }
  .rating-grid tbody th { max-width: 140px; }
  .score-chart-row { grid-template-columns: 90px 1fr 40px; }
}

.hidden { display: none !important; }
