/* Remite · panel. Sencillo: fondo cálido, una tarjeta blanca por pantalla, pocos bordes. */
:root {
  --bg: #f4f1ec; --surface: #fff; --surface-2: #f2eee8; --line: #ebe6de; --border: #e0d9cf;
  --text: #1d1b18; --muted: #77706a; --faint: #a59d94;
  --ink: #1d1b18; --ink-text: #fff;
  --ok: #2f8a57; --ok-soft: #e5f3ea; --warn: #a86b00; --bad: #c2372b; --bad-soft: #fbe9e7;
  --seal: #b0392a; --seal-ink: #fbf3ea;
  --focus: rgba(176, 57, 42, .28);
  --radius: 18px; --shadow: 0 1px 2px rgba(40, 30, 20, .04), 0 8px 24px rgba(40, 30, 20, .05);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; --mono: ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131110; --surface: #201d19; --surface-2: #2c2823; --line: #2b2722; --border: #3a342d;
    --text: #efebe5; --muted: #a39b91; --faint: #7a7269;
    --ink: #efebe5; --ink-text: #1d1a17;
    --ok: #5cc48a; --ok-soft: #173023; --warn: #e0a84a; --bad: #f0796c; --bad-soft: #3a1c18;
    --seal: #e0644d; --seal-ink: #1a0f0d; --focus: rgba(224, 100, 77, .35);
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #131110; --surface: #201d19; --surface-2: #2c2823; --line: #2b2722; --border: #3a342d;
  --text: #efebe5; --muted: #a39b91; --faint: #7a7269;
  --ink: #efebe5; --ink-text: #1d1a17;
  --ok: #5cc48a; --ok-soft: #173023; --warn: #e0a84a; --bad: #f0796c; --bad-soft: #3a1c18;
  --seal: #e0644d; --seal-ink: #1a0f0d; --focus: rgba(224, 100, 77, .35);
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
h1 { font-size: 22px; line-height: 1.25; margin: 0; letter-spacing: -.015em; font-weight: 650; }
h2 { font-size: 15px; margin: 0 0 4px; font-weight: 600; }
p { margin: 0 0 12px; }
code, .mono { font-family: var(--mono); font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { display: block; flex: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Cabecera */
.topbar-inner { max-width: 760px; margin: 0 auto; padding: 18px 20px 0; display: flex; align-items: center; gap: 18px; }
.brand { font-weight: 650; font-size: 16px; color: var(--text); display: flex; align-items: center; gap: 9px; text-decoration: none; letter-spacing: -.01em; }
.brand-seal { display: block; flex: none; }
.seal-wax { fill: var(--seal); }
.seal-ink { fill: var(--seal-ink); }
.nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav a { color: var(--muted); padding: 6px 11px; border-radius: 999px; font-size: 14px; font-weight: 500; white-space: nowrap; text-decoration: none; }
.nav a:hover { color: var(--text); }
.nav a.active { color: var(--text); background: var(--surface); box-shadow: var(--shadow); }
.topbar-tools { display: flex; gap: 2px; }
.topbar form { margin: 0; }

/* Página: una columna estrecha y, normalmente, una sola tarjeta */
.page { max-width: 760px; margin: 0 auto; padding: 30px 20px 72px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 0 4px 16px; }
.page-head p { margin: 4px 0 0; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px 22px; }
.card + .card { margin-top: 14px; }
.card-pad { padding: 22px; }
.section { padding: 18px 0; }
.section + .section { border-top: 1px solid var(--line); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-head h2 { margin: 0; }
.below { margin: 14px 6px 0; }

/* Botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 16px; border-radius: 999px; border: 0;
  font: 500 14px var(--font); cursor: pointer; background: var(--ink); color: var(--ink-text); white-space: nowrap; text-decoration: none; }
.btn:hover { opacity: .88; }
.btn-ghost { background: var(--surface-2); color: var(--text); }
.btn-ghost:hover { opacity: 1; background: var(--line); }
.btn-danger { background: transparent; color: var(--bad); padding: 0 10px; }
.btn-danger:hover { background: var(--bad-soft); opacity: 1; }
.btn-sm { height: 32px; padding: 0 13px; font-size: 13px; }
.btn-block { width: 100%; }
.icon-btn { width: 34px; height: 34px; border-radius: 50%; border: 0; background: transparent; color: var(--muted); display: inline-grid; place-items: center; cursor: pointer; text-decoration: none; padding: 0; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.danger:hover { background: var(--bad-soft); color: var(--bad); }

/* Formularios */
label { display: block; font-weight: 500; font-size: 13px; margin-bottom: 6px; color: var(--muted); }
.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.hint { color: var(--muted); font-size: 13px; margin-top: 6px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], select, textarea {
  width: 100%; height: 42px; padding: 0 14px; border-radius: 12px; border: 1px solid transparent; background: var(--surface-2); color: var(--text); font: 15px var(--font); transition: border-color .15s, background .15s; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--border); background: var(--surface); box-shadow: 0 0 0 3px var(--focus); }
input:disabled { color: var(--muted); }
select { appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%2377706a' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m3 4.5 3 3 3-3'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; }
textarea { height: auto; min-height: 96px; padding: 11px 14px; resize: vertical; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; font-size: 14px; color: var(--text); margin-bottom: 10px; }
.check input { margin-top: 3px; accent-color: var(--ink); }
.error-text { color: var(--bad); font-size: 13px; margin-top: 6px; }
.note { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; margin-top: 10px; font-size: 13px; color: var(--text); }
.note p { margin: 0 0 8px; }
.note p:last-child { margin-bottom: 0; }
.note .note-warn { color: var(--warn); font-weight: 500; }
.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: 2fr 1fr 1fr; }
@media (max-width: 640px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { height: 30px; padding: 0 12px; border-radius: 999px; border: 0; background: var(--surface-2); color: var(--text); font: 500 13px var(--font); cursor: pointer; }
.chip:hover { background: var(--line); }
details > summary { cursor: pointer; list-style: none; color: var(--muted); font-size: 14px; display: flex; align-items: center; gap: 8px; }
details > summary::-webkit-details-marker { display: none; }
details > summary::after { content: ""; width: 7px; height: 7px; border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor; transform: rotate(-45deg); transition: transform .15s; margin-left: 2px; }
details[open] > summary::after { transform: rotate(45deg); }
details > summary + * { margin-top: 14px; }

/* Selector de acceso: grupo de botones redondos */
.access { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.segmented { display: inline-flex; gap: 2px; padding: 4px; border-radius: 999px; background: var(--surface-2); }
.seg { margin: 0; cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg-btn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); transition: background .15s, color .15s, box-shadow .15s; }
.seg:hover .seg-btn { color: var(--text); }
.seg input:checked + .seg-btn { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(40,30,20,.08), 0 2px 8px rgba(40,30,20,.08); }
:root[data-theme="dark"] .seg input:checked + .seg-btn { background: #4a443c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .seg input:checked + .seg-btn { background: #4a443c; } }
.seg input:focus-visible + .seg-btn { outline: 2px solid var(--focus); outline-offset: 1px; }
.seg input[value="send"]:checked + .seg-btn { color: var(--seal); }
.access-text { display: flex; flex-direction: column; min-width: 0; font-size: 14px; line-height: 1.4; }
.access-text strong { font-weight: 600; }
.access-compact { gap: 10px; }
.access-compact .segmented { padding: 3px; }
.access-compact .seg-btn { width: 32px; height: 32px; }
.access-compact .access-text { font-size: 13px; color: var(--muted); width: 74px; }
.access-compact .access-text strong { font-weight: 500; }
.access.is-saving { opacity: .6; pointer-events: none; }

/* Filas (buzones, cuentas, conexiones) */
.list { margin: 0; }
.item { display: flex; align-items: center; gap: 14px; padding: 14px 0; }
.item + .item { border-top: 1px solid var(--line); }
.item-main { flex: 1; min-width: 0; }
.item-title { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-sub { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-tools { display: flex; gap: 2px; align-items: center; }
.item.is-off .item-title { color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--faint); }
.dot-ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot-bad { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--surface-2); color: var(--muted); display: grid; place-items: center; font-weight: 600; font-size: 14px; flex: none; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--surface-2); color: var(--muted); margin-left: 6px; vertical-align: 1px; }
@media (max-width: 640px) {
  .item-mailbox { flex-wrap: wrap; }
  .item-mailbox .access { order: 3; width: 100%; padding-left: 23px; }
}

/* Avisos */
.flash { padding: 11px 16px; border-radius: 14px; margin: 0 0 14px; font-size: 14px; }
.flash-ok { background: var(--ok-soft); color: var(--ok); }
.flash-bad { background: var(--bad-soft); color: var(--bad); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 12px); opacity: 0; pointer-events: none; background: var(--ink); color: var(--ink-text);
  padding: 10px 18px; border-radius: 999px; font-size: 14px; transition: opacity .2s, transform .2s; max-width: calc(100% - 32px); z-index: 10; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--bad); color: #fff; }

/* Copiar un enlace */
.copy { display: flex; gap: 8px; align-items: center; }
.copy input { font-family: var(--mono); font-size: 13px; }

/* Estadísticas */
.figures { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 640px) { .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.figure-value { font-size: 26px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.figure-label { color: var(--muted); font-size: 13px; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 110px; }
.bar { flex: 1; background: var(--ink); border-radius: 3px 3px 1px 1px; min-height: 2px; opacity: .8; }
.bar:hover { opacity: 1; }
.bar.zero { background: var(--line); opacity: 1; }
.bars-axis { display: flex; justify-content: space-between; color: var(--faint); font-size: 12px; margin-top: 6px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
th:first-child, td:first-child { padding-left: 0; } th:last-child, td:last-child { padding-right: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

/* Editor de la firma: se ve como en el correo (fondo blanco, la letra de los borradores) y sin
   los estilos del panel. Los estilos en línea de la firma siguen mandando. */
.sig-editor { min-height: 96px; max-height: 420px; overflow: auto; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: #fff; color: #1f2328; font: 14px/1.5 -apple-system, Helvetica, Arial, sans-serif; text-align: left; }
.sig-editor * { all: revert; }
.sig-editor:focus { outline: none; box-shadow: 0 0 0 3px var(--focus); }
.sig-editor:empty::before { content: attr(data-placeholder); color: #8a929e; }

/* Entrada, registro, invitación, autorizar */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-brand { display: flex; justify-content: center; margin-bottom: 22px; }
.auth-card .card { padding: 26px 24px; }
.auth-card h1 { margin-bottom: 6px; }
.auth-card .muted + form, .auth-card p.muted { margin-bottom: 18px; }
.auth-foot { text-align: center; margin-top: 16px; font-size: 13px; color: var(--muted); }
.empty { text-align: center; padding: 34px 12px; }
.empty p { margin: 6px 0 16px; }
.steps { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13px; } .steps li { margin-bottom: 5px; }

/* Tema en la cabecera: sistema, claro u oscuro */
.topbar-tools { align-items: center; gap: 8px; }
.theme-switch { padding: 3px; }
.theme-switch .seg-btn { width: 28px; height: 28px; }
@media (max-width: 640px) { .theme-switch .seg-btn { width: 26px; height: 26px; } .topbar-inner { gap: 12px; } }

/* Navegación: arriba en escritorio; en móvil, barra fija abajo con icono y nombre */
.nav-icon { display: none; }
@media (max-width: 640px) {
  .topbar-inner { padding-top: 14px; }
  .topbar-tools { margin-left: auto; }
  .nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; gap: 0; justify-content: space-around; overflow: visible;
    background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 5px 2px; border-radius: 12px; font-size: 11px; color: var(--faint); }
  .nav a.active { background: transparent; box-shadow: none; color: var(--text); }
  .nav a.active .nav-icon { color: var(--seal); }
  .nav-icon { display: block; }
  .page { padding-top: 22px; padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(80px + env(safe-area-inset-bottom)); }
}
