/* OPO Mailer — styles. Palette and type follow the OPO brand guide:
   N08 #0A0C0A · N04 #95A090 · N01 #FEFEFE · Mint #A9F894 · Moss #7FA56F · Blue #589CFE · Orange #FF6F29
   Feedback colours are functional only: success #1AE063 · warning #FEDB41 · error #FF3232 · info #5A23F2 */

:root {
  --night: #0A0C0A;
  --panel: #131712;
  --panel-2: #1B2419;
  --raise: #222D20;
  --line: rgba(254, 254, 254, 0.12);
  --line-strong: rgba(254, 254, 254, 0.24);
  --text: #FEFEFE;
  --muted: #95A090;
  --mint: #A9F894;
  --moss: #7FA56F;
  --blue: #589CFE;
  --orange: #FF6F29;
  --ok: #1AE063;
  --warn: #FEDB41;
  --bad: #FF3232;
  --info: #5A23F2;
  --font-head: "Roboto Flex", Impact, "Helvetica Neue", Arial, sans-serif;
  --font-body: "Instrument Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: "IBM Plex Mono", "Courier New", monospace;
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  background: var(--night);
  color: var(--text);
  font: 15px/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--mint); text-underline-offset: 3px; }
a:hover { color: #fff; }
:focus-visible { outline: 2px solid var(--mint); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--mint); color: var(--night); }

h1, h2, h3 { margin: 0; font-weight: 400; }
.display, h1 {
  font-family: var(--font-head);
  font-variation-settings: 'wdth' 80, 'wght' 800;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.005em;
  line-height: 0.98;
}
h1 { font-size: clamp(34px, 4.4vw, 52px); }
h2 { font-family: var(--font-head); font-variation-settings: 'wdth' 80, 'wght' 800; font-weight: 800; text-transform: uppercase; font-size: 24px; line-height: 1; letter-spacing: 0.01em; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.mono { font-family: var(--font-mono); letter-spacing: 0.02em; }
.small { font-size: 13px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.rail {
  position: sticky; top: 0; align-self: start; height: 100vh;
  display: flex; flex-direction: column; gap: 4px;
  padding: 22px 14px; border-right: 1px solid var(--line); background: var(--night);
  overflow-y: auto;
}
.brand { display: flex; align-items: baseline; gap: 10px; padding: 0 10px 22px; text-decoration: none; color: var(--text); }
.brand b { font-family: var(--font-head); font-variation-settings: 'wdth' 80, 'wght' 900; font-weight: 900; font-size: 34px; letter-spacing: 0.02em; color: var(--text); line-height: 1; }
.brand span { font-family: var(--font-mono); font-size: 12px; color: var(--muted); letter-spacing: 0.06em; }
.rail nav { display: flex; flex-direction: column; gap: 2px; }
.rail .group { margin: 18px 10px 6px; font: 500 11px var(--font-mono); letter-spacing: 0.08em; color: var(--muted); }
.rail a.nav {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 10px; border-radius: 8px; color: var(--text); text-decoration: none; font-weight: 500;
}
.rail a.nav:hover { background: var(--panel); }
.rail a.nav[aria-current="page"] { background: var(--panel-2); box-shadow: inset 3px 0 0 var(--mint); }
.rail a.nav .count { font: 400 12px var(--font-mono); color: var(--muted); }
.rail .who { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid var(--line); font-size: 13px; }
.rail .who form { display: inline; }
.link-btn { background: none; border: 0; padding: 0; color: var(--muted); font: inherit; text-decoration: underline; cursor: pointer; text-underline-offset: 3px; }
.link-btn:hover { color: var(--text); }

main { padding: 34px clamp(18px, 3.4vw, 48px) 80px; max-width: 1280px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; flex-wrap: wrap; margin-bottom: 26px; }
.page-head .sub { color: var(--muted); margin-top: 10px; max-width: 62ch; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: transparent; color: var(--text); cursor: pointer; text-decoration: none;
  font: 500 12.5px var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; line-height: 1.2;
}
.btn:hover { background: var(--panel-2); color: var(--text); }
.btn-primary { background: var(--mint); border-color: var(--mint); color: var(--night); }
.btn-primary:hover { background: #c2fbb2; color: var(--night); }
.btn-danger { border-color: var(--bad); color: #ff8a8a; }
.btn-danger:hover { background: rgba(255, 50, 50, 0.12); color: #ffb0b0; }
.btn-small { padding: 6px 10px; font-size: 11.5px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }

/* ---------- surfaces ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 22px; }
.panel + .panel, .section + .section { margin-top: 18px; }
.section { margin-top: 34px; }
.section > header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.section > header .hint { color: var(--muted); font-size: 13px; }
.cols { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.cols-2-1 { display: grid; gap: 18px; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
@media (max-width: 960px) { .cols-2-1 { grid-template-columns: 1fr; } }

.notice { border-radius: 10px; padding: 12px 16px; margin: 0 0 18px; border: 1px solid var(--line-strong); background: var(--panel); }
.notice p { margin: 4px 0 0; color: var(--muted); }
.notice-ok { border-color: var(--ok); }
.notice-error { border-color: var(--bad); }
.notice-warn { border-color: var(--warn); }
.notice-info { border-color: var(--blue); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { font: 500 11.5px var(--font-mono); letter-spacing: 0.06em; color: var(--muted); white-space: nowrap; background: var(--panel); position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(169, 248, 148, 0.04); }
td.num, th.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
td .sub { display: block; color: var(--muted); font-size: 13px; }
.empty { padding: 34px 22px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--text); margin-bottom: 4px; }

/* ---------- chips ---------- */
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font: 500 11.5px var(--font-mono); letter-spacing: 0.04em; border: 1px solid var(--line-strong); color: var(--text); white-space: nowrap; }
.chip-ok { border-color: var(--ok); color: var(--ok); }
.chip-warn { border-color: var(--warn); color: var(--warn); }
.chip-bad { border-color: var(--bad); color: #ff8a8a; }
.chip-info { background: var(--info); border-color: var(--info); color: #fff; }
.chip-neutral { color: var(--muted); }
.chip-mint { background: var(--mint); border-color: var(--mint); color: var(--night); }

/* ---------- forms ---------- */
label { display: block; font-weight: 600; margin-bottom: 6px; }
.field { margin-bottom: 18px; }
.field .help { color: var(--muted); font-size: 13px; margin-top: 6px; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=number], input[type=datetime-local], input[type=url], select, textarea {
  width: 100%; padding: 10px 12px; background: var(--night); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: 8px; font: inherit;
}
textarea { min-height: 120px; resize: vertical; font-family: var(--font-mono); font-size: 13px; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
input:focus, select:focus, textarea:focus { border-color: var(--mint); outline: none; box-shadow: 0 0 0 3px rgba(169, 248, 148, 0.18); }
input[type=checkbox], input[type=radio] { accent-color: var(--mint); width: 16px; height: 16px; margin: 0 8px 0 0; vertical-align: -3px; }
.check { display: flex; align-items: flex-start; gap: 0; font-weight: 400; margin-bottom: 8px; }
.check input { margin-top: 4px; flex: none; }
.row { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.inline-form { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.filters input[type=search] { max-width: 280px; }
.filters select { width: auto; min-width: 150px; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px 6px; margin: 0 0 18px; }
legend { padding: 0 8px; font: 500 11.5px var(--font-mono); letter-spacing: 0.06em; color: var(--muted); }

/* ---------- pager ---------- */
.pager { display: flex; gap: 14px; align-items: center; justify-content: center; margin-top: 16px; }
.pg { padding: 6px 12px; border: 1px solid var(--line-strong); border-radius: 8px; text-decoration: none; font: 500 12px var(--font-mono); text-transform: uppercase; letter-spacing: .05em; color: var(--text); }
.pg:hover { background: var(--panel-2); }
.pg-off { opacity: .35; border-style: dashed; }
.pg-info { color: var(--muted); font-size: 13px; }

/* ---------- funnel (the one memorable thing) ---------- */
.funnel { display: grid; gap: 10px; }
.funnel-row { display: grid; grid-template-columns: 130px minmax(0, 1fr) 150px; gap: 16px; align-items: center; }
.funnel-row .lbl { font-weight: 600; }
.funnel-row .lbl small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.funnel-bar { height: 34px; background: var(--panel-2); border-radius: 6px; position: relative; overflow: hidden; }
.funnel-bar i { position: absolute; inset: 0 auto 0 0; border-radius: 6px; min-width: 2px; }
.funnel-row .val { text-align: right; font-family: var(--font-mono); }
.funnel-row .val b { font-size: 20px; font-weight: 500; }
.funnel-row .val span { color: var(--muted); margin-left: 8px; font-size: 13px; }
.f-sent { background: var(--moss); } .f-delivered { background: #A9C79D; } .f-open { background: var(--mint); } .f-click { background: var(--blue); } .f-bad { background: var(--orange); }
@media (max-width: 700px) { .funnel-row { grid-template-columns: 1fr; gap: 4px; } .funnel-row .val { text-align: left; } }

.side-stats { display: grid; gap: 0; }
.side-stats div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.side-stats div:last-child { border-bottom: 0; }
.side-stats dt { color: var(--muted); }
.side-stats dd { margin: 0; font-family: var(--font-mono); text-align: right; }

/* ---------- checks ---------- */
.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.checks li { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 10px; align-items: start; }
.checks .ico { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font: 700 12px var(--font-mono); margin-top: 2px; }
.ico-block { background: var(--bad); color: #fff; }
.ico-warn { background: var(--warn); color: var(--night); }
.ico-pass { background: transparent; border: 1px solid var(--ok); color: var(--ok); }
.checks .t { font-weight: 600; }
.checks .d { color: var(--muted); font-size: 13.5px; word-break: break-word; }
.checks .tag { margin-left: 6px; }
.passed { margin-top: 14px; color: var(--muted); font-size: 13px; }
.passed summary { cursor: pointer; }
.passed ul { margin: 8px 0 0; padding-left: 20px; }

/* ---------- chart ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-axis { fill: var(--muted); font: 11px var(--font-mono); }
.bar-open { fill: var(--mint); } .bar-click { fill: var(--blue); }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

/* ---------- timeline ---------- */
.tl { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 1px solid var(--line-strong); display: grid; gap: 14px; }
.tl li { position: relative; }
.tl li::before { content: ""; position: absolute; left: -23px; top: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--night); border: 2px solid var(--moss); }
.tl li.t-open::before { border-color: var(--mint); background: var(--mint); }
.tl li.t-click::before { border-color: var(--blue); background: var(--blue); }
.tl li.t-bad::before { border-color: var(--orange); background: var(--orange); }
.tl .when { font: 400 12px var(--font-mono); color: var(--muted); }

/* ---------- misc ---------- */
code, .code { font-family: var(--font-mono); font-size: 13px; background: var(--night); border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; word-break: break-all; }
.copybox { display: flex; gap: 8px; align-items: stretch; }
.copybox code { flex: 1; padding: 10px 12px; }
.kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 8px 16px; margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 8px; background: var(--muted); }
.dot-ok { background: var(--ok); } .dot-warn { background: var(--warn); } .dot-bad { background: var(--bad); }
.tick { color: var(--mint); font-family: var(--font-mono); }
.dash { color: var(--muted); }
.progress { height: 6px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--mint); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login .box { width: min(420px, 100%); }
.login h1 { margin: 6px 0 24px; }
.login .brand { padding: 0 0 8px; }

/* ---------- small screens ---------- */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px 14px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 0 12px 0 0; }
  .rail nav { flex-direction: row; flex-wrap: wrap; }
  .rail .group { display: none; }
  .rail .who { margin: 0 0 0 auto; padding: 0; border: 0; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; } .kv dd { margin-bottom: 8px; }
}
@media print { .rail, .actions, .btn { display: none !important; } body { background: #fff; color: #000; } }
