/* =========================================================================
   Webmail — hoja de estilo
   Oscuro por defecto, claro por preferencia del sistema o elección explícita.
   ========================================================================= */

/* ------------------------------------------------------------ variables */

:root {
  --bg:            #0b0d12;
  --bg-deep:       #070910;
  --surface:       #12151c;
  --surface-2:     #171b24;
  --surface-3:     #1d222d;
  --border:        rgba(255, 255, 255, .075);
  --border-strong: rgba(255, 255, 255, .14);
  --text:          #e6e9f0;
  --text-soft:     #b6bdcc;
  --muted:         #838c9f;
  --faint:         #5c6474;

  --accent:        #818cf8;
  --accent-2:      #38bdf8;
  --accent-soft:   rgba(129, 140, 248, .14);
  --accent-ring:   rgba(129, 140, 248, .45);
  --grad:          linear-gradient(135deg, #818cf8, #38bdf8);

  --danger:        #f87171;
  --danger-soft:   rgba(248, 113, 113, .13);
  --warn:          #fbbf24;
  --ok:            #34d399;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-2: 0 4px 16px rgba(0, 0, 0, .35);
  --shadow-3: 0 18px 50px -12px rgba(0, 0, 0, .65);

  --r-sm: 7px;
  --r:    11px;
  --r-lg: 16px;
  --r-xl: 22px;

  --sidebar-w: 254px;
  --list-w:    384px;
  --top-h:     56px;

  --ease: cubic-bezier(.34, .9, .28, 1);
  --fast: 130ms var(--ease);
  --slow: 280ms var(--ease);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto,
          "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  color-scheme: dark;
}

/* Tema claro: por elección explícita (data-theme="light") o por preferencia
   del sistema cuando el tema está en «auto». Se repiten los valores en los dos
   bloques a propósito: así el modo automático sigue a los ajustes del sistema
   sin que la elección explícita dependa de una consulta de medios. */
:root[data-theme="auto"] { color-scheme: light dark; }

:root[data-theme="light"] {
  --bg:            #f6f7f9;
  --bg-deep:       #eceef2;
  --surface:       #ffffff;
  --surface-2:     #f9fafb;
  --surface-3:     #f1f3f7;
  --border:        rgba(15, 23, 42, .085);
  --border-strong: rgba(15, 23, 42, .17);
  --text:          #161a21;
  --text-soft:     #39404d;
  --muted:         #626b7b;
  --faint:         #8a93a3;

  --accent:        #5b62e8;
  --accent-2:      #0ea5e9;
  --accent-soft:   rgba(91, 98, 232, .1);
  --accent-ring:   rgba(91, 98, 232, .4);
  --grad:          linear-gradient(135deg, #5b62e8, #0ea5e9);

  --danger:        #dc2626;
  --danger-soft:   rgba(220, 38, 38, .09);

  --shadow-1: 0 1px 2px rgba(15, 23, 42, .07);
  --shadow-2: 0 4px 16px rgba(15, 23, 42, .09);
  --shadow-3: 0 18px 50px -14px rgba(15, 23, 42, .22);

  color-scheme: light;
}

@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] {
    --bg:            #f6f7f9;
    --bg-deep:       #eceef2;
    --surface:       #ffffff;
    --surface-2:     #f9fafb;
    --surface-3:     #f1f3f7;
    --border:        rgba(15, 23, 42, .085);
    --border-strong: rgba(15, 23, 42, .17);
    --text:          #161a21;
    --text-soft:     #39404d;
    --muted:         #626b7b;
    --faint:         #8a93a3;
    --accent:        #5b62e8;
    --accent-2:      #0ea5e9;
    --accent-soft:   rgba(91, 98, 232, .1);
    --accent-ring:   rgba(91, 98, 232, .4);
    --grad:          linear-gradient(135deg, #5b62e8, #0ea5e9);
    --danger:        #dc2626;
    --danger-soft:   rgba(220, 38, 38, .09);
    --shadow-1: 0 1px 2px rgba(15, 23, 42, .07);
    --shadow-2: 0 4px 16px rgba(15, 23, 42, .09);
    --shadow-3: 0 18px 50px -14px rgba(15, 23, 42, .22);
    color-scheme: light;
  }
}

/* --------------------------------------------------------------- reajuste */

*, *::before, *::after { box-sizing: border-box; }

/* El `display: none` que aporta el atributo hidden viene de la hoja del
   navegador, así que cualquier `display: grid/flex` de aquí lo vencería y
   dejaría los paneles superpuestos invisibles pero interceptando los clics. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}

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

button { cursor: pointer; background: none; border: 0; padding: 0; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

svg {
  width: 20px; height: 20px;
  fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
  flex: none;
}

kbd {
  font: 600 11px/1 var(--mono);
  padding: 3px 5px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface-3);
  color: var(--muted);
}

:focus-visible {
  outline: 2px solid var(--accent-ring);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

::selection { background: var(--accent-soft); }

/* Barras de desplazamiento discretas */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border: 3px solid transparent;
  border-radius: 99px;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background-color: var(--faint); background-clip: content-box; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* =========================================================== componentes */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px;
  border-radius: var(--r);
  font-weight: 600; font-size: 14px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  transition: background var(--fast), border-color var(--fast), transform var(--fast), opacity var(--fast);
  white-space: nowrap;
}
.btn:hover { background: var(--border); }
.btn--sm { height: 30px; padding: 0 11px; font-size: 12.5px; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn svg { width: 17px; height: 17px; }

.btn--primary {
  background: var(--grad);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 12px -3px var(--accent-ring);
}
.btn--primary:hover { filter: brightness(1.08); background: var(--grad); }

.btn--ghost { background: transparent; }
.btn--ghost:hover { background: var(--surface-3); }

.btn--danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.btn--danger:hover { background: var(--danger); color: #fff; }

.btn--block { width: 100%; }

.iconbtn {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px;
  border-radius: var(--r-sm);
  color: var(--muted);
  transition: background var(--fast), color var(--fast);
}
.iconbtn:hover { background: var(--surface-3); color: var(--text); }
.iconbtn.is-on { background: var(--accent-soft); color: var(--accent); }
.iconbtn--tiny { width: 24px; height: 24px; }
.iconbtn--tiny svg { width: 15px; height: 15px; }

.linkbtn {
  color: var(--muted); font-size: 13px; font-weight: 500;
  padding: 3px 6px; border-radius: 6px;
  transition: color var(--fast), background var(--fast);
}
.linkbtn:hover { color: var(--accent); background: var(--accent-soft); }

.badge {
  margin-left: auto;
  min-width: 20px; padding: 1px 6px;
  border-radius: 99px;
  background: var(--accent-soft); color: var(--accent);
  font: 600 11px/17px var(--font); font-style: normal;
  font-variant-numeric: tabular-nums;
  text-align: center; white-space: nowrap; flex: none;
}
.badge:empty { display: none; }

.spinner {
  width: 15px; height: 15px;
  border: 2px solid rgba(255, 255, 255, .35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.checkbox { display: inline-grid; place-items: center; cursor: pointer; }
.checkbox input { position: absolute; opacity: 0; width: 0; height: 0; }
.checkbox__box {
  width: 17px; height: 17px;
  border: 1.8px solid var(--border-strong);
  border-radius: 5px;
  transition: background var(--fast), border-color var(--fast);
  position: relative;
}
.checkbox input:checked + .checkbox__box {
  background: var(--accent); border-color: var(--accent);
}
.checkbox input:checked + .checkbox__box::after {
  content: ''; position: absolute; inset: 0;
  background: no-repeat center/11px
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 12l5 5L20 6'/%3E%3C/svg%3E");
}
.checkbox input:focus-visible + .checkbox__box { outline: 2px solid var(--accent-ring); outline-offset: 2px; }

.field { margin-bottom: 14px; }
.field label {
  display: block; margin-bottom: 6px;
  font-size: 12.5px; font-weight: 600; color: var(--muted);
  letter-spacing: .01em;
}
.field__wrap { position: relative; }
.field__toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 6px; color: var(--faint);
}
.field__toggle:hover { color: var(--text); background: var(--surface-3); }
.field__hint { margin: 5px 0 0; font-size: 12px; color: var(--faint); }

input[type="text"], input[type="password"], input[type="email"],
input[type="search"], input[type="number"], select, textarea {
  width: 100%;
  height: 40px; padding: 0 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  transition: border-color var(--fast), background var(--fast), box-shadow var(--fast);
  -webkit-appearance: none; appearance: none;
}
textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 84px; line-height: 1.55; }

input:hover, select:hover, textarea:hover { border-color: var(--border-strong); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder, textarea::placeholder { color: var(--faint); }

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23838c9f' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 17px;
  padding-right: 34px;
}
/* El listado nativo no hereda el tema. En oscuro, fondo negro y texto blanco. */
select option,
select optgroup {
  background-color: #12151c;
  color: #e6e9f0;
}
:root[data-theme="light"] select option,
:root[data-theme="light"] select optgroup {
  background-color: #fff;
  color: #161a21;
}
@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] select option,
  :root[data-theme="auto"] select optgroup {
    background-color: #fff;
    color: #161a21;
  }
}

input[type="search"]::-webkit-search-cancel-button { display: none; }

/* El selector de color trae su propio marco del navegador: se normaliza para
   que no desentone con el resto de campos. */
input[type="color"] {
  width: 100%; height: 40px; padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  cursor: pointer;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 7px; }
input[type="color"]::-moz-color-swatch { border: 0; border-radius: 7px; }

/* ================================================================ acceso */

.login {
  min-height: 100dvh;
  display: grid; place-items: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
  background: var(--bg-deep);
}

.login__aura {
  position: absolute; inset: -30%;
  background:
    radial-gradient(38% 42% at 22% 18%, rgba(129, 140, 248, .3), transparent 70%),
    radial-gradient(32% 38% at 82% 78%, rgba(56, 189, 248, .24), transparent 70%),
    radial-gradient(28% 30% at 70% 12%, rgba(168, 85, 247, .16), transparent 70%);
  filter: blur(26px);
  animation: drift 22s ease-in-out infinite alternate;
  pointer-events: none;
}
@keyframes drift {
  from { transform: translate3d(-2%, -1%, 0) scale(1); }
  to   { transform: translate3d(3%, 2%, 0) scale(1.08); }
}

.login__card {
  position: relative;
  width: 100%; max-width: 396px;
  padding: 34px 30px 26px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-3);
  animation: rise var(--slow) both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(14px) scale(.985); }
  to   { opacity: 1; transform: none; }
}

.login__brand { text-align: center; margin-bottom: 26px; }
.login__logo { height: 52px; margin: 0 auto 14px; }
.brandlogo { height: 30px; width: auto; display: block; }
.brandlogo--light { display: none; }
:root[data-theme="light"] .brandlogo--dark { display: none; }
:root[data-theme="light"] .brandlogo--light { display: block; }
@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] .brandlogo--dark { display: none; }
  :root[data-theme="auto"] .brandlogo--light { display: block; }
}
.login__sub { margin: 0; color: var(--muted); font-size: 13.5px; }

.login__error {
  margin: 0 0 14px;
  padding: 9px 12px;
  background: var(--danger-soft);
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  border-radius: var(--r);
  color: var(--danger);
  font-size: 13px;
  animation: shake 340ms var(--ease);
}
@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  30%, 70% { transform: translateX(2px); }
  50%      { transform: translateX(-2px); }
}

.login__note {
  margin: 18px 0 0;
  font-size: 11.5px; line-height: 1.5;
  color: var(--faint); text-align: center;
}

.login__signup {
  margin: 14px 0 0;
  font-size: 12.5px; text-align: center;
  color: var(--muted);
}
.login__signup a { color: var(--accent); text-decoration: none; }
.login__signup a:hover { text-decoration: underline; }

.login__sub--ok { color: var(--accent); font-weight: 600; }

.field__optional { color: var(--faint); font-weight: 400; }

.hpot {
  position: absolute; left: -9999px; top: auto;
  width: 1px; height: 1px; overflow: hidden;
}

/* =========================================================== estructura */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) var(--list-w) minmax(0, 1fr);
  grid-template-rows: var(--top-h) minmax(0, 1fr);
  grid-template-areas:
    "top  top  top"
    "side list reader";
  height: 100dvh;
  overflow: hidden;
}

/* ---------------------------------------------------------- barra superior */

.topbar {
  grid-area: top;
  display: flex; align-items: center; gap: 12px;
  padding: 0 14px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  z-index: 40;
}

.topbar__menu { display: none; }

.topbar__brand {
  display: flex; align-items: center; gap: 9px;
  width: calc(var(--sidebar-w) - 28px);
  font-weight: 700; font-size: 15.5px; letter-spacing: -.01em;
}
.topbar__brand .brandlogo { height: 28px; }

.search {
  position: relative;
  flex: 1; max-width: 560px;
}
.search input {
  height: 36px;
  padding-left: 36px; padding-right: 64px;
  background: var(--surface-2);
  border-radius: 99px;
}
.search__icon {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--faint); pointer-events: none;
}
.search__kbd { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); }
.search:focus-within .search__kbd { display: none; }
.search__clear {
  position: absolute; right: 7px; top: 50%; transform: translateY(-50%);
  display: grid; place-items: center;
  width: 24px; height: 24px; border-radius: 50%;
  color: var(--faint);
}
.search__clear:hover { background: var(--surface-3); color: var(--text); }
.search__clear svg { width: 14px; height: 14px; }

.topbar__actions { display: flex; align-items: center; gap: 4px; margin-left: auto; }

.livedot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--faint);
  margin-right: 6px;
  transition: background var(--slow), box-shadow var(--slow);
}
.livedot.is-live { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }
.livedot.is-busy { background: var(--accent-2); animation: pulse 1.1s ease-in-out infinite; }
.livedot.is-error { background: var(--danger); }
@keyframes pulse { 50% { opacity: .35; } }

.topbar__alert {
  position: relative;
  color: var(--danger);
  animation: alertPop 220ms var(--ease) both;
}
.topbar__alert:hover { background: var(--danger-soft); color: var(--danger); }
.topbar__alert-badge {
  position: absolute; top: 2px; right: 2px;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 99px;
  background: var(--danger); color: #fff;
  font: 700 10px/16px var(--font); font-style: normal;
  text-align: center; white-space: nowrap;
  box-shadow: 0 0 0 2px var(--surface-2);
  margin-left: 0;
}
@keyframes alertPop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.ico-sun { display: none; }
:root[data-theme="light"] .ico-moon { display: none; }
:root[data-theme="light"] .ico-sun  { display: block; }
@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] .ico-moon { display: none; }
  :root[data-theme="auto"] .ico-sun  { display: block; }
}

.avatar {
  width: 31px; height: 31px; border-radius: 50%;
  background: var(--grad); color: #fff;
  font: 700 12px/1 var(--font);
  display: grid; place-items: center;
  margin-left: 4px;
  transition: transform var(--fast), box-shadow var(--fast);
}
.avatar:hover { transform: scale(1.06); box-shadow: 0 0 0 3px var(--accent-soft); }
.avatar.has-logo { background-size: cover; background-position: center; background-repeat: no-repeat; }

.profilelogo { display: flex; align-items: center; gap: 16px; }
.profilelogo .avatar { width: 64px; height: 64px; margin: 0; font-size: 20px; flex: none; box-shadow: 0 0 0 3px var(--surface), 0 0 0 4px var(--border); }
.profilelogo__txt { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; min-width: 0; flex: 1; }
.filepick { display: flex; align-items: center; gap: 8px; width: 100%; min-width: 0; }
.filepick .btn { flex: none; height: 40px; }
.filepick__name {
  flex: 1; min-width: 0; height: 40px;
  display: flex; align-items: center; padding: 0 14px;
  border-radius: var(--r);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--faint); font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.filepick__name.is-set { color: var(--text); border-color: var(--border-strong); }

/* ------------------------------------------------------------------ menús */

.menu { position: relative; }
.menu__panel {
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 226px; padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  z-index: 60;
  animation: pop 150ms var(--ease) both;
}
@keyframes pop {
  from { opacity: 0; transform: translateY(-5px) scale(.97); }
  to   { opacity: 1; transform: none; }
}
.menu__head { padding: 9px 11px 11px; border-bottom: 1px solid var(--border); margin-bottom: 5px; }
.menu__head strong { display: block; font-size: 14px; }
.menu__head span { font-size: 12px; color: var(--muted); }
.menu__item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 11px; border-radius: var(--r-sm);
  font-size: 13.5px; color: var(--text-soft); text-align: left;
  transition: background var(--fast), color var(--fast);
}
.menu__item:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.menu__item svg { width: 16px; height: 16px; color: var(--muted); }
/* Entradas del menú que solo aparecen cuando no caben como botón suelto. */
.menu__item--compact { display: none; }
.menu__item--danger { color: var(--danger); }
.menu__item--danger:hover { background: var(--danger-soft); color: var(--danger); }
.menu__item--danger svg { color: var(--danger); }
.menu__sep { height: 1px; background: var(--border); margin: 5px 0; }

/* ---------------------------------------------------------------- columna */

.sidebar {
  grid-area: side;
  display: flex; flex-direction: column;
  padding: 14px 10px;
  background: var(--bg);
  border-right: 1px solid var(--border);
  overflow: hidden;
  min-height: 0;
}

.sidebar__scroll {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.btn--compose { flex: none; margin-bottom: 10px; height: 41px; }
.btn--compose svg { width: 18px; height: 18px; }

.nav { display: flex; flex-direction: column; gap: 1px; }

.nav__title {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 11px 6px;
  font-size: 11px; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--faint);
}
.nav__title--accounts { margin-top: 14px; }

.foldsearch {
  position: relative;
  display: block;
  flex: none;
  margin: 0 2px 12px;
}
.foldsearch input {
  width: 100%;
  height: 32px;
  padding: 0 30px 0 30px;
  border-radius: 99px;
  background: var(--surface);
  font-size: 12.5px;
}
.foldsearch__icon {
  position: absolute; left: 9px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; color: var(--faint); pointer-events: none;
}
.foldsearch__clear {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  display: grid; place-items: center;
  width: 22px; height: 22px; border-radius: 50%; color: var(--faint);
}
.foldsearch__clear:hover { background: var(--surface-3); color: var(--text); }
.foldsearch__clear svg { width: 13px; height: 13px; }
.foldsearch__empty {
  margin: 8px 10px;
  font-size: 12.5px;
  color: var(--faint);
}

.nav__item {
  display: flex; align-items: center; gap: 11px;
  width: 100%; padding: 8px 11px;
  border-radius: var(--r);
  font-size: 13.5px; font-weight: 500; color: var(--text-soft);
  text-align: left;
  transition: background var(--fast), color var(--fast);
  position: relative;
}
.nav__item svg { width: 17px; height: 17px; color: var(--muted); transition: color var(--fast); }
.nav__item:hover { background: var(--surface-2); color: var(--text); }
.nav__item.is-active {
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
}
.nav__item.is-active svg { color: var(--accent); }
.nav__item.is-active::before {
  content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 17px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.nav__item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Cuentas y sus carpetas */
.accounts { display: flex; flex-direction: column; gap: 3px; }

.acct { border-radius: var(--r); }

.acct__head {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 8px 10px;
  border-radius: var(--r);
  font-size: 13px; font-weight: 600; color: var(--text-soft);
  text-align: left;
  transition: background var(--fast);
}
.acct__head:hover { background: var(--surface-2); }
.acct__dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.acct__name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct__chev { width: 14px; height: 14px; color: var(--faint); transition: transform var(--fast); }
.acct.is-open .acct__chev { transform: rotate(90deg); }
.acct__err { color: var(--danger); width: 14px; height: 14px; }

.acct__folders { display: none; flex-direction: column; gap: 1px; padding: 2px 0 6px; }
.acct.is-open .acct__folders { display: flex; }

.fld {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 6px 10px 6px 20px;
  border-radius: var(--r-sm);
  font-size: 12.8px; color: var(--muted);
  text-align: left;
  transition: background var(--fast), color var(--fast);
}
.fld:hover { background: var(--surface-2); color: var(--text); }
.fld.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.fld svg { width: 15px; height: 15px; }
.fld__name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fld__n { flex: none; font-size: 11px; font-weight: 600; color: var(--faint); font-variant-numeric: tabular-nums; }
.fldrow.is-active .fld__n { color: var(--accent); }

.fldrow {
  display: flex; align-items: center;
  border-radius: var(--r-sm);
  cursor: grab;
}
.fldrow:active { cursor: grabbing; }
.fldrow .fld { flex: 1; min-width: 0; width: auto; padding-left: 8px; }
.fldrow.is-active .fld { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.fldrow.is-drag { opacity: .4; }
.fldrow.is-over { box-shadow: inset 0 2px 0 var(--accent); }
.fldrow.is-drop { background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent); }
.fldrow.is-dropbad { background: var(--danger-soft, rgba(180, 40, 40, .12)); box-shadow: inset 0 0 0 1.5px var(--danger, #c0392b); }
.fldrow__chev {
  flex: none; width: 16px; height: 22px; margin-left: 1px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 4px; color: var(--faint);
}
.fldrow__chev svg { width: 12px; height: 12px; transition: transform var(--fast); }
.fldrow.is-open > .fldrow__chev svg { transform: rotate(90deg); }
.fldrow__chev:hover { background: var(--surface-3); color: var(--text); }
.fldrow__chev.is-spacer { pointer-events: none; }

.fldrow__more {
  flex: none; width: 22px; height: 22px; margin-right: 4px;
  border-radius: var(--r-sm); color: var(--faint); opacity: .55;
}
.fldrow__more svg { width: 14px; height: 14px; }
.fldrow:hover .fldrow__more,
.fldrow:focus-within .fldrow__more,
.fldrow__more[aria-expanded="true"] { opacity: 1; }
.fldrow__more:hover { background: var(--surface-3); color: var(--text); }
.fld--add { color: var(--faint); }
.fld--add svg { width: 14px; height: 14px; }

.fldmenu {
  position: fixed; z-index: 80;
  min-width: 176px; padding: 5px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
}
.fldmenu button {
  display: block; width: 100%;
  padding: 8px 10px; border-radius: var(--r-sm);
  font-size: 13px; color: var(--text-soft); text-align: left;
}
.fldmenu button:hover { background: var(--surface-3); color: var(--text); }
.fldmenu button.is-danger { color: var(--danger); }
.fldmenu button.is-danger:hover { background: var(--danger-soft); color: var(--danger); }

.sidebar__foot { margin-top: auto; padding-top: 14px; text-align: center; }

/* ------------------------------------------------------- lista de mensajes */

.list {
  grid-area: list;
  display: flex; flex-direction: column;
  min-width: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.list__head {
  display: flex; align-items: center; gap: 11px;
  height: 49px; padding: 0 14px;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.list__title {
  margin: 0; font-size: 14.5px; font-weight: 700; letter-spacing: -.005em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.list__tools { margin-left: auto; display: flex; gap: 2px; }
.list__tools .iconbtn { width: 30px; height: 30px; }
.list__tools svg { width: 17px; height: 17px; }

.bulk {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 14px;
  background: var(--accent-soft);
  border-bottom: 1px solid var(--border);
  animation: slideDown 150ms var(--ease) both;
}
@keyframes slideDown { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.bulk__count { font-size: 12.5px; font-weight: 700; color: var(--accent); }
.bulk__count::after { content: ' seleccionados'; font-weight: 500; }
.bulk__actions { display: flex; gap: 1px; margin-left: 4px; }
.bulk__actions .iconbtn { width: 30px; height: 30px; color: var(--accent); }
.bulk__actions .iconbtn:hover { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.bulk__actions svg { width: 16px; height: 16px; }
.bulk .linkbtn { margin-left: auto; }

.list__body { flex: 1; overflow-y: auto; overscroll-behavior: contain; outline: none; }
.list__foot { padding: 10px 14px 16px; flex: none; }

/* Una fila de la lista */
.msg {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  position: relative;
  transition: background var(--fast);
  animation: fadeIn 200ms var(--ease) both;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.msg:hover { background: var(--surface-2); }
.msg.is-drag { opacity: .45; }
.msg.is-selected { background: var(--accent-soft); }
.msg.is-open { background: var(--surface-3); }
.msg.is-open::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: var(--accent);
}
.msg.is-unread .msg__from { font-weight: 700; color: var(--text); }
.msg.is-unread .msg__subject { font-weight: 600; color: var(--text); }
.msg.is-unread .msg__date { color: var(--accent); font-weight: 600; }

.msg__gutter { display: flex; flex-direction: column; align-items: center; gap: 7px; padding-top: 2px; }

.msg__unread {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.msg:not(.is-unread) .msg__unread { background: transparent; box-shadow: none; }

.msg__body { min-width: 0; }

.msg__top { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.msg__from {
  font-size: 13.5px; font-weight: 500; color: var(--text-soft);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  flex: 1; min-width: 0;
}
.msg__date { font-size: 11.5px; color: var(--faint); flex: none; font-variant-numeric: tabular-nums; }
.msg__del {
  flex: none; width: 26px; height: 26px; border-radius: var(--r-sm);
  color: var(--faint); display: grid; place-items: center;
}
.msg__del svg { width: 15px; height: 15px; }
.msg__del:hover { background: var(--danger-soft, rgba(180, 40, 40, .12)); color: var(--danger, #c0392b); }

.msg__subject {
  font-size: 13.5px; color: var(--text-soft);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  margin-bottom: 2px;
}
.msg__preview {
  font-size: 12.5px; color: var(--faint); line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  line-clamp: 2;
  overflow: hidden;
}
body[data-density="compact"] .msg__preview { -webkit-line-clamp: 1; line-clamp: 1; }
body[data-density="compact"] .msg { padding: 7px 14px; }
body[data-density="roomy"] .msg { padding: 14px; }

.msg__meta { display: flex; align-items: center; gap: 6px; margin-top: 5px; }
.msg__tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 7px; border-radius: 99px;
  font-size: 10.5px; font-weight: 600;
  background: var(--surface-3); color: var(--muted);
}
.msg__tag i { width: 6px; height: 6px; border-radius: 50%; }
.msg__icon { width: 14px; height: 14px; color: var(--faint); }
.msg__icon--flag { color: var(--warn); fill: var(--warn); }
.msg__icon--answered { color: var(--accent-2); }

/* Estados de la lista */
.empty {
  display: grid; place-items: center; gap: 12px;
  padding: 64px 28px; text-align: center; color: var(--faint);
}
.empty svg { width: 44px; height: 44px; stroke-width: 1.3; opacity: .6; }
.empty p { margin: 0; font-size: 13.5px; }
.empty strong { color: var(--text-soft); font-size: 14.5px; }

.skeleton { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.sk {
  height: 10px; border-radius: 5px;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
  margin-bottom: 7px;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.sk--sm { width: 32%; }
.sk--md { width: 68%; }
.sk--lg { width: 88%; }

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

.reader {
  grid-area: reader;
  display: flex; flex-direction: column;
  min-width: 0;
  background: var(--bg);
  overflow: hidden;
}

.reader__empty {
  flex: 1;
  display: grid; place-content: center; justify-items: center; gap: 10px;
  color: var(--faint); text-align: center; padding: 30px;
}
.reader__empty svg { width: 54px; height: 54px; stroke-width: 1.2; opacity: .45; }
.reader__empty p { margin: 0; font-size: 14px; }
.reader__hint { font-size: 12px; opacity: .8; }
.reader__hint kbd { margin: 0 2px; }

.reader__content { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.rhead {
  padding: 18px 26px 14px;
  border-bottom: 1px solid var(--border);
  flex: none;
}

.rhead__top { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; }

.reader__back { display: none; flex: none; }

.rhead__subject {
  margin: 0; flex: 1;
  font-size: 19px; font-weight: 700; line-height: 1.32;
  letter-spacing: -.012em;
  word-break: break-word;
}

.rhead__acts { display: flex; gap: 2px; flex: none; }

.rhead__who { display: flex; align-items: center; gap: 12px; }

.rhead__avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  font: 700 15px/1 var(--font); color: #fff;
  flex: none;
}

.rhead__info { min-width: 0; flex: 1; }
.rhead__name { font-size: 14.5px; font-weight: 600; }
.rhead__addr { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rhead__book { border: 0; background: none; padding: 0; color: var(--accent); font-size: 12px; font-weight: 600; cursor: pointer; }
.rhead__book:hover { text-decoration: underline; }
.rhead__to {
  font-size: 12.5px; color: var(--faint); margin-top: 3px;
  display: flex; align-items: center; gap: 5px; flex-wrap: wrap;
}
.rhead__to button { color: var(--accent); font-size: 12px; }
.rhead__date { font-size: 12.5px; color: var(--muted); text-align: right; flex: none; }

.notice {
  display: flex; align-items: center; gap: 10px;
  margin: 12px 26px 0; padding: 9px 13px;
  background: color-mix(in srgb, var(--warn) 11%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn) 28%, transparent);
  border-radius: var(--r);
  font-size: 12.5px; color: var(--text-soft);
}
.notice svg { width: 16px; height: 16px; color: var(--warn); }
.notice button {
  margin-left: auto; padding: 4px 10px;
  background: var(--warn); color: #201803;
  border-radius: 7px; font-size: 12px; font-weight: 700;
  white-space: nowrap;
}

.rbody { flex: 1; overflow: hidden; display: flex; padding: 0 26px; }

/* Con la altura ya ajustada al contenido, el desplazamiento lo lleva el panel,
   no el marco: así un correo corto no deja un hueco enorme. */
.rbody.is-fitted { overflow-y: auto; display: block; padding-top: 16px; padding-bottom: 20px; }
.rbody.is-fitted iframe { flex: none; display: block; }

.rbody iframe {
  flex: 1; width: 100%; border: 0;
  background: transparent;
  color-scheme: normal;
}

/* El HTML del remitente se presenta sobre una hoja clara: sus colores están
   pensados para fondo blanco y forzarlos a oscuro deja texto ilegible. */
.rbody iframe.is-paper {
  background: #fff;
  border-radius: var(--r);
  box-shadow: var(--shadow-1);
}
:root[data-theme="light"] .rbody iframe.is-paper {
  box-shadow: none;
  border: 1px solid var(--border);
}
@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] .rbody iframe.is-paper {
    box-shadow: none;
    border: 1px solid var(--border);
  }
}

.rattach {
  flex: none;
  padding: 13px 26px 18px;
  border-top: 1px solid var(--border);
}
.rattach__title {
  font-size: 11.5px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--faint);
  margin-bottom: 9px;
}
.rattach__grid { display: flex; flex-wrap: wrap; gap: 8px; }

.att {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 12px 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-size: 12.5px;
  transition: border-color var(--fast), background var(--fast), transform var(--fast);
  max-width: 270px;
}
.att:hover {
  border-color: var(--accent); background: var(--surface-3);
  text-decoration: none; transform: translateY(-1px);
}
.att__ico {
  width: 30px; height: 30px; border-radius: 7px;
  display: grid; place-items: center; flex: none;
  background: var(--accent-soft); color: var(--accent);
}
.att__ico svg { width: 15px; height: 15px; }
.att__txt { min-width: 0; }
.att__name {
  font-weight: 500; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.att__size { font-size: 11px; color: var(--faint); }

/* ============================================================== redacción */

.composer {
  position: fixed; inset: 0;
  display: grid; place-items: end center;
  z-index: 90;
  pointer-events: none;
  padding: 0 20px 20px;
}

.composer__box {
  pointer-events: auto;
  width: min(760px, 100%);
  max-height: min(84dvh, 760px);
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: var(--shadow-3);
  animation: slideUp 220ms var(--ease) both;
  overflow: hidden;
}
@keyframes slideUp { from { opacity: 0; transform: translateY(26px); } to { opacity: 1; transform: none; } }

.composer.is-max { place-items: center; padding: 22px; }
.composer.is-max .composer__box {
  width: min(1040px, 100%); height: min(92dvh, 940px); max-height: none;
  border-radius: var(--r-lg);
}
.composer.is-min .composer__box { max-height: none; height: auto; }
.composer.is-min .composer__body,
.composer.is-min .composer__foot { display: none; }

.composer__head {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  flex: none;
}
.composer__head h3 { margin: 0; font-size: 13.5px; font-weight: 700; }
.composer__headActions { margin-left: auto; display: flex; gap: 1px; }
.composer__headActions .iconbtn { width: 28px; height: 28px; }
.composer__headActions svg { width: 15px; height: 15px; }

.composer__body { flex: 1; overflow-y: auto; padding: 4px 0 0; display: flex; flex-direction: column; }

.crow {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 16px;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.crow > label {
  width: 52px; flex: none;
  font-size: 12.5px; font-weight: 600; color: var(--muted);
}
.frompick { position: relative; flex: 1; min-width: 0; }
.frompick__btn {
  width: 100%; height: 36px;
  display: flex; align-items: center; gap: 8px;
  padding: 0 10px;
  border-radius: 10px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  text-align: left;
}
.frompick__btn:hover { border-color: var(--border-strong); }
.frompick__dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--muted); }
.frompick__txt { flex: 1; min-width: 0; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.frompick__chev { width: 16px; height: 16px; color: var(--faint); flex: none; }
.frompick__menu {
  position: absolute; z-index: 40;
  left: 0; right: 0; top: calc(100% + 6px);
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: var(--shadow-3);
  max-height: 280px; overflow: auto;
}
.composer__box.is-from-open,
.composer__box.is-from-open .composer__body { overflow: visible; }
.frompick__opt {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 8px;
  border-radius: 8px;
  text-align: left;
}
.frompick__opt:hover { background: var(--surface-3); }
.frompick__opt.is-on { background: var(--accent-soft); }
.frompick__who { flex: 1; min-width: 0; }
.frompick__who strong { display: block; font-size: 13px; font-weight: 600; }
.frompick__who span { display: block; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.frompick__star {
  width: 28px; height: 28px; flex: none;
  display: grid; place-items: center;
  border-radius: 8px; color: var(--faint);
}
.frompick__star svg { width: 15px; height: 15px; }
.frompick__star:hover { background: var(--surface); color: var(--warn); }
.frompick__star.is-on { color: var(--warn); }
.frompick__star.is-on svg { fill: var(--warn); }

.crow input:not([type="file"]), .crow select {
  flex: 1; height: 30px;
  background: transparent; border: 0; box-shadow: none; padding: 0;
}
.crow input:focus, .crow select:focus { box-shadow: none; background: transparent; }
.crow select { padding-right: 26px; background-position: right 0 center; }
.crow__toggles { display: flex; gap: 2px; flex: none; }

.crow--chips { align-items: flex-start; padding-top: 6px; padding-bottom: 6px; }
.crow--chips > label { padding-top: 7px; }

.chips {
  flex: 1; display: flex; flex-wrap: wrap; gap: 5px; align-items: center;
  min-height: 30px;
}
.chips input { flex: 1; min-width: 130px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 5px 3px 9px;
  background: var(--accent-soft);
  border-radius: 99px;
  font-size: 12.5px; color: var(--accent);
  max-width: 100%;
  animation: pop 130ms var(--ease) both;
}
.chip.is-bad { background: var(--danger-soft); color: var(--danger); }
.chip__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip__x {
  display: grid; place-items: center;
  width: 17px; height: 17px; border-radius: 50%;
  color: inherit; opacity: .65;
}
.chip__x:hover { background: color-mix(in srgb, currentColor 22%, transparent); opacity: 1; }
.chip__x svg { width: 11px; height: 11px; stroke-width: 2.6; }

.editor__tools {
  display: flex; align-items: center; gap: 1px; flex-wrap: wrap;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.editor__tools .iconbtn { width: 30px; height: 30px; font-size: 13px; }
.editor__tools svg { width: 16px; height: 16px; }
.editor__sep { width: 1px; height: 18px; background: var(--border); margin: 0 5px; }

.editor {
  flex: 1;
  min-height: 190px;
  padding: 16px;
  outline: none;
  overflow-y: auto;
  font-size: 14.5px; line-height: 1.62;
  word-wrap: break-word;
}
.editor:empty::before {
  content: 'Escribe tu mensaje…';
  color: var(--faint);
}
.editor a { color: var(--accent); }
.editor blockquote {
  margin: 8px 0 8px 2px; padding-left: 13px;
  border-left: 2.5px solid var(--border-strong);
  color: var(--muted);
}
.editor .wm-signature { color: var(--text-soft); }
.editor img { max-width: 100%; height: auto; }

.attachments { display: flex; flex-wrap: wrap; gap: 7px; padding: 0 16px 14px; flex: none; }
.attachments:empty { display: none; }

.attachments .att { max-width: 240px; }
.attachments .att__x {
  display: grid; place-items: center;
  width: 20px; height: 20px; border-radius: 50%;
  color: var(--faint); margin-left: 3px;
}
.attachments .att__x:hover { background: var(--danger-soft); color: var(--danger); }
.attachments .att__x svg { width: 12px; height: 12px; stroke-width: 2.5; }
.att.is-uploading { opacity: .6; }
.att__bar { height: 2px; background: var(--accent); border-radius: 2px; margin-top: 4px; transition: width 200ms linear; }

.composer__foot {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  flex: none;
}
.composer__hint { font-size: 11.5px; color: var(--faint); }
.composer__spacer { flex: 1; }
.composer__box.is-sig-open { overflow: visible; }
.sigpick { position: relative; }
.sigpick__menu {
  position: absolute; right: 0; bottom: calc(100% + 8px);
  width: min(280px, 72vw); max-height: 280px; overflow-y: auto;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: var(--shadow-3);
  z-index: 6;
}
.sigpick__opt {
  display: block; width: 100%; text-align: left;
  padding: 8px 10px; border: 0; border-radius: 8px;
  background: transparent; color: var(--text);
  font: inherit; font-size: 13px; cursor: pointer;
}
.sigpick__opt:hover { background: var(--surface-3); }
.sigpick__opt.is-on { background: var(--accent-soft); color: var(--accent); }

/* Sugerencias de direcciones */
.suggest {
  position: fixed;
  min-width: 260px; max-width: 380px;
  max-height: 232px; overflow-y: auto;
  padding: 5px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r);
  box-shadow: var(--shadow-3);
  z-index: 120;
  animation: pop 120ms var(--ease) both;
}
.suggest__item {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 7px 9px; border-radius: var(--r-sm);
  text-align: left; font-size: 13px;
  transition: background var(--fast);
}
.suggest__item:hover, .suggest__item.is-active { background: var(--accent-soft); }
.suggest__av {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--grad); color: #fff;
  display: grid; place-items: center;
  font: 700 10.5px/1 var(--font); flex: none;
}
.suggest__txt { min-width: 0; }
.suggest__name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest__mail { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ================================================================ avisos */

.ask {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center;
  padding: 22px;
}
.ask__backdrop {
  position: absolute; inset: 0;
  background: rgba(3, 5, 10, .55);
  backdrop-filter: blur(4px);
}
.ask__box {
  position: relative;
  width: min(420px, 100%);
  padding: 22px 22px 18px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  box-shadow: var(--shadow-3);
  animation: rise 180ms var(--ease) both;
}
.ask__box h3 { margin: 0 0 8px; font-size: 16px; letter-spacing: -.01em; }
.ask__box p { margin: 0; color: var(--text-soft); font-size: 14px; line-height: 1.5; white-space: pre-wrap; }
.ask__acts { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* ================================================================ modales */

.modal {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  padding: 22px;
  z-index: 100;
}
.modal__backdrop, .palette__backdrop {
  position: absolute; inset: 0;
  background: rgba(3, 5, 10, .62);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: fadeIn 160ms var(--ease) both;
}
.modal__box {
  position: relative;
  width: min(620px, 100%);
  max-height: 88dvh;
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  animation: rise 200ms var(--ease) both;
  overflow: hidden;
}
.modal__box.is-wide { width: min(880px, 100%); }
.modal__head {
  display: flex; align-items: center; gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.modal__head h3 { margin: 0; font-size: 16px; font-weight: 700; flex: 1; letter-spacing: -.01em; }
.modal__body { padding: 18px; overflow-y: auto; flex: 1; }
.movefind { position: sticky; top: 0; z-index: 1; margin: -18px -18px 12px; padding: 12px 18px 10px; background: var(--surface); }
.movefind input { width: 100%; height: 36px; padding: 0 14px; border-radius: 99px; }
.modal__foot {
  display: flex; align-items: center; gap: 9px; justify-content: flex-end;
  padding: 13px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  flex: none;
}
.modal__foot:empty { display: none; }
.modal__foot .modal__left { margin-right: auto; }

/* Contenido habitual dentro de modales */
.formgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.formgrid .span2 { grid-column: 1 / -1; }
@media (max-width: 620px) { .formgrid { grid-template-columns: 1fr; } }

.fieldset {
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 15px;
  margin-bottom: 15px;
}
.fieldset > legend {
  padding: 0 7px; margin-left: -7px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--faint);
}

/* ---------------------------------------------------------------- reglas */

.rule.is-off { opacity: .55; }
.rule .rowitem__sub { line-height: 1.5; }

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

.rulerow {
  display: flex; align-items: center; gap: 8px;
  padding: 9px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
}
.rulerow select, .rulerow input {
  height: 34px;
  background: var(--surface);
  flex: 0 1 auto;
  min-width: 0;
}
.rulerow > select:first-child { flex: 1 1 170px; }
.rulerow select[data-k="op"] { flex: 0 1 148px; }
.rulerow .rulerow__wide { flex: 1 1 200px; }
.rulerow__val { position: relative; flex: 1 1 150px; display: flex; align-items: center; }
.rulerow__val input { width: 100%; }
.rulerow__unit {
  position: absolute; right: 10px;
  font-size: 12px; color: var(--faint); pointer-events: none;
}
.rulerow__gap { flex: 1 1 auto; }
.rulerow .iconbtn { flex: none; width: 30px; height: 30px; }
.rulerow .iconbtn svg { width: 15px; height: 15px; }

@media (max-width: 620px) {
  .rulerow { flex-wrap: wrap; }
  .rulerow > select:first-child { flex: 1 1 100%; }
  .rulerow select[data-k="op"] { flex: 1 1 45%; }
  .rulerow__val, .rulerow .rulerow__wide { flex: 1 1 45%; }
}

/* --------------------------------------------------- editor de la firma */

.sigedit {
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface-2);
  overflow: hidden;
  transition: border-color var(--fast), box-shadow var(--fast);
}
.sigedit:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.sigedit__tools {
  display: flex; align-items: center; gap: 1px; flex-wrap: wrap;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-3);
}
.sigedit__tools .iconbtn { width: 30px; height: 30px; font-size: 13px; }
.sigedit__tools svg { width: 16px; height: 16px; }

.sigedit__sel {
  width: auto; height: 30px;
  padding: 0 26px 0 8px;
  font-size: 12.5px;
  background-color: var(--surface);
  background-position: right 6px center;
  background-size: 15px;
  border-radius: var(--r-sm);
  max-width: 150px;
}
.sigedit__sel--sm { max-width: 112px; }

/* El selector de color se muestra como un botón con una banda del color. */
.sigedit__color {
  position: relative;
  display: grid; place-items: center;
  width: 30px; height: 30px;
  border-radius: var(--r-sm);
  cursor: pointer;
  color: var(--muted);
  transition: background var(--fast), color var(--fast);
}
.sigedit__color:hover { background: var(--surface); color: var(--text); }
.sigedit__color svg { width: 15px; height: 15px; margin-top: -3px; }
.sigedit__colorIco { font: 700 13px/1 var(--font); margin-top: -4px; }
.sigedit__color input[type="color"] {
  position: absolute; left: 4px; right: 4px; bottom: 4px;
  width: auto; height: 4px;
  padding: 0; border: 0; border-radius: 2px;
  cursor: pointer;
}
.sigedit__color input[type="color"]::-webkit-color-swatch { border-radius: 2px; }
.sigedit__color input[type="color"]::-moz-color-swatch { border-radius: 2px; }

.sigedit__body {
  min-height: 132px; max-height: 300px;
  padding: 13px 14px;
  overflow-y: auto;
  outline: none;
  background: var(--surface);
  font-size: 14px; line-height: 1.6;
  word-wrap: break-word;
}
.sigedit__body:empty::before {
  content: attr(data-placeholder);
  color: var(--faint);
  white-space: pre-line;
}
.sigedit__body img { max-width: 100%; height: auto; border-radius: 3px; }
.sigedit__body a { color: var(--accent); }
.sigedit__body hr { border: 0; border-top: 1px solid var(--border-strong); margin: 10px 0; }
.sigedit__body ul, .sigedit__body ol { margin: 6px 0; padding-left: 22px; }

.sigedit__foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 7px 12px;
  border-top: 1px solid var(--border);
  font-size: 11.5px; color: var(--faint);
}
.sigedit__foot > span:first-child { white-space: nowrap; }
.sigedit__footRight { display: flex; align-items: center; gap: 10px; margin-left: auto; }

/* Panel de plantillas: vive dentro del editor porque la ventana modal ya
   está ocupada por el formulario de la cuenta. */
.sigedit__tpl {
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  animation: slideDown 160ms var(--ease) both;
}
.sigedit__tplHead { padding: 12px 14px 4px; }
.sigedit__tplHead strong { display: block; font-size: 13px; margin-bottom: 3px; }
.sigedit__tplHead span { font-size: 12px; color: var(--muted); line-height: 1.5; }

.sigedit__tplGrid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 9px; padding: 11px 14px 14px;
}

.sigedit__tplItem {
  display: block; text-align: left;
  padding: 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  transition: border-color var(--fast), transform var(--fast), box-shadow var(--fast);
}
.sigedit__tplItem:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow-2);
}
.sigedit__tplName { display: block; font-size: 13px; font-weight: 600; }
.sigedit__tplDesc { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 9px; line-height: 1.45; }

/* La vista previa se muestra sobre fondo claro: la firma acabará en un correo,
   y ahí los colores se verán sobre blanco. */
.sigedit__preview {
  display: block;
  background: #fff;
  border-radius: 7px;
  padding: 11px;
  overflow: hidden;
  zoom: .82;
}
.sigedit__preview img { max-width: 100%; height: auto; }

@media (max-width: 620px) {
  .sigedit__sel { max-width: 108px; }
  .sigedit__foot { flex-direction: column; align-items: flex-start; gap: 3px; }
}

.result { display: flex; align-items: flex-start; gap: 9px; padding: 10px 12px; border-radius: var(--r); font-size: 13px; margin-bottom: 9px; }
.result--ok { background: color-mix(in srgb, var(--ok) 11%, transparent); color: var(--ok); }
.result--bad { background: var(--danger-soft); color: var(--danger); }
.result svg { width: 16px; height: 16px; margin-top: 1px; }
.result code { font: 12px/1.5 var(--mono); opacity: .85; display: block; margin-top: 3px; word-break: break-word; }

.rowlist { display: flex; flex-direction: column; gap: 7px; }
.rowitem {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
}
.rowitem__dot { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.rowitem__txt { flex: 1; min-width: 0; }
.rowitem__name { font-size: 13.5px; font-weight: 600; }
.rowitem__sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rowitem__acts { display: flex; gap: 2px; flex: none; }
.pill {
  padding: 2px 8px; border-radius: 99px;
  font-size: 10.5px; font-weight: 700;
  background: var(--accent-soft); color: var(--accent);
}
.pill--warn { background: var(--danger-soft); color: var(--danger); }

.switchrow {
  display: flex; align-items: center; gap: 13px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.switchrow:last-child { border-bottom: 0; }
.switchrow__txt { flex: 1; }
.switchrow__name { font-size: 13.5px; font-weight: 500; }
.switchrow__sub { font-size: 12px; color: var(--muted); }
.switchrow select { width: auto; min-width: 140px; height: 34px; flex: none; }

.switch { position: relative; width: 40px; height: 23px; flex: none; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch__track {
  position: absolute; inset: 0;
  background: var(--border-strong); border-radius: 99px;
  transition: background var(--fast);
}
.switch__track::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 17px; height: 17px; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow-1);
  transition: transform var(--fast);
}
.switch input:checked + .switch__track { background: var(--accent); }
.switch input:checked + .switch__track::after { transform: translateX(17px); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--accent-ring); outline-offset: 2px; }

.kbdlist { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 22px; }
@media (max-width: 560px) { .kbdlist { grid-template-columns: 1fr; } }
.kbdrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; }
.kbdrow span { color: var(--text-soft); }
.kbdrow div { display: flex; gap: 3px; flex: none; }

/* ==================================================== paleta de comandos */

.palette {
  position: fixed; inset: 0;
  display: grid; place-items: start center;
  padding: 12dvh 20px 20px;
  z-index: 130;
}
.palette__box {
  position: relative;
  width: min(580px, 100%);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  overflow: hidden;
  animation: rise 190ms var(--ease) both;
}
.palette__input {
  display: flex; align-items: center; gap: 11px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.palette__input svg { width: 18px; height: 18px; color: var(--faint); }
.palette__input input {
  flex: 1; height: auto; padding: 0;
  background: transparent; border: 0; box-shadow: none;
  font-size: 15.5px;
}
.palette__input input:focus { box-shadow: none; background: transparent; }
.palette__list { max-height: 384px; overflow-y: auto; padding: 6px; }
.palette__group {
  padding: 9px 11px 5px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--faint);
}
.palette__item {
  display: flex; align-items: center; gap: 11px;
  width: 100%; padding: 9px 11px; border-radius: var(--r-sm);
  text-align: left; font-size: 13.5px; color: var(--text-soft);
}
.palette__item svg { width: 16px; height: 16px; color: var(--muted); }
.palette__item.is-active { background: var(--accent-soft); color: var(--accent); }
.palette__item.is-active svg { color: var(--accent); }
.palette__item kbd { margin-left: auto; }
.palette__item em { font-style: normal; color: var(--faint); font-size: 12px; margin-left: auto; }

/* ================================================================ avisos */

.toasts {
  position: fixed; bottom: 18px; left: 18px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 200;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  max-width: 400px; padding: 11px 15px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--r);
  box-shadow: var(--shadow-3);
  font-size: 13.5px;
  pointer-events: auto;
  animation: toastIn 230ms var(--ease) both;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(-16px); } to { opacity: 1; transform: none; } }
.toast.is-out { animation: toastOut 180ms var(--ease) both; }
@keyframes toastOut { to { opacity: 0; transform: translateX(-16px); } }
.toast--ok { border-left-color: var(--ok); }
.toast--bad { border-left-color: var(--danger); }
.toast--warn { border-left-color: var(--warn); }
.toast svg { width: 17px; height: 17px; }
.toast--ok svg { color: var(--ok); }
.toast--bad svg { color: var(--danger); }
.toast--warn svg { color: var(--warn); }
.toast__txt { flex: 1; }
.toast__act { color: var(--accent); font-weight: 600; font-size: 13px; white-space: nowrap; }

/* ========================================================== adaptabilidad */

.backdrop-mobile { display: none; }

@media (max-width: 1180px) {
  :root { --list-w: 340px; }
}

/* Panel de lectura superpuesto */
@media (max-width: 1040px) {
  .app {
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    grid-template-areas: "top top" "side list";
  }
  .reader {
    position: fixed; inset: var(--top-h) 0 0 0;
    z-index: 50;
    transform: translateX(100%);
    transition: transform var(--slow);
    border-left: 1px solid var(--border);
  }
  .reader.is-open { transform: none; }
  .reader__back { display: inline-grid; }
  .reader__empty { display: none; }
}

/* Columna de navegación como cajón */
@media (max-width: 820px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "top" "list";
  }
  .topbar__menu { display: grid; }
  .topbar__brand { width: auto; }
  .topbar__brand span { display: none; }

  .sidebar {
    position: fixed; top: var(--top-h); bottom: 0; left: 0;
    width: 280px; z-index: 70;
    transform: translateX(-100%);
    transition: transform var(--slow);
    box-shadow: var(--shadow-3);
    background: var(--surface);
  }
  .sidebar.is-open { transform: none; }

  .backdrop-mobile {
    display: block;
    position: fixed; inset: var(--top-h) 0 0 0;
    background: rgba(3, 5, 10, .5);
    z-index: 65;
    animation: fadeIn 160ms var(--ease) both;
  }

  .list { border-right: 0; }
  .rhead, .rbody, .rattach { padding-left: 16px; padding-right: 16px; }

  /* En pantallas estrechas, ocho botones dejaban el asunto en una columna de
     apenas 90 px. El asunto pasa a ocupar su propia línea y las acciones
     secundarias se recogen en el menú. */
  .rhead__top { flex-wrap: wrap; }
  .rhead__subject { flex: 1 0 100%; order: -1; margin-bottom: 12px; }
  .rhead__acts { margin-left: auto; }
  .rhead__acts > [data-act="reply_all"],
  .rhead__acts > [data-act="forward"],
  .rhead__acts > [data-act="flag"] { display: none; }
  .menu__item--compact { display: flex; }
  .rhead__who { flex-wrap: wrap; row-gap: 8px; }
  .rhead__date { text-align: left; }
  .notice { margin-left: 16px; margin-right: 16px; }
  .composer { padding: 0; }
  .composer__box { max-height: 100dvh; height: 100dvh; border-radius: 0; width: 100%; }
  .composer.is-max { padding: 0; }
  .toasts { left: 12px; right: 12px; bottom: 12px; }
  .toast { max-width: none; }
}

@media (max-width: 560px) {
  .search__kbd { display: none; }
  /* La barra superior va muy justa: el tema y el indicador en directo se
     consultan desde los ajustes, así que el buscador se queda con el espacio. */
  #btnTheme, .livedot { display: none; }
  .topbar { gap: 8px; padding: 0 10px; }
  .search input { padding-right: 34px; }
  .rhead__subject { font-size: 17px; }
  .bulk__count::after { content: ''; }
  .modal { padding: 0; place-items: stretch; }
  .modal__box { width: 100%; max-height: 100dvh; height: 100dvh; border-radius: 0; }
  .palette { padding: 0; place-items: stretch; }
  .palette__box { width: 100%; height: 100dvh; border-radius: 0; }
  .palette__list { max-height: none; height: calc(100dvh - 58px); }
}

/* -------------------------------------------------------------- impresión */

@media print {
  .topbar, .sidebar, .list, .composer, .toasts, .rhead__acts { display: none !important; }
  .app { display: block; height: auto; }
  .reader { position: static; transform: none; overflow: visible; }
  .rbody { overflow: visible; }
}

/* Utilidades */
.u-mono { font-family: var(--mono); font-size: 12.5px; }
.u-muted { color: var(--muted); }
.u-small { font-size: 12.5px; }
.u-mb { margin-bottom: 13px; }
.u-mt { margin-top: 13px; }
.u-center { text-align: center; }
.u-break { word-break: break-word; }
.u-pre { white-space: pre-wrap; font-family: var(--mono); font-size: 12px; }

.umgr__bar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.umgr__add {
  width: 42px; height: 42px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--grad); color: #fff; border: 0;
  box-shadow: 0 2px 12px -3px var(--accent-ring);
}
.umgr__add:hover { filter: brightness(1.08); }
.umgr__add svg { width: 18px; height: 18px; }
.umgr__search {
  display: flex; align-items: center; gap: 8px;
  flex: 1; height: 42px; padding: 0 14px; margin: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.umgr__search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--surface); }
.umgr__search svg { width: 16px; height: 16px; color: var(--faint); flex: none; }
.umgr__search input {
  flex: 1; width: auto; min-width: 0; height: 100%; padding: 0; border: 0; background: transparent;
  box-shadow: none; border-radius: 0;
}
.umgr__search input:focus { box-shadow: none; background: transparent; }
.ucard {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-2);
  padding: 16px;
  margin: 14px 0;
}
.ucard--new { background: transparent; border-style: dashed; }
.ucard__head { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; border-radius: 10px; }
.ucard__head:hover { background: var(--surface-3); }
.ucard.is-folded .ucard__head { margin: -6px; padding: 6px; width: calc(100% + 12px); }
.ucard:not(.is-folded) .ucard__head { margin: -6px -6px 8px; padding: 6px; width: calc(100% + 12px); }
.ucard.is-folded .ucard__body { display: none; }
.ucard__who { min-width: 0; flex: 1; }
.ucard__who strong { display: block; font-size: 15px; }
.ucard__who span { font-size: 12.5px; color: var(--muted); }
.ucard__chev { width: 16px; height: 16px; color: var(--faint); transition: transform var(--fast); }
.ucard:not(.is-folded) .ucard__chev { transform: rotate(90deg); }
.ucard__av {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--grad); color: #fff;
  font: 700 13px/1 var(--font);
}
.uagenda { margin-top: 14px; }
.uagenda__title { font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.uagenda__row { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 13.5px; cursor: pointer; }
.ucard__foot { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.bookcard {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px; margin-top: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
}
.bookcard__av {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  display: grid; place-items: center; color: #fff; font: 700 13px/1 var(--font);
}
.bookcard__txt { min-width: 0; flex: 1; }
.bookcard__txt strong { display: block; }
.bookcard__txt span { display: block; color: var(--muted); font-size: 13px; }
.bookcard__acts { display: flex; gap: 6px; flex: none; }
.booksec { margin-top: 22px; }
.booksec h2 { margin: 0 0 8px; font-size: 15px; }
.ucard__foot .btn--danger { margin-left: auto; }
.ugrants {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
}
.ugrants__head, .ugrant {
  display: grid;
  grid-template-columns: minmax(0, 1fr) repeat(4, 64px);
  align-items: center;
  gap: 4px;
  padding: 9px 12px;
}
.ugrants__head {
  font-size: 11px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--faint);
  background: var(--surface-3);
}
.ugrants__head span:not(:first-child), .ugrant .checkbox { justify-self: center; }
.ugrant + .ugrant { border-top: 1px solid var(--border); }
.ugrant__name { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 600; font-size: 13.5px; }
.ugrant__name i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
@media (max-width: 640px) {
  .ugrants__head, .ugrant { grid-template-columns: minmax(0, 1fr) repeat(4, 36px); padding-inline: 8px; }
  .filepick { flex-wrap: wrap; }
  .filepick__name { flex: 1 1 160px; }
}

.chip.is-warn { background: color-mix(in srgb, var(--warn) 20%, transparent); color: color-mix(in srgb, var(--warn) 70%, black); }
:root[data-theme="dark"] .chip.is-warn { color: var(--warn); }
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] .chip.is-warn { color: var(--warn); }
}
.chip.is-ok { background: var(--accent-soft); color: var(--accent); }

.upending {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  margin-bottom: 16px;
  overflow: hidden;
}
.upending__head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  font-size: 12.5px; font-weight: 700; letter-spacing: .03em;
  text-transform: uppercase; color: var(--faint);
  background: var(--surface-3);
}
.upending__row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  flex-wrap: wrap;
}
.upending__row + .upending__row { border-top: 1px solid var(--border); }
.upending__who {
  display: flex; align-items: center; gap: 8px;
  min-width: 0; flex: 1 1 160px;
  text-align: left; border-radius: 8px;
  padding: 2px 4px; margin: -2px -4px;
}
.upending__who:hover { background: var(--surface-3); }
.upending__who-txt { min-width: 0; }
.upending__who-txt strong { display: block; font-size: 14px; }
.upending__who-txt span { font-size: 12px; color: var(--muted); }
.upending__chev {
  width: 14px; height: 14px; flex: none; color: var(--faint);
  transition: transform var(--fast);
}
.upending__who.is-open .upending__chev { transform: rotate(90deg); }
.upending__acts { display: flex; gap: 6px; flex: none; margin-left: auto; }

.upending__detail {
  flex: 1 0 100%;
  margin-top: 8px; padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-3);
  display: flex; flex-direction: column; gap: 6px;
}
.upending__detail-row {
  display: flex; align-items: baseline; gap: 8px;
  font-size: 12.5px;
  flex-wrap: wrap;
}
.upending__detail-label {
  min-width: 110px; flex: none;
  color: var(--faint); font-weight: 600;
}
.upending__detail-ip {
  color: var(--muted); font: 12px var(--mono);
  margin-left: auto;
}

/* ------------------------------------------------- panel de altas (stats) */

.stats-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
@media (max-width: 640px) {
  .stats-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.stat {
  display: flex; flex-direction: column; gap: 2px;
  padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
}
.stat__value { font: 600 22px/1.1 var(--font); color: var(--text); }
.stat__label { font-size: 12px; color: var(--muted); }
.stat--warn .stat__value { color: var(--warn); }
.stat--ok .stat__value { color: var(--accent); }
.stat--bad .stat__value { color: var(--danger); }

.schart {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 12px 14px 8px;
  margin-bottom: 16px;
}
.schart__head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: 12px; color: var(--muted); margin-bottom: 6px;
}
.schart__tip { font-weight: 600; color: var(--text); min-height: 1.3em; }
.schart__svg { display: block; width: 100%; height: 84px; overflow: visible; }
.schart__bar { cursor: pointer; }
.schart__bar path[fill="var(--accent)"] { transition: opacity var(--fast); }
.schart__bar:hover path[fill="var(--accent)"] { opacity: .78; }

.sthrottle {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface);
  margin-bottom: 16px;
  font-size: 12.5px; color: var(--muted);
}

.firmas { max-width: 860px; margin: 0 auto; padding: 28px 20px 64px; }
.firmas .umgr__search { margin-top: 14px; }
.firmas__top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.firmas__top h1 { margin: 0; font-size: 22px; }
.firmas__back { color: var(--muted); font-size: 13px; }
.sigcard { border: 1px solid var(--border); background: var(--surface); border-radius: 12px; padding: 12px 14px; margin: 0 0 10px; }
.sigcard__top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sigcard__acts { display: flex; gap: 6px; }
.sigcard__preview { margin-top: 8px; max-height: 140px; overflow: hidden; font-size: 13px; }
.firmas .sigedit__body { min-height: 140px; }
