:root {
  color-scheme: dark;
  --ink: #edf4ff;
  --muted: #8391a9;
  --dim: #54627a;
  --bg: #070d19;
  --surface: #0c1526;
  --surface-2: #111d31;
  --line: #21304a;
  --line-bright: #324766;
  --blue: #4f8cff;
  --cyan: #53d9ff;
  --green: #48d7a1;
  --amber: #f6bd60;
  --red: #ff6d7a;
  --radius: 16px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(55, 83, 125, .07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(55, 83, 125, .07) 1px, transparent 1px),
    radial-gradient(circle at 82% -10%, rgba(47, 111, 237, .16), transparent 36%),
    var(--bg);
  background-size: 40px 40px, 40px 40px, auto, auto;
}

button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.topbar {
  height: 72px;
  padding: 0 clamp(20px, 4vw, 64px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(7, 13, 25, .86);
  backdrop-filter: blur(16px);
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 13px;
  color: var(--ink);
  text-decoration: none;
  font-size: .82rem;
  font-weight: 760;
  letter-spacing: .13em;
}

.brand-mark { width: 29px; height: 29px; display: grid; gap: 3px; align-content: center; }
.brand-mark i { display: block; height: 3px; border-radius: 99px; background: var(--cyan); box-shadow: 0 0 16px rgba(83, 217, 255, .35); }
.brand-mark i:nth-child(1) { width: 17px; }
.brand-mark i:nth-child(2) { width: 27px; }
.brand-mark i:nth-child(3) { width: 22px; }

.top-actions { display: flex; align-items: center; gap: 20px; }
.secure-pill, .sender-chip, .pool-count {
  font-size: .72rem;
  letter-spacing: .08em;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
}
.secure-pill span { display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 9px var(--green); }
.text-button { border: 0; padding: 6px; color: var(--muted); background: transparent; cursor: pointer; }
.text-button:hover { color: var(--ink); }

.workspace { width: min(1240px, calc(100% - 40px)); margin: 0 auto; padding: 48px 0 56px; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 28px; margin-bottom: 28px; }
.eyebrow { margin: 0 0 10px; color: var(--cyan); font-size: .72rem; font-weight: 750; letter-spacing: .18em; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(1.85rem, 3vw, 2.65rem); line-height: 1.12; letter-spacing: -.035em; }
.page-heading p:last-child { margin-bottom: 0; color: var(--muted); }
.page-heading strong { color: #b9d1ff; font-weight: 650; }
.quota-card { min-width: 154px; padding: 16px 19px; border-left: 2px solid var(--blue); background: linear-gradient(90deg, rgba(79,140,255,.12), transparent); }
.quota-card span { display: block; color: var(--muted); font-size: .78rem; }
.quota-card strong { display: block; margin-top: 3px; font-size: 1.9rem; line-height: 1; }
.quota-card small { color: var(--dim); font-size: .8rem; }

.notice { display: flex; align-items: center; gap: 12px; margin: 0 0 20px; padding: 14px 16px; border: 1px solid; border-radius: 12px; font-size: .91rem; }
.notice-success { color: #baf4dc; border-color: rgba(72,215,161,.36); background: rgba(72,215,161,.08); }
.notice-error { color: #ffc5ca; border-color: rgba(255,109,122,.36); background: rgba(255,109,122,.08); }
.notice-icon { display: grid; place-items: center; width: 22px; height: 22px; border: 1px solid currentColor; border-radius: 50%; font-size: .75rem; font-weight: 800; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(330px, .78fr); gap: 18px; align-items: start; }
.status-column { display: grid; gap: 18px; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(145deg, rgba(17,29,49,.94), rgba(10,19,34,.95)); box-shadow: 0 24px 60px rgba(0,0,0,.19); overflow: hidden; }
.panel-heading { min-height: 77px; padding: 20px 24px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.panel-heading > div { display: flex; align-items: center; gap: 12px; }
.panel-heading h2 { margin: 0; font-size: 1rem; letter-spacing: -.01em; }
.panel-heading.compact { min-height: 65px; padding-block: 16px; }
.section-number { color: var(--dim); font: 700 .72rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.sender-chip { color: #9cbcff; border-color: rgba(79,140,255,.28); background: rgba(79,140,255,.07); }
.pool-count { color: var(--green); border-color: rgba(72,215,161,.24); }

.compose-form { padding: 24px; }
.field-grid { display: grid; grid-template-columns: 1fr 1.35fr; gap: 14px; }
.field-grid-three { grid-template-columns: .8fr 1.05fr 1.15fr; }
.field { margin-bottom: 19px; }
.is-hidden { display: none !important; }
.field label { display: block; margin-bottom: 8px; color: #b9c5d8; font-size: .84rem; font-weight: 650; }
.optional-label { margin-left: 6px; color: var(--dim); font-size: .7rem; font-weight: 600; }
.label-row { display: flex; align-items: center; justify-content: space-between; }
.label-row span { color: var(--dim); font-size: .72rem; }
input, textarea { width: 100%; color: var(--ink); border: 1px solid var(--line-bright); border-radius: 10px; outline: none; background: rgba(5,11,21,.72); transition: border-color .16s, box-shadow .16s, background .16s; }
input { height: 48px; padding: 0 14px; }
textarea { min-height: 178px; resize: vertical; padding: 13px 14px; line-height: 1.6; }
.code-editor { min-height: 240px; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: .84rem; tab-size: 2; }
.raw-eml-panel { padding: 15px; border: 1px solid rgba(72,215,161,.28); border-radius: 12px; background: rgba(72,215,161,.035); }
.raw-eml-editor { min-height: 360px; color: #cfe0f8; white-space: pre; overflow: auto; resize: vertical; }
.raw-eml-editor[readonly] { background: rgba(4,10,19,.88); cursor: text; }
.field-note { margin: 10px 0 0; color: var(--muted); font-size: .75rem; line-height: 1.55; }
.manual-only { transition: opacity .16s; }
.manual-only.is-disabled { opacity: .38; pointer-events: none; }
input::placeholder, textarea::placeholder { color: #4f5c70; }
input:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(79,140,255,.14); background: rgba(7,14,27,.94); }
.form-footer { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-top: 4px; }
.form-footer p { margin: 0; color: var(--dim); font-size: .78rem; }
button[type="submit"] { min-height: 45px; padding: 0 18px; border: 0; border-radius: 9px; color: white; font-weight: 720; background: linear-gradient(135deg, #3577f1, #2759c7); box-shadow: 0 9px 24px rgba(39,89,199,.24); cursor: pointer; }
button[type="submit"]:hover { filter: brightness(1.09); }
button[type="submit"]:focus-visible { outline: 3px solid rgba(83,217,255,.5); outline-offset: 2px; }
button[type="submit"] span { margin-left: 8px; }
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.file-drop { min-height: 76px; margin: 0 !important; padding: 13px 15px; border: 1px dashed var(--line-bright); border-radius: 11px; display: flex !important; align-items: center; gap: 12px; background: rgba(5,11,21,.42); cursor: pointer; }
.file-drop:hover, .file-input:focus-visible + .file-drop { border-color: var(--blue); background: rgba(79,140,255,.06); }
.file-icon { display: grid; place-items: center; width: 36px; height: 36px; flex: 0 0 auto; border: 1px solid rgba(83,217,255,.35); border-radius: 9px; color: var(--cyan); font-size: 1.25rem; }
.file-drop strong, .file-drop small { display: block; }
.file-drop strong { margin-bottom: 4px; color: var(--ink); font-size: .84rem; }
.file-drop small { color: var(--dim); font-size: .72rem; font-weight: 500; }
.eml-drop { background: linear-gradient(90deg, rgba(79,140,255,.08), rgba(5,11,21,.42)); }
.eml-drop.is-loading { border-color: var(--blue); }
.eml-drop.is-ready { border-color: rgba(72,215,161,.55); background: rgba(72,215,161,.06); }
.eml-drop.is-ready .file-icon { color: var(--green); border-color: rgba(72,215,161,.45); }
.eml-drop.is-error { border-color: rgba(255,109,122,.55); background: rgba(255,109,122,.06); }
.eml-drop.is-error .file-icon, .eml-drop.is-error small { color: #ff9aa4; }

.node-list { padding: 9px 15px 14px; }
.node-row { min-height: 62px; display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 9px 8px; border-bottom: 1px solid rgba(33,48,74,.7); }
.node-row:last-child { border-bottom: 0; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); box-shadow: 0 0 10px rgba(255,109,122,.32); }
.status-dot.online { background: var(--green); box-shadow: 0 0 10px rgba(72,215,161,.4); }
.node-row strong, .node-row span { display: block; }
.node-row strong { margin-bottom: 3px; font-size: .85rem; font-weight: 650; }
.node-row div span { color: var(--dim); font-size: .72rem; }
.node-row .latency { color: var(--muted); font: .72rem ui-monospace, SFMono-Regular, Menlo, monospace; }

.policy-list { margin: 0; padding: 9px 23px 18px; }
.policy-list > div { min-height: 47px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid rgba(33,48,74,.7); }
.policy-list > div:last-child { border-bottom: 0; }
.policy-list dt { color: var(--muted); font: 750 .75rem ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .06em; }
.policy-list dd { margin: 0; color: var(--muted); font-size: .73rem; }
.policy-ok, .policy-watch { display: inline-block; margin-right: 6px; font-size: .65rem; font-weight: 780; letter-spacing: .07em; }
.policy-ok { color: var(--green); }
.policy-watch { color: var(--amber); }

footer { min-height: 64px; padding: 0 clamp(20px, 4vw, 64px); border-top: 1px solid var(--line); color: var(--dim); display: flex; align-items: center; justify-content: space-between; font: .67rem ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .1em; }

.login-page { display: grid; place-items: center; padding: 28px; }
.login-shell { width: min(960px, 100%); min-height: 560px; display: grid; grid-template-columns: 1.18fr .82fr; border: 1px solid var(--line); border-radius: 20px; overflow: hidden; background: rgba(10,18,32,.94); box-shadow: 0 36px 90px rgba(0,0,0,.38); }
.brand-panel { position: relative; min-height: 560px; padding: 38px; display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; background: radial-gradient(circle at 20% 20%, rgba(79,140,255,.24), transparent 38%), linear-gradient(145deg, #101d33, #0a1322); }
.brand-panel::after { content: ""; position: absolute; inset: 0; opacity: .38; background-image: linear-gradient(rgba(83,217,255,.1) 1px, transparent 1px), linear-gradient(90deg, rgba(83,217,255,.1) 1px, transparent 1px); background-size: 42px 42px; mask-image: linear-gradient(to bottom right, black, transparent 65%); }
.brand-panel > * { position: relative; z-index: 1; }
.brand-copy { max-width: 420px; }
.brand-copy h1 { font-size: clamp(2rem, 4.5vw, 3.7rem); }
.brand-copy > p:last-child { max-width: 360px; color: var(--muted); line-height: 1.7; }
.relay-diagram { position: relative; width: 290px; height: 82px; }
.relay-diagram .node { position: absolute; width: 13px; height: 13px; border: 2px solid var(--cyan); border-radius: 50%; background: var(--surface); box-shadow: 0 0 16px rgba(83,217,255,.45); }
.relay-diagram .node-main { left: 0; top: 34px; width: 16px; height: 16px; background: var(--blue); }
.node-one { right: 0; top: 0; }.node-two { right: 0; top: 23px; }.node-three { right: 0; top: 46px; }.node-four { right: 0; top: 69px; }
.relay-diagram .line { position: absolute; left: 14px; width: 266px; height: 1px; transform-origin: left center; background: linear-gradient(90deg, var(--blue), rgba(83,217,255,.35)); }
.line-one { top: 41px; transform: rotate(-8deg); }.line-two { top: 41px; transform: rotate(-3deg); }.line-three { top: 41px; transform: rotate(3deg); }.line-four { top: 41px; transform: rotate(8deg); }
.login-card { padding: 55px 42px; display: flex; flex-direction: column; justify-content: center; }
.login-card h2 { margin-bottom: 8px; font-size: 1.75rem; }
.muted, .microcopy { color: var(--muted); }
.login-card form { margin-top: 30px; }
.login-card label { display: block; margin-bottom: 9px; color: #b9c5d8; font-size: .84rem; font-weight: 650; }
.login-card button { width: 100%; margin-top: 14px; }
.form-error { margin: 9px 0 0; color: #ff9aa4; font-size: .8rem; }
.microcopy { margin: 24px 0 0; text-align: center; font-size: .74rem; }

@media (max-width: 880px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .login-shell { grid-template-columns: 1fr; }
  .brand-panel { min-height: 300px; padding: 28px; }
  .brand-copy h1 { font-size: 2.3rem; }
  .relay-diagram { display: none; }
  .login-card { padding: 38px 28px; }
}

@media (max-width: 600px) {
  .topbar { height: 64px; padding-inline: 16px; }
  .brand-lockup { font-size: .7rem; }
  .secure-pill { display: none; }
  .workspace { width: min(100% - 24px, 1240px); padding-top: 30px; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .quota-card { width: 100%; }
  .panel-heading, .compose-form { padding-left: 17px; padding-right: 17px; }
  .panel-heading { align-items: flex-start; flex-direction: column; }
  .panel-heading.compact { align-items: center; flex-direction: row; }
  .form-footer { align-items: stretch; flex-direction: column; }
  .field-grid { grid-template-columns: 1fr; gap: 0; }
  .form-footer button { width: 100%; }
  footer { align-items: flex-start; flex-direction: column; justify-content: center; gap: 7px; }
  .login-page { padding: 12px; }
  .brand-panel { min-height: 260px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
