:root {
  --paper: #f3f5f8;
  --rail: #1b2430;
  --rail-ink: #e8edf3;
  --surface: #ffffff;
  --ink: #1c2430;
  --muted: #5d6b7a;
  --line: #e3e8ee;
  --green: #5b2a6b;
  --green-ink: #ffffff;
  --danger: #9b3b42;
  --shadow: 0 8px 24px rgba(27, 36, 48, 0.06);
  font-family: "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
}

button, input, textarea {
  font: inherit;
  color: inherit;
}

button { cursor: pointer; }

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 32px;
  background: white;
  border-bottom: 1px solid var(--line);
}

.page-title {
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 18px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--green);
  color: white;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  flex: none;
}

.brand {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: white;
  padding: 0;
}

.brand-sub {
  color: #b7c3d1;
  font-size: 12px;
  padding: 0;
}

.nav-label {
  margin: 12px 12px 4px;
  color: #8ea0b3;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.account {
  color: var(--muted);
  font-size: 14px;
}

.shell {
  display: grid;
  grid-template-columns: 232px 1fr;
  min-height: 100vh;
}

.workspace { min-width: 0; }

.rail {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 22px 12px;
  background: var(--rail);
  color: var(--rail-ink);
}

.rail button {
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 8px;
  padding: 11px 12px;
  color: #d5dee8;
  font-weight: 600;
}

.rail button[aria-current="page"] {
  background: rgba(91, 42, 107, 0.55);
  color: white;
}

main {
  padding: 28px 32px 64px;
  max-width: 1180px;
}

h1 {
  font-weight: 700;
  font-size: 30px;
  letter-spacing: -0.03em;
  margin: 0 0 6px;
}

h2 {
  font-size: 15px;
  margin: 0 0 8px;
}

.lede, .muted { color: var(--muted); }

.lede { margin: 0 0 22px; max-width: 40rem; line-height: 1.5; }

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: end;
}

.stack { display: flex; flex-direction: column; gap: 6px; }

label { font-size: 13px; color: var(--muted); }

input, textarea, select {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  min-width: 0;
}

textarea { min-height: 240px; resize: vertical; line-height: 1.5; }

.grow { flex: 1; }

button.primary, button.ghost, button.danger {
  border-radius: 8px;
  padding: 10px 14px;
  border: 1px solid transparent;
}

button.primary { background: var(--green); color: var(--green-ink); font-weight: 600; }
button.ghost { background: white; border-color: var(--line); }
a.linkish {
  display: inline-flex;
  align-items: center;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  background: white;
}
button.danger { background: transparent; color: var(--danger); border-color: #e4c8c4; }
button:disabled { opacity: 0.55; cursor: default; }

.banner {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 16px;
}

.banner.error { border-color: #e4c8c4; color: var(--danger); }
.banner.ok { border-color: #c9dfd3; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th {
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

th, td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.actions { display: flex; gap: 8px; justify-content: flex-end; }

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
  gap: 22px;
  align-items: start;
}

.letter {
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px;
  min-height: 320px;
}

.letter .who { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.letter h2 { font-family: Georgia, serif; font-size: 22px; font-weight: 500; }
.writer {
  min-height: 280px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  line-height: 1.5;
  outline: none;
}

.writer table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.writer th { background: #5b2a6b; color: white; padding: 8px 10px; text-align: left; font-size: 14px; }
.writer td { border: 1px solid #e4dced; padding: 8px 10px; font-size: 14px; }
.writer img { max-width: 100%; height: auto; display: block; margin: 12px auto; }
.writer a { color: #1a4f8b; }

.preview-mail {
  background: #e7eef6;
  border-radius: 12px;
  overflow: auto;
}

.preview-mail img { max-width: 100%; height: auto; }

.list { display: flex; flex-direction: column; gap: 8px; }

.update {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
}

.update strong { display: block; margin-bottom: 4px; }
.update span { color: var(--muted); font-size: 13px; }
.update-main {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  padding: 0;
  text-align: left;
}
.update-actions { display: flex; align-items: center; gap: 8px; }

.perf-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.metric, .delivery-row {
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.metric span, .delivery-row span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin: 6px 0 4px;
  font-size: 32px;
  letter-spacing: -0.03em;
}

.metric em { color: var(--muted); font-style: normal; font-size: 13px; }

.delivery-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 16px;
}

.delivery-row strong { display: block; margin-top: 4px; font-size: 22px; }

.perf-split {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(260px, 0.8fr);
  gap: 16px;
  margin-bottom: 16px;
}

.perf-split h2 { margin: 0 0 12px; font-size: 16px; }

.click-badge {
  display: inline-block;
  margin-left: 6px;
  background: var(--green);
  color: white;
  border-radius: 999px;
  font-size: 11px;
  padding: 1px 7px;
  vertical-align: middle;
}

.day {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 10px;
  align-items: center;
  margin: 8px 0;
  font-size: 13px;
  color: var(--muted);
}

.bar-track {
  display: block;
  height: 8px;
  background: #eef1f4;
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  display: block;
  height: 8px;
  background: var(--green);
  border-radius: 999px;
}

.pill {
  align-self: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #52606d;
  background: #eef1f4;
  border-radius: 999px;
  padding: 4px 10px;
}

.pill.sending { background: #fff4e5; color: #9a6700; }
.pill.sent { background: #e7f6ee; color: #1b7a45; }
.pill.scheduled { background: #efe6f4; color: #5b2a6b; }
.pill.archived { background: #eef1f4; color: #52606d; }

.check-list { margin: 8px 0 12px; padding-left: 18px; color: var(--muted); }
.check-list li { margin: 4px 0; }
.pill.draft { background: #eef1f4; color: #52606d; }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.page-head .lede { margin: 0; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 180px));
  gap: 12px;
  margin-bottom: 18px;
}

.stat {
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.stat strong {
  display: block;
  margin-top: 4px;
  font-size: 28px;
  letter-spacing: -0.03em;
}

.import-card h2, .fold h2, #contact-form h2, .list-head h2 { font-size: 16px; }

.drop {
  margin-top: 8px;
  border: 1.5px dashed #c5b3cc;
  background: #fbf8fc;
  border-radius: 12px;
  padding: 28px 20px;
  text-align: center;
}

.drop.over { background: #f3eaf6; border-color: var(--green); }

.drop strong { display: block; font-size: 18px; margin-bottom: 6px; }
.drop p { margin: 0 auto 14px; max-width: 36rem; color: var(--muted); }

.columns { margin: 12px 0 0; }
.columns b { color: var(--ink); }

.fold { margin: 16px 0; }
.fold summary { cursor: pointer; font-weight: 700; }
.fold form { margin-top: 12px; }

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 0 0 16px;
}

.tab {
  border: 1px solid var(--line);
  background: white;
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  font: inherit;
  color: var(--ink);
}

.tab[aria-current="true"] {
  background: var(--green);
  color: white;
  border-color: var(--green);
}

#new-list { margin-left: auto; }

.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
}

.check {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.list-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 8px 0 10px;
}

.table-card { padding: 8px 16px 12px; overflow-x: auto; }
.table-card h2 { margin: 12px 0; }
.fine { color: var(--muted); font-size: 12px; margin-top: 3px; font-weight: 400; }

.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpi {
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
  border-top: 3px solid var(--green);
}

.kpi span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.kpi strong {
  display: block;
  margin: 8px 0 4px;
  font-size: 32px;
  letter-spacing: -0.03em;
}

.kpi em { color: var(--muted); font-style: normal; font-size: 13px; }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.template {
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.template h2 { font-size: 16px; }
.empty { color: var(--muted); padding: 18px 8px; }

body > main {
  max-width: 440px;
  margin: 10vh auto;
  padding: 8px;
}

dialog.thanks {
  border: 0;
  border-radius: 14px;
  padding: 28px 32px;
  max-width: 22rem;
  text-align: center;
  box-shadow: 0 18px 50px rgba(27, 36, 48, 0.18);
}

dialog.thanks h2 {
  margin: 0 0 8px;
  font-size: 1.25rem;
}

dialog.thanks p {
  margin: 0;
  color: var(--muted);
}

dialog.thanks::backdrop {
  background: rgba(27, 36, 48, 0.45);
}

.steps { margin: 0; padding-left: 18px; line-height: 1.55; }
.steps li { margin: 8px 0; }
code { font-family: Consolas, monospace; font-size: 0.92em; }

.search { width: min(280px, 100%); }

#qr svg { width: 196px; height: 196px; display: block; }
.secret, #backup-list { font-family: Consolas, monospace; letter-spacing: 0.04em; }
#backup-list { line-height: 1.8; padding-left: 1.2rem; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .rail { flex-direction: row; align-items: center; overflow: auto; padding: 12px; }
  .brand-lockup { padding: 0 8px; }
  .brand-sub, .nav-label { display: none; }
  .split, .stats, .perf-metrics, .perf-split, .delivery-row, .kpis { grid-template-columns: 1fr; }
  .page-head, .list-head { flex-direction: column; align-items: stretch; }
  main { padding: 20px 16px 48px; }
}
