/* =========================================================
   WhatsApp Dashboard — estilo GoHighLevel
   ========================================================= */
:root {
  --bg:           #f4f6f8;
  --panel:        #ffffff;
  --border:       #e6e9ef;
  --border-soft:  #eef1f5;
  --text:         #1c2434;
  --text-soft:    #5b6577;
  --text-mute:    #9aa3b2;
  --brand:        #2f6df6;   /* azul GHL */
  --brand-dark:   #1f54cc;
  --wa:           #25d366;   /* verde WhatsApp */
  --wa-bubble:    #e7ffdb;   /* burbuja saliente */
  --in-bubble:    #ffffff;
  --rail:         #16203a;   /* navy oscuro del rail */
  --rail-soft:    #28324d;
  --read:         #34b7f1;   /* ticks leídos */
  --danger:       #e5484d;
  --shadow:       0 1px 3px rgba(18,28,45,.08), 0 4px 16px rgba(18,28,45,.06);
  --radius:       12px;
  --thread-bg:    #efeae2;
  --thread-tint:  rgba(239,234,226,.96);
  --hover:        #f9fafc;
  --active:       #eef4ff;
  --input-bg:     #ffffff;
}

/* ============ TEMA OSCURO ============ */
[data-theme="dark"] {
  --bg:           #0d1420;
  --panel:        #151d2c;
  --border:       #25304a;
  --border-soft:  #1d2638;
  --text:         #e6e9f0;
  --text-soft:    #9aa6bd;
  --text-mute:    #6b7689;
  --brand:        #4d83ff;
  --brand-dark:   #3a6ae6;
  --wa-bubble:    #144d3c;   /* burbuja saliente (WhatsApp dark) */
  --in-bubble:    #1f2a37;   /* burbuja entrante */
  --rail:         #0a0f18;
  --rail-soft:    #1c2434;
  --shadow:       0 1px 3px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
  --thread-bg:    #0b141a;
  --thread-tint:  rgba(11,20,26,.94);
  --hover:        #1b2433;
  --active:       #1d2c47;
  --input-bg:     #1f2a37;
}
[data-theme="dark"] .conv__chan { border-color: var(--panel); }
[data-theme="dark"] .date-sep { background: #1f2c33cc; color: var(--text-soft); }
[data-theme="dark"] .msg { box-shadow: 0 1px 1px rgba(0,0,0,.2); }
[data-theme="dark"] .window-warn { background: #2a2310; border-top-color: #4a3d12; color: #e8c66a; }
[data-theme="dark"] .tag { background: #1d2c47; }
[data-theme="dark"] .qa { background: var(--bg); }
[data-theme="dark"] .qa:hover { background: #1d2c47; }
[data-theme="dark"] .radio:has(input:checked) { background: #17223a; }
[data-theme="dark"] .tpl:hover { background: #17223a; }
[data-theme="dark"] code, [data-theme="dark"] .hint code { background: #0d1420; }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #2c3850; }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: #3a496a; }

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
svg { width: 20px; height: 20px; fill: currentColor; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; font-size: 14px; }

/* ============ SHELL ============ */
.app {
  display: grid;
  grid-template-columns: 64px 340px 1fr 320px;
  height: 100vh;
  overflow: hidden;
}

/* ============ RAIL ============ */
.rail {
  background: var(--rail);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 0;
  gap: 6px;
}
.rail__logo {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--brand);
  color: #fff; font-weight: 700; font-size: 20px;
  display: grid; place-items: center; margin-bottom: 10px;
}
.rail__btn {
  width: 42px; height: 42px; border-radius: 10px;
  color: #9aa6c4; display: grid; place-items: center;
  transition: background .15s, color .15s;
}
.rail__btn:hover { background: var(--rail-soft); color: #fff; }
.rail__btn--active { background: var(--rail-soft); color: #fff; }
.rail__spacer { flex: 1; }
#btnTheme .icon-sun { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.rail__avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--brand); color: #fff;
  display: grid; place-items: center; font-weight: 600; font-size: 13px;
  margin-top: 6px;
}

/* ============ LISTA DE CONVERSACIONES ============ */
.list {
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
}
.list__head { padding: 18px 16px 0; border-bottom: 1px solid var(--border-soft); }
.list__title-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.list__title-actions { display: flex; align-items: center; gap: 8px; }
.list__head h1 { font-size: 18px; font-weight: 700; }
/* botón prender/apagar chatbot */
.bot-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 700;
  border: 1px solid transparent; cursor: pointer; transition: background .12s, color .12s, opacity .12s;
}
.bot-toggle svg { width: 15px; height: 15px; fill: currentColor; }
.bot-toggle--on { background: #d8f5e3; color: #0f7a3d; }
.bot-toggle--on:hover { background: #bdeecd; }
.bot-toggle--off { background: var(--bg); color: var(--text-mute); }
.bot-toggle--off:hover { background: var(--border); }
[data-theme="dark"] .bot-toggle--on { background: rgba(26,161,121,.2); color: #34d399; }
[data-theme="dark"] .bot-toggle--off { background: rgba(255,255,255,.06); color: var(--text-mute); }
.bot-toggle.is-loading { opacity: .55; pointer-events: none; }
.conn {
  font-size: 10px; font-weight: 700; letter-spacing: .5px;
  padding: 3px 8px; border-radius: 20px;
}
.conn--demo { background: #fff3d6; color: #9a6b00; }
.conn--live { background: #d8f5e3; color: #0f7a3d; }
.conn--error { background: #fde2e2; color: #b42318; }

.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border-radius: 10px;
  padding: 9px 12px; margin: 14px 0 12px;
}
.search svg { width: 18px; height: 18px; color: var(--text-mute); }
.search input { flex: 1; border: none; background: none; outline: none; color: var(--text); }

.tabs { display: flex; gap: 4px; }
.tab {
  padding: 8px 12px; font-size: 13px; font-weight: 500; color: var(--text-soft);
  border-bottom: 2px solid transparent; transition: color .15s, border-color .15s;
}
.tab:hover { color: var(--text); }
.tab--active { color: var(--brand); border-color: var(--brand); font-weight: 600; }

.list__body { flex: 1; overflow-y: auto; }

.conv {
  display: flex; gap: 12px; padding: 13px 16px;
  border-bottom: 1px solid var(--border-soft); cursor: pointer;
  transition: background .12s;
}
.conv:hover { background: var(--hover); }
.conv--active { background: var(--active); }
.conv--active:hover { background: var(--active); }
.conv__avatar { position: relative; flex-shrink: 0; }
.conv__chan {
  position: absolute; right: -2px; bottom: -2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--wa); border: 2px solid #fff;
  display: grid; place-items: center;
}
.conv__chan svg { width: 9px; height: 9px; fill: #fff; }
.conv__main { flex: 1; min-width: 0; }
.conv__top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.conv__name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv__time { font-size: 11px; color: var(--text-mute); flex-shrink: 0; }
.conv__bottom { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 3px; }
.conv__preview { font-size: 13px; color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv__preview .tick { color: var(--text-mute); }
.conv__badge {
  background: var(--wa); color: #fff; font-size: 11px; font-weight: 700;
  min-width: 18px; height: 18px; border-radius: 9px; padding: 0 5px;
  display: grid; place-items: center; flex-shrink: 0;
}
.conv--unread .conv__name { font-weight: 700; }
.conv--unread .conv__preview { color: var(--text); font-weight: 500; }
/* handoff */
.conv__bottom .conv__preview { flex: 1; min-width: 0; }
.conv__handoff {
  font-size: 9.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .3px;
  color: #b45309; background: #fef3c7; padding: 1px 6px; border-radius: 5px; flex-shrink: 0;
}
[data-theme="dark"] .conv__handoff { background: rgba(245,158,11,.22); color: #fbbf24; }
.conv--handoff { box-shadow: inset 3px 0 0 #f59e0b; }
.tab__count { font-weight: 700; }
.tab--handoff.tab--has { color: #b45309; }
[data-theme="dark"] .tab--handoff.tab--has { color: #fbbf24; }

/* ============ AVATAR ============ */
.avatar {
  width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center; color: #fff;
  font-weight: 600; font-size: 15px; flex-shrink: 0;
}
.avatar--lg { width: 72px; height: 72px; font-size: 24px; }

/* ============ HILO DE CHAT ============ */
.thread {
  background: var(--thread-bg); /* fondo tipo WhatsApp */
  background-image: linear-gradient(var(--thread-tint), var(--thread-tint));
  display: flex; flex-direction: column; overflow: hidden; position: relative;
}
.thread__empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--text-mute); gap: 14px;
}
.thread__empty-icon { width: 70px; height: 70px; border-radius: 50%; background: var(--panel); display: grid; place-items: center; box-shadow: var(--shadow); }
.thread__empty-icon svg { width: 34px; height: 34px; color: var(--text-mute); }

.thread__inner { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.thread__head {
  background: var(--panel); border-bottom: 1px solid var(--border);
  padding: 11px 18px; display: flex; align-items: center; justify-content: space-between;
}
.thread__head-contact { display: flex; align-items: center; gap: 12px; }
.thread__head .avatar { width: 42px; height: 42px; font-size: 14px; }
.thread__name { font-weight: 600; font-size: 15px; }
.thread__sub { font-size: 12px; color: var(--text-soft); display: flex; align-items: center; gap: 4px; }
.chan-badge { display: inline-flex; align-items: center; gap: 3px; color: var(--wa); font-weight: 600; }
.chan-badge svg { width: 12px; height: 12px; fill: currentColor; }
.thread__head-actions { display: flex; align-items: center; gap: 8px; }

.thread__messages { flex: 1; overflow-y: auto; padding: 20px 8% 12px; display: flex; flex-direction: column; gap: 4px; }

.date-sep { align-self: center; background: #ffffffcc; color: var(--text-soft); font-size: 12px; font-weight: 500; padding: 5px 12px; border-radius: 8px; margin: 10px 0; box-shadow: 0 1px 1px rgba(0,0,0,.04); }

.msg { max-width: 65%; padding: 7px 10px 5px; border-radius: 9px; position: relative; box-shadow: 0 1px 1px rgba(0,0,0,.06); font-size: 14px; line-height: 1.4; word-wrap: break-word; }
.msg--in  { align-self: flex-start; background: var(--in-bubble); border-top-left-radius: 2px; }
.msg--out { align-self: flex-end; background: var(--wa-bubble); border-top-right-radius: 2px; }
.msg__text { white-space: pre-wrap; }
.msg__meta { display: flex; align-items: center; gap: 4px; justify-content: flex-end; margin-top: 2px; }
.msg__time { font-size: 10.5px; color: var(--text-mute); }
.msg__tick { width: 16px; height: 16px; color: var(--text-mute); }
.msg__tick.read { color: var(--read); }
.msg__tick svg { width: 16px; height: 16px; }
.msg__chan { display: inline-flex; align-items: center; opacity: .85; }
.msg__chan svg { width: 13px; height: 13px; fill: currentColor; }
.msg--template { border-left: 3px solid var(--brand); }
.msg__tplflag { font-size: 10px; font-weight: 700; color: var(--brand); text-transform: uppercase; letter-spacing: .4px; margin-bottom: 2px; }
.msg--failed { background: #fde6e6; }
.msg--failed .msg__time { color: var(--danger); }
.msg--media { max-width: 320px; }
.msg__media { margin-bottom: 4px; }
.msg__media img,
.msg__media video { max-width: 100%; border-radius: 6px; display: block; }
.js-media-open { cursor: pointer; }
.msg__media--audio { min-width: 230px; }
.msg__media--audio audio { width: 100%; height: 38px; display: block; }
/* miniatura de video con overlay de play */
.msg__media--video { position: relative; }
.msg__media--video video { pointer-events: none; }
.msg__play {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 46px; height: 46px; border-radius: 50%; background: rgba(0,0,0,.55);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 18px; padding-left: 3px; pointer-events: none;
}
.msg__doc {
  display: flex; align-items: center; gap: 9px; margin-bottom: 4px;
  padding: 9px 11px; border-radius: 8px; text-decoration: none;
  background: rgba(0,0,0,.05); color: var(--text); min-width: 180px; max-width: 260px;
}
[data-theme="dark"] .msg__doc { background: rgba(255,255,255,.08); }
.msg__doc:hover { background: rgba(0,0,0,.09); }
[data-theme="dark"] .msg__doc:hover { background: rgba(255,255,255,.13); }
.msg__doc svg { flex-shrink: 0; color: var(--brand); }
.msg__doc-name { font-size: 13px; font-weight: 500; word-break: break-word; overflow-wrap: anywhere; }
.msg__doc-hint { margin-left: auto; flex-shrink: 0; font-size: 11px; font-weight: 700; color: var(--brand); text-transform: uppercase; letter-spacing: .3px; }

/* ===== Visor de media (lightbox) ===== */
.media-modal { position: fixed; inset: 0; z-index: 1000; display: flex; flex-direction: column; }
.media-modal[hidden] { display: none; }
.media-modal__backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.88); }
.media-modal__bar {
  position: relative; z-index: 2; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 16px;
}
.media-modal__name { color: #fff; font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-modal__actions { display: flex; gap: 6px; flex-shrink: 0; }
.media-modal__btn {
  width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px; background: rgba(255,255,255,.14); color: #fff; text-decoration: none;
  border: none; cursor: pointer; font-size: 17px; line-height: 1;
}
.media-modal__btn:hover { background: rgba(255,255,255,.28); }
.media-modal__body {
  position: relative; z-index: 2; flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center; padding: 0 16px 16px;
}
.media-modal__img { max-width: 96%; max-height: 100%; object-fit: contain; border-radius: 6px; }
.media-modal__media { max-width: 96%; max-height: 100%; }
.media-modal__frame { width: min(1000px, 96%); height: 100%; border: none; border-radius: 6px; background: #fff; }
.media-modal__noprev {
  background: var(--panel); border-radius: 12px; padding: 28px 32px; text-align: center;
  color: var(--text); display: flex; flex-direction: column; align-items: center; gap: 14px; max-width: 360px;
}
.media-modal__noprev svg { width: 48px; height: 48px; color: var(--brand); }
.media-modal__noprev p { font-size: 14px; color: var(--text-mute); }

/* ===== Detalles: GHL (nota, oportunidades, custom fields) ===== */
.details__ghlnote { margin: 6px 18px 0; font-size: 12px; color: var(--text-mute); }
.opp {
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px;
  background: var(--panel);
}
.opp__top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.opp__name { font-size: 13px; font-weight: 600; color: var(--text); word-break: break-word; }
.opp__status {
  flex-shrink: 0; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px;
  padding: 2px 7px; border-radius: 999px; background: rgba(0,0,0,.08); color: var(--text-soft);
}
[data-theme="dark"] .opp__status { background: rgba(255,255,255,.12); }
.opp__status--open { background: rgba(47,109,246,.15); color: #2f6df6; }
.opp__status--won  { background: rgba(26,161,121,.16); color: #1aa179; }
.opp__status--lost,
.opp__status--abandoned { background: rgba(239,68,68,.14); color: var(--danger); }
.opp__path { font-size: 12px; color: var(--text-mute); margin-top: 4px; }
.opp__value { font-size: 13px; font-weight: 700; color: var(--text); margin-top: 4px; }
/* valores largos de custom fields: no romper el layout */
#detCustom dd { white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; max-height: 160px; overflow: auto; }

/* aviso ventana 24h */
.window-warn {
  background: #fff7e6; border-top: 1px solid #ffe3a3; color: #8a5a00;
  display: flex; align-items: center; gap: 8px; padding: 9px 18px; font-size: 13px;
}
.window-warn svg { width: 18px; height: 18px; fill: #d99100; flex-shrink: 0; }

/* ============ COMPOSER ============ */
.composer { background: var(--panel); border-top: 1px solid var(--border); padding: 8px 16px 12px; }
.composer__tools { display: flex; align-items: center; gap: 4px; margin-bottom: 6px; }
.composer__spacer { flex: 1; }
.composer__hint { font-size: 11px; color: var(--text-mute); }
.composer__row { display: flex; align-items: flex-end; gap: 8px; }
/* barra de grabación de voz */
.composer__rec { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.composer__rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); flex-shrink: 0; animation: recpulse 1s infinite; }
@keyframes recpulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
.composer__rec-time { font-size: 14px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.composer__rec-hint { font-size: 13px; color: var(--text-mute); }
.composer__rec-cancel { color: var(--danger); }
.composer__rec-cancel:hover { background: rgba(239,68,68,.12); }
.composer textarea {
  flex: 1; resize: none; max-height: 140px; border: 1px solid var(--border);
  border-radius: 22px; padding: 11px 16px; outline: none; line-height: 1.4;
  transition: border-color .15s; background: var(--input-bg); color: var(--text);
}
.composer textarea:focus { border-color: var(--brand); }
.btn-send {
  width: 44px; height: 44px; border-radius: 50%; background: var(--brand); color: #fff;
  display: grid; place-items: center; flex-shrink: 0; transition: background .15s, transform .1s;
}
.btn-send:hover { background: var(--brand-dark); }
.btn-send:active { transform: scale(.94); }

/* ============ BOTONES ============ */
.btn-icon { width: 34px; height: 34px; border-radius: 8px; color: var(--text-soft); display: grid; place-items: center; transition: background .12s, color .12s; }
.btn-icon:hover { background: var(--bg); color: var(--text); }
.btn-icon--danger:hover { background: rgba(239,68,68,.12); color: var(--danger); }
.btn-ghost { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 8px; font-size: 13px; font-weight: 500; color: var(--text-soft); border: 1px solid var(--border); transition: background .12s; }
.btn-ghost:hover { background: var(--bg); }
.btn-ghost svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 2; fill: none; }
.btn-primary { padding: 9px 18px; border-radius: 8px; background: var(--brand); color: #fff; font-weight: 600; transition: background .15s; }
.btn-primary:hover { background: var(--brand-dark); }

/* ============ DETALLES DE CONTACTO ============ */
.details { background: var(--panel); border-left: 1px solid var(--border); overflow-y: auto; }
.details__head { padding: 26px 20px 20px; text-align: center; border-bottom: 1px solid var(--border-soft); }
.details__head .avatar { margin: 0 auto 12px; }
.details__name { font-size: 17px; font-weight: 700; }
/* toggle Abierta/Cerrada (estilo pastilla, como el del bot) */
.pill-toggle {
  display: inline-flex; align-items: center; gap: 7px;
  margin: 8px auto 2px; padding: 5px 14px; border-radius: 20px;
  font-size: 12.5px; font-weight: 700; cursor: pointer; border: 1px solid transparent;
  transition: background .12s, color .12s;
}
.pill-toggle__dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.pill-toggle--on { background: #d8f5e3; color: #0f7a3d; }
.pill-toggle--on:hover { background: #bdeecd; }
.pill-toggle--off { background: #fde2e2; color: #b42318; }
.pill-toggle--off:hover { background: #f9cccc; }
[data-theme="dark"] .pill-toggle--on { background: rgba(26,161,121,.2); color: #34d399; }
[data-theme="dark"] .pill-toggle--off { background: rgba(239,68,68,.18); color: #f87171; }
.details__phone { font-size: 13px; color: var(--text-soft); margin-top: 2px; }
.details__quick { display: flex; gap: 10px; justify-content: center; margin-top: 14px; }
.qa { width: 40px; height: 40px; border-radius: 10px; background: var(--bg); color: var(--brand); display: grid; place-items: center; cursor: pointer; transition: background .12s; }
.qa:hover { background: #e6eeff; }
.details__section { padding: 18px 20px; border-bottom: 1px solid var(--border-soft); }
.details__section h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-mute); margin-bottom: 12px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { background: #eef4ff; color: var(--brand); font-size: 12px; font-weight: 500; padding: 4px 10px; border-radius: 20px; }
.fields { display: flex; flex-direction: column; gap: 10px; }
.fields div { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.fields dt { color: var(--text-soft); }
.fields dd { font-weight: 500; text-align: right; }
.status-pills { display: flex; gap: 8px; }
.pill { flex: 1; padding: 8px; border-radius: 8px; border: 1px solid var(--border); font-weight: 500; color: var(--text-soft); transition: all .12s; }
.pill--active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ============ MODALES ============ */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; }
.modal[hidden] { display: none; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(18,28,45,.45); backdrop-filter: blur(2px); }
.modal__card { position: relative; background: var(--panel); border-radius: 16px; width: 540px; max-width: 92vw; max-height: 88vh; overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal__card--sm { width: 420px; }
.modal__head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal__head h2 { font-size: 17px; font-weight: 700; }
.modal__body { padding: 20px 22px; overflow-y: auto; }
.modal__foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

.mode-switch { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.radio { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; font-size: 13px; transition: border-color .12s, background .12s; }
.radio:has(input:checked) { border-color: var(--brand); background: #f4f8ff; }
.radio input { width: 16px; height: 16px; accent-color: var(--brand); }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.form-group label small { font-weight: 400; color: var(--text-mute); }
.form-group input, .form-group select { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; outline: none; transition: border-color .12s; background: var(--input-bg); color: var(--text); }
.form-group input:focus, .form-group select:focus { border-color: var(--brand); }
.hint { font-size: 12px; color: var(--text-mute); margin-top: 6px; line-height: 1.45; }
.hint code, code { background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: 12px; font-family: ui-monospace, Menlo, Consolas, monospace; }

/* plantillas */
.tpl { padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px; cursor: pointer; transition: border-color .12s, background .12s; }
.tpl:hover { border-color: var(--brand); background: #f4f8ff; }
.tpl__name { font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.tpl__cat { font-size: 10px; font-weight: 700; color: var(--brand); background: #eef4ff; padding: 2px 7px; border-radius: 10px; text-transform: uppercase; }
.tpl__body { font-size: 13px; color: var(--text-soft); margin-top: 5px; }

/* toast */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #1c2434; color: #fff; padding: 11px 20px; border-radius: 10px; font-size: 13px; font-weight: 500; box-shadow: var(--shadow); z-index: 200; animation: toastIn .2s ease; }
.toast[hidden] { display: none; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #cfd6e0; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #b6bfcd; }

/* responsive básico */
@media (max-width: 1100px) { .app { grid-template-columns: 64px 300px 1fr; } .details { display: none; } }
@media (max-width: 820px)  { .app { grid-template-columns: 64px 1fr; } .list { display: none; } }
