@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

/* ================= Tokens ================= */
:root {
  --bg: #f3f5fb;
  --surface: #ffffff;
  --surface-2: #f8f9fd;
  --border: #e4e7f0;
  --text: #0f172a;
  --text-2: #475569;
  --muted: #8a94a8;

  --primary: #4f46e5;
  --primary-2: #6366f1;
  --primary-soft: #eef0ff;
  --teal: #0d9488;
  --teal-soft: #e6f7f5;
  --amber: #d97706;
  --amber-soft: #fef5e6;
  --rose: #e11d48;
  --rose-soft: #fdecef;
  --violet: #7c3aed;
  --violet-soft: #f3edff;
  --sky: #0284c7;
  --sky-soft: #e7f4fc;
  --green: #16a34a;
  --green-soft: #e8f7ee;
  --wa: #25d366;

  --sidebar: #0f1330;
  --sidebar-2: #171c45;
  --sidebar-text: #aab1d6;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 8px 24px -12px rgba(15, 23, 42, .12);
  --shadow-lg: 0 24px 60px -20px rgba(15, 23, 42, .35);
  --radius: 14px;
  --radius-sm: 10px;
  --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  --chat-bg: #efeae2;
  --bubble: #d9fdd3;
}

:root[data-theme='dark'] {
  --bg: #0b0e1d;
  --surface: #131731;
  --surface-2: #181d3b;
  --border: #252b52;
  --text: #e8ebfa;
  --text-2: #b3bad8;
  --muted: #7a82a8;
  --primary: #818cf8;
  --primary-2: #6366f1;
  --primary-soft: #1e2350;
  --teal: #2dd4bf;
  --teal-soft: #0f2e33;
  --amber: #fbbf24;
  --amber-soft: #33270f;
  --rose: #fb7185;
  --rose-soft: #361626;
  --violet: #a78bfa;
  --violet-soft: #2a1d4d;
  --sky: #38bdf8;
  --sky-soft: #0f2a40;
  --green: #4ade80;
  --green-soft: #12301f;
  --sidebar: #090b18;
  --sidebar-2: #12163a;
  --shadow: 0 1px 3px rgba(0, 0, 0, .3), 0 8px 24px -12px rgba(0, 0, 0, .5);
  --chat-bg: #0b141a;
  --bubble: #005c4b;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ================= Botones y formularios ================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: pointer; font-weight: 600; font-size: 14px;
  transition: transform .08s ease, background .15s, box-shadow .15s, border-color .15s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--primary-2), var(--violet)); color: #fff; box-shadow: 0 6px 16px -6px rgba(79, 70, 229, .6); }
.btn-primary:hover:not(:disabled) { box-shadow: 0 8px 22px -6px rgba(79, 70, 229, .75); }
.btn-wa { background: var(--wa); color: #073b1c; }
.btn-wa:hover:not(:disabled) { filter: brightness(1.05); }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-danger { background: var(--rose-soft); color: var(--rose); }
.btn-danger:hover:not(:disabled) { background: var(--rose); color: #fff; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-icon { width: 36px; height: 36px; padding: 0; }
.btn-block { width: 100%; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-weight: 600; font-size: 13px; color: var(--text-2); }
.hint { font-size: 12.5px; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; min-height: 42px; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.textarea { resize: vertical; min-height: 150px; line-height: 1.55; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 18%, transparent); }
.input-icon { position: relative; }
.input-icon > svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.input-icon > .input { padding-left: 40px; }

/* Switch */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { width: 42px; height: 24px; border-radius: 99px; background: var(--border); position: relative; transition: background .2s; flex: none; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .2s; }
.switch input:checked + .track { background: var(--green); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 25%, transparent); }

/* ================= Login ================= */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-hero {
  position: relative; overflow: hidden; color: #fff; padding: 48px;
  display: flex; flex-direction: column; justify-content: space-between;
  background: radial-gradient(circle at 15% 20%, #7c3aed 0, transparent 45%),
              radial-gradient(circle at 85% 80%, #0d9488 0, transparent 45%),
              radial-gradient(circle at 80% 10%, #e11d48 0, transparent 35%),
              linear-gradient(135deg, #1e1b6b, #0f1330);
}
.auth-hero::before {
  content: ''; position: absolute; inset: 0; opacity: .12;
  background-image: linear-gradient(rgba(255,255,255,.5) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.5) 1px, transparent 1px);
  background-size: 40px 40px; mask-image: linear-gradient(180deg, #000, transparent 85%);
}
.auth-hero > * { position: relative; }
.brand { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 18px; letter-spacing: -.01em; }
.brand-logo {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--wa), #0d9488); box-shadow: 0 8px 20px -8px rgba(37, 211, 102, .8);
}
.brand-logo svg { width: 22px; height: 22px; }
.brand small { display: block; font-weight: 500; font-size: 12px; opacity: .7; }
.auth-hero h1 { font-size: clamp(28px, 3.2vw, 42px); font-weight: 800; letter-spacing: -.02em; max-width: 520px; }
.auth-hero p.lead { opacity: .8; max-width: 460px; font-size: 16px; margin: 14px 0 28px; }
.feature-list { display: grid; gap: 12px; max-width: 440px; }
.feature { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 12px; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12); backdrop-filter: blur(6px); }
.feature .dot { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.auth-foot { font-size: 12.5px; opacity: .6; }

.auth-panel { display: grid; place-items: center; padding: 32px 20px; background: var(--bg); }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h2 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.auth-card .sub { color: var(--text-2); margin: 6px 0 28px; }
.auth-card form { display: grid; gap: 16px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px; display: grid; }
.alert { padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13.5px; display: flex; gap: 8px; align-items: flex-start; }
.alert-error { background: var(--rose-soft); color: var(--rose); }
.alert-info { background: var(--sky-soft); color: var(--sky); }
.alert-warn { background: var(--amber-soft); color: var(--amber); }

/* ================= Layout app ================= */
.app { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 8px;
  padding: 22px 16px; color: var(--sidebar-text);
  background: linear-gradient(180deg, var(--sidebar), var(--sidebar-2));
}
.sidebar .brand { color: #fff; padding: 0 8px 18px; border-bottom: 1px solid rgba(255,255,255,.07); margin-bottom: 10px; }
.nav-title { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; opacity: .5; padding: 10px 12px 4px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin: 2px 0; border-radius: 10px;
  color: var(--sidebar-text); font-weight: 600; transition: background .15s, color .15s;
}
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: linear-gradient(135deg, rgba(99,102,241,.95), rgba(124,58,237,.95)); color: #fff; box-shadow: 0 8px 20px -10px rgba(124,58,237,.9); }
.nav a .badge-dot { margin-left: auto; }
.sidebar-foot { margin-top: auto; padding: 14px; border-radius: 12px; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.06); font-size: 13px; }
.sidebar-foot strong { color: #fff; display: block; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 14px 28px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 20px; font-weight: 800; letter-spacing: -.01em; }
.topbar .crumb { color: var(--muted); font-size: 12.5px; }
.topbar .spacer { flex: 1; }
.menu-btn { display: none; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 6px 4px 4px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff; background: linear-gradient(135deg, var(--amber), var(--rose)); font-size: 13px; text-transform: uppercase; }
.content { padding: 28px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; max-width: 1280px; width: 100%; }
.content > *, .stack > *, .grid-2 > *, .grid-form > *, .connect-wrap > * { min-width: 0; }

.status-pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 99px; font-weight: 600; font-size: 12.5px; }
.badge-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }
.st-connected { background: var(--green-soft); color: var(--green); }
.st-connecting, .st-qr { background: var(--amber-soft); color: var(--amber); }
.st-disconnected { background: var(--rose-soft); color: var(--rose); }
.st-connecting .badge-dot, .st-qr .badge-dot { animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* ================= Tarjetas ================= */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-head h3 { font-size: 15.5px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.card-body { padding: 20px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.stat { position: relative; overflow: hidden; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.stat::after { content: ''; position: absolute; right: -30px; top: -30px; width: 110px; height: 110px; border-radius: 50%; background: var(--tone-soft); opacity: .8; }
.stat .ico { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--tone-soft); color: var(--tone); position: relative; z-index: 1; }
.stat .val { font-size: 26px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.stat .lbl { color: var(--text-2); font-size: 13px; font-weight: 500; }
.tone-indigo { --tone: var(--primary); --tone-soft: var(--primary-soft); }
.tone-teal { --tone: var(--teal); --tone-soft: var(--teal-soft); }
.tone-amber { --tone: var(--amber); --tone-soft: var(--amber-soft); }
.tone-rose { --tone: var(--rose); --tone-soft: var(--rose-soft); }
.tone-violet { --tone: var(--violet); --tone-soft: var(--violet-soft); }
.tone-sky { --tone: var(--sky); --tone-soft: var(--sky-soft); }
.tone-green { --tone: var(--green); --tone-soft: var(--green-soft); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.grid-form { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 24px; align-items: start; }

.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 14px; padding: 14px 20px; border-top: 1px solid var(--border); }
.list-item:first-child { border-top: 0; }
.list-item .ico { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--tone-soft); color: var(--tone); flex: none; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .meta { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.date-chip { text-align: center; min-width: 58px; padding: 6px 8px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.date-chip b { display: block; font-size: 15px; }
.date-chip span { font-size: 11px; color: var(--muted); text-transform: uppercase; }

.empty { padding: 36px 20px; text-align: center; color: var(--muted); display: grid; justify-items: center; gap: 10px; }
.empty .ico { width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.empty .ico svg { width: 26px; height: 26px; }
.empty h4 { color: var(--text); font-size: 15px; }

.tag { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--tone-soft, var(--surface-2)); color: var(--tone, var(--text-2)); }

/* ================= Reportes ================= */
.reports { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; }
.report { display: flex; flex-direction: column; overflow: hidden; }
.report .bar { height: 5px; background: linear-gradient(90deg, var(--tone), color-mix(in srgb, var(--tone) 40%, var(--violet))); }
.report .top { padding: 18px 20px 0; display: flex; gap: 12px; align-items: flex-start; }
.report .top .grow { flex: 1; min-width: 0; }
.report h4 { font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.report .group { color: var(--text-2); font-size: 13px; display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.report .body { padding: 14px 20px; display: grid; gap: 12px; flex: 1; align-content: start; }
.report .excerpt { color: var(--text-2); font-size: 13px; background: var(--surface-2); border-radius: 10px; padding: 10px 12px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; min-height: 42px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.report .foot { display: flex; align-items: center; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); background: var(--surface-2); }
.report .foot .spacer { flex: 1; }
.report.off { opacity: .72; }

.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.day { height: 40px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 700; font-size: 13px; color: var(--text-2); }
.day.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.day-presets { display: flex; gap: 6px; flex-wrap: wrap; }
.day-presets button { background: none; border: 0; color: var(--primary); font-weight: 600; font-size: 12.5px; cursor: pointer; padding: 2px 4px; }

.times { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.time-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 6px 6px 12px; border-radius: 99px; background: var(--violet-soft); color: var(--violet); font-weight: 700; }
.time-chip button { width: 22px; height: 22px; border-radius: 50%; border: 0; background: transparent; color: inherit; cursor: pointer; display: grid; place-items: center; }
.time-chip button:hover { background: color-mix(in srgb, var(--violet) 18%, transparent); }
.time-add { display: flex; gap: 8px; }
.time-add .input { width: 130px; }

.vars { display: flex; flex-wrap: wrap; gap: 6px; }
.var { border: 1px dashed var(--border); background: var(--surface-2); border-radius: 8px; padding: 3px 8px; font-size: 12px; cursor: pointer; font-weight: 600; color: var(--teal); font-family: ui-monospace, monospace; }
.var:hover { border-color: var(--teal); }
.fmt-bar { display: flex; gap: 4px; }
.fmt-bar button { width: 32px; height: 30px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 700; }

.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 22px; text-align: center; cursor: pointer;
  display: grid; justify-items: center; gap: 6px; color: var(--text-2); transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--primary); background: var(--primary-soft); }
.dropzone .ico { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.files { display: grid; gap: 8px; }
.file { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.file .ext { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-size: 10.5px; font-weight: 800; color: #fff; flex: none; text-transform: uppercase; background-size: cover; background-position: center; }
.ext-pdf { background: #e5484d; } .ext-doc, .ext-docx { background: #2b6cde; } .ext-ppt, .ext-pptx { background: #e8690b; }
.ext-xls, .ext-xlsx { background: #178a52; } .ext-img { background: var(--violet); }
.file .grow { flex: 1; min-width: 0; }
.file .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file .size { font-size: 12px; color: var(--muted); }
.progress { height: 4px; border-radius: 4px; background: var(--border); overflow: hidden; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--primary), var(--teal)); width: 0; transition: width .2s; }

/* Vista previa estilo WhatsApp */
.phone { border-radius: 22px; overflow: hidden; border: 1px solid var(--border); box-shadow: var(--shadow); }
.phone-head { background: #075e54; color: #fff; padding: 12px 14px; display: flex; gap: 10px; align-items: center; }
.phone-head .avatar { background: linear-gradient(135deg, var(--wa), var(--teal)); }
.phone-head small { display: block; opacity: .75; font-size: 11.5px; }
.phone-body {
  background-color: var(--chat-bg); min-height: 260px; padding: 16px 12px; display: flex; flex-direction: column; gap: 6px; align-items: flex-end;
  background-image: radial-gradient(color-mix(in srgb, var(--text) 6%, transparent) 1px, transparent 1px); background-size: 16px 16px;
}
.bubble { background: var(--bubble); color: var(--text); padding: 7px 10px 18px; border-radius: 10px 0 10px 10px; max-width: 88%; position: relative; font-size: 13.5px; white-space: pre-wrap; word-wrap: break-word; box-shadow: 0 1px 1px rgba(0,0,0,.1); min-width: 80px; }
.bubble .t { position: absolute; right: 8px; bottom: 3px; font-size: 10.5px; opacity: .6; }
.bubble.doc { display: flex; gap: 10px; align-items: center; padding-bottom: 20px; min-width: 200px; }
.bubble.doc .ext { width: 34px; height: 40px; border-radius: 6px; display: grid; place-items: center; font-size: 9.5px; font-weight: 800; color: #fff; }
.bubble img { max-width: 220px; border-radius: 8px; display: block; }
.bubble code { font-family: ui-monospace, monospace; background: rgba(0,0,0,.06); padding: 0 4px; border-radius: 4px; }

/* ================= Conexión ================= */
.connect-wrap { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.qr-box { display: grid; place-items: center; gap: 14px; padding: 24px; text-align: center; }
.qr-frame { padding: 14px; border-radius: 18px; background: #fff; box-shadow: var(--shadow); position: relative; }
.qr-frame img { width: 260px; height: 260px; display: block; }
.pair-code { font-family: ui-monospace, monospace; font-size: 30px; font-weight: 800; letter-spacing: .18em; padding: 14px 20px; border-radius: 14px; background: var(--primary-soft); color: var(--primary); }
.steps { counter-reset: s; display: grid; gap: 14px; margin: 0; padding: 0; list-style: none; }
.steps li { position: relative; padding-left: 38px; min-height: 26px; color: var(--text-2); line-height: 1.6; }
.steps li::before { counter-increment: s; content: counter(s); position: absolute; left: 0; top: 0; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; background: var(--teal-soft); color: var(--teal); }
.tip > div { min-width: 0; overflow-wrap: anywhere; }
.profile { display: flex; align-items: center; gap: 16px; padding: 20px; border-radius: var(--radius); background: linear-gradient(135deg, var(--green-soft), var(--teal-soft)); }
.profile .big { width: 58px; height: 58px; border-radius: 18px; display: grid; place-items: center; background: var(--wa); color: #073b1c; }
.profile .big svg { width: 28px; height: 28px; }
.segmented { display: inline-flex; padding: 4px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.segmented button { border: 0; background: none; padding: 8px 14px; border-radius: 9px; cursor: pointer; font-weight: 600; color: var(--text-2); }
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ================= Tabla ================= */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 20px; border-top: 1px solid var(--border); white-space: nowrap; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--surface-2); border-top: 0; }
td.err { white-space: normal; color: var(--rose); font-size: 13px; min-width: 220px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ================= Modal y toasts ================= */
.modal-back { position: fixed; inset: 0; z-index: 50; background: rgba(8, 10, 30, .55); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 16px; animation: fade .15s; }
.modal { width: 100%; max-width: 440px; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 24px; display: grid; gap: 14px; animation: pop .18s ease; }
.modal h3 { font-size: 18px; }
.modal p { margin: 0; color: var(--text-2); }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 60; display: grid; gap: 10px; }
.toast { min-width: 260px; max-width: 380px; padding: 12px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--tone); box-shadow: var(--shadow-lg); display: flex; gap: 10px; align-items: flex-start; animation: pop .2s; }
.toast svg { color: var(--tone); margin-top: 1px; }

.sticky-actions { position: sticky; bottom: 0; z-index: 10; display: flex; gap: 10px; justify-content: flex-end; padding: 14px 0; background: linear-gradient(0deg, var(--bg) 70%, transparent); }
.stack { display: grid; gap: 18px; align-content: start; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.muted { color: var(--muted); }
.overlay { display: none; }

/* ================= Responsive ================= */
@media (max-width: 1200px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1024px) {
  .grid-form, .connect-wrap, .grid-2 { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth-hero { padding: 32px 24px; }
  .auth-hero .feature-list, .auth-hero .auth-foot { display: none; }
  .auth-hero p.lead { margin-bottom: 0; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 272px; z-index: 40; transform: translateX(-100%); transition: transform .25s ease; }
  .app.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .app.nav-open .overlay { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(8, 10, 30, .5); }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 12px 16px; }
  .content { padding: 18px 16px; gap: 18px; }
  .user-chip .uname { display: none; }
}
@media (max-width: 560px) {
  .stats { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat { padding: 14px; }
  .stat .val { font-size: 21px; }
  .reports { grid-template-columns: 1fr; }
  .topbar h1 { font-size: 17px; }
  .topbar .crumb { display: none; }
  .qr-frame img { width: 220px; height: 220px; }
  .toasts { left: 16px; right: 16px; }
  .toast { max-width: none; }
  .hide-sm { display: none !important; }
  .days { gap: 4px; }
  th, td { padding: 10px 14px; }
}

/* ================= v2: notificaciones, destinos, programación, estadísticas ================= */
.imp-banner { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; padding: 8px 16px; background: linear-gradient(90deg, var(--amber), var(--rose)); color: #fff; font-weight: 600; font-size: 13.5px; }
.imp-banner button { background: rgba(255,255,255,.2); border: 1px solid rgba(255,255,255,.5); color: #fff; border-radius: 8px; padding: 4px 10px; cursor: pointer; font-weight: 700; }

.bell { position: relative; }
.bell .count { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--rose); color: #fff; font-size: 11px; font-weight: 800; display: grid; place-items: center; border: 2px solid var(--bg); }
.popover { position: absolute; right: 0; top: calc(100% + 8px); width: min(380px, calc(100vw - 32px)); max-height: 70vh; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 45; }
.popover .list-item { align-items: flex-start; }
.popover .list-item .meta { white-space: normal; }
.pop-wrap { position: relative; }

.picker-list { max-height: 260px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.picker-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; cursor: pointer; border-top: 1px solid var(--border); background: var(--surface); width: 100%; text-align: left; border-left: 0; border-right: 0; border-bottom: 0; }
.picker-item:first-child { border-top: 0; }
.picker-item:hover { background: var(--primary-soft); }
.picker-item .grow { flex: 1; min-width: 0; }
.picker-item .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.target-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 6px 5px 10px; border-radius: 99px; background: var(--teal-soft); color: var(--teal); font-weight: 600; font-size: 13px; max-width: 100%; }
.target-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.target-chip button { width: 22px; height: 22px; border-radius: 50%; border: 0; background: transparent; color: inherit; cursor: pointer; display: grid; place-items: center; flex: none; }
.target-chip.contact { background: var(--sky-soft); color: var(--sky); }

.month-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.month-grid .day { height: 36px; }
.chip-btn { border: 1px solid var(--border); background: var(--surface); border-radius: 99px; padding: 6px 12px; cursor: pointer; font-weight: 600; font-size: 12.5px; color: var(--text-2); }
.chip-btn.on { background: var(--primary); border-color: var(--primary); color: #fff; }

.var-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto; gap: 8px; align-items: center; }
.var-row .input { min-height: 38px; padding: 8px 10px; }
.file-flags { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 4px; }
.file-flags label { display: inline-flex; gap: 6px; align-items: center; font-size: 12.5px; color: var(--text-2); cursor: pointer; }
.file .grow { display: grid; gap: 2px; }
.report.drag { outline: 2px dashed var(--primary); outline-offset: 3px; }
.tip { display: flex; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--violet-soft); color: var(--text-2); font-size: 13px; }
.tip svg { color: var(--violet); margin-top: 2px; }
.tip code, .hint code { font-family: ui-monospace, monospace; background: var(--surface); padding: 1px 6px; border-radius: 6px; color: var(--violet); font-size: 12px; }
.meter { height: 8px; border-radius: 8px; background: var(--border); overflow: hidden; }
.meter > div { height: 100%; background: linear-gradient(90deg, var(--teal), var(--primary)); }
.meter.warn > div { background: var(--amber); }

/* Gráfico de envíos */
.chart { position: relative; }
.chart g.col:hover path, .chart g.col:hover rect + rect { opacity: .8; }
.chart-tip { position: absolute; pointer-events: none; background: var(--text); color: var(--bg); padding: 8px 10px; border-radius: 8px; font-size: 12.5px; box-shadow: var(--shadow-lg); transform: translate(-50%, -110%); white-space: nowrap; z-index: 5; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend .ok { background: var(--green); }
.legend .err { background: repeating-linear-gradient(135deg, var(--rose) 0 3px, color-mix(in srgb, var(--rose) 35%, var(--surface)) 3px 6px); }

.totp-box { display: grid; justify-items: center; gap: 10px; text-align: center; }
.totp-box img { width: 200px; height: 200px; border-radius: 12px; background: #fff; padding: 8px; }
.secret { font-family: ui-monospace, monospace; font-size: 13px; letter-spacing: .08em; background: var(--surface-2); padding: 6px 10px; border-radius: 8px; word-break: break-all; }
.code-input { font-size: 22px; letter-spacing: .4em; text-align: center; font-family: ui-monospace, monospace; }

@media (max-width: 560px) {
  .var-row { grid-template-columns: 1fr 1fr auto; }
  .report .foot { flex-wrap: wrap; }
}
