/* ============================================================
   GESTOR DE ACCESOS — style.css
   ============================================================ */

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

:root {
  --bg:   #f4f3ef;
  --sur:  #ffffff;
  --bd:   #e2e0da;
  --bd2:  #c6c4be;
  --tx:   #1a1918;
  --mu:   #78756f;
  --hi:   #b0ada6;
  --primary: #1677ff;
  --primary-2: #16b8d9;
  --primary-soft: #e9f4ff;
  --primary-shadow: rgba(22,119,255,.24);
  --search-placeholder: #7f838a;
  --sticky-bg: rgba(244,243,239,.92);
  --sur-glass: rgba(255,255,255,.88);
  --card-glow: rgba(22,119,255,.08);
  --pu:   #6c63d6;  --pu2: #eeedfb;
  --gr:   #189e72;  --gr2: #dff5ec;
  --bl:   #1a6abf;  --bl2: #e3f0fb;
  --co:   #c94e28;  --co2: #fae9e4;
  --am:   #a8761c;  --am2: #fbf0da;
  --r:    10px;
  --rs:   7px;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--tx);
  min-height: 100vh;
  font-size: 14px;
}

/* ── Login ── */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}
.login-wrap {
  width: 100%;
  max-width: 400px;
  padding: 20px;
}
.login-box {
  background: var(--sur);
  border-radius: 14px;
  padding: 36px 32px;
  box-shadow: 0 4px 24px rgba(0,0,0,.10);
  border: 1px solid var(--bd);
}
.login-logo {
  font-size: 36px;
  text-align: center;
  margin-bottom: 10px;
}
.login-title {
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 24px;
  color: var(--tx);
}
.lfi {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
}
.lfi label {
  font-size: 12px;
  color: var(--mu);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.lfi input {
  padding: 10px 12px;
  border: 1px solid var(--bd2);
  border-radius: var(--rs);
  font-size: 14px;
  color: var(--tx);
  background: var(--bg);
  outline: none;
  transition: border .15s;
}
.lfi input:focus { border-color: var(--pu); background: #fff; }
.login-btn {
  width: 100%;
  padding: 11px;
  background: var(--pu);
  color: #fff;
  border: none;
  border-radius: var(--rs);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 6px;
  transition: opacity .15s;
}
.login-btn:hover { opacity: .88; }
.login-notice {
  padding: 10px 14px;
  border-radius: var(--rs);
  font-size: 13px;
  margin-bottom: 16px;
}
.login-notice.error { background: var(--co2); color: var(--co); }
.login-notice.warn  { background: #fff3cd; color: #856404; }

/* ── App layout ── */
.app {
  width: min(96%, 1800px);
  margin: 0 auto;
  padding: 0 20px 60px;
}

/* ── Header ── */
.hd {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
}
.logo {
  width: 32px;
  height: 32px;
  background: var(--pu);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 17px;
  flex-shrink: 0;
}
h1 { font-size: 20px; font-weight: 600; }
.hd-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.hd-user {
  font-size: 13px;
  color: var(--mu);
}
.btn-logout {
  font-size: 12px;
  padding: 5px 12px;
  border-radius: var(--rs);
  border: 1px solid var(--bd2);
  background: var(--sur);
  color: var(--mu);
  text-decoration: none;
  transition: all .15s;
}
.btn-logout:hover { border-color: var(--co); color: var(--co); }

/* ── Buscador ── */
.sw { position: relative; margin-bottom: 20px; }
.sw input {
  width: 100%;
  padding: 10px 36px 10px 38px;
  border: 1px solid var(--bd2);
  border-radius: var(--r);
  font-size: 14px;
  background: var(--sur);
  color: var(--tx);
  outline: none;
  transition: border .15s;
}
.sw input:focus { border-color: var(--pu); }
.sil, .sir {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: var(--hi);
  border: none;
  background: none;
  display: flex;
  align-items: center;
  padding: 0;
}
.sil { left: 11px; pointer-events: none; }
.sir { right: 10px; cursor: pointer; padding: 4px; }

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--rs);
  font-size: 13px;
  cursor: pointer;
  border: 1px solid var(--bd2);
  background: var(--sur);
  color: var(--mu);
  transition: all .15s;
  line-height: 1;
}
.bdg {
  border-radius: 20px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 600;
}
.tab[data-c=todos].on   { background: #efefef; color: #333;      border-color: #999;      font-weight: 500; }
.tab[data-c=cpanel].on  { background: var(--pu2); color: var(--pu); border-color: var(--pu); font-weight: 500; }
.tab[data-c=cuentas].on { background: var(--gr2); color: var(--gr); border-color: var(--gr); font-weight: 500; }
.tab[data-c=correos].on { background: var(--bl2); color: var(--bl); border-color: var(--bl); font-weight: 500; }
.tab[data-c=clientes].on{ background: var(--co2); color: var(--co); border-color: var(--co); font-weight: 500; }
.tab[data-c=notas].on   { background: var(--am2); color: var(--am); border-color: var(--am); font-weight: 500; }
.tab[data-c=todos]   .bdg { background: #e8e8e8;   color: #555; }
.tab[data-c=cpanel]  .bdg { background: var(--pu2); color: var(--pu); }
.tab[data-c=cuentas] .bdg { background: var(--gr2); color: var(--gr); }
.tab[data-c=correos] .bdg { background: var(--bl2); color: var(--bl); }
.tab[data-c=clientes] .bdg { background: var(--co2); color: var(--co); }
.tab[data-c=notas]    .bdg { background: var(--am2); color: var(--am); }

/* ── Toolbar ── */
.tb {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.tb-left  { display: flex; align-items: center; gap: 10px; }
.tb-right { display: flex; gap: 8px; }
.cnt { font-size: 12px; color: var(--mu); }

.btns {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 13px;
  border-radius: var(--rs);
  font-size: 12px;
  cursor: pointer;
  border: 1px solid var(--bd2);
  background: var(--sur);
  color: var(--mu);
  transition: all .15s;
}
.btns:hover    { border-color: var(--pu); color: var(--pu); }
.btns.sort-on  { background: var(--pu2); color: var(--pu); border-color: var(--pu); font-weight: 500; }

.btnp {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border-radius: var(--rs);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1.5px solid transparent;
  color: #fff;
  transition: all .15s;
}
.btnp:hover { opacity: .88; }

/* ── Formulario agregar ── */
.fw {
  background: var(--sur);
  border-radius: var(--r);
  padding: 18px 20px;
  margin-bottom: 14px;
  border: 1.5px solid var(--pu);
}
.fw.gc { border-color: var(--gr); }
.fw.bc { border-color: var(--bl); }
.fw.cc { border-color: var(--co); }
.fw.nc { border-color: var(--am); }
.fg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
}
.fi { display: flex; flex-direction: column; gap: 4px; }
.fi.full { grid-column: 1 / -1; }
.fi label {
  font-size: 11px;
  color: var(--mu);
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 500;
}
.fi label span { color: var(--co); }
.fi input,
.fi textarea {
  padding: 8px 10px;
  border: 1px solid var(--bd2);
  border-radius: var(--rs);
  font-size: 13px;
  color: var(--tx);
  background: var(--bg);
  outline: none;
  font-family: inherit;
  width: 100%;
  transition: border .15s;
}
.fi input:focus,
.fi textarea:focus { border-color: var(--pu); background: #fff; }
.fi textarea { resize: vertical; min-height: 58px; }
.fa { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.btn {
  padding: 7px 16px;
  border-radius: var(--rs);
  font-size: 13px;
  cursor: pointer;
  border: 1px solid var(--bd2);
  background: var(--sur);
  color: var(--mu);
}
.btn:hover { background: var(--bg); }
.btno {
  padding: 7px 16px;
  border-radius: var(--rs);
  font-size: 13px;
  cursor: pointer;
  border: none;
  color: #fff;
  font-weight: 500;
}
.btno:hover { opacity: .88; }

/* ── Cards ── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}
.card {
  background: var(--sur);
  border: 1px solid var(--bd);
  border-radius: var(--r);
  padding: 14px 16px;
}
.card.cat-cpanel  { border-left: 3px solid var(--pu); }
.card.cat-cuentas { border-left: 3px solid var(--gr); }
.card.cat-correos { border-left: 3px solid var(--bl); }
.card.cat-clientes{ border-left: 3px solid var(--co); }
.ch {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}
.cn { font-weight: 600; font-size: 14px; }
.cm { font-size: 11px; color: var(--hi); margin-top: 2px; }
.cact {
  display: flex;
  gap: 2px;
  align-items: center;
  padding-left: 8px;
  flex-shrink: 0;
}
.ib {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--hi);
  padding: 4px;
  display: inline-flex;
  align-items: center;
  border-radius: 4px;
  transition: all .15s;
}
.ib:hover    { background: var(--bg); }
.ib.ie:hover { color: var(--bl); }
.ib.id:hover { color: var(--co); }
.fds {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 3px 12px;
  font-size: 13px;
}
.fk  { color: var(--mu); white-space: nowrap; padding: 2px 0; }
.fv  { color: var(--tx); padding: 2px 0; display: flex; align-items: flex-start; gap: 4px; word-break: break-all; flex-wrap: wrap; }
.sec { font-family: monospace; letter-spacing: 2px; font-size: 12px; }

/* Etiqueta categoria */
.cl {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 8px;
  padding: 3px 9px;
  border-radius: 20px;
}

/* ── Modales ── */
.ov {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.38);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 50px;
  z-index: 300;
}
.md {
  background: var(--sur);
  border-radius: 14px;
  padding: 24px;
  width: 96%;
  max-width: 580px;
  max-height: 86vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
}
.md h3  { font-size: 16px; font-weight: 600; margin-bottom: 16px; }
.md > p { font-size: 13px; color: var(--mu); margin-bottom: 12px; }
textarea.imp {
  width: 100%;
  height: 200px;
  font-size: 12px;
  font-family: monospace;
  resize: vertical;
  padding: 10px;
  border: 1px solid var(--bd2);
  border-radius: var(--rs);
  background: var(--bg);
  color: var(--tx);
}
.notice {
  background: var(--gr2);
  color: #0a5e40;
  border-radius: var(--rs);
  padding: 10px 14px;
  font-size: 13px;
  margin-top: 12px;
}

/* ── Empty ── */
.empty { text-align: center; padding: 44px 0; color: var(--hi); }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1a1918;
  color: #fff;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 9999;
  transition: opacity .4s;
}

/* ── Responsive ── */
@media (max-width: 700px) {
  body              { font-size: 16px; }
  .app              { width: 96%; padding: 16px 12px 40px; }
  h1                { font-size: 22px; }
  .fg               { grid-template-columns: 1fr; }
  .fi.full          { grid-column: 1; }
  .fi label         { font-size: 13px; }
  .fi input,
  .fi textarea      { font-size: 15px; padding: 10px 12px; }
  .tab              { padding: 8px 12px; font-size: 14px; }
  .bdg              { font-size: 13px; padding: 2px 8px; }
  .card-grid        { grid-template-columns: 1fr; }
  .card             { padding: 16px; }
  .cn               { font-size: 16px; }
  .cm               { font-size: 13px; }
  .fds              { font-size: 14px; gap: 4px 12px; }
  .fk               { font-size: 13px; }
  .fv               { font-size: 14px; }
  .tb               { flex-direction: column; align-items: flex-start; gap: 10px; }
  .tb-right         { width: 100%; justify-content: flex-end; }
  .btns             { font-size: 14px; padding: 9px 14px; }
  .btnp             { font-size: 14px; padding: 9px 16px; }
  .cnt              { font-size: 14px; }
  .hd-user          { display: none; }
  .ib               { padding: 6px; }
  /* Login responsive */
  .login-box        { padding: 28px 20px; }
  .login-title      { font-size: 20px; }
  .lfi label        { font-size: 14px; }
  .lfi input        { font-size: 16px; padding: 12px; }
  .login-btn        { font-size: 16px; padding: 13px; }
  /* Modal responsive */
  .md               { padding: 20px 16px; }
  .md h3            { font-size: 18px; }
  .btn, .btno       { font-size: 15px; padding: 10px 18px; }
}


/* ============================================================
   TEMA CLARO / OSCURO
   ============================================================ */
:root {
  color-scheme: light;
  --field-focus: #ffffff;
  --neutral-on: #efefef;
  --neutral-on-tx: #333333;
  --neutral-badge: #e8e8e8;
  --neutral-badge-tx: #555555;
  --warn-bg: #fff3cd;
  --warn-tx: #856404;
  --notice-tx: #0a5e40;
  --overlay-theme: rgba(0,0,0,.38);
  --theme-shadow: 0 4px 24px rgba(0,0,0,.10);
  --theme-modal-shadow: 0 8px 32px rgba(0,0,0,.18);
  --toast-bg-theme: #1a1918;
  --toast-tx-theme: #ffffff;
  --glow-a: transparent;
  --glow-b: transparent;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg:   #050914;
  --sur:  #0d1626;
  --bd:   #21324d;
  --bd2:  #344b6d;
  --tx:   #f2f7ff;
  --mu:   #a9b8ce;
  --hi:   #7d90ad;
  --primary: #3b82f6;
  --primary-2: #22d3ee;
  --primary-soft: #122b4b;
  --primary-shadow: rgba(42,143,255,.34);
  --search-placeholder: #93a5bf;
  --sur-glass: rgba(13,22,38,.84);
  --card-glow: rgba(48,151,255,.14);
  --sticky-bg: rgba(5,9,20,.86);
  --pu:   #a193ff;  --pu2: #27234d;
  --gr:   #4bd3a0;  --gr2: #123b32;
  --bl:   #62b7ff;  --bl2: #113653;
  --co:   #ff8b70;  --co2: #482620;
  --am:   #e5b45f;  --am2: #42341a;
  --field-focus: #11233a;
  --neutral-on: #1a2a42;
  --neutral-on-tx: #dce8f7;
  --neutral-badge: #20314a;
  --neutral-badge-tx: #b9c9dd;
  --warn-bg: #463817;
  --warn-tx: #ffd979;
  --notice-tx: #70e4b8;
  --overlay-theme: rgba(1,6,15,.72);
  --theme-shadow: 0 18px 50px rgba(0,0,0,.34);
  --theme-modal-shadow: 0 24px 60px rgba(0,0,0,.48);
  --toast-bg-theme: #edf4ff;
  --toast-tx-theme: #07111f;
  --glow-a: rgba(91,72,255,.20);
  --glow-b: rgba(0,196,255,.15);
}

html { min-height: 100%; background: var(--bg); }
body,
.login-body {
  background:
    radial-gradient(circle at 12% -10%, var(--glow-a), transparent 34%),
    radial-gradient(circle at 92% 0%, var(--glow-b), transparent 31%),
    var(--bg);
  transition: background-color .2s ease, color .2s ease;
}

.theme-icon { display: block; }
:root:not([data-theme="dark"]) .theme-icon-dark { display: none; }
:root[data-theme="dark"] .theme-icon-light { display: none; }

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 3px 7px;
  border: 1px solid var(--bd2);
  border-radius: 999px;
  background: var(--sur);
  color: var(--mu);
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease, color .18s ease, box-shadow .18s ease;
}
.theme-toggle:hover { border-color: var(--pu); color: var(--pu); }
.theme-toggle:focus-visible { outline: 2px solid var(--pu); outline-offset: 2px; }
.theme-toggle svg { width: 14px; height: 14px; display: block; }
.theme-toggle-track {
  position: relative;
  width: 30px;
  height: 16px;
  border-radius: 999px;
  background: var(--bd2);
  box-shadow: inset 0 1px 3px rgba(0,0,0,.12);
  transition: background .18s ease;
}
.theme-toggle-knob {
  position: absolute;
  width: 12px;
  height: 12px;
  left: 2px;
  top: 2px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
  transition: transform .2s ease;
}
:root[data-theme="dark"] .theme-toggle-track { background: linear-gradient(90deg,#7469ef,#35b9e9); }
:root[data-theme="dark"] .theme-toggle-knob { transform: translateX(14px); }
:root[data-theme="dark"] .theme-toggle-moon { color: #8edcff; }
:root:not([data-theme="dark"]) .theme-toggle-sun { color: #c58a16; }

.login-box { position: relative; overflow: hidden; box-shadow: var(--theme-shadow); }
.login-box > .theme-toggle { position: absolute; top: 16px; right: 16px; z-index: 2; }
.login-logo {
  width: 132px;
  height: 132px;
  margin: 0 auto 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-brand-icon { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 12px 18px rgba(25,64,160,.14)); }
:root[data-theme="dark"] .login-box {
  background: linear-gradient(155deg,#111f34 0%,var(--sur) 58%,#0b1728 100%);
  border-color: #2a3d5a;
}
:root[data-theme="dark"] .login-brand-icon { filter: drop-shadow(0 14px 26px rgba(62,91,255,.26)); }
.login-title { font-size: 20px; }

.logo {
  width: 40px;
  height: 40px;
  background: transparent;
  border-radius: 0;
  padding: 0;
}
.app-brand-icon { width: 100%; height: 100%; object-fit: contain; }

.lfi input:focus,
.fi input:focus,
.fi textarea:focus { background: var(--field-focus); }
.login-notice.warn { background: var(--warn-bg); color: var(--warn-tx); }
.tab[data-c=todos].on { background: var(--neutral-on); color: var(--neutral-on-tx); border-color: var(--bd2); }
.tab[data-c=todos] .bdg { background: var(--neutral-badge); color: var(--neutral-badge-tx); }
.notice { color: var(--notice-tx); }
.ov { background: var(--overlay-theme); backdrop-filter: blur(4px); }
.md { border: 1px solid var(--bd); box-shadow: var(--theme-modal-shadow); }
.toast { background: var(--toast-bg-theme); color: var(--toast-tx-theme); }
.sw input::placeholder,
textarea::placeholder,
input::placeholder { color: var(--search-placeholder); opacity: 1; }

:root[data-theme="dark"] .card { box-shadow: 0 10px 28px rgba(0,0,0,.13); }
:root[data-theme="dark"] .sw input,
:root[data-theme="dark"] .tab,
:root[data-theme="dark"] .btns,
:root[data-theme="dark"] .btn,
:root[data-theme="dark"] .btn-logout,
:root[data-theme="dark"] .fw,
:root[data-theme="dark"] .card,
:root[data-theme="dark"] .md { border-color: var(--bd); }

@media (max-width: 700px) {
  .logo { width: 36px; height: 36px; }
  .theme-toggle { height: 29px; padding: 3px 6px; }
  .theme-toggle-sun,
  .theme-toggle-moon { display: none; }
  .login-logo { width: 118px; height: 118px; }
  .login-box > .theme-toggle { top: 12px; right: 12px; }
}


/* ============================================================
   UI 3.1 — STICKY, ACCIONES, GRID 4 COLUMNAS Y DARK PRO
   ============================================================ */
.control-shell {
  position: sticky;
  top: 0;
  z-index: 120;
  margin: 0 -20px 14px;
  padding: 18px 20px 12px;
  background: var(--sticky-bg);
  border-bottom: 1px solid color-mix(in srgb, var(--bd) 84%, transparent);
  backdrop-filter: blur(20px) saturate(145%);
  -webkit-backdrop-filter: blur(20px) saturate(145%);
  box-shadow: 0 10px 30px rgba(20,32,55,.05);
}
.control-shell .hd { margin-bottom: 14px; }
.control-shell .sw { margin-bottom: 12px; }
.control-shell .tabs { margin-bottom: 10px; }
.control-shell .tb { margin-bottom: 0; }
#fc { scroll-margin-top: 230px; }

.btnp {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);
  border-color: rgba(255,255,255,.16);
  box-shadow: 0 8px 18px var(--primary-shadow), inset 0 1px 0 rgba(255,255,255,.22);
  letter-spacing: .01em;
}
.btnp:hover {
  opacity: 1;
  transform: translateY(-1px);
  box-shadow: 0 11px 24px var(--primary-shadow), inset 0 1px 0 rgba(255,255,255,.25);
}
.btnp.is-cancel {
  background: var(--sur);
  color: var(--mu);
  border-color: var(--bd2);
  box-shadow: none;
  transform: none;
}
.login-btn {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);
  box-shadow: 0 9px 22px var(--primary-shadow), inset 0 1px 0 rgba(255,255,255,.22);
}
.login-btn:hover { opacity: 1; box-shadow: 0 12px 28px var(--primary-shadow); }
.btno {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);
  box-shadow: 0 7px 16px var(--primary-shadow), inset 0 1px 0 rgba(255,255,255,.20);
}
.btno:hover { opacity: 1; filter: brightness(1.06); }
.btns:hover { border-color: var(--primary); color: var(--primary); }
.btns.sort-on {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: color-mix(in srgb, var(--primary) 65%, var(--bd));
}

.add-category-modal { max-width: 520px; }
.add-category-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}
.add-category-card {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  padding: 14px;
  border: 1px solid var(--bd);
  border-radius: 12px;
  background: var(--sur);
  color: var(--tx);
  cursor: pointer;
  transition: border-color .16s ease, transform .16s ease, box-shadow .16s ease;
}
.add-category-card:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(0,0,0,.08); }
.add-category-card b { display: block; font-size: 13px; margin-bottom: 3px; }
.add-category-card small { display: block; color: var(--mu); font-size: 11px; line-height: 1.3; }
.add-category-card .aci { font-size: 22px; }
.ac-cpanel:hover { border-color: var(--pu); }
.ac-cuentas:hover { border-color: var(--gr); }
.ac-correos:hover { border-color: var(--bl); }
.ac-clientes:hover { border-color: var(--co); }
.ac-notas:hover { border-color: var(--am); }

:root[data-theme="dark"] body,
:root[data-theme="dark"] .login-body {
  background:
    radial-gradient(900px 520px at 8% -10%, rgba(91,72,255,.22), transparent 60%),
    radial-gradient(850px 520px at 95% -4%, rgba(0,196,255,.16), transparent 58%),
    linear-gradient(180deg, #050914 0%, #070d19 48%, #050914 100%);
  background-attachment: fixed;
}
:root[data-theme="dark"] .control-shell {
  background: var(--sticky-bg);
  border-bottom-color: rgba(109,148,204,.18);
  box-shadow: 0 12px 40px rgba(0,0,0,.28), inset 0 -1px 0 rgba(255,255,255,.025);
}
:root[data-theme="dark"] .hd h1 {
  background: linear-gradient(90deg, #f6f9ff 0%, #b9d8ff 62%, #7ee8ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
:root[data-theme="dark"] .sw input {
  background: rgba(12,22,38,.78);
  border-color: rgba(112,151,207,.28);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.025), 0 8px 22px rgba(0,0,0,.16);
}
:root[data-theme="dark"] .sw input:focus {
  border-color: rgba(61,160,255,.74);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12), 0 10px 26px rgba(0,0,0,.20);
}
:root[data-theme="dark"] .tab,
:root[data-theme="dark"] .btns,
:root[data-theme="dark"] .btn,
:root[data-theme="dark"] .btn-logout,
:root[data-theme="dark"] .theme-toggle {
  background: rgba(14,24,42,.78);
  border-color: rgba(117,157,213,.22);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.025);
}
:root[data-theme="dark"] .card {
  background:
    linear-gradient(145deg, rgba(18,30,51,.96) 0%, rgba(11,20,35,.95) 62%, rgba(9,17,31,.98) 100%);
  border-color: rgba(116,155,208,.18);
  box-shadow:
    0 13px 34px rgba(0,0,0,.25),
    0 0 0 1px rgba(255,255,255,.015) inset,
    0 1px 0 rgba(255,255,255,.04) inset,
    0 0 34px var(--card-glow);
}
:root[data-theme="dark"] .card:hover { border-color: rgba(95,164,255,.32); }
:root[data-theme="dark"] .fw,
:root[data-theme="dark"] .md,
:root[data-theme="dark"] .add-category-card {
  background: linear-gradient(150deg, rgba(17,29,49,.98), rgba(10,18,32,.98));
  border-color: rgba(116,155,208,.22);
  box-shadow: 0 18px 46px rgba(0,0,0,.30), inset 0 1px 0 rgba(255,255,255,.035);
}
:root[data-theme="dark"] .fi input,
:root[data-theme="dark"] .fi textarea,
:root[data-theme="dark"] textarea.imp,
:root[data-theme="dark"] .lfi input {
  background: rgba(6,13,25,.72);
  border-color: rgba(118,158,215,.24);
}
:root[data-theme="dark"] .fi input:focus,
:root[data-theme="dark"] .fi textarea:focus,
:root[data-theme="dark"] .lfi input:focus {
  background: rgba(9,19,34,.92);
  border-color: rgba(64,164,255,.70);
  box-shadow: 0 0 0 3px rgba(59,130,246,.10);
}
:root[data-theme="dark"] .theme-toggle:hover,
:root[data-theme="dark"] .btns:hover { border-color: rgba(59,160,255,.62); }
:root[data-theme="dark"] .login-box {
  background:
    radial-gradient(circle at 82% 8%, rgba(34,211,238,.10), transparent 30%),
    radial-gradient(circle at 8% 98%, rgba(91,72,255,.13), transparent 36%),
    linear-gradient(155deg, rgba(17,31,53,.98), rgba(9,17,31,.99));
  border-color: rgba(117,158,215,.25);
  box-shadow: 0 28px 80px rgba(0,0,0,.42), inset 0 1px 0 rgba(255,255,255,.04);
}

@media (max-width: 1100px) and (min-width: 701px) {
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
  .app { width: 100%; padding: 0 12px 36px; }
  .control-shell {
    margin: 0 -12px 12px;
    padding: 10px 12px 9px;
  }
  .control-shell .hd { margin-bottom: 9px; }
  .control-shell .sw { margin-bottom: 9px; }
  .control-shell .tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    margin-bottom: 8px;
    padding-bottom: 2px;
  }
  .control-shell .tabs::-webkit-scrollbar { display: none; }
  .control-shell .tab { flex: 0 0 auto; }
  .control-shell .tb { flex-direction: row; align-items: center; gap: 6px; }
  .control-shell .tb-right { width: auto; margin-left: auto; }
  .sw input { font-size: 15px; min-height: 42px; }
  .sw input::placeholder { color: var(--search-placeholder); opacity: 1; }
  .card-grid { grid-template-columns: 1fr; }
  .add-category-grid { grid-template-columns: 1fr; }
  #fc { scroll-margin-top: 210px; }
}

@media (max-width: 480px) {
  .tb-left .cnt { display: none; }
  .btns, .btnp { padding: 8px 10px; font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *,*::before,*::after { transition: none !important; }
}

/* Enlace de acceso directo (autologin) */
.fv .lk{color:var(--bl,#2563eb);text-decoration:none;border-bottom:1px dashed currentColor;cursor:pointer;word-break:break-all}
.fv .lk:hover{opacity:.8}

/* ============================================================
   CONFIGURACION / ACTUALIZACIONES
   ============================================================ */
.gear-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; padding: 0;
  background: none; border: none; border-radius: var(--rs);
  color: var(--mu); cursor: pointer;
  transition: color .15s;
  -webkit-tap-highlight-color: transparent;
}
.gear-btn:hover  { color: var(--primary); }
.gear-btn:focus  { outline: none; }
.gear-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Gira el icono, no el boton */
.gear-btn svg { transition: transform .4s ease; transform-origin: 50% 50%; }
.gear-btn:hover svg { transform: rotate(90deg); }

.cfg-md { max-width: 620px; width: 100%; }

.cfg-tabs { display: flex; gap: 6px; margin: 14px 0 16px; border-bottom: 1px solid var(--bd); }
.cfg-tab {
  padding: 8px 14px; font-size: 13px; color: var(--mu);
  background: none; border: none; border-bottom: 2px solid transparent;
  cursor: pointer; font-family: inherit;
}
.cfg-tab.on { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }

.cfg-ver {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px; background: var(--primary-soft);
  border: 1px solid var(--bd); border-radius: var(--rs); margin-bottom: 14px;
}
.cfg-ver small { display: block; font-size: 11px; color: var(--mu); margin-bottom: 2px; }
.cfg-ver b     { font-size: 18px; color: var(--tx); }

.cfg-sec { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--bd); }
.cfg-sec-hd {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; font-weight: 600; margin-bottom: 6px;
}
.cfg-note { font-size: 11.5px; color: var(--mu); line-height: 1.5; margin-bottom: 10px; }

.upd-row, .bk-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 13px; margin-bottom: 7px;
  background: var(--sur); border: 1px solid var(--bd); border-radius: var(--rs);
}
.upd-row.on { border-color: var(--primary); background: var(--primary-soft); }
.upd-row small, .bk-row small { display: block; font-size: 11px; color: var(--mu); margin-top: 2px; }
.upd-notas { font-size: 12px; color: var(--tx); margin-top: 6px; white-space: pre-wrap; line-height: 1.5; }

.pill {
  display: inline-block; font-size: 10px; font-weight: 600; padding: 2px 7px;
  border-radius: 20px; background: var(--bd); color: var(--mu); vertical-align: 2px;
}
.pill.nu { background: var(--gr2); color: var(--gr); }

.bk-act { display: flex; gap: 6px; flex-shrink: 0; }
.bk-del { color: var(--co); padding: 5px 9px; }
.bk-del:hover { border-color: var(--co); color: var(--co); }

.diag {
  display: grid; grid-template-columns: 1fr auto; gap: 9px 16px;
  font-size: 12.5px; padding: 14px;
  background: var(--sur); border: 1px solid var(--bd); border-radius: var(--rs);
}
.diag span:nth-child(odd) { color: var(--mu); }

@media (max-width: 560px) {
  .cfg-ver, .upd-row, .bk-row { flex-direction: column; align-items: stretch; }
  .cfg-ver button, .upd-row button { width: 100%; }
}

/* Enlace de descarga dentro de las filas de copias */
a.btns { text-decoration: none; display: inline-flex; align-items: center; }

/* Categoria sin coincidencias durante una busqueda */
.tab-off { opacity: .38; cursor: default; }
.tab-off:hover { background: var(--sur); border-color: var(--bd); }

/* ── Tamano de fuente ── */
.fs-ctl { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.fs-btn { min-width: 46px; font-weight: 600; }
.fs-btn:disabled { opacity: .4; cursor: default; }
.fs-val {
  min-width: 64px; text-align: center; padding: 7px 10px;
  background: var(--sur); border: 1px solid var(--bd); border-radius: var(--rs);
}
.fs-demo {
  padding: 13px; background: var(--sur);
  border: 1px solid var(--bd); border-radius: var(--rs);
}
.fs-demo b    { display: block; margin-bottom: 4px; }
.fs-demo span { font-size: 12.5px; color: var(--mu); }

/* ── Registro de cambios ── */
.chlog {
  max-height: 340px; overflow-y: auto; padding: 14px;
  background: var(--sur); border: 1px solid var(--bd); border-radius: var(--rs);
  font-size: 12.5px; line-height: 1.65; white-space: pre-wrap;
  color: var(--mu);
}
.chlog .chv {
  display: block; margin: 14px 0 4px; font-size: 13.5px;
  color: var(--primary); font-weight: 600;
}
.chlog .chv:first-child { margin-top: 0; }

/* ── Ficha en modo lectura ── */
.card-open { cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.card-open:hover { border-color: var(--bd2); box-shadow: 0 2px 10px rgba(0,0,0,.06); }
.card-open .cact button { cursor: pointer; }
.ib.iv:hover { color: var(--primary); }

.vw-md { max-width: 560px; width: 100%; }
.vw-hd { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.vw-hd h3 { margin: 0; }
.vw-hd small { color: var(--mu); font-size: 11.5px; }
.vw-x { font-size: 15px; line-height: 1; padding: 4px 8px; }

.vw-body { margin: 16px 0 4px; }
.vrow {
  display: grid; grid-template-columns: 130px 1fr; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--bd);
}
.vrow:last-child { border-bottom: none; }
.vk { font-size: 12px; color: var(--mu); padding-top: 1px; }
.vv { display: flex; align-items: flex-start; gap: 6px; flex-wrap: wrap; font-size: 13.5px; }
.vtxt { white-space: pre-wrap; word-break: break-word; }

.btnd {
  padding: 9px 16px; font-family: inherit; font-size: 13px;
  background: var(--sur); color: var(--co);
  border: 1px solid var(--bd); border-radius: var(--rs); cursor: pointer;
  margin-right: auto;
}
.btnd:hover { border-color: var(--co); background: var(--co2); }

@media (max-width: 520px) {
  .vrow { grid-template-columns: 1fr; gap: 3px; }
}

/* ── Editor enriquecido ── */
.rich { border: 1px solid var(--bd2); border-radius: var(--rs); overflow: hidden; background: var(--sur); }
.rt {
  display: flex; align-items: center; flex-wrap: wrap; gap: 2px;
  padding: 5px 6px; background: var(--bg); border-bottom: 1px solid var(--bd);
}
.rt-b {
  min-width: 28px; height: 26px; padding: 0 6px; font-size: 12.5px;
  background: none; color: var(--mu); border: 1px solid transparent;
  border-radius: 4px; cursor: pointer; font-family: inherit; line-height: 1;
}
.rt-b:hover { background: var(--sur); border-color: var(--bd); color: var(--tx); }
.rt-sep { width: 1px; height: 16px; background: var(--bd); margin: 0 4px; }
.re {
  min-height: 150px; max-height: 380px; overflow-y: auto;
  padding: 12px 13px; font-size: 13.5px; line-height: 1.65; color: var(--tx);
  outline: none;
}
.re:focus { box-shadow: inset 0 0 0 2px var(--primary-soft); }
.re p           { margin: 0 0 8px; }
.re h3          { font-size: 15px; margin: 12px 0 6px; }
.re blockquote  { margin: 8px 0; padding-left: 12px; border-left: 3px solid var(--bd2); color: var(--mu); }
.re ul, .re ol  { margin: 6px 0; padding-left: 22px; }
.re a           { color: var(--bl); }

/* ── Adjuntos ── */
.adj-drop {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 16px; text-align: center; cursor: pointer;
  background: var(--sur); border: 1.5px dashed var(--bd2); border-radius: var(--rs);
  color: var(--mu); font-size: 12.5px; transition: border-color .15s, background .15s;
}
.adj-drop:hover, .adj-drop.over { border-color: var(--primary); background: var(--primary-soft); }
.adj-drop small { font-size: 11px; opacity: .8; }
.adj-list { margin-top: 8px; }
.adj-row {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; margin-bottom: 5px; font-size: 12.5px;
  background: var(--sur); border: 1px solid var(--bd); border-radius: var(--rs);
}
.adj-n { flex: 1; word-break: break-all; }
.adj-s { color: var(--mu); font-size: 11px; white-space: nowrap; }
.adj-load { color: var(--mu); font-style: italic; }

.adj-view { display: flex; flex-direction: column; gap: 5px; width: 100%; }
.adj-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 11px; text-decoration: none; color: var(--tx); font-size: 12.5px;
  background: var(--sur); border: 1px solid var(--bd); border-radius: var(--rs);
}
.adj-item:hover { border-color: var(--primary); color: var(--primary); }

.vrow-full { grid-template-columns: 1fr; gap: 6px; }
.vrich { font-size: 13.5px; line-height: 1.65; word-break: break-word; }
.vrich p          { margin: 0 0 8px; }
.vrich h3         { font-size: 15px; margin: 12px 0 6px; }
.vrich blockquote { margin: 8px 0; padding-left: 12px; border-left: 3px solid var(--bd2); color: var(--mu); }
.vrich ul, .vrich ol { margin: 6px 0; padding-left: 22px; }
.vrich a          { color: var(--bl); }

/* ── Summernote integrado con el tema ── */
.sn-host { min-height: 40px; }
.note-editor.note-frame {
  border: 1px solid var(--bd2); border-radius: var(--rs);
  margin-bottom: 0; background: var(--sur);
}
.note-editor.note-frame .note-toolbar {
  background: var(--bg); border-bottom: 1px solid var(--bd); padding: 5px 6px;
}
.note-editor.note-frame .note-btn {
  background: var(--sur); border-color: var(--bd); color: var(--tx);
  border-radius: 4px; font-size: 12px;
}
.note-editor.note-frame .note-btn:hover { background: var(--bg); border-color: var(--bd2); }
.note-editor.note-frame .note-btn.active { background: var(--primary-soft); color: var(--primary); }
.note-editor.note-frame .note-editing-area .note-editable {
  background: var(--sur); color: var(--tx);
  font-family: inherit; font-size: 13.5px; line-height: 1.65; padding: 12px 13px;
}
.note-editor.note-frame .note-editable img { max-width: 100%; height: auto; }
.note-editor.note-frame .note-statusbar { background: var(--bg); border-top: 1px solid var(--bd); }
.note-editor.note-frame .note-placeholder { color: var(--mu); padding: 12px 13px; }
.note-modal .modal-content { background: var(--sur); color: var(--tx); }
.note-modal .modal-header { border-bottom: 1px solid var(--bd); }
.note-modal .modal-footer { border-top: 1px solid var(--bd); }
.note-editor .note-dropdown-menu { background: var(--sur); border: 1px solid var(--bd); }
.note-editor .note-dropdown-item:hover { background: var(--bg); }
.re-plano {
  min-height: 150px; padding: 12px 13px; font-size: 13.5px; line-height: 1.65;
  border: 1px solid var(--bd2); border-radius: var(--rs); background: var(--sur); outline: none;
}
/* Las imagenes de las notas, en la ficha */
.vrich img { max-width: 100%; height: auto; border-radius: 4px; }
.vrich table { border-collapse: collapse; margin: 8px 0; }
.vrich td, .vrich th { border: 1px solid var(--bd2); padding: 5px 8px; }

/* v1.3.2 — filtros y adjuntos dentro de Summernote */
.tab-off { cursor: pointer; }
.note-editor.note-frame .note-toolbar .note-btn svg { display:block; }
.note-editor.note-frame .note-toolbar .note-btn[aria-label="Adjuntar archivo"] { min-width: 30px; }
.load-error { margin: 20px 0; line-height: 1.6; }
#ba:disabled { opacity: .55; cursor: not-allowed; }

/* ── v1.3.4 — Modo depuracion ─────────────────────────────── */
.debug-settings { margin-bottom: 18px; }
.debug-setting-row {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
}
.debug-setting-row > div { min-width: 0; }
.debug-setting-row .cfg-note { margin: 5px 0 0; }
.debug-switch { display: inline-flex; align-items: center; cursor: pointer; flex: 0 0 auto; }
.debug-switch input { position: absolute; opacity: 0; pointer-events: none; }
.debug-switch-track {
  width: 46px; height: 25px; padding: 2px; border-radius: 999px;
  background: var(--bd2); border: 1px solid var(--bd); transition: .18s ease;
  box-sizing: border-box;
}
.debug-switch-knob {
  display: block; width: 19px; height: 19px; border-radius: 50%;
  background: var(--sur); box-shadow: 0 1px 4px rgba(0,0,0,.18); transition: transform .18s ease;
}
.debug-switch input:checked + .debug-switch-track { background: var(--primary); border-color: var(--primary); }
.debug-switch input:checked + .debug-switch-track .debug-switch-knob { transform: translateX(21px); }
.debug-switch input:disabled + .debug-switch-track { opacity: .55; cursor: wait; }
.debug-cfg-state {
  margin-top: 12px; padding: 9px 11px; border: 1px solid var(--bd); border-radius: var(--rs);
  background: var(--bg); color: var(--mu); font-size: 12px;
}
.debug-cfg-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.debug-panel {
  position: fixed; z-index: 99999; right: 18px; bottom: 18px;
  width: min(570px, calc(100vw - 36px)); height: 370px;
  flex-direction: column; overflow: hidden;
  background: #171f47; color: #dce5ff;
  border: 1px solid #45508b; border-radius: 18px;
  box-shadow: 0 18px 55px rgba(5,10,35,.34);
  font-size: 12px;
}
.debug-panel::before {
  content: ''; position: absolute; inset: -1px; border-radius: 18px; pointer-events: none;
  border-bottom: 1px solid rgba(239,78,153,.65); border-right: 1px solid rgba(239,78,153,.38);
}
.debug-panel.is-expanded {
  width: min(960px, calc(100vw - 36px)); height: min(76vh, 760px);
}
.debug-panel.is-min { height: 52px; }
.debug-panel.is-min .debug-log-view { display: none; }
.debug-panel-head {
  position: relative; z-index: 1; min-height: 51px; padding: 0 13px 0 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border-bottom: 1px solid #3b4679; background: #111833;
}
.debug-panel-head strong { color: #fff; font-size: 13px; white-space: nowrap; }
.debug-panel-actions { display: flex; align-items: center; gap: 5px; }
.debug-panel-actions button {
  height: 28px; padding: 0 8px; border: 1px solid transparent; border-radius: 6px;
  background: transparent; color: #b9c4ef; font: inherit; cursor: pointer;
}
.debug-panel-actions button:hover { background: #242d5b; border-color: #3e4b83; color: #fff; }
.debug-log-view {
  position: relative; z-index: 1; flex: 1; margin: 0; padding: 13px 15px 18px;
  overflow: auto; white-space: pre-wrap; word-break: break-word;
  background: #1b2553; color: #c8d3ff; font: 11.5px/1.72 Consolas, "SFMono-Regular", Menlo, Monaco, monospace;
  scrollbar-width: thin;
}

@media (max-width: 640px) {
  .debug-panel { right: 8px; bottom: 8px; width: calc(100vw - 16px); height: 48vh; border-radius: 13px; }
  .debug-panel.is-expanded { width: calc(100vw - 16px); height: 78vh; }
  .debug-panel-head { padding: 0 8px 0 11px; }
  .debug-panel-actions button { padding: 0 6px; font-size: 10.5px; }
  .debug-setting-row { align-items: flex-start; }
}


/* ── v1.3.8 — Vista previa de adjuntos ─────────────────────── */
.adj-preview-modal { width: min(980px, calc(100vw - 32px)); max-width: 980px; }
.adj-preview-body {
  min-height: 220px; max-height: min(72vh, 720px); margin: 16px 0 4px;
  display: flex; align-items: center; justify-content: center; overflow: auto;
  background: var(--bg); border: 1px solid var(--bd); border-radius: var(--rs);
}
.adj-preview-image { display: block; max-width: 100%; max-height: 68vh; object-fit: contain; margin: auto; }
.adj-preview-frame { display: block; width: 100%; height: min(68vh, 680px); border: 0; background: #fff; }
.adj-preview-unsupported { max-width: 520px; padding: 38px 28px; text-align: center; color: var(--mu); }
.adj-preview-unsupported b { display: block; margin-bottom: 8px; color: var(--tx); font-size: 15px; }
.adj-preview-unsupported p { margin: 0; line-height: 1.6; }
.adj-preview-download { text-decoration: none; margin-right: auto; }
.vrich a, .lk { cursor: pointer; }
@media (max-width: 640px) {
  .adj-preview-modal { width: calc(100vw - 16px); }
  .adj-preview-body { max-height: 70vh; }
  .adj-preview-frame { height: 65vh; }
}

/* ── v1.3.9 — visor de adjuntos robusto ──────────────────── */
.adj-preview-loading { padding: 36px 24px; color: var(--mu); text-align: center; }
.adj-preview-text { width:100%; min-height:220px; margin:0; padding:18px; box-sizing:border-box; white-space:pre-wrap; overflow-wrap:anywhere; font:13px/1.55 ui-monospace,SFMono-Regular,Consolas,monospace; color:var(--tx); background:var(--bg); }
