:root {
  --bg: #eef7f0;
  --ink: #0d1e35;
  --muted: #575757;
  --panel: #ffffff;
  --line: #eaecef;
  --navy: #163b7c;
  --navy-dark: #0f3371;
  --green: #55b56c;
  --green-dark: #3d8f52;
  --warn: #b45309;
  --danger: #b42318;
  --ready: #1f7a3a;
  --shadow: 0 12px 32px rgba(22, 59, 124, 0.1);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Manrope, system-ui, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, #f0f6ff, transparent 36%),
    linear-gradient(180deg, #ffffff 0%, var(--bg) 42%);
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image: linear-gradient(rgba(22, 59, 124, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(22, 59, 124, 0.04) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
}

.utility-bar {
  position: relative;
  z-index: 1;
  background: var(--navy);
  color: white;
}
.utility-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 10px 24px;
  display: flex;
  justify-content: flex-end;
  gap: 18px;
}
.utility-inner a {
  color: white;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  opacity: 0.82;
}
.utility-inner a:hover,
.utility-inner a.active { opacity: 1; }
.utility-inner a.active { border-bottom: 2px solid var(--green); padding-bottom: 2px; }

.topbar, main { position: relative; z-index: 1; }
.topbar {
  max-width: 1120px;
  margin: 0 auto;
  padding: 22px 24px 8px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}
.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}
.brand img { display: block; width: 46px; height: auto; }
.wordmark {
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1;
}
.wordmark .best { color: var(--navy); }
.wordmark .infra { color: var(--green); }
.brand p { margin: 6px 0 0; color: var(--muted); font-size: 13px; font-weight: 500; }
.status-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  border: 1px solid var(--line);
  background: white;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
}
.pill.ok { color: var(--ready); border-color: #b7e4c4; background: #eef7f0; }
.pill.warn { color: var(--warn); border-color: #f9dbaf; background: #fff6ed; }
.pill.bad { color: var(--danger); border-color: #fecdca; background: #fef3f2; }

main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 16px 24px 64px;
  display: grid;
  gap: 18px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.panel-head h3 { margin: 0; color: var(--navy); }
.panel-head p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.filter-field { min-width: 240px; margin: 0; }

.dropzone {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 8px;
  padding: 36px 20px;
  border: 1.5px dashed #9bb6d6;
  border-radius: 18px;
  background: #f6faff;
  cursor: pointer;
}
.dropzone.drag { background: #eef7f0; border-color: var(--green); }
.dropzone h2 { margin: 8px 0 0; font-size: 22px; color: var(--navy); }
.dropzone p { margin: 0; max-width: 560px; color: var(--muted); line-height: 1.5; }
.drop-icon {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--navy);
  color: white;
  font-weight: 700;
  letter-spacing: 0.4px;
}
.file-chip {
  margin-top: 8px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
}
.field { display: grid; gap: 6px; margin-bottom: 14px; font-size: 14px; font-weight: 650; color: var(--navy); }
.field select,
.field input {
  border: 1px solid #c9d4e4;
  border-radius: 12px;
  padding: 12px;
  font: inherit;
  font-weight: 500;
  background: white;
  color: var(--ink);
}
.field select:focus,
.field input:focus {
  outline: 2px solid rgba(85, 181, 108, 0.45);
  border-color: var(--green);
}
.toolbar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
}
.toolbar .field { margin-bottom: 0; }
.notice {
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
}
.notice.warn {
  background: #fff6ed;
  border: 1px solid #f9dbaf;
  color: var(--warn);
}
.activity-list {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}
.activity-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbf9 100%);
}
.activity-main {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}
.activity-identity h4 {
  margin: 0;
  font-size: 17px;
  color: var(--navy);
}
.activity-email {
  margin: 4px 0 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}
.activity-meta {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
}
.activity-status {
  display: grid;
  justify-items: end;
  gap: 8px;
}
.activity-time {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}
.interest-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 10px;
  background: #eef4fb;
  color: var(--navy);
  font-size: 12px;
  font-weight: 700;
}
.chip.muted {
  background: #f4f4f4;
  color: var(--muted);
}
.metric-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.metric {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: white;
}
.metric span {
  display: block;
  font-size: 11px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
.metric strong {
  display: block;
  margin-top: 4px;
  font-size: 14px;
  color: var(--ink);
}
.metric.ok strong { color: var(--ready); }
.metric.bad strong { color: var(--danger); }
.empty-card {
  text-align: center;
  color: var(--muted);
  padding: 28px 16px;
  border: 1px dashed #c9d4e4;
  border-radius: 16px;
}
.history-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}
.history-card {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(140px, 0.8fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
}
.history-card h4 {
  margin: 0;
  font-size: 15px;
  color: var(--navy);
}
.history-card p {
  margin: 3px 0 0;
  font-size: 13px;
  color: var(--muted);
}
.history-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.hint { color: var(--muted); font-size: 13px; margin: 14px 0 0; }
code { background: #f0f6ff; color: var(--navy); padding: 1px 6px; border-radius: 6px; }

.btn {
  border: 0;
  border-radius: 16px;
  padding: 12px 16px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--green); color: white; }
.btn.primary:hover:not(:disabled) { background: var(--green-dark); }
.btn.ghost { background: white; color: var(--navy); border: 1px solid #c9d4e4; }

[hidden] { display: none !important; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.stats.three { grid-template-columns: repeat(3, 1fr); }
.stats.four { grid-template-columns: repeat(4, 1fr); }
.stats article {
  background: white;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.stats span { color: var(--muted); font-size: 13px; font-weight: 600; }
.stats strong { display: block; margin-top: 6px; font-size: 28px; color: var(--navy); }
.stats article.opened strong { color: var(--ready); }
.stats article.opens strong { color: var(--navy); }
.stats article.expert strong { color: var(--green-dark); }
.stats article.closed strong { color: var(--muted); }

.table-wrap { overflow: auto; margin-top: 16px; }
table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  vertical-align: top;
}
th { color: var(--muted); font-size: 12px; letter-spacing: 0.3px; text-transform: uppercase; }
.empty { color: var(--muted); text-align: center; padding: 24px !important; }

.badge {
  display: inline-flex;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
}
.badge.ready { background: #eef7f0; color: var(--ready); }
.badge.skipped { background: #fff6ed; color: var(--warn); }
.badge.sent { background: #f0f6ff; color: var(--navy); }
.badge.failed { background: #fef3f2; color: var(--danger); }
.badge.opened { background: #eef7f0; color: var(--ready); }
.badge.unopened { background: #f4f4f4; color: #575757; }
.badge.expert { background: #eef7f0; color: var(--green-dark); }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: var(--navy);
  color: white;
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 5;
}

@media (max-width: 800px) {
  .topbar, .stats, .stats.three, .stats.four { display: grid; }
  .stats, .stats.three, .stats.four { grid-template-columns: 1fr 1fr; }
  .wordmark { font-size: 22px; }
  .activity-main,
  .history-card {
    grid-template-columns: 1fr;
    display: grid;
  }
  .activity-status,
  .history-card { justify-items: start; }
  .metric-row { grid-template-columns: 1fr 1fr; }
  .toolbar { width: 100%; }
  .toolbar .filter-field { min-width: 0; flex: 1; }
}
