/* BumbleShop Admin: tokens, layout y componentes. Claro y oscuro segun el sistema. */
:root {
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  /* Letra cuadrada de la marca (Bahnschrift viene con Windows; si no, la del sistema). */
  --font-brand: "Bahnschrift", "DIN Alternate", "D-DIN", "Barlow", "Segoe UI", ui-sans-serif, system-ui, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Code", Consolas, monospace;

  --brand-green: #0C2E26;
  --brand-green-2: #15463A;
  --brand-amber: #F2B200;
  --brand-ink: #06110D;
  --brand-cream: #F4F1EA;
  --brand-gold: #8A5800;
  --brand-sage: #9DB4A7;

  --bg: #F4F1EA;
  --surface: #FFFEFB;
  --surface-2: #FAF8F3;
  --surface-hover: #EFEBE1;
  --border: #E4DED1;
  --border-strong: #D3CBBA;
  --text: #0F2A23;
  --text-2: #4E655C;
  --text-3: #8A9B93;

  --primary: #0C2E26;
  --primary-hover: #15463A;
  --primary-soft: #E2ECE6;
  --primary-text: #0C2E26;
  --on-primary: #F4F1EA;
  --accent: #F2B200;
  --accent-soft: #FCEFC4;
  --accent-text: #8A5800;
  --focus: #F2B200;

  --success: #1F7A55;
  --success-soft: #DCEFE4;
  --warning: #8A5800;
  --warning-soft: #FCEFC4;
  --danger: #C0392B;
  --danger-soft: #F8E1DD;
  --info: #2F6B57;
  --info-soft: #E2ECE6;

  --sidebar-bg: #06110D;
  --sidebar-text: #CFDDD5;
  --sidebar-muted: #7F9A8D;
  --sidebar-hover: rgba(255, 255, 255, 0.06);
  --sidebar-active: rgba(242, 178, 0, 0.16);

  --bubble-me: #0C2E26;
  --bubble-me-text: #F4F1EA;
  --bubble-bot: #FFFEFB;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(12, 46, 38, 0.06);
  --shadow: 0 1px 3px rgba(12, 46, 38, 0.08), 0 4px 16px rgba(12, 46, 38, 0.05);
  --shadow-lg: 0 20px 50px rgba(12, 46, 38, 0.22);
  --sidebar-w: 268px;
  --topbar-h: 60px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #040B08;
    --surface: #09150F;
    --surface-2: #071009;
    --surface-hover: #10231B;
    --border: #16291F;
    --border-strong: #24402F;
    --text: #F4F1EA;
    --text-2: #A9BEB3;
    --text-3: #6F8B7E;
    --primary: #F2B200;
    --primary-hover: #FFC52E;
    --primary-soft: rgba(242, 178, 0, 0.14);
    --primary-text: #F6C744;
    --on-primary: #0C2E26;
    --accent-soft: rgba(242, 178, 0, 0.14);
    --accent-text: #F6C744;
    --success: #5CC995;
    --success-soft: rgba(92, 201, 149, 0.14);
    --warning: #F6C744;
    --warning-soft: rgba(242, 178, 0, 0.14);
    --danger: #F08A7E;
    --danger-soft: rgba(240, 138, 126, 0.14);
    --info: #9DB4A7;
    --info-soft: rgba(157, 180, 167, 0.14);
    --sidebar-bg: #020604;
    --bubble-me: #F2B200;
    --bubble-me-text: #0C2E26;
    --bubble-bot: #10231B;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.5);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
p { margin: 0; }
code, .mono { font-family: var(--mono); font-size: 0.92em; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

.boot { height: 100vh; display: grid; place-items: center; }
.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
}
.spinner.sm { width: 16px; height: 16px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Login ─────────────────────────────────────────────────────────────── */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-hero {
  position: relative; overflow: hidden; padding: 48px; color: #e2e8f0;
  background: radial-gradient(900px 520px at 50% 18%, rgba(242, 178, 0, 0.16), transparent 62%),
              radial-gradient(700px 420px at 110% 110%, rgba(157, 180, 167, 0.14), transparent 60%),
              var(--brand-ink);
  display: flex; flex-direction: column; justify-content: space-between;
}
.login-hero .hero-logo { display: grid; justify-items: center; gap: 22px; text-align: center; margin: 24px 0; }
.login-hero .hero-logo .robot { width: 168px; height: 168px; }
.login-hero .hero-logo .wordmark { font-size: 56px; }
.tagline { font-family: var(--font-brand); font-size: 13px; letter-spacing: 0.42em; text-transform: uppercase; color: var(--brand-sage); }
.login-hero .hero-copy { max-width: 460px; margin: 0 auto; text-align: center; }
.login-hero .features { justify-content: center; }
.login-hero h1 { font-size: 26px; font-weight: 700; color: var(--brand-cream); letter-spacing: -0.01em; }
.login-hero p { margin-top: 12px; font-size: 15px; color: var(--brand-sage); }
.login-hero .features { display: grid; gap: 14px; margin-top: 36px; }
.login-hero .feature { display: flex; gap: 12px; align-items: center; color: #CFDDD5; text-align: left; }
.login-hero .feature .icon-wrap { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: rgba(255,255,255,0.07); color: var(--brand-amber); flex: none; }
.login-hero small { color: #6F8B7E; text-align: center; }
.login-panel { display: flex; flex-direction: column; padding: 24px 32px; background: var(--surface); }
.login-panel .top { display: flex; justify-content: flex-end; }
.login-form { margin: auto; width: 100%; max-width: 380px; display: grid; gap: 18px; }
.login-form h2 { font-size: 28px; font-weight: 700; font-family: var(--font-brand); }
.login-form .brand .robot { width: 52px; height: 52px; }
.login-form .subtitle { color: var(--text-2); margin-top: -10px; }

/* ── Marca ─────────────────────────────────────────────────────────────── */
.brand { display: flex; align-items: center; gap: 10px; }
.brand .robot { width: 38px; height: 38px; flex: none; }
.brand small { display: block; font-family: var(--font); font-weight: 500; font-size: 10.5px; color: var(--sidebar-muted); letter-spacing: 0.06em; text-transform: uppercase; margin-top: 1px; }
.robot { display: inline-grid; place-items: center; line-height: 0; }
.robot svg { width: 100%; height: 100%; display: block; }
.wordmark { font-family: var(--font-brand); font-weight: 700; font-size: 20px; letter-spacing: -0.01em; line-height: 1; white-space: nowrap; }
.wordmark .b { color: var(--brand-amber); }
.wordmark .s { color: var(--brand-cream); }
.wordmark.on-light .b { color: var(--brand-gold); }
.wordmark.on-light .s { color: var(--brand-green); }
@media (prefers-color-scheme: dark) { .wordmark.on-light .b { color: var(--brand-amber); } .wordmark.on-light .s { color: var(--brand-cream); } }

/* ── Shell ─────────────────────────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow: hidden;
  background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column; border-right: 1px solid rgba(255,255,255,0.04);
}
.sidebar-head { padding: 18px 18px 14px; }
.sidebar-scroll { flex: 1; overflow-y: auto; padding: 4px 10px 12px; }
.sidebar-section { margin-top: 18px; }
.sidebar-label {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 10px 6px; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--sidebar-muted);
}
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; margin: 1px 0;
  border: 0; border-radius: 9px; background: transparent; color: var(--sidebar-text); cursor: pointer; text-align: left;
  font-size: 14px; text-decoration: none !important;
}
.nav-item:hover { background: var(--sidebar-hover); color: var(--brand-cream); }
.nav-item.active { background: var(--sidebar-active); color: var(--brand-cream); }
.nav-item.active .nav-icon { color: var(--brand-amber); }
.nav-item .nav-icon { color: var(--sidebar-muted); display: grid; place-items: center; }
.nav-item .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.store-avatar {
  width: 26px; height: 26px; border-radius: 8px; flex: none; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; font-family: var(--font-brand);
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #4E655C; flex: none; }
.status-dot.on { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18); }
.sidebar-search { margin: 0 6px 8px; position: relative; }
.sidebar-search input {
  width: 100%; padding: 7px 10px 7px 32px; border-radius: 9px; border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04); color: var(--brand-cream); font-size: 13px;
}
.sidebar-search input::placeholder { color: #7F9A8D; }
.sidebar-search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: #7F9A8D; }
.sidebar-foot { padding: 12px; border-top: 1px solid rgba(255,255,255,0.06); position: relative; }
.user-chip {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border-radius: 10px;
  background: transparent; border: 0; cursor: pointer; color: var(--brand-cream); text-align: left;
}
.user-chip:hover { background: var(--sidebar-hover); }
.user-chip .who { flex: 1; min-width: 0; }
.user-chip .who strong { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .who span { font-size: 12px; color: var(--sidebar-muted); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--brand-green-2); color: var(--brand-amber); font-weight: 600; font-size: 13px; font-family: var(--font-brand);
}
.avatar.lg { width: 56px; height: 56px; font-size: 20px; }
.menu {
  position: absolute; z-index: 50; min-width: 220px; padding: 6px; border-radius: 12px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
}
.sidebar-foot .menu { bottom: calc(100% - 4px); left: 12px; right: 12px; }
.menu button, .menu a {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px;
  background: none; cursor: pointer; text-align: left; color: var(--text); text-decoration: none;
}
.menu button:hover, .menu a:hover { background: var(--surface-hover); text-decoration: none; }
.menu .sep { height: 1px; background: var(--border); margin: 6px 4px; }
.menu .danger { color: var(--danger); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: none; position: sticky; top: 0; z-index: 30; height: var(--topbar-h); padding: 0 12px;
  align-items: center; gap: 10px; background: var(--sidebar-bg); color: var(--brand-cream);
}
.topbar .robot { width: 30px; height: 30px; }
.topbar .title { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.backdrop { position: fixed; inset: 0; background: rgba(6, 25, 20, 0.6); z-index: 40; animation: fade 0.15s ease; }
@keyframes fade { from { opacity: 0; } }

.page { padding: 28px 32px 40px; max-width: 1240px; width: 100%; margin: 0 auto; }
.page.full { max-width: none; padding: 0; height: 100vh; display: flex; flex-direction: column; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; font-weight: 700; font-family: var(--font-brand); letter-spacing: -0.005em; }
.page-head .lead { color: var(--text-2); margin-top: 4px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Tienda ────────────────────────────────────────────────────────────── */
.store-head { padding: 20px 28px 0; background: var(--surface); border-bottom: 1px solid var(--border); }
.store-head .row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.store-head .store-avatar { width: 44px; height: 44px; border-radius: 12px; font-size: 16px; }
.store-head h1 { font-size: 20px; font-weight: 700; font-family: var(--font-brand); }
.store-head .meta { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; color: var(--text-2); font-size: 13px; margin-top: 2px; }
.tabs { display: flex; gap: 2px; margin-top: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; border: 0; background: none; cursor: pointer;
  color: var(--text-2); font-weight: 500; border-bottom: 2px solid transparent; white-space: nowrap; text-decoration: none !important;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary-text); border-bottom-color: var(--accent); }
.store-body { flex: 1; min-height: 0; overflow: auto; }
.store-body.chat-mode { overflow: hidden; display: flex; }
.store-body > .page { padding-top: 24px; }

/* ── Tarjetas y rejillas ───────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-head h2, .card-head h3 { font-size: 15px; font-weight: 650; }
.card-head .hint { color: var(--text-2); font-size: 13px; margin-top: 2px; }
.card-body { padding: 20px; }
.card-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.auto { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.stack { display: grid; gap: 16px; }
.row-flex { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--text-2); }
.subtle { color: var(--text-3); }
.small { font-size: 12.5px; }
.stat { padding: 18px 20px; display: flex; gap: 14px; align-items: center; }
.stat .icon-wrap { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.stat .icon-wrap.honey { background: var(--accent-soft); color: var(--accent-text); }
.stat .icon-wrap.green { background: var(--success-soft); color: var(--success); }
.stat strong { font-size: 22px; display: block; line-height: 1.1; }
.stat span { color: var(--text-2); font-size: 13px; }

.store-card { display: flex; flex-direction: column; gap: 14px; padding: 18px; transition: box-shadow 0.15s, transform 0.15s, border-color 0.15s; }
.store-card:hover { box-shadow: var(--shadow); border-color: var(--border-strong); transform: translateY(-1px); }
.store-card .top { display: flex; gap: 12px; align-items: center; }
.store-card .store-avatar { width: 42px; height: 42px; border-radius: 12px; font-size: 15px; }
.store-card h3 { font-size: 15px; font-weight: 650; }
.store-card .chips { display: flex; gap: 6px; flex-wrap: wrap; }
.store-card .foot { display: flex; gap: 8px; margin-top: auto; }

.info-list { display: grid; gap: 0; }
.info-list > div { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px dashed var(--border); }
.info-list > div:last-child { border-bottom: 0; }
.info-list dt { color: var(--text-2); }
.info-list dd { margin: 0; font-weight: 500; text-align: right; overflow-wrap: anywhere; }

/* ── Botones ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 14px;
  border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 550; cursor: pointer; white-space: nowrap; transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
  text-decoration: none !important;
}
.btn:hover { background: var(--surface-hover); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); box-shadow: var(--shadow-sm); }
.btn.primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-hover); }
.btn.sm { height: 32px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn.icon { width: 38px; padding: 0; }
.btn.icon.sm { width: 32px; }
.btn.block { width: 100%; }
.btn.lg { height: 44px; font-size: 15px; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 10px; background: transparent; color: inherit; cursor: pointer; }
.icon-btn:hover { background: rgba(127, 127, 127, 0.14); }

/* ── Formularios ───────────────────────────────────────────────────────── */
.field { display: grid; gap: 6px; align-content: start; }
.label { font-weight: 550; font-size: 13px; }
label.field { font-weight: 400; font-size: inherit; }
.field .help { color: var(--text-2); font-size: 12.5px; }
.field .error { color: var(--danger); font-size: 12.5px; }
.input, .select, .textarea {
  width: 100%; min-height: 40px; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); transition: border-color 0.12s, box-shadow 0.12s;
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.invalid { border-color: var(--danger); }
.textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.textarea.code { font-family: var(--mono); font-size: 13px; min-height: 260px; }
.input-group { position: relative; }
.input-group .input { padding-left: 38px; }
.input-group > svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.input-group .trail { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.form-grid { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: 1 / -1; }

.toggle { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle .track {
  flex: none; width: 40px; height: 24px; border-radius: 99px; background: var(--border-strong); position: relative; transition: background 0.15s; margin-top: 1px;
}
.toggle .track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.25); transition: transform 0.15s;
}
.toggle input:checked + .track { background: var(--primary); }
.toggle input:checked + .track::after { transform: translateX(16px); }
.toggle input:focus-visible + .track { outline: 2px solid var(--primary); outline-offset: 2px; }
.toggle .text strong { display: block; font-weight: 550; }
.toggle .text span { color: var(--text-2); font-size: 13px; }
.toggle.disabled { opacity: 0.55; cursor: not-allowed; }

.segmented { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--surface-hover); gap: 2px; }
.segmented button { border: 0; background: none; padding: 5px 12px; border-radius: 8px; cursor: pointer; color: var(--text-2); font-weight: 550; font-size: 13px; }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.checkbox { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }
.checkbox input { width: 16px; height: 16px; accent-color: var(--primary); }

/* ── Insignias ─────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600;
  background: var(--surface-hover); color: var(--text-2); white-space: nowrap;
}
.badge.admin { background: var(--accent-soft); color: var(--accent-text); }
.badge.manager { background: var(--primary-soft); color: var(--primary-text); }
.badge.user { background: var(--info-soft); color: var(--info); }
.badge.success, .badge.open { background: var(--success-soft); color: var(--success); }
.badge.warning, .badge.in_progress { background: var(--warning-soft); color: var(--warning); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.closed { background: var(--surface-hover); color: var(--text-2); }

/* ── Tablas ────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 12px; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; color: var(--text-3);
  padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap;
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--surface-hover); }
.table .cell-user { display: flex; align-items: center; gap: 10px; }
.table .cell-user .avatar { width: 32px; height: 32px; font-size: 12px; }
.table .actions { text-align: right; white-space: nowrap; }

.empty { display: grid; place-items: center; text-align: center; gap: 8px; padding: 48px 20px; color: var(--text-2); }
.empty .icon-wrap { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: var(--surface-hover); color: var(--text-3); margin-bottom: 6px; }
.empty strong { color: var(--text); font-size: 15px; }

.alert { display: flex; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--info-soft); color: var(--info); align-items: flex-start; }
.alert.warning { background: var(--warning-soft); color: var(--warning); }
.alert.danger { background: var(--danger-soft); color: var(--danger); }
.alert .body { flex: 1; color: var(--text); }
.alert .body strong { display: block; }

/* ── Modal ─────────────────────────────────────────────────────────────── */
.modal-layer { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; background: rgba(6, 25, 20, 0.6); animation: fade 0.15s ease; }
.modal {
  width: 100%; max-width: 560px; max-height: calc(100vh - 32px); display: flex; flex-direction: column;
  background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); animation: pop 0.18s ease;
}
.modal.wide { max-width: 820px; }
@keyframes pop { from { transform: translateY(8px) scale(0.98); opacity: 0; } }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { flex: 1; font-size: 17px; font-weight: 650; }
.modal-body { padding: 20px; overflow-y: auto; display: grid; gap: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }

/* ── Avisos ────────────────────────────────────────────────────────────── */
.toasts { position: fixed; z-index: 200; right: 20px; top: 20px; display: grid; gap: 8px; max-width: min(380px, calc(100vw - 40px)); }
.toast {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: var(--brand-green); color: var(--brand-cream);
  box-shadow: var(--shadow-lg); animation: pop 0.2s ease; font-size: 13.5px;
}
.toast.error { background: #7A231A; }
.toast .ico { color: var(--brand-amber); display: grid; }
.toast.error .ico { color: #fecaca; }

/* ── Chat ──────────────────────────────────────────────────────────────── */
.chat { flex: 1; display: flex; flex-direction: column; min-height: 0; background: var(--bg); }
.chat-bar { display: flex; align-items: center; gap: 12px; padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--border); }
.chat-bar .who { flex: 1; min-width: 0; }
.chat-bar .who strong { display: block; font-size: 14px; }
.chat-bar .who span { font-size: 12.5px; color: var(--text-2); }
.bot-avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-green); color: var(--brand-amber); flex: none; }
.bot-avatar .robot { width: 72%; height: 72%; }
.chat-scroll { flex: 1; overflow-y: auto; padding: 24px 20px; }
.chat-inner { max-width: 820px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
.msg { display: flex; gap: 10px; align-items: flex-end; max-width: 88%; }
.msg.me { align-self: flex-end; flex-direction: row-reverse; }
.msg .bot-avatar { width: 28px; height: 28px; }
.msg.error .bot-avatar { background: var(--danger-soft); color: var(--danger); }
.bubble {
  padding: 10px 14px; border-radius: 16px; background: var(--bubble-bot); border: 1px solid var(--border);
  box-shadow: var(--shadow-sm); white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55;
}
.msg.bot .bubble { border-bottom-left-radius: 6px; }
.msg.me .bubble { background: var(--bubble-me); color: var(--bubble-me-text); border-color: transparent; border-bottom-right-radius: 6px; }
.msg.me .bubble a { color: inherit; text-decoration: underline; }
.msg.error .bubble { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.bubble.image { padding: 6px; max-width: 340px; }
.bubble.image img { display: block; width: 100%; border-radius: 12px; background: var(--surface-hover); }
.bubble.image .caption { padding: 8px 8px 4px; }
.bubble .file-chip { margin-top: 6px; }
.msg-time { font-size: 11px; color: var(--text-3); margin: 0 4px 2px; white-space: nowrap; }
.typing { display: inline-flex; gap: 4px; padding: 14px 16px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); animation: blink 1.2s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.chat-empty { margin: auto; max-width: 560px; text-align: center; display: grid; gap: 14px; justify-items: center; padding: 24px 0; }
.chat-empty .bot-avatar { width: 76px; height: 76px; }
.chat-empty h2 { font-size: 22px; }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 6px; }
.suggestion {
  padding: 8px 14px; border-radius: 99px; border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer;
  color: var(--text); font-size: 13px; transition: border-color 0.12s, background 0.12s;
}
.suggestion:hover { border-color: var(--accent); background: var(--accent-soft); }
.composer { padding: 12px 20px 16px; background: transparent; }
.composer-box {
  max-width: 820px; margin: 0 auto; display: flex; flex-direction: column; gap: 8px; padding: 8px; border-radius: 18px;
  background: var(--surface); border: 1px solid var(--border-strong); box-shadow: var(--shadow);
}
.composer-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer-row { display: flex; align-items: flex-end; gap: 6px; }
.composer textarea {
  flex: 1; border: 0; outline: none; resize: none; background: transparent; padding: 8px 6px; max-height: 180px; min-height: 38px; line-height: 1.45;
}
.composer .send { width: 38px; height: 38px; border-radius: 12px; border: 0; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; cursor: pointer; flex: none; }
.composer .send:disabled { opacity: 0.4; cursor: not-allowed; }
.composer .hint { max-width: 820px; margin: 6px auto 0; text-align: center; font-size: 11.5px; color: var(--text-3); }
.file-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 4px; }
.file-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; background: var(--surface-hover); font-size: 12.5px; }
.msg.me .file-chip { background: rgba(255, 255, 255, 0.18); }

/* ── Tickets ───────────────────────────────────────────────────────────── */
.tickets-layout { display: grid; grid-template-columns: minmax(300px, 400px) 1fr; gap: 16px; align-items: start; }
.ticket-list { max-height: calc(100vh - 230px); overflow-y: auto; }
.ticket-item { display: grid; gap: 4px; padding: 14px 16px; border-bottom: 1px solid var(--border); cursor: pointer; background: none; border-left: 3px solid transparent; width: 100%; text-align: left; border-top: 0; border-right: 0; }
.ticket-item:hover { background: var(--surface-hover); }
.ticket-item.active { background: var(--primary-soft); border-left-color: var(--accent); }
.ticket-item .line { display: flex; gap: 8px; align-items: center; }
.ticket-item .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.ticket-detail .timeline { display: grid; gap: 12px; }
.tmsg { padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); }
.tmsg.admin { background: var(--primary-soft); border-color: transparent; }
.tmsg .who { display: flex; gap: 8px; align-items: center; font-size: 12.5px; color: var(--text-2); margin-bottom: 4px; }
.tmsg .body { white-space: pre-wrap; overflow-wrap: anywhere; }
.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.attachments img { width: 120px; height: 90px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.extra-grid { display: grid; gap: 10px; }
.extra-grid > div { padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); }
.extra-grid strong { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--accent-text); }

/* ── Tipos de ticket ───────────────────────────────────────────────────── */
.type-card { display: flex; gap: 14px; padding: 16px 18px; align-items: flex-start; }
.type-card .order { display: grid; gap: 2px; }
.type-card .content { flex: 1; min-width: 0; }
.type-card h3 { font-size: 15px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.type-card p { color: var(--text-2); margin-top: 4px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.type-card.disabled { opacity: 0.65; }
.fields-editor { display: grid; gap: 10px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr 2fr auto auto; gap: 8px; align-items: center; padding: 10px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }

.timeline-audit { display: grid; }
.audit-row { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); align-items: center; }
.audit-row:last-child { border-bottom: 0; }
.audit-row .dot { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-hover); color: var(--text-2); flex: none; }

.settings-grid { grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); align-items: start; }

/* ── WhatsApp ──────────────────────────────────────────────────────────── */
.title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.title-row h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.wa-chip {
  display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 10px; border-radius: 99px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.wa-chip:hover { border-color: var(--accent); background: var(--accent-soft); }
.wa-chip:disabled { cursor: default; opacity: 0.7; }
.wa-chip > svg { color: var(--success); }
.wa-unread { padding: 1px 7px; border-radius: 99px; background: var(--accent); color: var(--brand-green); font-size: 11.5px; font-weight: 700; }
.status-dot.warn { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.status-dot.bad { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.status-dot.busy { background: var(--text-3); animation: blink 1.2s infinite ease-in-out; }
.wa-center { display: grid; justify-items: center; text-align: center; gap: 12px; padding: 28px 12px; }
.wa-center h2 { font-size: 18px; }
.wa-center p { max-width: 520px; }
.wa-icon { width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; background: var(--danger-soft); color: var(--danger); }
.wa-icon.ok { background: var(--success-soft); color: var(--success); }
.wa-icon.warn { background: var(--warning-soft); color: var(--warning); }
.cmd { display: inline-block; padding: 8px 12px; border-radius: 8px; background: var(--surface-hover); user-select: all; }
.wa-grid { display: grid; grid-template-columns: auto 1fr; gap: 28px; align-items: center; }
.wa-grid h2 { font-size: 18px; }
.qr-box { width: 304px; height: 304px; padding: 12px; border-radius: 16px; background: #fff; display: grid; place-items: center; box-shadow: var(--shadow); }
.qr-box img { display: block; width: 280px; height: 280px; image-rendering: pixelated; }
.pair-box { width: 304px; padding: 28px 12px; border-radius: 16px; background: var(--surface-2); border: 1px dashed var(--border-strong); display: grid; gap: 8px; justify-items: center; }
.pair-code { font-family: var(--font-brand); font-weight: 700; color: var(--primary-text); font-size: 38px; letter-spacing: 0.08em; user-select: all; }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 6px; }

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tickets-layout, .settings-grid, .wa-grid { grid-template-columns: 1fr; }
  .wa-grid { justify-items: center; }
  .ticket-list { max-height: none; }
}
@media (max-width: 900px) {
  .login { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 50; left: 0; top: 0; bottom: 0; width: min(86vw, var(--sidebar-w)); transform: translateX(-100%); transition: transform 0.22s ease; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .topbar { display: flex; }
  .page { padding: 20px 16px 32px; }
  .page.full { height: calc(100vh - var(--topbar-h)); height: calc(100dvh - var(--topbar-h)); }
  .store-head { padding: 12px 16px 0; }
  .store-head .row { flex-wrap: nowrap; }
  .store-head .row > .badge { display: none; }
  .store-head .store-avatar { width: 36px; height: 36px; font-size: 13px; }
  .store-head h1 { font-size: 17px; }
  .wa-chip { height: 26px; padding: 0 8px; }
  .store-head .meta { font-size: 12px; gap: 6px; }
  .tabs { margin-top: 10px; }
  .grid.cols-2, .grid.cols-3, .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .chat-bar { padding: 10px 14px; }
  .chat-bar .btn span { display: none; }
  .chat-bar .btn { width: 36px; padding: 0; }
  .chat-scroll { padding: 16px 12px; }
  .composer { padding: 8px 10px 12px; }
  .msg { max-width: 94%; }
  .field-row { grid-template-columns: 1fr 1fr; }
  .field-row .wide { grid-column: 1 / -1; }
  .table .hide-sm { display: none; }
  .modal-layer { padding: 0; place-items: end stretch; }
  .modal { max-width: none; max-height: 92vh; border-radius: 18px 18px 0 0; }
  .toasts { left: 16px; right: 16px; top: calc(var(--topbar-h) + 8px); max-width: none; }
}
@media (max-width: 560px) {
  .grid.cols-4 { grid-template-columns: 1fr 1fr; }
  .page-head h1 { font-size: 20px; }
  .stat { padding: 14px; }
  .stat strong { font-size: 19px; }
}
