:root {
  --ink: #17202a;
  --ink-2: #263340;
  --muted: #66727f;
  --line: #dfe3e8;
  --line-strong: #c7ced6;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-2: #f9fafb;
  --accent: #2057e8;
  --accent-dark: #1745c0;
  --danger: #b42318;
  --danger-bg: #fef3f2;
  --warn: #b54708;
  --warn-bg: #fffaeb;
  --ok: #067647;
  --ok-bg: #ecfdf3;
  --hold: #6941c6;
  --hold-bg: #f4f3ff;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-lg: 0 18px 45px rgba(16, 24, 40, 0.12);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; }
a { color: var(--accent); }
[hidden] { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.muted { color: var(--muted); }

/* Login */
.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1100px 500px at 15% -10%, #e6ecff 0%, transparent 60%),
    radial-gradient(900px 500px at 110% 10%, #eaf5ef 0%, transparent 55%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 34px 34px 28px;
  box-shadow: var(--shadow-lg);
}
.login-card h1 { font-size: 24px; letter-spacing: -0.02em; margin: 22px 0 6px; }
.login-card p { margin-bottom: 20px; }
.login-card form { display: grid; gap: 8px; margin-top: 18px; }
.login-card label { font-weight: 600; font-size: 13px; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(32, 87, 232, 0.14);
}
textarea { resize: vertical; min-height: 84px; }
.form-error { color: var(--danger); min-height: 20px; font-size: 13px; }

/* Wordmark */
.wordmark { font-weight: 800; letter-spacing: -0.03em; font-size: 20px; color: var(--ink); }
.wordmark span { color: var(--accent); font-weight: 650; }
.wordmark.compact { color: #fff; font-size: 17px; }
.wordmark.compact span { color: #9db7ff; }

/* Shell */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  height: 56px;
  background: var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  gap: 16px;
}
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar-user { color: #aeb9c6; font-size: 13px; }
.select {
  width: auto;
  min-width: 160px;
  background: #22303d;
  border-color: #33424f;
  color: #f2f5f8;
  padding: 7px 10px;
}
.select:focus { border-color: #6f8fff; box-shadow: none; }

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 0;
}
.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  overflow: auto;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sidebar-head h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.campaign-list { display: flex; flex-direction: column; gap: 6px; }
.campaign-item {
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 10px;
  padding: 10px 10px;
  cursor: pointer;
  display: grid;
  gap: 3px;
}
.campaign-item:hover { background: var(--panel-2); }
.campaign-item.active { background: #eef3ff; border-color: #cfdcff; }
.campaign-item strong { font-size: 13px; font-weight: 650; }
.campaign-item small { color: var(--muted); font-size: 12px; }

.metrics { border-top: 1px solid var(--line); padding-top: 14px; display: grid; gap: 10px; }
.metric-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.metric {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 10px;
}
.metric span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.metric strong { font-size: 18px; letter-spacing: -0.02em; }
.metric-note { font-size: 12px; color: var(--muted); }

.content {
  min-width: 0;
  padding: 22px 26px 40px;
  overflow: auto;
}
.panel-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.panel-head h1 { font-size: 22px; letter-spacing: -0.02em; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.active { background: var(--ink); border-color: var(--ink); color: #fff; }

/* Draft list */
.draft-list { display: flex; flex-direction: column; gap: 8px; }
.draft-row {
  text-align: left;
  font: inherit;
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 16px;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.draft-row:hover { border-color: #b9c6d6; }
.draft-row.selected { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(32, 87, 232, 0.12); }
.draft-main strong { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.draft-main small { color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.draft-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.draft-side { text-align: right; display: grid; gap: 4px; justify-items: end; }
.draft-side small { color: var(--muted); font-size: 12px; }
.empty {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 34px;
  text-align: center;
  color: var(--muted);
  background: var(--panel);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.danger { background: var(--danger-bg); color: var(--danger); }
.badge.hold { background: var(--hold-bg); color: var(--hold); }
.badge.neutral { background: #eef1f4; color: #44515e; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* Detail */
.detail-panel {
  margin-top: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}
.detail-head h2 { font-size: 18px; letter-spacing: -0.01em; }
.detail-head .sub { color: var(--muted); font-size: 12px; margin-top: 3px; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.pane { padding: 18px 20px; min-width: 0; }
.pane + .pane { border-left: 1px solid var(--line); }
.pane h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 10px;
}
.subject { font-size: 16px; font-weight: 650; margin-bottom: 8px; overflow-wrap: anywhere; }
.meta-line { color: var(--muted); font-size: 12px; display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.body-preview {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #0f1720;
  color: #e7edf4;
  border-radius: 10px;
  padding: 16px;
  font: 13px/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  max-height: 420px;
  overflow: auto;
}
.artifact-link { display: inline-flex; gap: 6px; align-items: center; margin-top: 10px; font-size: 12px; }
.findings { display: grid; gap: 6px; margin-top: 14px; }
.finding {
  border: 1px solid var(--line);
  border-left: 3px solid var(--muted);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  background: var(--panel);
}
.finding.block { border-left-color: var(--danger); background: var(--danger-bg); }
.finding.warn { border-left-color: var(--warn); background: var(--warn-bg); }
.finding.hold { border-left-color: var(--hold); background: var(--hold-bg); }
.finding.info { border-left-color: var(--accent); }
.finding strong { display: block; font-size: 11px; letter-spacing: 0.03em; text-transform: uppercase; margin-bottom: 2px; }
.finding p { color: #3b4652; }
.empty-note { color: var(--muted); font-size: 12px; }

.form { display: grid; gap: 10px; }
.form label { font-weight: 600; font-size: 12px; }
.form .hint { font-weight: 400; color: var(--muted); font-size: 11px; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500 !important; }
.check input { width: auto; }
.publish-box {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  display: grid;
  gap: 8px;
}
.publish-box textarea { min-height: 84px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.approval-box {
  margin-top: 14px;
  background: var(--ok-bg);
  border: 1px solid #abefc6;
  border-radius: 9px;
  padding: 10px 12px;
  font-size: 12px;
  color: #085d3a;
}
.approval-box strong { display: block; margin-bottom: 2px; }

/* Buttons */
.btn {
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--ink);
  border-radius: 8px;
  padding: 9px 14px;
  font-weight: 650;
  font-size: 13px;
  cursor: pointer;
}
.btn:hover { border-color: #aab7c6; background: #fbfcfd; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn.danger { color: var(--danger); border-color: #f1b8b3; background: #fff; }
.btn.danger:hover { background: var(--danger-bg); }
.btn.ghost { background: transparent; border-color: transparent; color: #c9d2dc; }
.btn.ghost:hover { background: rgba(255, 255, 255, 0.08); }
.btn.small { padding: 6px 10px; font-size: 12px; }
.btn.wide { width: 100%; }
.btn.subtle { background: var(--panel-2); }

/* Create panel */
.create-panel {
  margin-top: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-lg);
}
.create-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.create-grid .full { grid-column: 1 / -1; }

/* Toast */
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: var(--ink);
  color: #fff;
  border-radius: 10px;
  padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  max-width: 380px;
  z-index: 50;
}
.toast.error { background: #7a271a; }

@media (max-width: 1050px) {
  .layout { grid-template-columns: 250px minmax(0, 1fr); }
  .detail-grid { grid-template-columns: 1fr; }
  .pane + .pane { border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 760px) {
  .layout { display: block; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .content { padding: 16px; }
  .draft-row { grid-template-columns: 1fr; gap: 8px; }
  .draft-side { text-align: left; justify-items: start; }
  .panel-head { align-items: flex-start; flex-direction: column; }
  .create-grid { grid-template-columns: 1fr; }
  .topbar-user { display: none; }
}

.alert-line {
  border-left: 3px solid var(--danger);
  background: var(--danger-bg);
  color: #7a271a;
  border-radius: 6px;
  padding: 7px 9px;
  font-size: 12px;
  margin-top: 6px;
}

.weekday-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.weekday-row .check { font-weight: 500; }

.sender-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.sender-row .check { font-weight: 500; }

.roster-table-wrap { overflow: auto; max-height: 620px; border: 1px solid var(--line); border-radius: 10px; }
.roster-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.roster-table th, .roster-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.roster-table th { position: sticky; top: 0; background: var(--panel-2); z-index: 1; font-weight: 650; }
.roster-table tr:last-child td { border-bottom: 0; }
.roster-table td.domain { color: var(--muted); white-space: nowrap; }
.roster-table td.contact { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.roster-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 12px 0; }
.roster-toolbar input { flex: 1; min-width: 220px; }
.roster-counts { display: flex; gap: 6px; flex-wrap: wrap; }

/* Deliverability */
.deliverability-controls { margin-top: 0; }
.deliverability-report { margin-top: 16px; }
.report-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.report-score { display: flex; align-items: center; gap: 10px; font-size: 20px; }
.report-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 14px 0; }
.report-card { border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: var(--panel-2); display: flex; flex-direction: column; gap: 2px; }
.report-card span { color: var(--muted); font-size: 12px; }
.report-card strong { font-size: 18px; }
.report-card small { color: var(--muted); }
.report-section { margin-top: 16px; }
.report-section h3 { margin-bottom: 6px; }
.issue-list { display: grid; gap: 8px; margin: 8px 0; }
.issue { border-left: 3px solid var(--line-strong); background: var(--panel-2); border-radius: 6px; padding: 8px 10px; font-size: 12px; }
.issue.critical, .issue.high { border-left-color: var(--danger); background: var(--danger-bg); }
.issue.medium, .issue.warn { border-left-color: var(--warn); background: var(--warn-bg); }
.issue.low { border-left-color: var(--accent); }
.issue p { margin-top: 3px; }
.links-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.links-table th, .links-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; word-break: break-all; }
.links-table th { background: var(--panel-2); font-weight: 650; }
.raw-report { margin-top: 16px; }
.raw-report summary { cursor: pointer; font-weight: 650; }
.raw-report pre { max-height: 320px; overflow: auto; background: var(--ink); color: #e6edf3; padding: 10px; border-radius: 8px; font-size: 11px; }
