/* ============ Tokens ============ */
:root {
    --bg: #F6F7F9; --surface: #FFFFFF; --surface-2: #F9FAFB;
    --border: #E9EBF1; --border-strong: #D9DCE5;
    --text: #101828; --text-2: #475467; --text-3: #98A2B3;
    --hover: #F2F4F7; --row-hover: #FAFBFD;
  
    --brand: #465FFF; --t-brand: #3541E3;
    --purple: #7A5AF8; --t-purple: #6941C6;
    --blue: #4A6FF3;  --t-blue: #2C4FD8;
    --warn: #F79009;  --t-warn: #B54708;
    --green: #12B76A;  --t-green: #027948;
    --red: #F04438;   --t-red: #B42318;
    --cyan: #0E9384;  --t-cyan: #087443;
  
    --wa-me: #D9FDD3; --wa-me-t: #12261C;
    --shadow: 0 14px 38px -14px rgba(16,24,40,.18);
    --r: 12px;
  }
  .dark {
    --bg: #0D1017; --surface: #141926; --surface-2: #1A2030;
    --border: #242C3D; --border-strong: #33405C;
    --text: #F0F2F5; --text-2: #A5ADC1; --text-3: #6A7385;
    --hover: #1B2233; --row-hover: #181F2E;
  
    --t-brand: #94A3FF; --t-purple: #BCA5FF; --t-blue: #99ADFF;
    --t-warn: #FDBA68; --t-green: #62D39B; --t-red: #F98F87; --t-cyan: #5BC9BE;
  
    --wa-me: #005C4B; --wa-me-t: #DFF6E5;
    --shadow: 0 14px 38px -14px rgba(0,0,0,.6);
  }
  html.theming, html.theming * { transition: background-color .28s ease, border-color .28s ease, color .28s ease, fill .28s ease, box-shadow .28s ease !important; }
  * { margin: 0; box-sizing: border-box; }
  html, body { height: 100%; }
  body { font-family: 'Outfit', sans-serif; font-size: 14px; color: var(--text); background: var(--bg); overflow-x: hidden; }
  button { font-family: inherit; cursor: pointer; }
  ::selection { background: color-mix(in srgb, var(--brand) 22%, transparent); }
  :focus-visible { outline: 2px solid var(--t-brand); outline-offset: 2px; border-radius: 6px; }
  ::-webkit-scrollbar { width: 9px; height: 9px; }
  ::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }
  ::-webkit-scrollbar-track { background: transparent; }
  .num { font-variant-numeric: tabular-nums; }
  
  /* ============ Layout ============ */
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 290px; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; z-index: 60; transition: transform .3s ease; }
  .content { margin-left: 290px; min-height: 100vh; display: flex; flex-direction: column; }
  #scrim { display: none; position: fixed; inset: 0; background: rgba(13,17,25,.5); z-index: 55; }
  
  /* ============ Sidebar ============ */
  .side-brand { display: flex; align-items: center; justify-content: space-between; padding: 30px 20px 24px; }
  .brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-size: 17px; font-weight: 600; letter-spacing: -.2px; }
  .side-close { display: none; }
  .side-scroll { flex: 1; overflow-y: auto; padding: 0 14px 24px; }
  .side-label { font-size: 11px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); margin: 22px 8px 10px; }
  
  .menu-item {
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    padding: 7px 8px;
    border: 0;
    background: none;
    border-radius: 8px;
    color: var(--text-2);
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    transition: background .15s, color .15s;
    text-decoration: none;
  }

  .menu-item:hover { background: var(--hover); color: var(--text); }
  .menu-item.active { background: var(--hover); color: var(--text); font-weight: 600; }
  .mi-ic { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; flex: none; }
  .mi-ic svg { width: 18px; height: 18px; stroke-width: 1.8; }
  .ic-brand { background: color-mix(in srgb, var(--brand) 11%, transparent); color: var(--t-brand); }
  .ic-purple { background: color-mix(in srgb, var(--purple) 11%, transparent); color: var(--t-purple); }
  .ic-blue { background: color-mix(in srgb, var(--blue) 11%, transparent); color: var(--t-blue); }
  .ic-warn { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--t-warn); }
  .ic-green { background: color-mix(in srgb, var(--green) 13%, transparent); color: var(--t-green); }
  .ic-gray { background: var(--surface-2); color: var(--text-3); }
  .menu-item .chev { margin-left: auto; width: 18px; height: 18px; color: var(--text-3); transition: transform .25s ease; flex: none; }
  .menu-item .chev svg { width: 18px; height: 18px; }
  .menu-group.open > .menu-item .chev { transform: rotate(180deg); }
  .menu-group.has-active > .menu-item { color: var(--text); }
  .soon { margin-left: auto; font-size: 10px; font-weight: 600; color: var(--t-purple); background: color-mix(in srgb, var(--purple) 11%, transparent); padding: 2px 8px; border-radius: 99px; flex: none; }
  .submenu { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .3s ease; }
  .menu-group.open .submenu { grid-template-rows: 1fr; }
  .submenu ul { overflow: hidden; list-style: none; margin-left: 18px; padding-left: 14px; border-left: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }
  
  .sub-item {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 6px 8px;
    border: 0;
    background: none;
    border-radius: 7px;
    color: var(--text-2);
    font-size: 13.5px;
    text-align: left;
    transition: background .15s, color .15s;
    text-decoration: none;
  }
  
  .sub-item svg { width: 16px; height: 16px; opacity: .7; flex: none; }
  .sub-item:hover { color: var(--text); background: var(--hover); }
  .sub-item.active { color: var(--t-brand); background: color-mix(in srgb, var(--brand) 9%, transparent); font-weight: 600; }
  .sub-item.active svg { opacity: 1; }
  @keyframes pulse { 50% { opacity: .35; } }
  
  /* ============ Topbar ============ */
  .topbar { position: sticky; top: 0; z-index: 50; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 14px; height: 72px; padding: 0 28px; }
  .tb-btn { display: none; width: 42px; height: 42px; border: 1px solid var(--border); border-radius: 10px; background: none; color: var(--text-2); place-items: center; }
  .tb-btn svg { width: 18px; height: 18px; }
  .searchbar { display: flex; align-items: center; gap: 10px; height: 44px; width: 430px; max-width: 52vw; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); padding: 0 6px 0 13px; color: var(--text-3); transition: border-color .15s, box-shadow .15s; }
  .searchbar:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 14%, transparent); }
  .searchbar svg { width: 17px; height: 17px; flex: none; }
  .searchbar input { flex: 1; min-width: 0; border: 0; background: none; outline: none; font: inherit; font-size: 14px; color: var(--text); }
  .searchbar input::placeholder { color: var(--text-3); }
  .kbd { font-family: ui-monospace, monospace; font-size: 11px; color: var(--text-3); border: 1px solid var(--border); background: var(--surface-2); border-radius: 6px; padding: 3px 7px; white-space: nowrap; }
  .tb-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
  
  .tb-round { width: 44px; height: 44px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); display: grid; place-items: center; transition: background .15s, color .15s; }
  .tb-round:hover { background: var(--hover); color: var(--text); }
  .tb-round svg { width: 19px; height: 19px; }
  
  .avatar { width: 38px; height: 38px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); font-size: 12.5px; font-weight: 600; display: grid; place-items: center; flex: none; }
  .avatar.lg { width: 56px; height: 56px; font-size: 17px; }
  .avatar.sm { width: 26px; height: 26px; font-size: 10px; }
  button.avatar { cursor: pointer; transition: border-color .15s, color .15s, background .15s; }
  button.avatar:hover { border-color: var(--border-strong); color: var(--text); background: var(--hover); }

  /* ✅ AJUSTES PARA QUE EL AVATAR DEL TOPBAR SEA DEL MISMO TAMAÑO QUE EL BOTÓN DE TEMA */
  .tb-user .avatar {
    width: 44px;
    height: 44px;
  }
  .tb-user .avatar svg {
    width: 20px;
    height: 20px;
  }
  .um-head .avatar {
    width: 40px;
    height: 40px;
    font-size: 0; /* Oculta texto residual si lo hubiera */
  }
  .um-head .avatar svg {
    width: 20px;
    height: 20px;
  }
  
  /* menú de usuario (avatar) */
  .tb-user { position: relative; }
  .user-menu { position: absolute; right: 0; top: calc(100% + 10px); width: 250px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; opacity: 0; visibility: hidden; transform: translateY(-5px); transition: opacity .16s ease, transform .16s ease, visibility .16s; z-index: 80; }
  .user-menu.open { opacity: 1; visibility: visible; transform: none; }
  .um-head { display: flex; align-items: center; gap: 12px; padding: 12px 12px 14px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
  .um-head b { font-size: 13.5px; font-weight: 600; display: block; }
  .um-head span { font-size: 12px; color: var(--text-3); }
  .um-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; background: none; border-radius: 8px; font: 500 13.5px 'Outfit'; color: var(--text-2); text-align: left; transition: background .15s, color .15s; }
  .um-item:hover { background: var(--hover); color: var(--text); }
  .um-item svg { width: 16px; height: 16px; }
  
  /* ============ Page ============ */
  .page { width: 100%; max-width: 1240px; margin: 0 auto; padding: 28px 32px 80px; }
  .page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; flex-wrap: wrap; margin-bottom: 22px; }
  .page-head h1 { font-size: 24px; font-weight: 600; letter-spacing: -.3px; }
  .sub { margin-top: 4px; color: var(--text-2); font-size: 13.5px; }
  .head-actions { display: flex; gap: 10px; align-items: center; }
  
  /* ============ Buttons ============ */
  .btn { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 9px; border: 1px solid transparent; font-size: 13.5px; font-weight: 600; transition: background .15s, border-color .15s, transform .06s; }
  .btn:active { transform: translateY(1px); }
  .btn svg { width: 16px; height: 16px; stroke-width: 2; }
  .btn-primary { background: var(--brand); color: #fff; }
  .btn-primary:hover { background: color-mix(in srgb, var(--brand) 88%, #000); }
  .btn-ghost { background: var(--surface); border-color: var(--border-strong); color: var(--text-2); }
  .btn-ghost:hover { color: var(--text); background: var(--hover); }
  .btn-danger { background: transparent; border-color: color-mix(in srgb, var(--red) 40%, transparent); color: var(--t-red); }
  .btn-danger:hover { background: color-mix(in srgb, var(--red) 9%, transparent); }
  .btn-sm { height: 33px; padding: 0 12px; font-size: 12.5px; border-radius: 8px; }
  .btn-sm svg { width: 14px; height: 14px; }
  
  /* ============ Toolbar ============ */
  .toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
  .search { display: flex; align-items: center; gap: 9px; height: 40px; width: 280px; max-width: 100%; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface); padding: 0 12px; color: var(--text-3); transition: border-color .15s, box-shadow .15s; }
  .search:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 14%, transparent); }
  .search svg { width: 15px; height: 15px; flex: none; }
  .search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; font: inherit; font-size: 13.5px; color: var(--text); }
  .search input::placeholder { color: var(--text-3); }
  .sel { position: relative; display: inline-flex; }
  .sel::after { content: ""; position: absolute; right: 12px; top: 50%; width: 7px; height: 7px; border-right: 1.7px solid var(--text-3); border-bottom: 1.7px solid var(--text-3); transform: translateY(-70%) rotate(45deg); pointer-events: none; }
  .sel select { appearance: none; height: 40px; border: 1px solid var(--border-strong); background: var(--surface); border-radius: 9px; font: 500 13.5px 'Outfit'; color: var(--text-2); padding: 0 32px 0 13px; cursor: pointer; }
  .sel select:hover { color: var(--text); }
  .count-line { width: 100%; font-size: 12.5px; color: var(--text-3); margin-bottom: 12px; }
  
  /* ============ Cards & tables ============ */
  .card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); }
  .table-wrap { overflow-x: auto; }
  table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
  th { font-size: 12px; font-weight: 500; color: var(--text-3); text-align: left; padding: 12px 22px; border-bottom: 1px solid var(--border); white-space: nowrap; }
  th[data-sort] { cursor: pointer; user-select: none; }
  th[data-sort]:hover { color: var(--text-2); }
  .sort-ind { display: inline-block; width: 12px; text-align: center; opacity: 0; font-size: 9px; }
  th.sorted .sort-ind { opacity: 1; }
  td { padding: 13px 22px; border-bottom: 1px solid var(--border); vertical-align: middle; }
  tbody tr { transition: background .12s; }
  tbody tr:hover { background: var(--row-hover); }
  tbody tr:last-child td { border-bottom: 0; }
  .cell-name { display: flex; align-items: center; gap: 11px; min-width: 200px; }
  .cell-name b { font-weight: 600; font-size: 13.5px; }
  .cell-name button { border: 0; background: none; padding: 0; font: inherit; color: var(--text); text-align: left; }
  .cell-name button:hover { color: var(--t-brand); }
  .phone { color: var(--text-2); white-space: nowrap; }
  .row-actions { display: flex; gap: 16px; justify-content: flex-end; white-space: nowrap; }
  .act { border: 0; background: none; padding: 0; font-size: 13px; font-weight: 500; color: var(--text-2); border-radius: 4px; }
  .act:hover { color: var(--t-brand); }
  .act.danger:hover { color: var(--t-red); }
  .badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; padding: 2px 10px; border-radius: 99px; white-space: nowrap; }
  .badge::before { content: ""; width: 5px; height: 5px; border-radius: 99px; background: currentColor; }
  .b-brand { background: color-mix(in srgb, var(--brand) 10%, transparent); color: var(--t-brand); }
  .b-gray { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
  .b-warn { background: color-mix(in srgb, var(--warn) 13%, transparent); color: var(--t-warn); }
  .b-purple { background: color-mix(in srgb, var(--purple) 10%, transparent); color: var(--t-purple); }
  .b-green { background: color-mix(in srgb, var(--green) 12%, transparent); color: var(--t-green); }
  .b-red { background: color-mix(in srgb, var(--red) 10%, transparent); color: var(--t-red); }
  .b-blue { background: color-mix(in srgb, var(--blue) 10%, transparent); color: var(--t-blue); }
  .empty { padding: 56px 20px; text-align: center; }
  .empty svg { width: 28px; height: 28px; color: var(--text-3); margin-bottom: 10px; }
  .empty b { display: block; font-size: 15px; margin-bottom: 4px; }
  .empty p { color: var(--text-3); font-size: 13px; margin-bottom: 16px; }
  .chip { display: inline-block; font-size: 11.5px; font-weight: 500; padding: 2px 9px; border-radius: 99px; margin: 1px 2px 1px 0; white-space: nowrap; }
  
  /* ============ Formularios (página completa, nunca modal) ============ */
  .backlink { display: inline-flex; align-items: center; gap: 7px; border: 0; background: none; color: var(--text-2); font-size: 13px; font-weight: 600; padding: 0; margin-bottom: 18px; }
  .backlink:hover { color: var(--t-brand); }
  .backlink svg { width: 15px; height: 15px; }
  .form-card { padding: 26px 28px; }
  .form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 20px; }
  .span2 { grid-column: 1 / -1; }
  .field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
  .field label { font-size: 13px; font-weight: 500; color: var(--text-2); }
  .field input, .field select, .field textarea, .qadd input { height: 42px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface); padding: 0 13px; font: 400 14px 'Outfit'; color: var(--text); width: 100%; transition: border-color .15s, box-shadow .15s; }
  .field textarea { height: auto; min-height: 88px; padding: 11px 13px; resize: vertical; line-height: 1.55; }
  .field input:focus, .field select:focus, .field textarea:focus, .qadd input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 14%, transparent); }
  .field.err input, .field.err select { border-color: var(--red); }
  .field .msg { display: none; font-size: 11.5px; color: var(--t-red); }
  .field.err .msg { display: block; }
  .fsel { position: relative; }
  .fsel::after { content: ""; position: absolute; right: 13px; top: 19px; width: 7px; height: 7px; border-right: 1.7px solid var(--text-3); border-bottom: 1.7px solid var(--text-3); transform: rotate(45deg); pointer-events: none; }
  .fsel select { appearance: none; padding-right: 34px; }
  .form-foot { display: flex; align-items: center; gap: 10px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }
  .form-foot .spacer { flex: 1; }
  .tagpick { display: flex; flex-wrap: wrap; gap: 8px; padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: 9px; min-height: 42px; align-items: center; }
  .tagpick .chip { cursor: pointer; border: 1.5px solid transparent; opacity: .6; transition: opacity .15s; }
  .tagpick .chip.on { opacity: 1; border-color: currentColor; }
  
  /* ============ Detalle de organización ============ */
  .detail-head { display: flex; align-items: flex-start; gap: 18px; flex-wrap: wrap; margin-bottom: 22px; }
  .detail-head h1 { font-size: 22px; font-weight: 600; letter-spacing: -.3px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
  .kv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px 24px; padding: 22px 26px; }
  .kv dt { font-size: 11.5px; color: var(--text-3); margin-bottom: 4px; }
  .kv dd { font-size: 13.5px; font-weight: 500; }
  .card-h { display: flex; align-items: center; justify-content: space-between; padding: 16px 26px; border-bottom: 1px solid var(--border); font-size: 14px; font-weight: 600; }
  .card-b { padding: 8px 12px; }
  .rel-row { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 9px; transition: background .12s; }
  .rel-row:hover { background: var(--hover); }
  .rel-row .grow { flex: 1; min-width: 0; }
  .rel-row b { font-size: 13.5px; font-weight: 600; display: block; }
  .rel-row span { font-size: 12.5px; color: var(--text-3); }
  .note { padding: 16px 26px; font-size: 13.5px; color: var(--text-2); line-height: 1.65; white-space: pre-wrap; }
  
  /* ============ Panel ============ */
  .stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 18px; }
  .stat { padding: 20px 22px; }
  .stat .top { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
  .stat .top span { font-size: 12.5px; color: var(--text-3); font-weight: 500; }
  .stat .big { font-size: 26px; font-weight: 600; letter-spacing: -.5px; line-height: 1.1; }
  .stat .delta { margin-top: 7px; font-size: 12px; color: var(--t-green); font-weight: 500; }
  .dash-grid { display: grid; grid-template-columns: 3fr 2fr; gap: 16px; }
  .mini-row { display: flex; align-items: center; gap: 11px; padding: 10px 14px; border-radius: 9px; }
  .mini-row:hover { background: var(--hover); }
  .mini-row .grow { flex: 1; min-width: 0; }
  .mini-row b { font-size: 13px; font-weight: 600; display: block; }
  .mini-row span { font-size: 12px; color: var(--text-3); }
  .mini-table { padding: 6px 10px; }
  .view-all { border: 0; background: none; color: var(--t-brand); font-size: 12.5px; font-weight: 600; padding: 4px; }
  .view-all:hover { text-decoration: underline; }
  
  /* ============ Kanban (negocios) ============ */
  .kanban { display: flex; gap: 14px; align-items: flex-start; overflow-x: auto; padding-bottom: 10px; }
  .kcol { flex: 1; min-width: 225px; border-radius: 12px; }
  .kcol.over { background: color-mix(in srgb, var(--brand) 6%, transparent); outline: 2px dashed color-mix(in srgb, var(--brand) 45%, transparent); outline-offset: 6px; }
  .kcol-h { display: flex; align-items: center; gap: 8px; padding: 6px 10px 12px; font-size: 13px; font-weight: 600; }
  .kcol-h .n { font-size: 11px; font-weight: 600; color: var(--text-3); background: var(--surface-2); border: 1px solid var(--border); border-radius: 99px; padding: 1px 8px; }
  .kcol-h .sum { margin-left: auto; font-size: 11.5px; color: var(--text-3); font-weight: 500; }
  .kstack { display: flex; flex-direction: column; gap: 10px; min-height: 60px; }
  .kcard { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 13px 14px; cursor: grab; transition: box-shadow .15s, border-color .15s; }
  .kcard:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
  .kcard.dragging { opacity: .45; cursor: grabbing; }
  .kcard b { font-size: 13.5px; font-weight: 600; display: block; margin-bottom: 3px; }
  .kcard .org { font-size: 12.5px; color: var(--text-3); margin-bottom: 11px; }
  .kcard .foot { display: flex; align-items: center; gap: 8px; }
  .kcard .val { font-size: 14px; font-weight: 600; }
  .kcard .date { margin-left: auto; font-size: 11px; color: var(--text-3); }
  
  /* ============ Tareas ============ */
  .task-prog { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
  .task-prog .bar { flex: 1; height: 6px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 99px; overflow: hidden; }
  .task-prog .bar i { display: block; height: 100%; background: var(--brand); border-radius: 99px; transition: width .3s; }
  .task-prog .p { font-size: 12px; color: var(--text-3); }
  .trow { display: flex; align-items: center; gap: 13px; padding: 13px 22px; border-bottom: 1px solid var(--border); }
  .trow:last-of-type { border-bottom: 0; }
  .trow.done .tt { color: var(--text-3); text-decoration: line-through; }
  .tk { width: 19px; height: 19px; border: 1.6px solid var(--border-strong); border-radius: 6px; background: var(--surface); display: grid; place-items: center; flex: none; transition: background .15s, border-color .15s; }
  .tk svg { width: 12px; height: 12px; color: #fff; stroke-width: 3; opacity: 0; transition: opacity .15s; }
  .trow.done .tk { background: var(--brand); border-color: var(--brand); }
  .trow.done .tk svg { opacity: 1; }
  .tt { flex: 1; font-size: 13.5px; min-width: 0; }
  .tt span { color: var(--text-3); font-size: 12.5px; }
  .due { font-size: 11.5px; font-weight: 500; color: var(--text-2); border: 1px solid var(--border); border-radius: 99px; padding: 2px 10px; white-space: nowrap; }
  .due.today { color: var(--t-warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
  .due.over { color: var(--t-red); border-color: color-mix(in srgb, var(--red) 45%, transparent); }
  .qadd { display: flex; align-items: center; gap: 10px; padding: 13px 22px; border-top: 1px solid var(--border); }
  .qadd svg { width: 16px; height: 16px; color: var(--text-3); flex: none; }
  .qadd input { flex: 1; border: 0; background: none; outline: none; font: inherit; font-size: 13.5px; color: var(--text); }
  .qadd input::placeholder { color: var(--text-3); }
  
  /* ============ Bandeja de entrada ============ */
  .inbox { display: grid; grid-template-columns: 330px 1fr; min-height: 600px; }
  .chat-list { border-right: 1px solid var(--border); overflow-y: auto; max-height: 640px; }
  .chat-item { display: flex; gap: 11px; width: 100%; padding: 13px 16px; border: 0; background: none; text-align: left; border-bottom: 1px solid var(--border); transition: background .12s; }
  .chat-item:hover { background: var(--hover); }
  .chat-item.active { background: color-mix(in srgb, var(--brand) 7%, transparent); }
  .chat-item .grow { flex: 1; min-width: 0; }
  .chat-item b { font-size: 13.5px; font-weight: 600; display: flex; justify-content: space-between; gap: 8px; }
  .chat-item b time { font-size: 10.5px; color: var(--text-3); font-weight: 500; flex: none; }
  .chat-item p { font-size: 12.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
  .unread-n { flex: none; background: var(--green); color: #fff; font-size: 10.5px; font-weight: 700; border-radius: 99px; min-width: 18px; height: 18px; display: grid; place-items: center; padding: 0 5px; align-self: center; }
  .chat-pane { display: flex; flex-direction: column; min-width: 0; }
  .chat-top { display: flex; align-items: center; gap: 12px; padding: 13px 20px; border-bottom: 1px solid var(--border); }
  .chat-top b { font-size: 14px; font-weight: 600; display: block; }
  .chat-top span { font-size: 11.5px; color: var(--t-green); display: flex; align-items: center; gap: 5px; }
  .chat-top span::before { content: ""; width: 6px; height: 6px; border-radius: 99px; background: var(--green); }
  .chat-top .btn { margin-left: auto; }
  .msgs { flex: 1; overflow-y: auto; max-height: 470px; padding: 20px; display: flex; flex-direction: column; gap: 8px; background: var(--surface-2); }
  .msg { max-width: 68%; padding: 8px 13px; border-radius: 12px; font-size: 13.5px; line-height: 1.45; position: relative; }
  .msg time { display: block; font-size: 10px; opacity: .55; margin-top: 3px; }
  .msg .rr { width: 14px; height: 14px; color: var(--t-blue); vertical-align: -2px; margin-left: 4px; }
  .msg:not(.me) { background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; align-self: flex-start; }
  .msg.me { background: var(--wa-me); color: var(--wa-me-t); border-bottom-right-radius: 4px; align-self: flex-end; }
  .typing { display: inline-flex; gap: 4px; padding: 12px 14px; }
  .typing i { width: 6px; height: 6px; border-radius: 99px; background: var(--text-3); animation: tp 1s infinite; }
  .typing i:nth-child(2) { animation-delay: .15s; }
  .typing i:nth-child(3) { animation-delay: .3s; }
  @keyframes tp { 50% { opacity: .25; transform: translateY(-2px); } }
  .chat-form { display: flex; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--border); }
  .chat-form input { flex: 1; height: 40px; border: 1px solid var(--border-strong); border-radius: 99px; background: var(--surface); padding: 0 16px; font: inherit; font-size: 13.5px; color: var(--text); outline: none; }
  .chat-form input:focus { border-color: var(--brand); }
  
  /* ============ Importar / Conexión / Calendario ============ */
  .dropzone { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 44px 20px; border: 1.5px dashed var(--border-strong); border-radius: var(--r); color: var(--text-3); cursor: pointer; text-align: center; transition: border-color .15s, background .15s; }
  .dropzone:hover, .dropzone.over { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 4%, transparent); }
  .dropzone svg { width: 30px; height: 30px; margin-bottom: 6px; }
  .dropzone b { color: var(--text); }
  .dropzone small { font-size: 12px; }
  .file-row { display: flex; align-items: center; gap: 11px; padding: 10px 14px; border: 1px solid var(--border); border-radius: 9px; margin-top: 10px; font-size: 13px; }
  .file-row svg { width: 16px; height: 16px; color: var(--t-brand); }
  .file-row .grow { flex: 1; min-width: 0; }
  .file-row span { color: var(--text-3); font-size: 12px; }
  .file-row button { border: 0; background: none; color: var(--text-3); display: grid; place-items: center; }
  .file-row button:hover { color: var(--t-red); }
  .conn { max-width: 520px; margin: 0 auto; text-align: center; padding: 34px 32px; }
  .conn .st { display: inline-flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 600; margin-bottom: 22px; }
  .conn .st i { width: 10px; height: 10px; border-radius: 99px; background: var(--red); }
  .conn .st.on i { background: var(--green); }
  .conn .st.w i { background: var(--warn); animation: pulse 1s infinite; }
  .qr { width: 210px; height: 210px; margin: 0 auto 20px; border: 1px solid var(--border); border-radius: 14px; padding: 16px; background: #fff; }
  .steps { text-align: left; margin: 8px 0 24px; display: flex; flex-direction: column; gap: 12px; }
  .step { display: flex; gap: 13px; font-size: 13.5px; color: var(--text-2); line-height: 1.5; }
  .step b { width: 24px; height: 24px; border-radius: 99px; background: color-mix(in srgb, var(--brand) 10%, transparent); color: var(--t-brand); font-size: 12px; display: grid; place-items: center; flex: none; margin-top: 1px; }
  .cal-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
  .cal-head h2 { font-size: 16px; font-weight: 600; flex: 1; }
  .cal-nav { width: 34px; height: 34px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); color: var(--text-2); display: grid; place-items: center; }
  .cal-nav:hover { background: var(--hover); color: var(--text); }
  .cal-nav svg { width: 15px; height: 15px; }
  .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; padding: 18px; }
  .cal-dow { font-size: 11px; font-weight: 600; color: var(--text-3); text-align: center; padding: 6px 0; text-transform: uppercase; letter-spacing: .05em; }
  .cal-day { aspect-ratio: 1.25; border-radius: 9px; padding: 7px 9px; font-size: 12.5px; color: var(--text-2); display: flex; flex-direction: column; gap: 5px; min-height: 62px; }
  .cal-day:not(.blank):not(.out):hover { background: var(--hover); }
  .cal-day.today { background: var(--brand); color: #fff; font-weight: 600; }
  .cal-day .n { font-size: 12.5px; }
  .ev { width: 6px; height: 6px; border-radius: 99px; display: inline-block; margin-right: 3px; }
  .cal-legend { display: flex; gap: 18px; padding: 0 20px 18px; font-size: 12px; color: var(--text-3); }
  .cal-legend i { width: 7px; height: 7px; border-radius: 99px; display: inline-block; margin-right: 6px; }
  
  /* ============ Etiquetas / Ajustes / IA ============ */
  .tag-new { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 16px 20px; margin-bottom: 16px; }
  .tag-new input { flex: 1; min-width: 180px; }
  .swatches { display: flex; gap: 7px; }
  .sw { width: 24px; height: 24px; border-radius: 99px; border: 2px solid transparent; cursor: pointer; transition: transform .1s; }
  .sw:hover { transform: scale(1.12); }
  .sw.on { border-color: var(--text); box-shadow: 0 0 0 2px var(--surface) inset; }
  .tag-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
  .tag-card { padding: 16px 18px; display: flex; align-items: center; gap: 12px; }
  .tag-card i.dot { width: 11px; height: 11px; border-radius: 99px; flex: none; }
  .tag-card b { font-size: 14px; }
  .tag-card span { display: block; font-size: 12px; color: var(--text-3); margin-top: 2px; }
  .tag-card .icon-btn { margin-left: auto; }
  .icon-btn { width: 30px; height: 30px; border-radius: 7px; border: 0; background: none; color: var(--text-3); display: grid; place-items: center; }
  .icon-btn:hover { background: var(--hover); color: var(--t-red); }
  .icon-btn svg { width: 15px; height: 15px; }
  .set-grid { display: grid; grid-template-columns: 1fr; gap: 16px; max-width: 720px; }
  .theme-opts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 20px 26px; }
  .theme-opt { border: 1.5px solid var(--border-strong); border-radius: 12px; padding: 12px; background: none; display: flex; flex-direction: column; gap: 10px; font: inherit; color: var(--text-2); transition: border-color .15s; }
  .theme-opt:hover { border-color: var(--t-brand); }
  .theme-opt.on { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
  .theme-opt .prev { height: 54px; border-radius: 8px; overflow: hidden; display: flex; border: 1px solid var(--border); }
  .prev .ps { width: 22%; background: #E9EAF0; }
  .prev .pb { flex: 1; padding: 6px; display: flex; flex-direction: column; gap: 4px; }
  .prev .pb i { display: block; height: 6px; border-radius: 3px; background: #E9EAF0; }
  .prev .pb i:first-child { width: 70%; }
  .prev.light { background: #FDFDFE; }
  .prev.dark .ps { background: #1C2333; }
  .prev.dark { background: #12172A; }
  .prev.dark .pb i { background: #232C44; }
  .prev.split .ps { background: linear-gradient(90deg, #E9EAF0 50%, #1C2333 50%); }
  .prev.split { background: linear-gradient(90deg, #FDFDFE 50%, #12172A 50%); }
  .prev.split .pb { background: none; }
  .prev.split .pb i { background: linear-gradient(90deg, #E9EAF0 50%, #232C44 50%); }
  .theme-opt b { font-size: 13px; }
  .soon-wrap { max-width: 460px; margin: 48px auto; text-align: center; padding: 44px 36px; }
  .soon-ic { width: 60px; height: 60px; border-radius: 18px; background: color-mix(in srgb, var(--purple) 12%, transparent); color: var(--t-purple); display: grid; place-items: center; margin: 0 auto 18px; }
  .soon-ic svg { width: 27px; height: 27px; }
  .soon-wrap h2 { font-size: 19px; margin-bottom: 6px; display: inline-flex; align-items: center; gap: 10px; }
  .soon-wrap p { color: var(--text-2); font-size: 13.5px; line-height: 1.65; margin-bottom: 22px; }

  /* ============ Toasts Flotantes ============ */
  #toasts {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 380px;
    pointer-events: none;
  }

  #toasts .toast {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 14px 16px;
    font-size: 13.5px;
    color: var(--text);
    animation: tin .3s cubic-bezier(.2,.9,.3,1.1);
    transition: all .3s ease;
  }

  #toasts .toast svg {
    width: 18px;
    height: 18px;
    flex: none;
  }

  #toasts .toast.success {
    background: color-mix(in srgb, var(--green) 6%, var(--surface));
    border-color: color-mix(in srgb, var(--green) 20%, var(--border));
  }
  #toasts .toast.success svg { color: var(--t-green); }

  #toasts .toast.error {
    background: color-mix(in srgb, var(--red) 6%, var(--surface));
    border-color: color-mix(in srgb, var(--red) 20%, var(--border));
  }
  #toasts .toast.error svg { color: var(--t-red); }

  #toasts .toast.warning {
    background: color-mix(in srgb, var(--warn) 6%, var(--surface));
    border-color: color-mix(in srgb, var(--warn) 20%, var(--border));
  }
  #toasts .toast.warning svg { color: var(--t-warn); }

  #toasts .toast.info {
    background: color-mix(in srgb, var(--brand) 6%, var(--surface));
    border-color: color-mix(in srgb, var(--brand) 20%, var(--border));
  }
  #toasts .toast.info svg { color: var(--t-brand); }

  .toast-close {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-3);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: background .15s, color .15s;
    display: grid;
    place-items: center;
    opacity: 0.6;
  }
  .toast-close:hover {
    background: var(--hover);
    color: var(--text);
    opacity: 1;
  }
  .toast-close svg {
    width: 16px;
    height: 16px;
    margin: 0;
  }

  #toasts .toast.out {
    animation: tout .25s forwards;
  }

  @keyframes tin {
    from { opacity: 0; transform: translateY(16px) scale(.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
  }

  @keyframes tout {
    to { opacity: 0; transform: translateY(-8px) scale(.98); margin-bottom: -60px; }
  }

  /* ============ Alertas en línea (Para formularios o página) ============ */
  .alert {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 18px;
    border-radius: 10px;
    font-size: 13.5px;
    border: 1px solid transparent;
    margin-bottom: 20px;
    line-height: 1.5;
  }
  .alert svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }

  .alert-success { 
    background: color-mix(in srgb, var(--green) 8%, transparent); 
    border-color: color-mix(in srgb, var(--green) 20%, transparent); 
    color: var(--t-green); 
  }
  .alert-success svg { color: var(--t-green); }

  .alert-error { 
    background: color-mix(in srgb, var(--red) 8%, transparent); 
    border-color: color-mix(in srgb, var(--red) 20%, transparent); 
    color: var(--t-red); 
  }
  .alert-error svg { color: var(--t-red); }

  .alert-warning { 
    background: color-mix(in srgb, var(--warn) 8%, transparent); 
    border-color: color-mix(in srgb, var(--warn) 20%, transparent); 
    color: var(--t-warn); 
  }
  .alert-warning svg { color: var(--t-warn); }

  /* ============ Login Layout ============ */
  .login-layout {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: var(--bg);
    padding: 20px;
  }
  .login-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 32px;
  }
  .login-header {
    text-align: center;
    margin-bottom: 28px;
  }
  .login-header .brand {
    justify-content: center;
    font-size: 20px;
    margin-bottom: 8px;
    display: inline-flex;
  }
  .login-header p {
    color: var(--text-2);
    font-size: 14px;
  }
  .login-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 13px;
    color: var(--text-3);
  }
  .login-footer a {
    color: var(--t-brand);
    text-decoration: none;
    font-weight: 500;
  }
  .login-footer a:hover {
    text-decoration: underline;
  }
  
  /* ============ Responsive ============ */
  @media (max-width: 1023px) {
    .sidebar { transform: translateX(-102%); }
    body.side-open .sidebar { transform: none; }
    body.side-open #scrim { display: block; }
    .content { margin-left: 0; }
    .tb-btn { display: grid; }
    .side-close { display: grid; width: 36px; height: 36px; border: 1px solid var(--border); border-radius: 8px; background: none; color: var(--text-2); place-items: center; }
    .searchbar { flex: 1; max-width: none; }
    .kbd { display: none; }
  }
  @media (max-width: 860px) {
    .form-grid { grid-template-columns: 1fr; }
    .dash-grid { grid-template-columns: 1fr; }
    .inbox { grid-template-columns: 1fr; }
    .chat-list { max-height: 260px; border-right: 0; border-bottom: 1px solid var(--border); }
    .page { padding: 22px 18px 70px; }
  }




  /* ============ Scrollbar Super Fino para el Sidebar ============ */
.side-scroll::-webkit-scrollbar {
  width: 4px; /* Grosor ultra fino */
}

.side-scroll::-webkit-scrollbar-track {
  background: transparent; /* Fondo invisible */
}

.side-scroll::-webkit-scrollbar-thumb {
  background: var(--border-strong); /* Color sutil */
  border-radius: 99px;
}

/* Opcional: se hace un poquito más visible solo cuando pasas el mouse por encima */
.side-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--text-3);
}