/* ============================================================
   Aimotive Console — Design System
   Aura purple, clean modern SaaS. Plus Jakarta Sans.
   ============================================================ */

:root {
  /* Brand — Aimotive corporate blue (#1b2bb8) */
  --purple-50:  #eef0fc;
  --purple-100: #dde1f9;
  --purple-200: #bdc5f1;
  --purple-300: #919ce6;
  --purple-400: #5566d6;
  --purple-500: #2533c2;   /* bright primary */
  --purple-600: #1b2bb8;   /* corporate primary */
  --purple-700: #16229a;
  --purple-800: #111b78;
  --purple-900: #0b1250;

  /* Neutrals (slightly blue-tinted) */
  --ink:        #14172b;
  --ink-2:      #343852;
  --muted:      #64687f;
  --muted-2:    #8e92a8;
  --line:       #e9eaf2;
  --line-2:     #dfe1ec;
  --surface:    #ffffff;
  --bg:         #f5f6fb;
  --bg-2:       #eef0f7;

  /* Status */
  --green:   #16a34a;
  --green-bg:#e8f7ee;
  --amber:   #d97706;
  --amber-bg:#fdf2e3;
  --red:     #dc2626;
  --red-bg:  #fdeaea;
  --blue:    #2563eb;
  --blue-bg: #e9f0ff;
  --whatsapp:#25d366;

  /* Radius & shadow */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --shadow-sm: 0 1px 2px rgba(26,21,35,.05), 0 1px 3px rgba(26,21,35,.04);
  --shadow-md: 0 4px 16px rgba(17,27,120,.07), 0 1px 4px rgba(17,27,120,.04);
  --shadow-lg: 0 16px 48px rgba(17,27,120,.16), 0 4px 12px rgba(17,27,120,.07);
  --shadow-purple: 0 8px 24px rgba(27,43,184,.28);

  --sidebar-w: 256px;
  --topbar-h: 64px;

  --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'Space Grotesk', ui-monospace, 'SF Mono', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#root { height: 100%; }

button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; }
a { color: inherit; text-decoration: none; }

::selection { background: var(--purple-200); color: var(--purple-900); }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 20px; border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--muted-2); }

/* ===================== Layout ===================== */
.app-shell { display: flex; height: 100%; overflow: hidden; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  height: 100%;
}

.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; height: 100%; }

.topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.page-scroll { flex: 1; overflow-y: auto; }
.page { padding: 28px 32px 64px; max-width: 1320px; margin: 0 auto; }

/* ===================== Sidebar bits ===================== */
.brand {
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  padding: 24px 20px 20px;
}
.brand-wordmark { height: 33px; width: auto; display: block; }
.brand-console {
  font-size: 10.5px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase;
  color: var(--purple-600); background: var(--purple-50); border-radius: 6px; padding: 3px 8px;
}
.brand-icon { height: 30px; width: auto; display: block; }
/* Login: bigger logo, flush-left with the content */
.brand-login { padding: 0 0 4px; gap: 12px; }
.brand-login .brand-wordmark { height: 48px; }
.brand-login .brand-console { font-size: 12px; padding: 4px 11px; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(150deg, var(--purple-400), var(--purple-600) 60%, var(--purple-800));
  display: grid; place-items: center; flex-shrink: 0;
  box-shadow: var(--shadow-purple);
}
.brand-name { font-weight: 800; font-size: 17px; letter-spacing: -.02em; }
.brand-sub { font-size: 11px; color: var(--muted-2); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }

.nav-section { padding: 6px 14px; }
.nav-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted-2); padding: 14px 12px 7px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: var(--r-sm);
  color: var(--ink-2); font-weight: 600; font-size: 14px;
  width: 100%; text-align: left; transition: background .12s, color .12s;
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--bg-2); color: var(--ink); }
.nav-item.active { background: var(--purple-50); color: var(--purple-700); }
.nav-item.active svg { color: var(--purple-600); }
.nav-item svg { color: var(--muted-2); flex-shrink: 0; }
.nav-item .nav-badge {
  margin-left: auto; background: var(--purple-500); color: #fff;
  font-size: 11px; font-weight: 700; border-radius: 20px; padding: 1px 7px; min-width: 20px; text-align: center;
}
.nav-item.active .nav-badge { background: var(--purple-600); }

.sidebar-foot { margin-top: auto; padding: 14px; border-top: 1px solid var(--line); }
.user-chip {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-md);
  width: 100%; transition: background .12s;
}
.user-chip:hover { background: var(--bg-2); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff;
}
.user-chip .u-name { font-weight: 700; font-size: 13.5px; line-height: 1.2; }
.user-chip .u-role { font-size: 11.5px; color: var(--muted); }

/* ===================== Typography ===================== */
.page-head { margin-bottom: 24px; }
.page-title { font-size: 25px; font-weight: 800; letter-spacing: -.025em; }
.page-sub { color: var(--muted); font-size: 14.5px; margin-top: 4px; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--purple-600); }
.section-title { font-size: 16px; font-weight: 800; letter-spacing: -.01em; }
.num { font-family: var(--mono); font-feature-settings: "tnum"; letter-spacing: -.02em; }

/* ===================== Cards ===================== */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px 22px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px; border-bottom: 1px solid var(--line);
}

/* Stat card */
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 18px 20px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.stat-label { font-size: 13px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.stat-value { font-size: 30px; font-weight: 800; letter-spacing: -.03em; margin-top: 8px; font-family: var(--mono); }
.stat-value small { font-size: 16px; color: var(--muted-2); font-weight: 600; }
.stat-foot { font-size: 12.5px; margin-top: 7px; display: flex; align-items: center; gap: 5px; font-weight: 600; }
.stat-ico {
  position: absolute; top: 16px; right: 16px; width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center; background: var(--purple-50); color: var(--purple-600);
}

.grid { display: grid; gap: 16px; }
.g-2 { grid-template-columns: repeat(2,1fr); }
.g-3 { grid-template-columns: repeat(3,1fr); }
.g-4 { grid-template-columns: repeat(4,1fr); }
.flex { display: flex; }
.between { justify-content: space-between; }
.items-center { align-items: center; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.mt-8{margin-top:8px}.mt-16{margin-top:16px}.mt-24{margin-top:24px}.mt-32{margin-top:32px}
.wrap { flex-wrap: wrap; }

/* ===================== Badges / pills ===================== */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 700; white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; }
.b-green { background: var(--green-bg); color: var(--green); }
.b-amber { background: var(--amber-bg); color: var(--amber); }
.b-red   { background: var(--red-bg);  color: var(--red); }
.b-blue  { background: var(--blue-bg); color: var(--blue); }
.b-purple{ background: var(--purple-100); color: var(--purple-700); }
.b-gray  { background: var(--bg-2); color: var(--muted); }

.tag {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px;
  border-radius: 7px; font-size: 12px; font-weight: 600; background: var(--bg-2); color: var(--ink-2);
  border: 1px solid var(--line-2);
}

/* ===================== Buttons ===================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px; border-radius: 10px; font-weight: 700; font-size: 13.5px;
  transition: transform .08s, background .12s, box-shadow .12s, border-color .12s; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--purple-500); color: #fff; box-shadow: var(--shadow-purple); }
.btn-primary:hover { background: var(--purple-600); }
.btn-ghost { background: var(--surface); color: var(--ink-2); border: 1px solid var(--line-2); box-shadow: var(--shadow-sm); }
.btn-ghost:hover { background: var(--bg-2); border-color: var(--muted-2); }
.btn-subtle { background: var(--bg-2); color: var(--ink-2); }
.btn-subtle:hover { background: var(--line-2); }
.btn-wa { background: var(--whatsapp); color: #fff; }
.btn-wa:hover { filter: brightness(.95); }
.btn-danger { background: var(--red-bg); color: var(--red); }
.btn-danger:hover { background: #fbdada; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn-lg { padding: 12px 20px; font-size: 15px; border-radius: 12px; }
.btn-icon { padding: 8px; border-radius: 9px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ===================== Table ===================== */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl thead th {
  text-align: left; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted-2); padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap;
  position: sticky; top: 0; background: var(--surface); z-index: 1;
}
.tbl tbody td { padding: 14px 16px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
.tbl tbody tr { transition: background .1s; cursor: pointer; }
.tbl tbody tr:hover { background: var(--purple-50); }
.tbl tbody tr:last-child td { border-bottom: none; }
.sort-th { cursor: pointer; user-select: none; transition: color .12s; }
.sort-th:hover { color: var(--purple-600); }
.sort-th.active { color: var(--purple-600); }
.sort-th-in { display: inline-flex; align-items: center; gap: 5px; }
.sort-ar { font-size: 9px; opacity: .9; }
.sort-th:not(.active) .sort-ar { opacity: .35; }
.cell-strong { font-weight: 700; line-height: 1.3; }
.cell-mut { color: var(--muted); font-size: 13px; line-height: 1.35; }

/* ===================== Progress ===================== */
.progress { height: 8px; background: var(--bg-2); border-radius: 20px; overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 20px; background: var(--purple-500); transition: width .5s; }
.progress.thin { height: 6px; }
.progress.green > span { background: var(--green); }
.progress.amber > span { background: var(--amber); }

/* Conversation pips (X/10) */
.pips { display: inline-flex; gap: 3px; }
.pip { width: 11px; height: 11px; border-radius: 3px; background: var(--bg-2); border: 1px solid var(--line-2); }
.pip.on { background: var(--purple-500); border-color: var(--purple-500); }
.pip.last { background: var(--purple-300); border-color: var(--purple-300); }

/* ===================== Inputs ===================== */
.field { display: block; margin-bottom: 16px; }
.field-label { font-size: 13px; font-weight: 700; color: var(--ink-2); margin-bottom: 7px; display: block; }
.field-hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.input, .select, .textarea {
  width: 100%; padding: 10px 13px; border: 1px solid var(--line-2); border-radius: 10px;
  font-size: 14px; color: var(--ink); background: var(--surface); transition: border-color .12s, box-shadow .12s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--purple-400); box-shadow: 0 0 0 3px var(--purple-100);
}
.input-search {
  display: flex; align-items: center; gap: 9px; padding: 8px 13px; background: var(--bg);
  border: 1px solid var(--line-2); border-radius: 10px; color: var(--muted);
}
.input-search input { border: none; background: none; outline: none; font-size: 14px; width: 100%; color: var(--ink); }

/* Toggle switch */
.switch { width: 40px; height: 23px; border-radius: 20px; background: var(--line-2); position: relative; transition: background .15s; flex-shrink: 0; }
.switch.on { background: var(--purple-500); }
.switch::after { content:''; position: absolute; top: 2px; left: 2px; width: 19px; height: 19px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: var(--shadow-sm); }
.switch.on::after { left: 19px; }

/* Segmented control */
.seg { display: inline-flex; background: var(--bg-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { padding: 6px 13px; border-radius: 8px; font-size: 13px; font-weight: 700; color: var(--muted); }
.seg button.active { background: var(--surface); color: var(--purple-700); box-shadow: var(--shadow-sm); }

/* ===================== Misc ===================== */
.divider { height: 1px; background: var(--line); margin: 18px 0; }
.kbd { font-family: var(--mono); font-size: 11px; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 5px; padding: 1px 6px; color: var(--muted); }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }

/* Avatar list */
.av-sm { width: 30px; height: 30px; font-size: 12px; border-radius: 9px; }

/* WhatsApp chat bubbles */
.wa-window { background: #e9e2da; border-radius: 14px; padding: 16px; background-image: radial-gradient(circle, rgba(0,0,0,.03) 1px, transparent 1px); background-size: 18px 18px; }
.wa-msg { max-width: 78%; padding: 8px 11px; border-radius: 9px; font-size: 13.5px; line-height: 1.45; margin-bottom: 8px; box-shadow: 0 1px 1px rgba(0,0,0,.08); position: relative; }
.wa-in { background: #fff; align-self: flex-start; border-top-left-radius: 2px; }
.wa-out { background: #d9fdd3; align-self: flex-end; border-top-right-radius: 2px; }
.wa-time { font-size: 10px; color: rgba(0,0,0,.4); float: right; margin: 6px 0 -2px 8px; }
.wa-col { display: flex; flex-direction: column; }

/* Toast */
.toast-host { position: fixed; bottom: 24px; right: 24px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--ink); color: #fff; padding: 13px 18px; border-radius: 12px; font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 11px; animation: toastIn .25s cubic-bezier(.2,.8,.2,1) both;
  max-width: 380px;
}
.toast .t-ico { width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; flex-shrink: 0; }
@keyframes toastIn { from { opacity: .5; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(26,21,35,.45); backdrop-filter: blur(3px); z-index: 100; display: grid; place-items: center; padding: 24px; }
.modal { background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; animation: modalIn .22s cubic-bezier(.2,.8,.2,1) both; }
@keyframes modalIn { from { opacity: .7; transform: translateY(10px) scale(.99) } to { opacity: 1; transform: none } }
.modal-head { padding: 22px 24px 0; }
.modal-body { padding: 18px 24px; }
.modal-foot { padding: 16px 24px 22px; display: flex; gap: 10px; justify-content: flex-end; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 22px; }
.tab { padding: 11px 16px; font-weight: 700; font-size: 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color .12s; }
.tab:hover { color: var(--ink-2); }
.tab.active { color: var(--purple-700); border-bottom-color: var(--purple-500); }

/* Donut */
.donut-wrap { position: relative; display: grid; place-items: center; }
.donut-center { position: absolute; text-align: center; }

/* fade-in for routed pages — opacity only, capture-safe */
.fade-in { animation: pageIn .3s ease both; }
@keyframes pageIn { from { opacity: .82 } to { opacity: 1 } }

/* link */
.link { color: var(--purple-600); font-weight: 700; cursor: pointer; }
.link:hover { text-decoration: underline; }

/* Consultas realizadas cell (clickable) */
.consultas-cell {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 11px; border-radius: 9px; white-space: nowrap;
  background: var(--purple-50); border: 1px solid var(--purple-100); transition: background .12s, border-color .12s;
}
.consultas-cell:hover { background: var(--purple-100); border-color: var(--purple-200); }
.consultas-cell .count { font-size: 16px; font-weight: 800; color: var(--purple-700); }
.consultas-cell .of { font-size: 12.5px; font-weight: 700; color: var(--muted-2); }
.consultas-cell .see { font-size: 12px; font-weight: 700; color: var(--purple-600); margin-left: 4px; }
.consultas-cell svg { color: var(--purple-500); }

/* Pieces list (modal) */
.pieces-list { display: flex; flex-direction: column; }
.piece-row { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--line); }
.piece-row:last-child { border-bottom: none; }
.piece-idx { width: 26px; height: 26px; border-radius: 8px; background: var(--bg-2); color: var(--muted); font-size: 12px; font-weight: 700; display: grid; place-items: center; flex-shrink: 0; }
.piece-ico { width: 30px; height: 30px; border-radius: 9px; background: var(--purple-50); color: var(--purple-600); display: grid; place-items: center; flex-shrink: 0; }
.piece-txt { font-size: 14px; font-weight: 600; }

/* mini bar chart */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 90px; }
.bar { flex: 1; background: var(--purple-200); border-radius: 5px 5px 0 0; min-height: 4px; transition: height .4s; position: relative; }
.bar.hl { background: var(--purple-500); }

/* breadcrumb */
.crumb { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 14px; }
.crumb .link:hover { text-decoration: underline; }

/* avatar-pic for tallers */
.id-pill { font-family: var(--mono); font-size: 12px; color: var(--muted-2); }
