:root {
  --bg: #f6f6fb;
  --surface: #ffffff;
  --surface-2: #f0f0f7;
  --line: #dcdce8;
  --text: #15151f;
  --muted: #5c5e6e;
  --accent: #4c3fe0;
  --accent-2: #6d5efc;
  --accent-soft: #ecebfe;
  --ok: #17784e;
  --ok-soft: #e1f3ea;
  --warn: #8f5a00;
  --warn-soft: #fbf0db;
  --bad: #b3261e;
  --bad-soft: #fbe7e6;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(21,21,40,.05), 0 6px 20px rgba(21,21,40,.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0d14;
    --surface: #15151f;
    --surface-2: #1d1d2a;
    --line: #2b2b3b;
    --text: #ececf3;
    --muted: #9c9db0;
    --accent: #a59cff;
    --accent-2: #8b80ff;
    --accent-soft: #221f45;
    --ok: #57c28d;
    --ok-soft: #13281e;
    --warn: #e0ab5a;
    --warn-soft: #2b2415;
    --bad: #f2837a;
    --bad-soft: #2e1a19;
    --shadow: 0 1px 2px rgba(0,0,0,.45);
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent); }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }
h1 { font-size: 1.5rem; margin: 0 0 .2rem; letter-spacing: -.02em; }
h2 { font-size: 1.1rem; margin: 0 0 .6rem; letter-spacing: -.01em; }
h3 { font-size: .95rem; margin: 0 0 .35rem; }
p { margin: 0 0 .7rem; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }

.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; background: var(--surface); padding: 8px; z-index: 10; }

.topbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 20px; background: var(--surface);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
}
.brand {
  font-weight: 720; font-size: 1.06rem; display: flex; align-items: center; gap: 9px;
  letter-spacing: -.025em; color: var(--text); text-decoration: none;
}
.mark { display: block; border-radius: 7px; }
#nav { display: flex; gap: 2px; flex-wrap: wrap; margin-right: auto; }
#nav a {
  padding: 6px 11px; border-radius: 7px; text-decoration: none;
  color: var(--muted); font-size: .9rem; font-weight: 500;
}
#nav a:hover { background: var(--surface-2); color: var(--text); }
#nav a.active { background: var(--accent-soft); color: var(--accent); }
.local-badge {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ok); background: var(--ok-soft); padding: 3px 8px; border-radius: 20px; font-weight: 600;
}

.lang { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.lang button {
  border: 0; border-radius: 0; background: transparent; padding: 4px 9px; min-height: 0;
  font-size: .76rem; font-weight: 600; letter-spacing: .04em; color: var(--muted); box-shadow: none;
}
.lang button + button { border-left: 1px solid var(--line); }
.lang button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }

main { max-width: 980px; margin: 0 auto; padding: 24px 20px 60px; }
.head { margin-bottom: 20px; }
.head p { color: var(--muted); max-width: 66ch; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.grid { display: grid; gap: 12px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }

.stat { text-align: left; }
.stat .n { font-size: 1.9rem; font-weight: 640; letter-spacing: -.03em; line-height: 1.1; }
.stat .l { color: var(--muted); font-size: .84rem; }
.stat.bad .n { color: var(--bad); }
.stat.warn .n { color: var(--warn); }
.stat.ok .n { color: var(--ok); }

button, .btn {
  font: inherit; font-size: .88rem; font-weight: 500; cursor: pointer;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 7px; padding: 7px 12px;
  text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
button:hover, .btn:hover { border-color: var(--accent); color: var(--accent); }
button.primary, .btn.primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
button.primary:hover, .btn.primary:hover { filter: brightness(1.08); color: #fff; }
button.danger { color: var(--bad); }
button.danger:hover { border-color: var(--bad); }
button:disabled { opacity: .5; cursor: not-allowed; }

input, select, textarea {
  font: inherit; width: 100%; padding: 8px 10px; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 7px;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
label { display: block; font-size: .82rem; font-weight: 550; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 12px; }

.pill {
  display: inline-block; font-size: .74rem; font-weight: 600; padding: 2px 8px;
  border-radius: 20px; background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.pill.todo { background: var(--surface-2); color: var(--muted); }
.pill.sent { background: var(--accent-soft); color: var(--accent); }
.pill.ack { background: var(--accent-soft); color: var(--accent); }
.pill.done { background: var(--ok-soft); color: var(--ok); }
.pill.overdue { background: var(--bad-soft); color: var(--bad); }
.pill.refused { background: var(--bad-soft); color: var(--bad); }
.pill.escalated { background: var(--warn-soft); color: var(--warn); }
.pill.low { background: var(--warn-soft); color: var(--warn); }

.item {
  display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.item:last-child { border-bottom: 0; padding-bottom: 0; }
.item .body { flex: 1; min-width: 220px; }
.item .name { font-weight: 600; }
.item .meta { color: var(--muted); font-size: .84rem; }
.item .actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.notice { border-left: 3px solid var(--accent); background: var(--accent-soft); padding: 10px 14px; border-radius: 0 var(--radius) var(--radius) 0; margin-bottom: 14px; }
.notice.warn { border-color: var(--warn); background: var(--warn-soft); }
.notice.bad { border-color: var(--bad); background: var(--bad-soft); }
.notice p:last-child { margin-bottom: 0; }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }

.letter {
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; white-space: pre-wrap; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .84rem; line-height: 1.6; max-height: 60vh; overflow: auto;
}
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 20px;
  font-size: .86rem; z-index: 20; box-shadow: var(--shadow);
}
.foot { max-width: 980px; margin: 0 auto; padding: 20px; border-top: 1px solid var(--line); font-size: .84rem; color: var(--muted); }
.foot a { color: var(--accent); }

/* Delete data: grouped by how the user relates to each company */
.rel-pick { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.rel-pick select { width: auto; padding: 3px 8px; font-size: .82rem; min-height: 0; }
.rel-group h2 { margin-bottom: 4px; }
.rel-none { border-left: 3px solid var(--bad); }
.rel-customer { border-left: 3px solid var(--ok); }

/* Delete data: what to send next, and the send queue */
.work-card hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.work-row { display: flex; gap: 16px; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; }
.work-row > div:first-child { flex: 1 1 340px; }
.work-row h2 { margin-bottom: 4px; }
.work-row p { margin: 0 0 8px; max-width: 60ch; }
.work-row .list { margin-top: 6px; }
.work-row .pick .btn, .work-row .pick button { margin-left: auto; }
.work-row .pick .btn + button { margin-left: 0; }
.count.bad { background: var(--bad-soft); color: var(--bad); }
.send-card { border-color: var(--accent); }
.send-card .meter { margin-top: 10px; background: var(--surface-2); }
.send-card .meter span { background: var(--accent); }
.print-letter .letter { max-height: none; }

@media (max-width: 560px) {
  .topbar { padding: 10px 14px; }
  main { padding: 18px 14px 48px; }
  .local-badge { display: none; }
  .lang { order: 1; margin-left: auto; }
  #nav { order: 2; width: 100%; }
}
@media print {
  .topbar, .foot, .no-print { display: none !important; }
  .letter { max-height: none; border: 0; padding: 0; font-family: Georgia, serif; font-size: 11pt; }
  .card { border: 0; box-shadow: none; padding: 0; }
  .print-letter { break-after: page; }
  .print-letter:last-child { break-after: auto; }
}

.drop {
  border: 2px dashed var(--line); border-radius: var(--radius);
  padding: 26px 16px; text-align: center; background: var(--bg);
  transition: border-color .15s, background .15s;
}
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop p { margin: 0 0 6px; }

/* ---- layout rhythm ------------------------------------------------- */
main { max-width: 820px; }
.head { margin-bottom: 26px; }
.head h1 { font-size: 1.65rem; font-weight: 640; }
.head p { color: var(--muted); max-width: 60ch; margin: 0; }
.card { padding: 20px; margin-bottom: 16px; }
.card h2 { font-size: 1rem; font-weight: 620; display: flex; align-items: center; gap: 8px; }

/* a count that reads as data, not decoration */
.count {
  font-size: .78rem; font-weight: 600; color: var(--muted);
  background: var(--surface-2); border-radius: 20px; padding: 1px 9px;
}

/* ---- stat bar ------------------------------------------------------ */
.statbar {
  display: flex; gap: 28px; flex-wrap: wrap;
  padding: 16px 20px; margin-bottom: 16px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.statbar div { display: flex; flex-direction: column; gap: 1px; }
.statbar b { font-size: 1.45rem; font-weight: 640; letter-spacing: -.02em; line-height: 1.15; }
.statbar span { font-size: .8rem; color: var(--muted); }
.statbar .bad b { color: var(--bad); }

/* ---- selectable rows ----------------------------------------------- */
.list { border-top: 1px solid var(--line); }
.pick {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 2px; border-bottom: 1px solid var(--line);
  cursor: pointer; margin: 0; font-size: .9rem; font-weight: 400; color: var(--text);
}
.pick:hover { background: var(--surface-2); }
.pick input { width: auto; flex: none; }
.pick-name { font-weight: 550; }
.pick-meta { color: var(--muted); font-size: .82rem; margin-left: auto; }

.link-btn {
  background: none; border: 0; padding: 0; color: var(--accent);
  font-size: .84rem; cursor: pointer; text-decoration: underline;
}
.link-btn:hover { filter: brightness(1.15); }

/* ---- nav ------------------------------------------------------------ */
#nav a { font-size: .875rem; }

@media (max-width: 620px) {
  .pick-meta { display: none; }
  .statbar { gap: 18px; padding: 14px 16px; }
}

.danger-card { border-color: var(--bad); box-shadow: 0 0 0 1px var(--bad-soft), var(--shadow); }
.danger-card h2 { color: var(--bad); }

.block-card { border-color: var(--accent); }
.block-facts { display: flex; gap: 18px; flex-wrap: wrap; margin: 14px 0 6px; color: var(--muted); }
.block-facts b { color: var(--text); font-size: 1.05rem; }
.block-card ol { padding-left: 20px; margin: 8px 0 12px; }
.block-card ol li { margin-bottom: 6px; }
.block-card code { background: var(--surface-2); padding: 1px 6px; border-radius: 4px; }
#block-panel .row { margin: 4px 0 12px; }

/* ===== Home ============================================================= */
.hero { text-align: center; max-width: 620px; margin: 28px auto 0; }
.hero h1 { font-size: 2.1rem; font-weight: 680; letter-spacing: -.03em; margin-bottom: 10px; }
.hero > p { color: var(--muted); font-size: 1.02rem; margin: 0 auto 26px; max-width: 54ch; }
.drop-hero {
  padding: 46px 20px; border-radius: 16px; background: var(--surface);
  border: 2px dashed color-mix(in srgb, var(--accent) 45%, var(--line));
}
.drop-hero:hover, .drop-hero.over { border-color: var(--accent); background: var(--accent-soft); }
.drop-icon {
  width: 52px; height: 52px; margin: 0 auto 12px; border-radius: 50%;
  display: grid; place-items: center; background: var(--accent-soft); color: var(--accent);
}
.drop-title { font-size: 1.08rem; font-weight: 620; margin-bottom: 4px !important; }
.howto { text-align: left; margin-top: 14px; }
.howto summary, .senders summary { cursor: pointer; color: var(--muted); font-size: .88rem; }
.howto ul { margin: 10px 0 0; }

.home-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; }
.home-head h1 { font-size: 1.65rem; font-weight: 660; letter-spacing: -.02em; margin: 0; }
.home-head p { margin: 2px 0 0; font-size: .9rem; }
.back { display: inline-block; font-size: .85rem; margin-bottom: 8px; text-decoration: none; }

.actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.action {
  display: flex; flex-direction: column; gap: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px 18px 16px; box-shadow: var(--shadow); min-height: 196px;
}
.action-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.action-icon {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.action-n { font-size: 2rem; font-weight: 700; letter-spacing: -.04em; line-height: 1; }
.action h3 { font-size: 1.02rem; font-weight: 640; margin: 0; }
.action p { color: var(--muted); font-size: .88rem; margin: 0; flex: 1; }
.action-foot { display: flex; align-items: center; gap: 14px; margin-top: 10px; }
.action-foot .more { font-size: .84rem; color: var(--muted); }
.action.tone-bad .action-icon { background: var(--bad-soft); color: var(--bad); }
.action.tone-bad .action-n { color: var(--bad); }
.action.is-done { box-shadow: none; background: var(--bg); }
.action.is-done .action-icon { background: var(--ok-soft); color: var(--ok); }
.action.is-done .action-n { color: var(--ok); font-size: 1.6rem; }
.done-label { font-size: .86rem; font-weight: 600; color: var(--ok); }

.drop-compact {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; text-align: left;
  border-radius: 12px; margin: 6px 0 14px; color: var(--muted); font-size: .9rem;
}
.drop-compact svg { display: block; }
.senders { margin-top: 4px; }
.senders .list { margin-top: 10px; }
.panel { animation: rise .2s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* address health */
.addr { padding: 14px 0; border-top: 1px solid var(--line); }
.addr:first-of-type { border-top: 0; }
.addr-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.addr-head .mono { font-weight: 600; }
.addr p { font-size: .9rem; margin: 10px 0 6px; }
.addr ol { padding-left: 20px; margin: 4px 0 0; }
.addr ol li { margin-bottom: 5px; }
.meter { height: 6px; border-radius: 6px; background: var(--ok-soft); overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--bad); border-radius: 6px; }
.addr-ok .meter span { background: var(--warn); }

/* settings tools */
.tool-links { display: grid; gap: 8px; }
.tool-links a {
  display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--line); text-decoration: none; color: var(--text);
}
.tool-links a:hover { border-color: var(--accent); }
.tool-links span { font-size: .84rem; color: var(--muted); }

@media (max-width: 640px) {
  .actions { grid-template-columns: 1fr; }
  .action { min-height: 0; }
  .hero h1 { font-size: 1.7rem; }
}

/* ---- brand polish ------------------------------------------------------ */

.topbar { backdrop-filter: saturate(1.4) blur(10px); background: color-mix(in srgb, var(--surface) 88%, transparent); }
button.primary, .btn.primary {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  border-color: var(--accent); font-weight: 600;
  box-shadow: 0 1px 2px rgba(40,30,160,.25), inset 0 1px 0 rgba(255,255,255,.14);
}
@media (prefers-color-scheme: dark) {
  button.primary, .btn.primary { color: #0d0d14; }
  button.primary:hover, .btn.primary:hover { color: #0d0d14; }
}
button, .btn { border-radius: 9px; transition: border-color .12s, color .12s, filter .12s; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
#nav a.active { font-weight: 600; }

.hero { margin-top: 40px; }
.hero-mark { display: block; margin: 0 auto 18px; border-radius: 14px; box-shadow: 0 8px 28px rgba(76,63,224,.28); }
.hero h1 { font-size: 2.4rem; font-weight: 760; letter-spacing: -.035em; }
.trust {
  list-style: none; padding: 0; margin: 14px 0 0; display: flex; justify-content: center;
  flex-wrap: wrap; gap: 6px 18px; font-size: .84rem; color: var(--muted);
}
.trust li::before { content: "✓"; color: var(--ok); font-weight: 700; margin-right: 6px; }
.action-icon { background: var(--accent-soft); color: var(--accent); }
.foot p { margin-bottom: .45rem; }
@media (max-width: 560px) {
  .hero { margin-top: 18px; }
  .hero h1 { font-size: 1.85rem; }
}
.tpl-select { width: auto; max-width: 100%; }
.legal-title { font-size: 1.25rem; margin: 30px 0 4px; }
.legal ul { padding-left: 20px; margin: 0; }
.legal li { margin-bottom: 6px; }
.legal p:last-child { margin-bottom: 0; }
.hero-eyebrow { margin: -4px auto 14px !important; font-size: .9rem; color: var(--muted); }
.steps {
  list-style: none; counter-reset: step; padding: 0; margin: 0 auto 22px; max-width: 560px;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}
.steps li {
  counter-increment: step; display: flex; flex-direction: column; gap: 2px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 8px;
  font-size: .86rem; color: var(--muted);
}
.steps li::before {
  content: counter(step); width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: .78rem; margin-bottom: 4px;
}
.steps b { color: var(--text); font-size: .95rem; }
@media (max-width: 560px) { .steps { grid-template-columns: 1fr; } .steps li { flex-direction: row; gap: 6px; justify-content: flex-start; } .steps li::before { margin: 0 4px 0 0; } }
.aka { display: block; font-weight: 400; font-size: .8rem; color: var(--muted); }
.block-done { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.block-done .small { flex: 1 1 220px; }
