/* personnn-mail — tres paneles sobre una tarjeta de papel. Blanco y negro como
   el logo; el único color son las etiquetas (verde humano, ámbar agente) y los
   estados. La CSP del panel no permite style= en línea: todo vive en clases. */

@font-face {
  font-family: "Geist";
  src: url("/geist.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  /* perla: nada es blanco puro; cuatro matices del mismo tono cálido */
  --desk: #e4dfd6;        /* escritorio, detrás de la tarjeta */
  --card: #f5f2ec;        /* la tarjeta */
  --col: #ece7df;         /* columna de la lista, rellenos */
  --col-hover: #e6e0d6;
  --col-on: #ddd6cb;
  --white: #faf8f4;       /* superficies elevadas: perla más clara */
  --ink: #161513;
  --ink-2: #34312c;
  --muted: #77716a;
  --faint: #a69f95;
  --line: #e2dcd2;
  --line-2: #d3cbbf;
  --accent: #161513;      /* botones y foco: tinta, como el logo */
  --on-accent: #faf8f4;
  --soft: #e9e3da;        /* rellenos suaves (chips, contadores) */
  --green: #2fb985;
  --amber: #eba23a;
  --red: #d8463c;
  --red-soft: #fbeae8;
  --ok: #18825a;
  --ok-soft: #e2f4ec;
  --warn: #9a6512;
  --warn-soft: #fbefdb;
  --shadow: 0 1px 2px rgba(60, 50, 35, .05), 0 18px 50px rgba(60, 50, 35, .10);
  --sans: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-family: var(--sans);
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
}

@media (prefers-color-scheme: dark) {
  body:not([data-theme="light"]) {
    color-scheme: dark;
    --desk: #0c0c0d;
    --card: #151516;
    --col: #1b1b1d;
    --col-hover: #222224;
    --col-on: #2a2a2d;
    --white: #1f1f21;
    --ink: #f3f2f0;
    --ink-2: #d5d3cf;
    --muted: #93908b;
    --faint: #67645f;
    --line: #2a2a2c;
    --line-2: #37373a;
    --accent: #f3f2f0;
    --on-accent: #111111;
    --soft: #262628;
    --red-soft: #3a1d1b;
    --ok: #5fd3a4;
    --ok-soft: #15302a;
    --warn: #f1bd6b;
    --warn-soft: #3a2c14;
    --shadow: 0 18px 50px rgba(0, 0, 0, .5);
  }
}
body[data-theme="dark"] {
  color-scheme: dark;
  --desk: #0c0c0d;
  --card: #151516;
  --col: #1b1b1d;
  --col-hover: #222224;
  --col-on: #2a2a2d;
  --white: #1f1f21;
  --ink: #f3f2f0;
  --ink-2: #d5d3cf;
  --muted: #93908b;
  --faint: #67645f;
  --line: #2a2a2c;
  --line-2: #37373a;
  --accent: #f3f2f0;
  --on-accent: #111111;
  --soft: #262628;
  --red-soft: #3a1d1b;
  --ok: #5fd3a4;
  --ok-soft: #15302a;
  --warn: #f1bd6b;
  --warn-soft: #3a2c14;
  --shadow: 0 18px 50px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--desk); color: var(--ink); font-size: 14px; line-height: 1.5; letter-spacing: -.005em; }
a { color: inherit; }
::selection { background: var(--col-on); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
code { padding: 1px 6px; border-radius: 5px; background: var(--soft); font: 12px/1.6 var(--mono); overflow-wrap: anywhere; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.eyebrow { margin: 0 0 6px; color: var(--muted); font-size: 11.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }

/* ---------- botones ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 38px; padding: 8px 16px;
  border: 1px solid var(--line-2); border-radius: 10px;
  background: var(--white); color: var(--ink);
  font: inherit; font-weight: 550; text-decoration: none; cursor: pointer;
  transition: background-color .15s, border-color .15s, transform .1s, opacity .15s;
}
.btn:hover { border-color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn.sm { min-height: 32px; padding: 5px 12px; font-size: 13px; }
.btn.primary { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.btn.primary:hover { opacity: .86; }
button.link { padding: 0; border: 0; background: none; color: var(--ink); font: inherit; font-weight: 550; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.icon-btn {
  display: grid; place-items: center; width: 36px; height: 36px;
  border: 0; border-radius: 10px; background: none; color: var(--ink-2); cursor: pointer; text-decoration: none;
}
.icon-btn:hover, .icon-btn.on { background: var(--col); color: var(--ink); }

/* control segmentado (tema, idioma) */
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--col); }
.seg a { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 34px; height: 30px; padding: 0 10px; border-radius: 8px; color: var(--muted); font-size: 13px; font-weight: 550; text-decoration: none; }
.seg a:hover { color: var(--ink); }
.seg a.on { background: var(--white); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.seg svg { width: 16px; height: 16px; }

/* ---------- marco: tarjeta sobre el escritorio ---------- */

.shell {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  grid-template-rows: 64px minmax(0, 1fr);
  width: min(1480px, calc(100% - 48px));
  height: calc(100vh - 48px);
  margin: 24px auto;
  padding: 0 22px 22px 0;
  border-radius: 26px;
  background: var(--card);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.topbar { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; padding: 0 0 0 26px; }
.brand { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; }
.brand img { display: block; width: auto; height: 21px; }
.brand span { padding: 2px 8px; border: 1.5px solid var(--ink); border-radius: 6px; color: var(--ink); font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; line-height: 1.2; }
@media (prefers-color-scheme: dark) { body:not([data-theme="light"]) .brand img { filter: invert(1); } }
body[data-theme="dark"] .brand img { filter: invert(1); }
.top-actions { display: flex; align-items: center; gap: 4px; }
.top-actions form { margin: 0; }

/* ---------- barra lateral ---------- */

.side { display: flex; flex-direction: column; gap: 22px; min-height: 0; padding: 4px 18px 18px 22px; overflow-y: auto; }
.new-msg { width: 100%; min-height: 46px; border-radius: 12px; }
.new-msg svg { width: 17px; height: 17px; }
nav { display: flex; flex-direction: column; gap: 4px; }
.nav-link, .sub-link {
  display: flex; align-items: center; gap: 11px; min-width: 0;
  padding: 9px 10px; border-radius: 10px;
  color: var(--ink-2); font-weight: 500; text-decoration: none;
}
.nav-link:hover, .sub-link:hover { background: var(--col); }
.nav-link.on { color: var(--ink); font-weight: 650; }
.label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count {
  min-width: 22px; padding: 1px 7px; border-radius: 99px;
  background: var(--accent); color: var(--on-accent);
  font-size: 11px; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums;
}
.count.soft { background: none; color: var(--muted); padding: 0; min-width: 0; }
.sub { display: flex; flex-direction: column; gap: 2px; margin: 2px 0 0 19px; padding-left: 12px; border-left: 1.5px solid var(--line-2); }
.sub-link { padding: 8px 10px; font-size: 13.5px; }
.sub-link.on { background: var(--col-on); color: var(--ink); font-weight: 600; }
.tag { display: inline-block; width: 13px; height: 9px; flex: 0 0 auto; border-radius: 2px 5px 5px 2px; background: var(--faint); }
.tag.human { background: var(--green); }
.tag.agent { background: var(--amber); }
.tag.none { background: var(--red); }
.legend { display: flex; gap: 16px; padding: 0 10px; color: var(--muted); font-size: 12px; }
.legend span { display: flex; align-items: center; gap: 7px; }
.side-foot { margin-top: auto; padding: 0 2px; }

/* ---------- área principal ---------- */

.main { display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); gap: 22px; min-height: 0; position: relative; }
.pane { min-height: 0; overflow-y: auto; }
.pane.page { grid-column: 1 / -1; padding: 8px 26px 40px; background: var(--white); border-radius: 18px; }

/* lista de hilos */
.list { padding: 0 10px 12px; border-radius: 18px; background: var(--col); }
.list-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 20px 10px 12px; background: var(--col); }
.list-head h1 { margin: 0; font-size: 19px; font-weight: 650; letter-spacing: -.025em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-count { color: var(--muted); font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.threads { margin: 0; padding: 0; list-style: none; }
.thread {
  position: relative; display: flex; gap: 12px; padding: 13px 12px; border-radius: 13px;
  text-decoration: none; transition: background-color .12s;
}
.thread:hover { background: var(--col-hover); }
.thread.on { background: var(--white); box-shadow: 0 1px 3px rgba(0, 0, 0, .06); }
.t-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.t-top { display: flex; align-items: center; gap: 6px; min-width: 0; }
.who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; color: var(--ink-2); }
.t-top time { color: var(--faint); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.t-n { padding: 0 6px; border-radius: 6px; background: var(--soft); color: var(--muted); font-size: 11px; font-weight: 700; }
.subj { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; color: var(--ink-2); margin-top: 1px; }
.snip { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--muted); font-size: 13px; margin-top: 2px; }
.thread.unread .who, .thread.unread .subj { color: var(--ink); font-weight: 700; }
.thread.unread .t-top time { color: var(--ink); font-weight: 600; }
.thread.unread .who::before { content: ""; display: inline-block; width: 7px; height: 7px; margin: 0 7px 1px 0; border-radius: 50%; background: var(--ink); vertical-align: middle; }
.t-mb { margin-top: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--faint); font: 11px/1.3 var(--mono); }
.list-empty { padding: 30px 10px; color: var(--muted); text-align: center; }

/* avatares: 8 tonos apagados, estables por nombre */
.avatar {
  display: grid; place-items: center; width: 42px; height: 42px; flex: 0 0 auto;
  border-radius: 12px; font-weight: 650; font-size: 15px;
  background: var(--av-bg); color: var(--av-fg);
}
.avatar.sm { width: 38px; height: 38px; border-radius: 50%; font-size: 14px; }
.c0 { --av-bg: #e6e3f0; --av-fg: #4c4766; }
.c1 { --av-bg: #f3e1e1; --av-fg: #8a3f3f; }
.c2 { --av-bg: #ddeee6; --av-fg: #2f6b52; }
.c3 { --av-bg: #f3e9d9; --av-fg: #82602b; }
.c4 { --av-bg: #dfe8f2; --av-fg: #355a80; }
.c5 { --av-bg: #eee2ec; --av-fg: #7a4370; }
.c6 { --av-bg: #ddeeee; --av-fg: #2d6b6e; }
.c7 { --av-bg: #e8e6e2; --av-fg: #55524c; }
@media (prefers-color-scheme: dark) {
  body:not([data-theme="light"]) .c0 { --av-bg: #2a2834; --av-fg: #c3bddc; }
  body:not([data-theme="light"]) .c1 { --av-bg: #362425; --av-fg: #e6aeae; }
  body:not([data-theme="light"]) .c2 { --av-bg: #1d2f28; --av-fg: #9fd3bb; }
  body:not([data-theme="light"]) .c3 { --av-bg: #342b1d; --av-fg: #e2c08d; }
  body:not([data-theme="light"]) .c4 { --av-bg: #1f2a36; --av-fg: #a7c3e2; }
  body:not([data-theme="light"]) .c5 { --av-bg: #322331; --av-fg: #dcaed4; }
  body:not([data-theme="light"]) .c6 { --av-bg: #1c3031; --av-fg: #9dd2d4; }
  body:not([data-theme="light"]) .c7 { --av-bg: #2a2927; --av-fg: #c6c2bb; }
}
body[data-theme="dark"] .c0 { --av-bg: #2a2834; --av-fg: #c3bddc; }
body[data-theme="dark"] .c1 { --av-bg: #362425; --av-fg: #e6aeae; }
body[data-theme="dark"] .c2 { --av-bg: #1d2f28; --av-fg: #9fd3bb; }
body[data-theme="dark"] .c3 { --av-bg: #342b1d; --av-fg: #e2c08d; }
body[data-theme="dark"] .c4 { --av-bg: #1f2a36; --av-fg: #a7c3e2; }
body[data-theme="dark"] .c5 { --av-bg: #322331; --av-fg: #dcaed4; }
body[data-theme="dark"] .c6 { --av-bg: #1c3031; --av-fg: #9dd2d4; }
body[data-theme="dark"] .c7 { --av-bg: #2a2927; --av-fg: #c6c2bb; }

/* ---------- lectura ---------- */

.read { padding: 18px 4px 28px 0; }
.read > h1 { margin: 12px 0 14px; font-size: 26px; font-weight: 650; line-height: 1.2; letter-spacing: -.03em; overflow-wrap: anywhere; }
.read-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; }
.chip { padding: 4px 10px; border-radius: 7px; background: var(--col); color: var(--ink-2); font-size: 11.5px; font-weight: 600; font-family: var(--mono); letter-spacing: -.02em; }
.kind { display: inline-flex; align-items: center; gap: 7px; color: var(--ink-2); font-weight: 550; }
.meta-count { margin-left: auto; }
.back-mobile { display: none; }

.messages { display: flex; flex-direction: column; }
.msg { border-top: 1px solid var(--line); }
.msg:first-child { border-top: 0; }
.msg-head { display: flex; align-items: flex-start; gap: 12px; padding: 14px 0; cursor: pointer; list-style: none; }
.msg-head::-webkit-details-marker { display: none; }
.msg-who { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; font-size: 13.5px; }
.msg-from { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-from b { font-weight: 650; }
.msg-from .muted { font-size: 12.5px; }
.msg-to { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-snip { display: none; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg:not([open]) .msg-to { display: none; }
.msg:not([open]) .msg-snip { display: block; }
.msg-when { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; color: var(--faint); font-size: 12px; white-space: nowrap; }
.clip { display: inline-flex; align-items: center; gap: 3px; }
.clip svg { width: 13px; height: 13px; }
.status { padding: 1px 8px; border-radius: 99px; font-size: 11px; font-weight: 650; }
.status.sent { background: var(--ok-soft); color: var(--ok); }
.status.failed { background: var(--red-soft); color: var(--red); }
.status.sending, .status.rejected { background: var(--soft); color: var(--muted); }
.status.held { background: var(--warn-soft); color: var(--warn); }
.risk-box a { color: inherit; font-weight: 650; }
.msg-body { padding: 0 0 20px 50px; }
pre.body { margin: 0; color: var(--ink-2); font: 14.5px/1.7 var(--sans); white-space: pre-wrap; overflow-wrap: anywhere; }
.mail-frame { display: block; width: 100%; height: min(70vh, 760px); border: 1px solid var(--line); border-radius: 14px; background: #fff; resize: vertical; box-shadow: 0 1px 2px rgba(60, 50, 35, .05); }
.img-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-bottom: 10px; padding: 9px 12px; border-radius: 10px; background: var(--col); color: var(--muted); font-size: 12.5px; }
.img-bar svg { width: 16px; height: 16px; }
.img-bar span { flex: 1; min-width: 200px; }
.img-bar a { color: var(--ink); font-weight: 600; }
.plain { margin-top: 10px; }
.plain summary { color: var(--muted); font-size: 12.5px; cursor: pointer; }
.plain pre { margin-top: 10px; }
.atts { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0 0; padding: 0; list-style: none; }
.atts a { display: flex; align-items: center; gap: 11px; min-width: 220px; padding: 9px 12px 9px 9px; border: 1px solid var(--line); border-radius: 12px; background: var(--white); text-decoration: none; }
.atts a:hover { border-color: var(--line-2); background: var(--col); }
.att-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; background: var(--soft); color: var(--ink-2); }
.att-icon.img { background: var(--ok-soft); color: var(--ok); }
.att-text { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.3; }
.att-text b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 600; }
.att-text span { color: var(--faint); font-size: 11.5px; }
.att-dl { width: 16px; height: 16px; color: var(--faint); }
.inline-err { margin-bottom: 12px; padding: 9px 12px; border-radius: 10px; background: var(--red-soft); color: var(--red); font-size: 13px; }
.note { margin-top: 18px; padding: 14px 16px; border-radius: 12px; background: var(--col); color: var(--muted); }

/* responder / redactar */
.reply { margin-top: 10px; }
.reply-box, .compose-box { border: 1px solid var(--line); border-radius: 16px; background: var(--white); }
.reply-to { padding: 13px 18px 0; color: var(--ink-2); font-size: 12.5px; overflow-wrap: anywhere; }
textarea, input, select { font: inherit; color: var(--ink); }
.reply-box textarea, .compose-box textarea {
  display: block; width: 100%; min-height: 120px; padding: 12px 18px 16px;
  border: 0; border-radius: 0 0 16px 16px; background: none; resize: vertical; line-height: 1.6;
}
.reply-box textarea:focus, .compose-box textarea:focus, .line input:focus, .line select:focus { outline: none; }
.reply-box:focus-within, .compose-box:focus-within { border-color: var(--ink); }
.reply-bar { display: flex; align-items: center; gap: 14px; margin-top: 12px; }
.attach { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--muted); cursor: pointer; }
.attach:hover { color: var(--ink); }
.attach input { max-width: 220px; color: var(--muted); font-size: 12px; }
.attach input::file-selector-button { display: none; }
.check { display: flex; align-items: center; gap: 7px; color: var(--ink-2); font-size: 13px; }
.check input { accent-color: var(--ink); }
.send { margin-left: auto; min-height: 42px; padding: 0 20px; border-radius: 12px; }
.send svg { width: 16px; height: 16px; }

.page-head { padding: 18px 0 16px; }
.page-head h1 { margin: 0; font-size: 24px; font-weight: 650; letter-spacing: -.03em; }
.page-head p { margin: 4px 0 0; }
.compose { max-width: 820px; }
.line { display: flex; align-items: center; gap: 12px; padding: 0 18px; border-bottom: 1px solid var(--line); }
.line span { width: 56px; color: var(--muted); font-size: 13px; }
.line input, .line select { flex: 1; min-width: 0; padding: 13px 0; border: 0; background: none; }

/* placeholder / onboarding del panel de lectura */
.placeholder { display: grid; place-items: center; }
.placeholder-body { max-width: 340px; padding: 40px 20px; text-align: center; }
.placeholder-icon { display: inline-grid; place-items: center; width: 60px; height: 60px; border-radius: 18px; background: var(--col); color: var(--ink-2); }
.placeholder-icon svg { width: 26px; height: 26px; }
.placeholder h2, .onboard h2 { margin: 16px 0 6px; font-size: 18px; font-weight: 650; letter-spacing: -.02em; }
.placeholder p { margin: 0 0 18px; }
.placeholder-body { max-width: 380px; }
.ink { color: var(--ink); }
.mb-summary { margin: 0; padding: 0; list-style: none; border: 1px solid var(--line); border-radius: 14px; background: var(--white); text-align: left; overflow: hidden; }
.mb-summary li + li { border-top: 1px solid var(--line); }
.mb-summary a { display: flex; align-items: center; gap: 10px; padding: 11px 14px; text-decoration: none; font-size: 13px; }
.mb-summary a:hover { background: var(--col); }
.mb-summary span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 12px; }
.mb-summary b { font-variant-numeric: tabular-nums; }
.mb-summary em { color: var(--faint); font-style: normal; }
.onboard { width: min(480px, 100%); padding: 24px 8px; }
.onboard h2 { margin-top: 0; font-size: 22px; }
.onboard > p { margin: 0 0 18px; }

.steps { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; counter-reset: step; }
.steps li { counter-increment: step; }
.steps a { display: flex; align-items: flex-start; gap: 12px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--white); text-decoration: none; }
.steps a:hover { border-color: var(--line-2); }
.steps b { display: block; font-weight: 600; }
.steps small { display: block; color: var(--muted); font-size: 12.5px; }
.tick { display: grid; place-items: center; width: 24px; height: 24px; flex: 0 0 auto; margin-top: 1px; border: 1.5px solid var(--line-2); border-radius: 50%; color: var(--muted); font-size: 11.5px; font-weight: 700; }
.tick::before { content: counter(step); }
.steps li.done a { background: none; border-style: dashed; }
.steps li.done b { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--faint); }
.steps li.done .tick { border-color: var(--green); background: var(--green); color: #fff; }
.steps li.done .tick::before { content: "✓"; }

/* avisos */
.toast {
  position: absolute; top: 0; left: 50%; z-index: 5; transform: translateX(-50%);
  max-width: min(560px, 90%); padding: 9px 16px; border-radius: 10px; font-size: 13px; font-weight: 550;
  box-shadow: var(--shadow); animation: toast 5s ease forwards; pointer-events: none;
}
.toast.ok { background: var(--ink); color: var(--card); }
.toast.err { background: var(--red); color: #fff; animation: none; pointer-events: auto; }
@keyframes toast { 0%, 80% { opacity: 1; } 100% { opacity: 0; visibility: hidden; } }

/* ---------- ajustes ---------- */

.settings { padding-top: 0; }
.set-layout { display: grid; grid-template-columns: 180px minmax(0, 780px); gap: 36px; }
.set-nav { position: sticky; top: 0; display: flex; flex-direction: column; gap: 2px; align-self: start; padding-top: 86px; }
.set-nav a { display: flex; align-items: center; justify-content: space-between; padding: 7px 10px; border-radius: 8px; color: var(--muted); font-size: 13.5px; font-weight: 500; text-decoration: none; }
.set-nav a:hover { background: var(--col); color: var(--ink); }
.set-nav-n { color: var(--faint); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.set-main { min-width: 0; padding-bottom: 40px; }

.settings .card { margin: 0 0 18px; padding: 22px 24px; border: 1px solid var(--line); border-radius: 18px; background: var(--card); scroll-margin-top: 16px; }
.settings .card.secret { border-color: var(--ink); background: var(--white); }
.secret-title { margin: 0; }
.secret .muted { margin: 2px 0 10px; }
.token { display: block; padding: 12px 14px; border: 1px dashed var(--line-2); background: var(--white); font-size: 13px; user-select: all; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.card-head h2 { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: -.015em; }
.card-head p { margin: 3px 0 0; max-width: 560px; }
.card-head .push { margin: 0; flex: 0 0 auto; }

/* progreso del onboarding */
.onboarding { background: var(--white) !important; }
.progress-label { flex: 0 0 auto; padding: 3px 10px; border-radius: 99px; background: var(--col); color: var(--ink-2); font-size: 12px; font-weight: 650; font-variant-numeric: tabular-nums; }
.progress { height: 6px; margin: 0 0 16px; border-radius: 99px; background: var(--col); overflow: hidden; }
.progress span { display: block; height: 100%; border-radius: 99px; background: var(--green); transition: width .3s; }
.progress .p0 { width: 2%; } .progress .p1 { width: 16.6%; } .progress .p2 { width: 33.3%; }
.progress .p3 { width: 50%; } .progress .p4 { width: 66.6%; } .progress .p5 { width: 83.3%; } .progress .p6 { width: 100%; }
.settings .onboarding .steps { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ítems (una cuenta, un dominio, un buzón) */
.item { display: flex; flex-direction: column; gap: 14px; margin: 0 0 12px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--white); }
.item-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-height: 32px; }
.item-head b { font-weight: 650; }
.item-head .push { margin: 0 0 0 auto; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; background: var(--soft); color: var(--ink-2); font-size: 11.5px; font-weight: 600; }
.pill.ok, .pill.human { background: var(--ok-soft); color: var(--ok); }
.pill.warn, .pill.agent { background: var(--warn-soft); color: var(--warn); }
.callout { margin: 0 0 14px; padding: 11px 14px; border-radius: 12px; background: var(--col); color: var(--ink-2); }

/* campos: etiqueta arriba, mismo alto para todo */
.fld { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.fld-label { color: var(--ink-2); font-size: 12.5px; font-weight: 600; }
.fld-hint { color: var(--faint); font-size: 12px; }
.fld code.copy { display: block; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); font-size: 12.5px; user-select: all; }
.settings input, .settings select, .settings textarea, .field input {
  width: 100%; min-height: 40px; padding: 9px 12px;
  border: 1px solid var(--line-2); border-radius: 10px; background: var(--white);
  font-size: 14px; transition: border-color .15s, box-shadow .15s;
}
.settings textarea { min-height: 64px; resize: vertical; line-height: 1.5; }
.settings select { appearance: none; padding-right: 34px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 17px, calc(100% - 12px) 17px; background-size: 5px 5px; background-repeat: no-repeat; }
.settings input::placeholder, .settings textarea::placeholder { color: var(--faint); }
.settings input:focus, .settings select:focus, .settings textarea:focus, .field input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px var(--col); }
.settings .btn { min-height: 40px; }
.settings .btn.sm { min-height: 32px; }
.inline-form { display: flex; align-items: flex-start; gap: 10px; }
.inline-form .grow { flex: 1; }
.inline-form > .btn { margin-top: 25px; } /* alto de la etiqueta + espacio: queda alineado con el campo */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 12px; }
.form-grid .span2 { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }
.add-form { margin-top: 6px; padding: 16px 18px; border: 1px dashed var(--line-2); border-radius: 14px; }
.add-title { margin: 0; font-weight: 650; }

.howto { margin-top: 4px; padding: 14px 18px; border: 1px dashed var(--line-2); border-radius: 14px; }
.howto[open] { background: var(--white); border-style: solid; border-color: var(--line); }
.howto summary { font-weight: 600; cursor: pointer; }
.howto .form-grid { margin-top: 14px; }
.guide { margin: 14px 0 0; padding-left: 20px; color: var(--ink-2); }
.guide li { margin-bottom: 6px; }
.guide a { font-weight: 600; }
.check-box { padding: 14px 16px; border-radius: 12px; background: var(--col); }
.check-box p { margin: 0 0 8px; }
.check-box p:last-child { margin-bottom: 0; }
.table-wrap { overflow-x: auto; margin: 8px 0 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--white); }
.dns { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.dns th { padding: 8px 10px; color: var(--muted); font-weight: 600; text-align: left; border-bottom: 1px solid var(--line-2); }
.dns td { padding: 8px 10px; vertical-align: top; border-bottom: 1px solid var(--line); }
.dns tr:last-child td { border-bottom: 0; }
.dns code { background: var(--col); }
.pref { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); }
.pref:first-of-type { border-top: 0; padding-top: 0; }
.pref > span { font-weight: 550; }

@media (max-width: 1100px) {
  .set-layout { grid-template-columns: minmax(0, 1fr); }
  .set-nav { position: static; flex-direction: row; flex-wrap: wrap; padding-top: 0; order: -1; }
}
@media (max-width: 760px) {
  .form-grid, .settings .onboarding .steps { grid-template-columns: 1fr; }
  .inline-form { flex-direction: column; align-items: stretch; }
  .inline-form > .btn { margin-top: 0; }
  .card-head { flex-direction: column; }
}

/* copiar */
.copy-wrap { display: flex; align-items: stretch; gap: 8px; }
.copy-wrap code { flex: 1; min-width: 0; margin: 0; }
.copy-btn { flex: 0 0 auto; min-width: 92px; }
.copy-btn.done { border-color: var(--green); background: var(--ok-soft); color: var(--ok); }

/* ---------- actividad ---------- */

.activity { padding-bottom: 40px; }
.act-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; }
.act-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; margin-bottom: 20px; }
.act-card { display: flex; flex-direction: column; gap: 14px; padding: 18px 20px; border: 1px solid var(--line); border-radius: 18px; background: var(--card); }
.act-top { display: flex; align-items: center; gap: 12px; }
.act-id { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.3; }
.act-id b { font-weight: 650; }
.act-id span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font: 11.5px/1.4 var(--mono); }
.act-limit-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 7px; font-size: 13px; color: var(--ink-2); }
.act-limit-row b { font-size: 15px; font-variant-numeric: tabular-nums; }
.meter { height: 6px; border-radius: 99px; background: var(--col); overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: 99px; background: var(--ink); }
.meter span.hot { background: var(--red); }
.s0 { width: 0; } .s1 { width: 10%; } .s2 { width: 20%; } .s3 { width: 30%; } .s4 { width: 40%; } .s5 { width: 50%; }
.s6 { width: 60%; } .s7 { width: 70%; } .s8 { width: 80%; } .s9 { width: 90%; } .s10 { width: 100%; }
.act-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0; }
.act-stats div { padding: 10px 12px; border-radius: 12px; background: var(--white); }
.act-stats dt { color: var(--muted); font-size: 11.5px; }
.act-stats dd { margin: 0; font-size: 21px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.act-stats .bad dd { color: var(--red); }
.act-range { margin: -8px 0 0; color: var(--faint); font-size: 11.5px; }
.bars { display: grid; grid-template-columns: repeat(14, 1fr); align-items: end; gap: 4px; height: 92px; padding-top: 4px; }
.bar { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.pair { display: flex; align-items: flex-end; justify-content: center; gap: 2px; width: 100%; height: 72px; border-bottom: 1px solid var(--line); }
.pair span { display: block; width: 45%; max-width: 8px; border-radius: 2px 2px 0 0; }
.bar .b-in { background: var(--line-2); }
.bar .b-out { background: var(--ink); }
.bar .b-out.has-bad { background: var(--red); }
.bar i { color: var(--faint); font-size: 9.5px; font-style: normal; font-variant-numeric: tabular-nums; }
.h0 { height: 0; } .h1 { height: 10%; } .h2 { height: 20%; } .h3 { height: 30%; } .h4 { height: 40%; } .h5 { height: 50%; }
.h6 { height: 60%; } .h7 { height: 70%; } .h8 { height: 80%; } .h9 { height: 90%; } .h10 { height: 100%; }
.bars-legend { display: flex; flex-wrap: wrap; gap: 14px; color: var(--muted); font-size: 11.5px; }
.bars-legend span { display: flex; align-items: center; gap: 6px; }
.bars-legend .push { margin-left: auto; }
.lg-in, .lg-out { display: inline-block; width: 9px; height: 9px; border-radius: 2px; background: var(--line-2); }
.lg-out { background: var(--ink); }
.act-log { padding: 20px 22px; border: 1px solid var(--line); border-radius: 18px; background: var(--card); }
.act-log .card-head h2 { margin: 0; font-size: 17px; font-weight: 650; }
.act-log .card-head p { margin: 3px 0 0; }
.log { width: 100%; border-collapse: collapse; font-size: 13px; }
.log th { padding: 9px 10px; color: var(--muted); font-size: 12px; font-weight: 600; text-align: left; border-bottom: 1px solid var(--line-2); }
.log td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.log a { text-decoration: none; font-weight: 550; }
.log a:hover { text-decoration: underline; }
.log .mono { font: 11.5px var(--mono); color: var(--ink-2); white-space: nowrap; }
.log .mono .tag { margin-right: 7px; }
.log .dir { color: var(--muted); font-weight: 700; text-align: center; }
.log tr.out .dir { color: var(--ink); }
.log .nowrap { white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; }
.clip-cell { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill.bad { background: var(--red-soft); color: var(--red); }
.err-row td { padding-top: 0; color: var(--red); font: 11.5px var(--mono); border-bottom: 1px solid var(--line); }
.log tr.failed td { border-bottom: 0; }

/* capa de cuidado */
.mcp-box { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--white); }
.mcp-box p { margin: 0; }
.mcp-box code.copy { display: block; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); font-size: 12px; user-select: all; }
.risk-box { margin: 0 0 14px; padding: 12px 14px; border-radius: 12px; font-size: 13px; }
.risk-box.hostile { background: var(--red-soft); color: var(--red); }
.risk-box.suspicious { background: var(--warn-soft); color: var(--warn); }
.risk-box b { display: block; margin-bottom: 4px; }
.risk-box ul { margin: 0 0 6px; padding-left: 18px; }
.risk-box span { opacity: .85; font-size: 12px; }
.t-risk { font-size: 12px; line-height: 1; }
.t-risk.r2 { color: var(--red); }
.t-risk.r1 { color: var(--warn); }
.chain { flex: 0 0 auto; padding: 4px 11px; border-radius: 99px; font-size: 12px; font-weight: 650; }
.chain.ok { background: var(--ok-soft); color: var(--ok); }
.chain.bad { background: var(--red-soft); color: var(--red); }
.via { display: inline-block; padding: 1px 8px; border-radius: 6px; background: var(--soft); color: var(--ink-2); font: 600 11px var(--mono); text-transform: uppercase; }
.via.mcp { background: var(--ink); color: var(--card); }
.trace-hash { margin: 10px 0 0; overflow-wrap: anywhere; }
.trace-msg { color: inherit; }
.act-log + .act-log { margin-top: 18px; }

/* ---------- login ---------- */

body.login { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.login-card {
  display: flex; flex-direction: column; gap: 18px; width: min(400px, 100%);
  padding: 36px 34px 28px; border-radius: 24px; background: var(--card); box-shadow: var(--shadow);
}
.login-copy h1 { margin: 10px 0 4px; font-size: 26px; font-weight: 650; letter-spacing: -.03em; line-height: 1.15; }
.login-copy p { margin: 0; }
.field { display: flex; flex-direction: column; gap: 6px; color: var(--ink-2); font-size: 13px; font-weight: 600; }
.login-card .btn { min-height: 46px; }
.login-card .foot { margin: 0; font-size: 12px; text-align: center; }

/* ---------- responsive ---------- */

@media (max-width: 1100px) {
  .shell { grid-template-columns: 76px minmax(0, 1fr); }
  .side { padding: 4px 12px 18px; align-items: center; }
  .new-msg span, .side .label, .side .count, .legend, .sub { display: none; }
  .new-msg { width: 46px; padding: 0; }
  .nav-link { justify-content: center; }
  .theme-seg { flex-direction: column; }
}

@media (max-width: 760px) {
  body { font-size: 15px; }
  .shell { display: flex; flex-direction: column; width: 100%; height: auto; min-height: 100vh; margin: 0; padding: 0; border-radius: 0; box-shadow: none; overflow: visible; }
  .topbar { position: sticky; top: 0; z-index: 3; height: 56px; padding: 0 8px 0 16px; background: var(--card); border-bottom: 1px solid var(--line); }
  .side { flex-direction: row; align-items: center; gap: 8px; padding: 10px 16px; overflow-x: auto; }
  .side nav { flex-direction: row; }
  .side-foot { margin: 0 0 0 auto; }
  .theme-seg { flex-direction: row; }
  .new-msg { width: 44px; min-height: 40px; }
  .main { display: block; padding: 0 16px 24px; }
  .pane { overflow: visible; }
  .list { padding: 0 6px 8px; }
  .list.has-current { display: none; }
  .back-mobile { display: inline-flex; align-items: center; gap: 4px; color: var(--ink); font-weight: 600; text-decoration: none; margin-bottom: 8px; }
  .read { padding: 12px 0 24px; }
  .read > h1 { font-size: 22px; }
  .msg-body { padding-left: 0; }
  .pane.page { padding: 4px 14px 28px; }
  .placeholder { display: none; }
  .toast { position: fixed; top: 64px; }
}

/* ---------- por aprobar ---------- */
.count.warn { background: var(--amber); color: #2a1a00; }
.held-list { display: flex; flex-direction: column; gap: 16px; max-width: 820px; }
.held-card { display: flex; flex-direction: column; gap: 14px; padding: 18px 20px; border: 1px solid var(--line); border-left: 3px solid var(--amber); border-radius: 16px; background: var(--card); }
.held-head { display: flex; align-items: center; gap: 12px; }
.held-who { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.35; }
.held-who > span { color: var(--muted); font-size: 12px; }
.held-meta { display: grid; gap: 6px; margin: 0; padding: 12px 14px; border-radius: 12px; background: var(--white); font-size: 13px; }
.held-meta div { display: grid; grid-template-columns: 70px 1fr; gap: 10px; }
.held-meta dt { color: var(--muted); }
.held-meta dd { margin: 0; overflow-wrap: anywhere; }
.new-addr { display: inline-block; margin: 0 6px 2px 0; padding: 1px 8px; border-radius: 6px; background: var(--warn-soft); color: var(--warn); font: 600 12px var(--mono); }
.held-body { max-height: 260px; overflow: auto; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--white); font-size: 14px; }
.held-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.held-actions form { margin: 0; }
.held-actions .btn.sm { margin-right: auto; }
.approvals-empty { margin: 40px auto; }

.toggle { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); cursor: pointer; }
.toggle input { width: 18px !important; min-height: 18px !important; margin: 2px 0 0; accent-color: var(--ink); flex: 0 0 auto; }
.toggle b { display: block; font-size: 13.5px; font-weight: 600; }
.toggle small { display: block; color: var(--muted); font-size: 12px; }
.contacts { padding: 12px 14px; border: 1px dashed var(--line-2); border-radius: 12px; }
.contacts[open] { border-style: solid; border-color: var(--line); }
.contacts summary { font-weight: 600; font-size: 13.5px; cursor: pointer; }
.contacts > .fld-hint { margin: 8px 0 10px; }
.contact-list { display: flex; flex-direction: column; margin: 0 0 12px; padding: 0; list-style: none; border: 1px solid var(--line); border-radius: 10px; background: var(--white); }
.contact-list li { display: flex; align-items: center; gap: 10px; padding: 7px 12px; }
.contact-list li + li { border-top: 1px solid var(--line); }
.contact-list code { flex: 1; min-width: 0; background: none; padding: 0; }
.contact-list form { margin: 0; }

.account { margin: 0 0 10px; padding: 0 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font: 11.5px var(--mono); }
.login-card .foot a { color: var(--ink); font-weight: 600; }

/* Ajustes en pestañas: la sección activa marcada en el menú */
.set-nav a.on { background: var(--col); color: var(--ink); }
.settings .card[hidden] { display: none; }

/* Dirección del buzón: nombre @ dominio */
.addr-row { display: flex; align-items: center; gap: 8px; }
.addr-row input { flex: 1 1 40%; min-width: 0; }
.addr-row select { flex: 1 1 60%; min-width: 0; }
.addr-at { color: var(--muted); font-weight: 500; }

/* Token recién emitido para un buzón: comandos listos para copiar */
.connect.secret { margin: 12px 0 14px; padding: 16px 18px; border: 1px solid var(--ink); border-radius: 14px; background: var(--white); }
.connect .fld-label { display: block; margin: 14px 0 6px; }
.connect code.copy { display: block; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); font-size: 12px; line-height: 1.5; user-select: all; overflow-wrap: anywhere; white-space: pre-wrap; }
.connect > p.muted:last-child { margin-top: 12px; }
