/* Mi App Empresas — estilos del panel
   Estructura tipo WordPress (menú lateral + barra superior) con estilo moderno. */

:root {
  --primary: #ff6a00;
  --sidebar: #141414;
  --accent: #e8380d;
  --grad: linear-gradient(135deg, var(--primary) 0%, color-mix(in srgb, var(--primary) 55%, var(--accent)) 100%);
  --bg: #f5f5f4;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #0284c7;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --sidebar-w: 248px;
  --topbar-h: 60px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .4em; }
h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0 0 .8em; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88em; background: #f1f2f4; padding: 2px 6px; border-radius: 6px; word-break: break-all; }
small { font-size: .82rem; }
.muted { color: var(--muted); }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.pad { padding: 14px 16px; }
.icon { flex-shrink: 0; vertical-align: middle; }
[hidden] { display: none !important; }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar);
  color: #cbd5e1;
  position: fixed; inset: 0 auto 0 0;
  display: flex; flex-direction: column;
  z-index: 40;
  transition: transform .2s ease;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  height: var(--topbar-h); padding: 0 18px;
  color: #fff; font-weight: 700; font-size: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.sidebar-brand:hover { text-decoration: none; }
.sidebar-brand img { width: 32px; height: 32px; object-fit: contain; border-radius: 8px; background: #fff; }
.brand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0;
  display: inline-grid; place-items: center;
  background: var(--primary); color: #fff; font-weight: 800;
}
.menu { flex: 1; overflow-y: auto; padding: 12px 10px; }
.menu-label {
  display: flex; align-items: center; gap: 6px;
  margin: 18px 10px 6px; font-size: .7rem; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase; color: #64748b;
}
.menu-item > a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: 9px;
  color: #cbd5e1; font-weight: 500;
}
.menu-item > a:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.menu-item.active > a { background: var(--primary); color: #fff; }
.submenu { margin: 4px 0 6px 30px; border-left: 1px solid rgba(255, 255, 255, .1); }
.submenu a { display: block; padding: 6px 12px; color: #94a3b8; font-size: .9rem; }
.submenu a:hover { color: #fff; text-decoration: none; }
.submenu a.current { color: #fff; font-weight: 600; }
.sidebar-foot { padding: 12px 18px; font-size: .72rem; color: #64748b; border-top: 1px solid rgba(255, 255, 255, .07); }
.sidebar-backdrop { display: none; }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  padding: 0 22px;
  position: sticky; top: 0; z-index: 30;
}
.topbar-title { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.icon-btn.menu-toggle { display: none; }
.content { padding: 26px; max-width: 1280px; width: 100%; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px; border-radius: 9px; border: 1px solid transparent;
  font: inherit; font-weight: 600; font-size: .9rem; line-height: 1.2;
  cursor: pointer; white-space: nowrap;
  transition: filter .15s, background .15s;
}
.btn:hover { text-decoration: none; filter: brightness(.95); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-secondary { background: #fff; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: #f9fafb; }
.btn-danger { background: #fff; color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; }
.btn-ghost { background: transparent; color: var(--text); padding: 7px 10px; }
.btn-ghost:hover { background: #f1f2f4; }
.btn-sm { padding: 6px 11px; font-size: .84rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .6; cursor: default; }
.icon-btn {
  position: relative; display: inline-grid; place-items: center;
  width: 38px; height: 38px; border-radius: 9px;
  border: 0; background: transparent; color: var(--text); cursor: pointer;
}
.icon-btn:hover { background: #f1f2f4; }
.link-btn { border: 0; background: none; padding: 0; color: var(--primary); font: inherit; font-size: .85rem; cursor: pointer; }
.inline-form { display: inline; }

/* ---------- Dropdowns ---------- */
.dropdown { position: relative; }
.dropdown-menu {
  display: none; position: absolute; right: 0; top: calc(100% + 6px);
  min-width: 200px; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(16, 24, 40, .14); overflow: hidden; z-index: 50;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu > a { display: flex; align-items: center; gap: 9px; padding: 10px 14px; color: var(--text); }
.dropdown-menu > a:hover { background: #f6f7f9; text-decoration: none; }
.dropdown-wide { width: 340px; }
.dropdown-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.dropdown-foot { justify-content: center; border-top: 1px solid var(--border); font-weight: 600; color: var(--primary) !important; }
.dot-count {
  position: absolute; top: 3px; right: 2px;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: .68rem; font-weight: 700;
  display: grid; place-items: center; border: 2px solid #fff;
}
.notif-list { max-height: 360px; overflow-y: auto; }
.notif-item { display: block; padding: 10px 14px; border-bottom: 1px solid #f1f2f4; color: var(--text); }
.notif-item:hover { background: #f8f9fb; text-decoration: none; }
.notif-item.unread { background: #f5f8ff; }
.notif-item.unread strong::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--primary); margin-right: 6px; vertical-align: middle; }
.notif-item p { margin: 2px 0; color: var(--muted); font-size: .85rem; }

.user-btn { display: flex; align-items: center; gap: 9px; border: 0; background: transparent; cursor: pointer; padding: 4px 8px 4px 4px; border-radius: 10px; font: inherit; color: var(--text); text-align: left; }
.user-btn:hover { background: #f1f2f4; }
.user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-meta small { color: var(--muted); }
.avatar { display: inline-grid; place-items: center; border-radius: 50%; color: #fff; font-weight: 700; flex-shrink: 0; }

/* ---------- Encabezados y tarjetas ---------- */
.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-header p { margin: 2px 0 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; margin-bottom: 18px;
}
.card-title { font-size: 1rem; margin-bottom: 14px; }
.empty { text-align: center; color: var(--muted); padding: 36px 16px; }
.empty .icon { color: #c3c8d0; margin-bottom: 8px; }
.empty h3 { color: var(--text); }

/* ---------- Avisos y badges ---------- */
.notice { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; border: 1px solid; font-size: .92rem; }
.notice-success { background: #f0fdf4; border-color: #bbf7d0; color: #14532d; }
.notice-error { background: #fef2f2; border-color: #fecaca; color: #7f1d1d; }
.notice-warning { background: #fffbeb; border-color: #fde68a; color: #78350f; }
.notice-info { background: #f0f9ff; border-color: #bae6fd; color: #0c4a6e; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .74rem; font-weight: 650; line-height: 1.6; vertical-align: middle; white-space: nowrap; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #e0f2fe; color: #075985; }
.badge-neutral { background: #f1f2f4; color: #4b5563; }
.badge-primary { background: color-mix(in srgb, var(--primary) 14%, white); color: var(--primary); }

/* ---------- Formularios ---------- */
.form .field, .field { margin-bottom: 16px; display: flex; flex-direction: column; gap: 6px; }
.field > label { font-weight: 600; font-size: .88rem; }
.req { color: var(--danger); }
.help { color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=tel], input[type=search],
input[type=date], input[type=datetime-local], input[type=url], input[type=time], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 9px;
  font: inherit; color: var(--text); background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
input[type=color] { width: 64px; height: 40px; padding: 3px; border: 1px solid #d1d5db; border-radius: 9px; background: #fff; cursor: pointer; }
input[type=file] { font: inherit; font-size: .88rem; }
.field-check { flex-direction: row !important; }
.field-check label { display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.field-check input, .perm input { width: 17px; height: 17px; accent-color: var(--primary); }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 18px; }
.align-start { align-items: start; gap: 18px; }
.filters { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.filters input[type=search] { flex: 1; min-width: 200px; }
.filters select { width: auto; min-width: 180px; }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; margin: -20px; }
.card > .table-wrap:only-child { margin: -20px; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid #f0f1f3; vertical-align: middle; }
.table thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; background: #fafbfc; }
.table tbody tr:hover { background: #fafbfc; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .actions { text-align: right; white-space: nowrap; }
.table.kv th { width: 260px; text-transform: none; letter-spacing: 0; font-size: .9rem; color: var(--text); background: transparent; }
.cell-user { display: flex; align-items: center; gap: 10px; }
.cell-user > div { display: flex; flex-direction: column; }
.card h2.card-title + .table-wrap { margin-top: 0; }
.pagination { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pagination a, .pagination span.current { min-width: 34px; height: 34px; padding: 0 10px; display: inline-grid; place-items: center; border-radius: 8px; border: 1px solid var(--border); background: #fff; color: var(--text); }
.pagination span.current { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 600; }
.pagination .muted { margin-left: 10px; }

/* ---------- Escritorio ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; margin-bottom: 18px; }
.stat { display: flex; align-items: center; gap: 14px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); color: var(--text); }
a.stat:hover { text-decoration: none; border-color: var(--primary); }
.stat-icon { width: 42px; height: 42px; border-radius: 11px; display: inline-grid; place-items: center; background: color-mix(in srgb, var(--primary) 12%, white); color: var(--primary); flex-shrink: 0; }
.stat-value { font-size: 1.5rem; font-weight: 750; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: .85rem; }
.widgets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.widgets .card { margin: 0; }
.widget-wide { grid-column: 1 / -1; }
.feed { list-style: none; margin: 0 0 10px; padding: 0; }
.feed li { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid #f1f2f4; }
.feed li:last-child { border: 0; }
.feed small { display: block; }

/* ---------- Roles ---------- */
.role-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.role-card { margin: 0; display: flex; flex-direction: column; }
.role-head { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.role-head h3 { margin: 0 0 2px; }
.role-meta { display: flex; gap: 14px; color: var(--muted); font-size: .85rem; margin-top: auto; }
.role-meta span { display: inline-flex; align-items: center; gap: 5px; }
.role-actions { margin-top: 14px; }
.perm-toolbar { display: flex; justify-content: space-between; align-items: center; margin: 8px 0 12px; }
.perm-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.perm-group { margin: 0; border: 1px solid var(--border); }
.perm-group legend { font-weight: 700; padding: 0 6px; }
.perm-group legend label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.perm { display: flex; gap: 10px; align-items: flex-start; padding: 7px 0; cursor: pointer; }
.perm span { display: flex; flex-direction: column; }
.danger-zone { display: flex; justify-content: space-between; align-items: center; gap: 16px; border-color: #fecaca; }
.danger-zone p { margin: 2px 0 0; }

/* ---------- Plugins / conectores ---------- */
.upload-box { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; border-style: dashed; border-width: 2px; }
.upload-icon { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; background: #f1f2f4; color: var(--muted); }
.upload-text { flex: 1; min-width: 200px; display: flex; flex-direction: column; }
.plugin-list { margin: -20px; }
.plugin-row { display: flex; gap: 16px; padding: 18px 20px; border-bottom: 1px solid #f0f1f3; align-items: flex-start; }
.plugin-row:last-child { border: 0; }
.plugin-row.is-active { background: color-mix(in srgb, var(--primary) 4%, white); }
.plugin-icon { width: 44px; height: 44px; border-radius: 11px; display: grid; place-items: center; background: #f1f2f4; color: var(--muted); flex-shrink: 0; }
.is-active .plugin-icon { background: color-mix(in srgb, var(--primary) 14%, white); color: var(--primary); }
.plugin-info { flex: 1; min-width: 0; }
.plugin-info p { margin: 4px 0; }
.plugin-info .notice { margin: 10px 0 0; }
.plugin-title { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.plugin-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.split { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 18px; align-items: start; }
.split-nav { padding: 8px; }
.split-nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 9px; color: var(--text); font-weight: 500; }
.split-nav a span:nth-child(2) { flex: 1; }
.split-nav a:hover { background: #f4f5f7; text-decoration: none; }
.split-nav a.current { background: color-mix(in srgb, var(--primary) 10%, white); color: var(--primary); }
.status-dot { width: 9px; height: 9px; border-radius: 50%; }
.status-dot.on { background: var(--success); }
.status-dot.off { background: #d1d5db; }
.connector-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 16px; }
.connector-head > div { flex: 1; }
.connector-head h2 { margin: 0 0 2px; }
.connector-info { background: #f8f9fb; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 16px; }
.connector-info p:last-child { margin: 0; }
.code-block { background: #0f172a; color: #e2e8f0; padding: 14px 16px; border-radius: 10px; overflow-x: auto; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .82rem; white-space: pre-wrap; word-break: break-word; max-height: 520px; }
.copy { cursor: copy; }
.token-show { display: inline-block; margin-top: 6px; font-size: .95rem; background: #fff; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.current { color: var(--primary); border-color: var(--primary); }
.qa { border-bottom: 1px solid #f0f1f3; }
.qa:last-of-type { border: 0; }
.qa summary { display: flex; justify-content: space-between; gap: 12px; padding: 12px 4px; cursor: pointer; list-style: none; }
.qa summary::-webkit-details-marker { display: none; }
.qa-body { padding: 0 4px 14px; }
.logo-row { display: flex; gap: 14px; align-items: center; }
.logo-preview { width: 72px; height: 72px; border: 1px dashed #d1d5db; border-radius: 12px; display: grid; place-items: center; overflow: hidden; flex-shrink: 0; font-size: .75rem; }
.logo-preview img { max-width: 100%; max-height: 100%; }
.profile-head { display: flex; gap: 16px; align-items: center; }
.profile-head h2 { margin: 0; }
.profile-head p { margin: 0; }
.notif-page { list-style: none; margin: -20px; padding: 0; }
.notif-page li { display: flex; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid #f0f1f3; }
.notif-page li.unread { background: #f5f8ff; }
.notif-page p { margin: 2px 0 0; color: var(--muted); }

/* ---------- Login ---------- */
.auth-body { background: radial-gradient(1200px 500px at 50% -10%, color-mix(in srgb, var(--primary) 22%, white), var(--bg)); }
.auth-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 18px; font-size: 1.1rem; }
.auth-brand img { max-width: 120px; max-height: 72px; object-fit: contain; }
.auth-brand .brand-mark { width: 52px; height: 52px; border-radius: 14px; font-size: 1.5rem; }
.auth-card { width: 100%; max-width: 400px; background: #fff; border-radius: 16px; padding: 30px 28px; box-shadow: 0 10px 40px rgba(16, 24, 40, .1); }
.auth-card h1 { font-size: 1.35rem; margin-bottom: 16px; }
.auth-card .center { margin: 16px 0 0; }
.auth-icon { color: var(--primary); text-align: center; }
.auth-foot { margin-top: 22px; color: var(--muted); font-size: .8rem; }

/* ---------- Asistente ---------- */
.assistant-fab {
  position: fixed; right: 22px; bottom: 22px; z-index: 60;
  width: 56px; height: 56px; border-radius: 50%; border: 0;
  background: var(--primary); color: #fff; cursor: pointer;
  box-shadow: 0 8px 24px color-mix(in srgb, var(--primary) 45%, transparent);
  display: grid; place-items: center; transition: transform .15s;
}
.assistant-fab:hover { transform: scale(1.06); }
.assistant-panel {
  position: fixed; right: 22px; bottom: 90px; z-index: 61;
  width: 380px; max-width: calc(100vw - 24px); height: 560px; max-height: calc(100vh - 120px);
  background: #fff; border-radius: 16px; border: 1px solid var(--border);
  box-shadow: 0 20px 50px rgba(16, 24, 40, .2);
  display: flex; flex-direction: column; overflow: hidden;
}
.assistant-panel header { display: flex; justify-content: space-between; align-items: center; padding: 10px 10px 10px 16px; background: var(--primary); color: #fff; }
.assistant-panel header > div:first-child { display: flex; align-items: center; gap: 8px; }
.assistant-panel header .icon-btn { color: #fff; width: 34px; height: 34px; }
.assistant-panel header .icon-btn:hover { background: rgba(255, 255, 255, .15); }
.assistant-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; background: #f8f9fb; }
.msg { max-width: 86%; padding: 10px 13px; border-radius: 14px; font-size: .9rem; line-height: 1.5; word-wrap: break-word; }
.msg p { margin: 0 0 .5em; }
.msg p:last-child, .msg ol:last-child, .msg ul:last-child { margin-bottom: 0; }
.msg ol, .msg ul { margin: 0 0 .5em; padding-left: 20px; }
.msg-assistant { background: #fff; border: 1px solid var(--border); border-bottom-left-radius: 4px; align-self: flex-start; }
.msg-user { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; align-self: flex-end; white-space: pre-wrap; }
.msg-error { background: #fef2f2; color: #7f1d1d; border: 1px solid #fecaca; align-self: flex-start; }
.msg-typing { color: var(--muted); }
.msg-typing span { animation: blink 1.2s infinite; }
.msg-typing span:nth-child(2) { animation-delay: .2s; }
.msg-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }
.assistant-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); align-items: flex-end; }
.assistant-form textarea { resize: none; max-height: 120px; border-radius: 12px; }
.assistant-form .btn { height: 42px; width: 46px; padding: 0; border-radius: 12px; }
.assistant-foot { font-size: .72rem; color: var(--muted); text-align: center; padding: 0 10px 8px; }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .widgets { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr; }
  .split-nav { display: flex; overflow-x: auto; gap: 4px; }
  .split-nav a { white-space: nowrap; }
}
@media (max-width: 820px) {
  .sidebar { transform: translateX(-100%); }
  body.sidebar-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .3); }
  body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 35; }
  .main { margin-left: 0; }
  .icon-btn.menu-toggle { display: inline-grid; }
  .topbar { padding: 0 12px; }
  .user-meta { display: none; }
  .content { padding: 16px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .dropdown-wide { width: min(340px, calc(100vw - 24px)); right: -50px; }
  .table.responsive thead, .table-wrap .table thead { display: none; }
  .table-wrap .table tr { display: block; padding: 10px 16px; border-bottom: 1px solid #f0f1f3; }
  .table-wrap .table td { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border: 0; text-align: right; }
  .table-wrap .table td::before { content: attr(data-label); font-weight: 600; color: var(--muted); text-align: left; }
  .table-wrap .table td.actions { justify-content: flex-end; }
  .table-wrap .table td.actions::before, .table-wrap .table td.empty::before { content: none; }
  .table-wrap .table td.empty { justify-content: center; }
  .cell-user { justify-content: flex-end; text-align: right; }
  .table.kv th { width: auto; }
  .plugin-row { flex-wrap: wrap; }
  .plugin-actions { width: 100%; justify-content: flex-start; padding-left: 60px; }
  .danger-zone { flex-direction: column; align-items: flex-start; }
  .assistant-panel { right: 12px; left: 12px; width: auto; bottom: 84px; max-width: none; }
  .assistant-fab { right: 16px; bottom: 16px; }
}


/* =====================================================================
   TEMA MI APP — negro + naranja
   ===================================================================== */
body { font-family: "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }

/* Menú lateral */
.sidebar { overflow: hidden; }
.sidebar::after {
  content: ""; position: absolute; left: -40px; bottom: -30px; width: 300px; height: 210px;
  background: var(--grad); opacity: .9;
  clip-path: polygon(0 45%, 55% 100%, 0 100%);
  pointer-events: none; z-index: 0;
}
.sidebar::before {
  content: ""; position: absolute; left: 0; bottom: 0; width: 240px; height: 160px;
  background: color-mix(in srgb, var(--primary) 30%, transparent);
  clip-path: polygon(0 20%, 100% 100%, 0 100%);
  pointer-events: none; z-index: 0;
}
.sidebar > * { position: relative; z-index: 1; }
.sidebar-brand { border-bottom: 0; height: 68px; padding: 0 20px; }
.sidebar-brand .system-logo { width: 150px; height: auto; background: none; border-radius: 0; }
.sidebar-brand .company-logo { width: 38px; height: 38px; object-fit: contain; border-radius: 10px; background: #fff; padding: 3px; }
.menu { padding-top: 8px; }
.menu-item > a { padding: 11px 14px; border-radius: 11px; color: #d4d4d4; }
.menu-item > a .icon { color: #a3a3a3; }
.menu-item > a:hover { background: rgba(255, 255, 255, .06); }
.menu-item > a:hover .icon { color: #fff; }
.menu-item.active > a { background: var(--grad); color: #fff; font-weight: 600; box-shadow: 0 6px 18px color-mix(in srgb, var(--primary) 35%, transparent); }
.menu-item.active > a .icon { color: #fff; }
.submenu { border-left-color: color-mix(in srgb, var(--primary) 50%, transparent); }
.submenu a.current { color: var(--primary); }
.menu-label { color: #737373; }
.sidebar-foot { display: flex; align-items: center; gap: 8px; border-top-color: rgba(255, 255, 255, .06); color: #fff; font-weight: 600; text-shadow: 0 1px 2px rgba(0,0,0,.3); }
.sidebar-foot img { width: 18px; height: 18px; }

/* Barra superior oscura con línea naranja */
.topbar {
  background: var(--sidebar); color: #fff; border-bottom: 0; height: 68px;
  box-shadow: inset 0 -3px 0 transparent;
}
.topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--grad); }
.topbar-title { display: flex; flex-direction: column; line-height: 1.2; }
.topbar-title strong { font-size: 1.05rem; }
.topbar-title small { color: #a3a3a3; font-weight: 400; }
.topbar .icon-btn, .topbar .user-btn { color: #fff; }
.topbar .icon-btn:hover, .topbar .user-btn:hover { background: rgba(255, 255, 255, .08); }
.topbar .user-meta small { color: #a3a3a3; }
.topbar .avatar { box-shadow: 0 0 0 2px var(--sidebar), 0 0 0 4px color-mix(in srgb, var(--primary) 70%, transparent); }
.dot-count { border-color: var(--sidebar); background: var(--accent); }
:root { --topbar-h: 68px; }

/* Encabezado de página con barra naranja */
.page-header h1 { padding-left: 14px; position: relative; }
.page-header h1::before { content: ""; position: absolute; left: 0; top: 3px; bottom: 3px; width: 5px; border-radius: 3px; background: var(--grad); }
.page-header > div > p { padding-left: 14px; }

/* Botones */
.btn-primary { background: var(--grad); box-shadow: 0 4px 12px color-mix(in srgb, var(--primary) 30%, transparent); }
.btn-primary:hover { filter: brightness(1.05); }
.card { border-radius: 14px; border-color: #ececec; }
.card-title { display: flex; align-items: center; gap: 8px; }

/* Tarjetas de números: la primera resaltada en naranja */
.stat { border-radius: 14px; padding: 18px 20px; }
.stats > .stat:first-child { background: var(--grad); border-color: transparent; color: #fff; box-shadow: 0 10px 24px color-mix(in srgb, var(--primary) 30%, transparent); }
.stats > .stat:first-child .stat-label { color: rgba(255, 255, 255, .88); }
.stats > .stat:first-child .stat-icon { background: rgba(255, 255, 255, .2); color: #fff; }
.stat-value { font-size: 1.65rem; }

/* Tablas */
.table thead th { background: #fafaf9; }
.badge-primary { background: color-mix(in srgb, var(--primary) 15%, white); color: color-mix(in srgb, var(--primary) 80%, black); }

/* Pestañas */
.tabs a.current { color: var(--primary); border-color: var(--primary); }

/* Escritorio vacío */
.empty-bot { width: 120px; height: auto; margin-bottom: 6px; }

/* Login */
.auth-body { background: radial-gradient(900px 420px at 50% -5%, color-mix(in srgb, var(--primary) 35%, transparent), transparent 70%), #0f0f0f; color: #fff; }
.auth-brand { color: #fff; }
.auth-brand .system-logo { width: 220px; max-width: 70vw; max-height: none; }
.auth-brand .company-logo { max-width: 120px; max-height: 80px; background: #fff; padding: 6px; border-radius: 14px; }
.auth-brand strong { color: #d4d4d4; font-weight: 500; }
.auth-card { position: relative; color: var(--text); border-top: 4px solid var(--primary); overflow: visible; }
.auth-bot { position: absolute; right: -128px; bottom: -10px; width: 150px; pointer-events: none; filter: drop-shadow(0 10px 20px rgba(0,0,0,.4)); }
.auth-foot { display: flex; align-items: center; gap: 6px; color: #737373; }
.auth-foot img { width: 16px; height: 16px; }
@media (max-width: 720px) { .auth-bot { display: none; } }

/* Asistente: el robot */
.assistant-fab {
  width: 68px; height: 68px; padding: 0; overflow: visible;
  background: var(--sidebar);
  border: 3px solid var(--primary);
  box-shadow: 0 8px 26px color-mix(in srgb, var(--primary) 50%, transparent);
}
.assistant-fab img { width: 60px; height: 60px; object-fit: contain; margin-top: -4px; }
.assistant-fab::after { content: ""; position: absolute; right: 2px; top: 2px; width: 13px; height: 13px; border-radius: 50%; background: #22c55e; border: 2px solid var(--sidebar); }
.assistant-panel { bottom: 100px; border: 0; border-radius: 18px; }
.assistant-panel header { background: var(--sidebar); padding: 10px 10px 10px 12px; position: relative; }
.assistant-panel header::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--grad); }
.assistant-id { display: flex; align-items: center; gap: 10px; }
.assistant-id img { width: 42px; height: 42px; border-radius: 50%; background: #262626; object-fit: contain; }
.assistant-id span { display: flex; flex-direction: column; line-height: 1.2; }
.assistant-id small { color: #a3a3a3; font-size: .72rem; }
.assistant-id small::before { content: "●"; color: #22c55e; margin-right: 4px; font-size: .6rem; vertical-align: 1px; }
.msg-row { display: flex; gap: 8px; align-items: flex-end; align-self: flex-start; max-width: 92%; }
.msg-row .msg { max-width: none; }
.msg-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--sidebar); object-fit: contain; flex-shrink: 0; }
.msg-user { background: var(--grad); }
.assistant-form .btn { border-radius: 50%; width: 42px; }
.assistant-messages { background: #fafaf9; }

@media (max-width: 820px) {
  .topbar-title small { display: none; }
  .assistant-panel { bottom: 96px; }
}

/* ---------- Multiempresa ---------- */
.empresa-pill { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--card); color: var(--text); border-radius: 999px; padding: 6px 12px; font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; max-width: 240px; }
.empresa-pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empresa-pill.is-tenant { border-color: var(--primary); color: var(--primary); background: color-mix(in srgb, var(--primary) 8%, white); }
.empresa-list { max-height: 340px; overflow-y: auto; padding: 4px 0; }
.empresa-list form { margin: 0; }
.empresa-list button { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; background: none; border: 0; padding: 9px 16px; font: inherit; color: var(--text); cursor: pointer; }
.empresa-list button:hover { background: #f6f6f7; }
.empresa-list button.is-current { color: var(--primary); font-weight: 700; }
.plugin-pick { display: grid; gap: 8px; }
.plugin-pick-row { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.plugin-pick-row:has(input:checked) { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 6%, white); }
.plugin-pick-row input { margin-top: 4px; }
.tenant-banner { display: flex; align-items: center; gap: 10px; background: color-mix(in srgb, var(--primary) 10%, white); border: 1px solid color-mix(in srgb, var(--primary) 35%, white); color: #7a3300; padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; font-size: .9rem; }
.tenant-banner form { margin-left: auto; }
.embed-frame { width: 100%; min-height: calc(100vh - 190px); border: 1px solid var(--border); border-radius: var(--radius); background: #fff; display: block; }
@media (max-width: 720px) { .empresa-pill span { max-width: 110px; } }
