:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-strong: #f0f4f1;
  --ink: #18201d;
  --muted: #64716c;
  --line: #dce3df;
  --line-strong: #c6d2cc;
  --green: #1f7a5b;
  --green-dark: #14583f;
  --coral: #c4513f;
  --blue: #315f9c;
  --gold: #9a6a16;
  --shadow: 0 16px 34px rgba(20, 34, 28, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  width: min(1500px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 78px;
  padding: 14px 0 18px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-logo {
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
}

.topbar h1,
.section-heading h2,
.panel-title h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: clamp(2rem, 2.8rem, 3.25rem);
  line-height: 1;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.language-select {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 42px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
}

.language-select svg {
  width: 18px;
  height: 18px;
}

.language-select select {
  min-height: 32px;
  width: auto;
  min-width: 96px;
  border: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(230px, 280px) minmax(0, 1fr) minmax(280px, 340px);
  gap: 18px;
  align-items: start;
}

.panel,
.scan-bar,
.scan-results {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.filters-panel,
.manual-panel {
  position: sticky;
  top: 18px;
}

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

.panel-title {
  justify-content: flex-start;
  margin-bottom: 16px;
}

.panel-title.compact {
  margin: 18px 0 10px;
}

.panel-title svg,
.button svg,
.icon-button svg,
.meta svg,
.source-item svg,
.empty-state svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

.panel-title h2,
.section-heading h2 {
  font-size: 1.02rem;
}

.main-column {
  min-width: 0;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 13px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.field.inline {
  grid-template-columns: auto minmax(180px, 1fr);
  align-items: center;
  flex: 1;
  margin: 0;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fbfcfc;
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 96px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(31, 122, 91, 0.14);
}

.button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 7px;
  font-weight: 800;
  white-space: nowrap;
}

.button {
  padding: 0 14px;
}

.button.small {
  min-height: 34px;
  padding: 0 10px;
  font-size: 0.78rem;
}

.button.primary {
  background: var(--green);
  color: #fff;
}

.button.primary:hover {
  background: var(--green-dark);
}

.button.secondary {
  background: #fff;
  border-color: var(--line-strong);
  color: var(--ink);
}

.button:disabled,
.icon-button:disabled {
  cursor: default;
  opacity: 0.55;
}

.button.reminder-button.active {
  border-color: var(--green);
  background: #edf7f2;
  color: var(--green-dark);
}

.button.full {
  width: 100%;
}

.icon-button {
  width: 42px;
  background: #fff;
  border-color: var(--line-strong);
  color: var(--ink);
}

.icon-button:hover,
.icon-button.active {
  border-color: var(--green);
  color: var(--green);
}

.scan-bar {
  display: flex;
  align-items: end;
  gap: 12px;
  padding: 14px;
  margin-bottom: 16px;
}

.scan-results {
  padding: 14px;
  margin-bottom: 16px;
}

.scan-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.scan-summary svg {
  width: 18px;
  height: 18px;
  color: var(--green);
}

.scan-source-action {
  display: flex;
  justify-content: flex-end;
  margin: -2px 0 10px;
}

.candidate-list {
  display: grid;
  gap: 10px;
}

.candidate-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.candidate-row h3 {
  margin: 0 0 6px;
  font-size: 0.95rem;
}

.candidate-row p {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.section-heading {
  margin: 8px 0 13px;
}

.view-toggle {
  display: flex;
  gap: 7px;
}

.event-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.load-more-row {
  display: flex;
  justify-content: center;
  margin-top: 16px;
}

.load-more-row .button[hidden] {
  display: none;
}

.event-card {
  display: grid;
  gap: 12px;
  min-height: 230px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 5px solid var(--green);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.event-card[data-status="signal_faible"] {
  border-left-color: var(--gold);
}

.event-card[data-status="a_verifier"] {
  border-left-color: var(--blue);
}

.event-card[data-status="fiable"] {
  border-left-color: var(--green);
}

.event-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.event-title {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.date-badge {
  display: grid;
  place-items: center;
  align-content: center;
  flex: 0 0 62px;
  min-height: 62px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fbfcfc;
  color: var(--ink);
  text-align: center;
  line-height: 1;
}

.date-badge strong {
  display: block;
  font-size: 1.25rem;
}

.date-badge span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
}

.event-description {
  margin: 0;
  color: var(--muted);
  font-size: 0.91rem;
  line-height: 1.45;
}

.meta-grid {
  display: grid;
  gap: 8px;
}

.meta {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  background: #edf3f0;
  color: var(--green-dark);
  font-size: 0.76rem;
  font-weight: 850;
}

.pill.warn {
  background: #fff3dd;
  color: #7a4b00;
}

.pill.info {
  background: #e9f0fb;
  color: #244f89;
}

.event-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: auto;
}

.event-action-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.source-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  color: var(--green-dark);
  font-size: 0.84rem;
  font-weight: 850;
}

.danger-button {
  width: 34px;
  min-height: 34px;
  border-color: #efd4cf;
  color: var(--coral);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin-top: 8px;
}

.stat {
  min-height: 74px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.stat strong {
  display: block;
  font-size: 1.35rem;
}

.stat span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.source-list {
  display: grid;
  gap: 8px;
}

.admin-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-actions .button {
  flex: 1;
}

.source-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.source-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.source-item strong,
.source-item span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.source-item strong {
  font-size: 0.84rem;
  white-space: nowrap;
}

.source-item span {
  color: var(--muted);
  font-size: 0.76rem;
  overflow-wrap: anywhere;
}

.two-cols {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.checkbox-field {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  margin: 2px 0 15px;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 800;
}

.checkbox-field input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--green);
}

.event-list.table-mode {
  display: block;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.event-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
}

.event-table th,
.event-table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.event-table th {
  color: var(--muted);
  font-size: 0.74rem;
  text-transform: uppercase;
}

.event-table td {
  font-size: 0.9rem;
}

.event-table td:last-child {
  display: flex;
  align-items: center;
  gap: 8px;
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 10px;
  min-height: 250px;
  padding: 30px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.empty-state svg {
  width: 36px;
  height: 36px;
  color: var(--green);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  min-height: 44px;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1180px) {
  .content-grid {
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .manual-panel {
    grid-column: 1 / -1;
    position: static;
  }
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100% - 22px, 760px);
    padding-top: 14px;
  }

  .topbar {
    align-items: flex-start;
  }

  .content-grid,
  .event-list,
  .two-cols {
    grid-template-columns: 1fr;
  }

  .filters-panel {
    position: static;
  }

  .scan-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .field.inline {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .topbar {
    flex-direction: column;
  }

  .brand-logo {
    width: 50px;
    height: 50px;
  }

  .topbar-actions {
    width: 100%;
  }

  .topbar-actions .button {
    flex: 1;
  }

  .candidate-row,
  .event-header {
    grid-template-columns: 1fr;
  }

  .event-header {
    display: grid;
  }

  .date-badge {
    width: 62px;
  }
}
