:root {
  --ink: #17202a;
  --muted: #64748b;
  --line: #dbe3ea;
  --panel: #ffffff;
  --bg: #f3f6f8;
  --blue: #1769aa;
  --green: #23856d;
  --orange: #b76b21;
  --dark: #102030;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: var(--blue); text-decoration: none; }
main { width: min(1180px, calc(100% - 28px)); margin: 22px auto 46px; }

.topbar {
  background: var(--dark);
  color: white;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px max(14px, calc((100vw - 1180px) / 2));
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand { color: white; font-weight: 800; letter-spacing: 0; }
.brand span { color: #89c2f2; margin-left: 4px; }
nav { display: flex; gap: 8px; flex: 1; flex-wrap: wrap; }
nav a { color: #d8e8f8; padding: 8px 10px; border-radius: 6px; }
nav a:hover { background: rgba(255,255,255,.1); }
.mode { border: 1px solid rgba(255,255,255,.25); border-radius: 6px; padding: 6px 8px; font-size: 13px; }
.mode.encodage { background: rgba(35,133,109,.25); }
.mode.review { background: rgba(183,107,33,.25); }

.hero, .section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin: 20px 0;
}
h1, h2 { margin: 0; letter-spacing: 0; }
h1 { font-size: clamp(26px, 4vw, 40px); }
h2 { font-size: 18px; }
p { color: var(--muted); line-height: 1.45; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 8px 22px rgba(16, 32, 48, .06);
}
.grid.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin: 16px 0; }
.chart-panel { min-height: 330px; }
.chart-panel canvas { height: 260px !important; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.stats article {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}
.stats strong { display: block; font-size: 25px; }
.stats span { color: var(--muted); font-size: 13px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 11px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-size: 13px; }
tr:hover td { background: #f8fafc; }

.status { display: inline-block; border-radius: 999px; padding: 4px 9px; font-size: 12px; font-weight: 700; }
.status.draft { background: #f7e7d7; color: #7a3d08; }
.status.reviewed { background: #dfefff; color: #0a5b9a; }
.status.sent { background: #daf3ea; color: #11624f; }

button, .button {
  border: 0;
  border-radius: 6px;
  background: var(--blue);
  color: white;
  padding: 10px 13px;
  cursor: pointer;
  display: inline-block;
  font-weight: 700;
}
button.secondary, .button.secondary { background: #e9eef3; color: var(--ink); }
button:hover, .button:hover { filter: brightness(.96); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
label { display: grid; gap: 6px; font-weight: 700; color: #263443; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 11px 12px;
  font: inherit;
  background: white;
}
textarea { min-height: 120px; resize: vertical; }
.wide { grid-column: 1 / -1; }
.actions { display: flex; justify-content: flex-end; gap: 10px; }

.login {
  min-height: calc(100vh - 140px);
  display: grid;
  grid-template-columns: 1fr minmax(300px, 420px);
  gap: 26px;
  align-items: center;
}
.login h1 { color: var(--dark); }
.alert {
  background: #fff0f0;
  border: 1px solid #f0b8b8;
  color: #872525;
  padding: 10px;
  border-radius: 6px;
}
.metrics p { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.metrics span { color: var(--muted); }
.metrics strong { color: var(--ink); }
.send-box { display: grid; gap: 10px; margin-top: 14px; }
.mail-log { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }

@media (max-width: 820px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  nav { width: 100%; }
  .hero, .section-head { align-items: stretch; flex-direction: column; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.two, .form-grid, .login { grid-template-columns: 1fr; }
  main { width: min(100% - 18px, 1180px); }
}
