/* RetailFlow AI — retail foot-traffic intelligence UI */
@import url("https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700&family=IBM+Plex+Mono:wght@400;500;600&display=swap");

:root {
  /* Tema claro — legible para comercial */
  --bg: #f4f6f9;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --accent: #d97706;
  --accent-hover: #b45309;
  --accent-ink: #ffffff;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --phones: #0d9488;
  --wearables: #7c3aed;
  --devices: #059669;
  --radius: 12px;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  --font: "DM Sans", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --receipt-bg: #ffffff;
  --receipt-ink: #0f172a;
  --receipt-muted: #64748b;
  --receipt-line: #e2e8f0;
  --chart-grid: #e2e8f0;
  --chart-label: #64748b;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: var(--font);
  background:
    radial-gradient(900px 420px at 10% -5%, rgba(217, 119, 6, 0.07) 0%, transparent 55%),
    radial-gradient(700px 380px at 100% 0%, rgba(13, 148, 136, 0.06) 0%, transparent 50%),
    var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  color: var(--accent-hover);
}

.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

/* Layout */
.shell {
  max-width: 1140px;
  margin: 0 auto;
  padding: 1rem 1.25rem 3rem;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0 1.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
}
.brand:hover { color: var(--text); }
.brand .logo {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(145deg, #f59e0b 0%, #d97706 55%, #0d9488 120%);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  box-shadow: 0 4px 14px rgba(217, 119, 6, 0.25);
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
}
.nav a, .nav button.linkish {
  color: var(--text-muted);
  padding: 0.4rem 0.7rem;
  border-radius: 8px;
  border: none;
  background: transparent;
  font: inherit;
  cursor: pointer;
}
.nav a:hover, .nav a.active, .nav button.linkish:hover {
  color: var(--text);
  background: var(--bg-elevated);
}
.nav a.active {
  color: var(--accent);
  box-shadow: inset 0 -2px 0 var(--accent);
  border-radius: 8px 8px 0 0;
}

.user-chip {
  color: var(--text-muted);
  font-size: 0.82rem;
  margin-left: 0.35rem;
  font-family: var(--mono);
}

.page-title {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.page-header {
  margin-bottom: 1.15rem;
  align-items: flex-start;
}

/* Cards & KPIs */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.5rem;
}
.kpi-grid.compact {
  grid-template-columns: repeat(3, 1fr);
  gap: 0.65rem;
}

.kpi {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.kpi::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--border);
}
.kpi.phones::before { background: var(--phones); }
.kpi.wearables::before { background: var(--wearables); }
.kpi.devices::before { background: var(--devices); }
.kpi.online::before { background: var(--success); }

.kpi .label {
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}
.kpi .value {
  font-size: 1.9rem;
  font-weight: 600;
  margin-top: 0.25rem;
  font-family: var(--mono);
  letter-spacing: -0.03em;
}
.kpi.mini .value { font-size: 1.35rem; }
.kpi-sub {
  font-size: 0.78rem;
  margin-top: 0.2rem;
}
.kpi.phones .value { color: var(--phones); }
.kpi.wearables .value { color: var(--wearables); }
.kpi.devices .value { color: var(--devices); }
.kpi.online .value { color: var(--success); }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}
.card h2 {
  margin: 0 0 0.85rem;
  font-size: 1.02rem;
  font-weight: 600;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.card-header h2 { margin: 0; }
.card-hint { margin: -0.35rem 0 0.85rem; }

.grid-2 {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1.25rem;
  margin-bottom: 0;
}
.grid-2 > .card { margin-bottom: 1.25rem; }

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
th, td {
  text-align: left;
  padding: 0.65rem 0.5rem;
  border-bottom: 1px solid var(--border);
}
th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
tr:last-child td { border-bottom: none; }
td.num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}
td.small, .small { font-size: 0.78rem; }

.device-row.clickable {
  cursor: pointer;
  transition: background 0.12s ease;
}
.device-row.clickable:hover,
.device-row.clickable:focus {
  background: rgba(245, 165, 36, 0.07);
  outline: none;
}
.device-row.row-inactive {
  opacity: 0.55;
}

/* Chips & badges */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(143, 160, 184, 0.12);
  color: var(--text-muted);
  text-transform: lowercase;
}
.chip.cat-phone, .chip.cat-phones {
  background: rgba(61, 214, 198, 0.14);
  color: var(--phones);
}
.chip.cat-wearable, .chip.cat-wearables, .chip.cat-watch {
  background: rgba(155, 140, 255, 0.16);
  color: var(--wearables);
}
.chip.flag {
  background: rgba(245, 165, 36, 0.14);
  color: var(--accent);
  font-family: var(--mono);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}
.badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.badge.online {
  background: rgba(5, 150, 105, 0.12);
  color: var(--success);
}
.badge.offline {
  background: rgba(220, 38, 38, 0.08);
  color: var(--danger);
}
.badge.sensor-badge {
  gap: 0.4rem;
  padding: 0.35rem 0.7rem;
  font-size: 0.82rem;
}
.badge.sensor-badge .badge-ico {
  font-size: 0.95rem;
  line-height: 1;
}
.badge.online .badge-ico {
  animation: pulse 1.6s ease-in-out infinite;
}

/* Hero: pill grande sensor online/offline */
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}
.sensor-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
  min-width: 12rem;
}
.sensor-status-pill.is-online {
  border-color: rgba(5, 150, 105, 0.35);
  background: linear-gradient(135deg, rgba(5, 150, 105, 0.1), #fff 60%);
  color: var(--success);
}
.sensor-status-pill.is-offline {
  border-color: rgba(220, 38, 38, 0.28);
  background: linear-gradient(135deg, rgba(220, 38, 38, 0.08), #fff 60%);
  color: var(--danger);
}
.sensor-status-pill .sensor-ico {
  display: flex;
  flex-shrink: 0;
}
.sensor-status-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
.sensor-status-text strong {
  font-size: 0.92rem;
  font-weight: 650;
}
.sensor-status-text small {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 0.12rem;
}

/* Topbar chip */
.topbar-sensor {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}
.topbar-sensor.is-online {
  color: var(--success);
  border-color: rgba(5, 150, 105, 0.35);
  background: rgba(5, 150, 105, 0.08);
}
.topbar-sensor.is-offline {
  color: var(--danger);
  border-color: rgba(220, 38, 38, 0.3);
  background: rgba(220, 38, 38, 0.06);
}
.topbar-sensor-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}
.topbar-sensor.is-online .topbar-sensor-dot {
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.2);
  animation: pulse 1.5s ease-in-out infinite;
}
.topbar-sensor.is-offline .topbar-sensor-dot {
  background: var(--danger);
}

/* Forms */
.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
  margin-bottom: 0.5rem;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 1;
  min-width: 140px;
}
.field label {
  font-size: 0.8rem;
  color: var(--text-muted);
}
input[type="text"],
input[type="email"],
input[type="password"],
.select-inline {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0.55rem 0.75rem;
  font: inherit;
}
.select-inline {
  padding: 0.25rem 0.5rem;
  margin-left: 0.25rem;
  font-family: var(--mono);
  font-size: 0.85rem;
}
input:focus, .select-inline:focus {
  outline: 2px solid rgba(245, 165, 36, 0.4);
  border-color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: 8px;
  padding: 0.55rem 1rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 2px 12px rgba(245, 165, 36, 0.25);
}
.btn:hover {
  background: var(--accent-hover);
  color: var(--accent-ink);
}
.btn-secondary {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: none;
  font-weight: 600;
}
.btn-secondary:hover {
  background: #1c2636;
  color: var(--text);
  border-color: #3a4a63;
}
.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
}
.btn-block { width: 100%; }

.filter-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-muted);
  font-size: 0.88rem;
  cursor: pointer;
  user-select: none;
}
.filter-toggle input { accent-color: var(--accent); }

/* Alerts */
.alert {
  padding: 0.85rem 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  border: 1px solid;
  font-size: 0.9rem;
}
.alert-success {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #047857;
}
.alert-error {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}
.alert-token {
  background: #fffbeb;
  border-color: #fcd34d;
  color: #92400e;
}
.alert-note {
  background: #f5f3ff;
  border-color: #ddd6fe;
  color: #5b21b6;
  font-size: 0.88rem;
}
.token-box {
  margin-top: 0.5rem;
  font-family: var(--mono);
  font-size: 0.85rem;
  word-break: break-all;
  background: var(--bg);
  padding: 0.75rem;
  border-radius: 8px;
  border: 1px dashed rgba(245, 165, 36, 0.5);
  user-select: all;
}

/* Login */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem 1.75rem;
  box-shadow: var(--shadow);
}
.login-card h1 {
  margin: 0 0 0.25rem;
  font-size: 1.4rem;
}
.login-card .subtitle {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}
.login-card .field {
  margin-bottom: 0.9rem;
}

.muted {
  color: var(--text-muted);
  font-size: 0.85rem;
}
.footer-note {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-top: 2rem;
}
.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
  animation: pulse 1.5s ease-in-out infinite;
  margin-right: 0.25rem;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.plain-list {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.plain-list li { margin-bottom: 0.45rem; }
.note-card h2 { margin-bottom: 0.65rem; }

/* Chart / shares */
.chart-wrap {
  position: relative;
  width: 100%;
  min-height: 220px;
}
.legend-inline {
  display: flex;
  gap: 0.85rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.leg::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 0.3rem;
  vertical-align: -1px;
}
.leg.phones::before { background: var(--phones); }
.leg.wearables::before { background: var(--wearables); }

.share-bars { display: flex; flex-direction: column; gap: 0.85rem; }
.share-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  margin-bottom: 0.3rem;
}
.share-track {
  height: 10px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.share-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
}
.share-fill.phones { background: linear-gradient(90deg, #2bb8a8, var(--phones)); }
.share-fill.wearables { background: linear-gradient(90deg, #7b6ce0, var(--wearables)); }

/* ── Receipt drawer ───────────────────────────────── */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 9, 14, 0.62);
  backdrop-filter: blur(3px);
  z-index: 80;
  opacity: 0;
  transition: opacity 0.22s ease;
}
.drawer-overlay.open {
  opacity: 1;
}
.drawer-overlay[hidden] {
  display: none;
}

.receipt-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: min(380px, 100vw);
  z-index: 90;
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  pointer-events: none;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
.receipt-drawer.open {
  transform: translateX(0);
  pointer-events: auto;
}

.receipt {
  width: 100%;
  margin: 0.75rem;
  background: var(--receipt-bg);
  color: var(--receipt-ink);
  border-radius: 4px;
  box-shadow:
    0 20px 50px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(0, 0, 0, 0.06);
  display: flex;
  flex-direction: column;
  max-height: calc(100% - 1.5rem);
  font-family: var(--mono);
  position: relative;
  overflow: hidden;
}

.receipt-perforation {
  height: 12px;
  background:
    radial-gradient(circle at 8px 50%, transparent 5px, var(--receipt-bg) 5.5px) -4px 0 / 16px 12px;
  flex-shrink: 0;
}
.receipt-perforation.top {
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 8px 100%, var(--receipt-bg) 5px, transparent 5.5px);
  background-size: 16px 12px;
  background-position: -4px 0;
}
.receipt-perforation.bottom {
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 8px 0%, var(--receipt-bg) 5px, transparent 5.5px);
  background-size: 16px 12px;
  background-position: -4px 0;
  margin-top: auto;
}

.receipt-header {
  padding: 0.75rem 1.1rem 0.35rem;
  text-align: center;
  position: relative;
}
.receipt-store {
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  font-weight: 600;
  color: var(--receipt-muted);
}
.receipt-ticket {
  font-size: 1rem;
  font-weight: 600;
  margin-top: 0.2rem;
  letter-spacing: 0.02em;
}
.receipt-close {
  position: absolute;
  right: 0.55rem;
  top: 0.45rem;
  border: none;
  background: transparent;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--receipt-muted);
  cursor: pointer;
  padding: 0.15rem 0.4rem;
}
.receipt-close:hover { color: var(--receipt-ink); }

.receipt-divider {
  height: 0;
  margin: 0.4rem 1rem;
  border: none;
  border-top: 1px solid var(--receipt-line);
}
.receipt-divider.dashed {
  border-top: 1px dashed var(--receipt-line);
}

.receipt-body {
  padding: 0.5rem 1.15rem 0.85rem;
  overflow-y: auto;
  flex: 1;
  font-size: 0.82rem;
}

.receipt-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.28rem 0;
  border-bottom: 1px dotted var(--receipt-line);
}
.receipt-row:last-child { border-bottom: none; }
.receipt-row .k {
  color: var(--receipt-muted);
  text-transform: uppercase;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.receipt-row .v {
  text-align: right;
  font-weight: 500;
  word-break: break-all;
}

.receipt-id {
  text-align: center;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 0.5rem 0 0.65rem;
}

.receipt-chip-row {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.65rem;
}
.receipt-chip {
  background: #e8e0d0;
  color: var(--receipt-ink);
  border-radius: 4px;
  padding: 0.15rem 0.45rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.receipt-chip.flag {
  background: #f5a524;
  color: #1a1205;
}

.rssi-bar-wrap {
  margin: 0.55rem 0 0.25rem;
}
.rssi-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
  color: var(--receipt-muted);
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}
.rssi-bar-track {
  height: 8px;
  background: #ddd4c4;
  border-radius: 2px;
  overflow: hidden;
}
.rssi-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #c45c26, #f5a524 70%, #3dd6c6);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.receipt-footer {
  display: flex;
  justify-content: space-between;
  padding: 0.35rem 1.1rem 0.55rem;
  font-size: 0.68rem;
  color: var(--receipt-muted);
}

body.drawer-open {
  overflow: hidden;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 860px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
  .kpi-grid.compact {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .kpi .value { font-size: 1.5rem; }
  .nav a { padding: 0.35rem 0.5rem; font-size: 0.88rem; }
  .shell { padding: 0.75rem 0.85rem 2.5rem; }
  .receipt-drawer {
    width: 100vw;
  }
  .receipt {
    margin: 0.4rem;
    max-height: calc(100% - 0.8rem);
  }
}

/* app.js receipt-overlay (fallback drawer) */
.receipt-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  justify-content: flex-end;
}
.receipt-overlay.hidden { display: none; }
.receipt-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(2px);
}
.receipt-panel {
  position: relative;
  width: min(400px, 100vw);
  height: 100%;
  background: #f4efe4;
  color: #1a1510;
  box-shadow: -12px 0 40px rgba(0,0,0,0.45);
  overflow-y: auto;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  padding: 0 0 2rem;
  z-index: 1;
}
.receipt-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 1.1rem 1.15rem 0.75rem;
  border-bottom: 1px dashed #cbbfa8;
}
.receipt-eyebrow {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #7a6d58;
}
.receipt-id { font-size: 1.15rem; font-weight: 600; margin-top: 0.2rem; }
.receipt-close {
  border: none;
  background: transparent;
  font-size: 1.5rem;
  cursor: pointer;
  color: #5c5346;
  line-height: 1;
}
.receipt-body { padding: 0.85rem 1.15rem; }
.receipt-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.45rem 0;
  border-bottom: 1px dotted #ddd2be;
  font-size: 0.86rem;
}
.receipt-row span:first-child { color: #6e6354; }
.receipt-note { margin-top: 1rem; font-size: 0.75rem; line-height: 1.4; }
.rssi-track {
  height: 8px;
  background: #ddd4c4;
  border-radius: 2px;
  overflow: hidden;
  margin: 0.2rem 0 0.6rem;
}
.rssi-fill {
  height: 100%;
  background: linear-gradient(90deg, #c45c26, #f5a524 70%, #3dd6c6);
  width: 0%;
  transition: width 0.25s ease;
}
.alert-note {
  border-left: 3px solid var(--accent);
  background: rgba(245, 165, 36, 0.08);
}

.svg-chart {
  width: 100%;
  min-height: 220px;
}
.svg-chart svg {
  display: block;
  width: 100%;
  height: 220px;
}

/* Detalle al tocar un dispositivo (limpio) */
.detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(2px);
  z-index: 900;
}
.detail-overlay.hidden,
.detail-panel.hidden {
  display: none !important;
}
.detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(380px, 100vw);
  height: 100%;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  z-index: 910;
  box-shadow: -12px 0 40px rgba(0,0,0,0.4);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.detail-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 1.1rem 1.2rem;
  border-bottom: 1px solid var(--border);
}
.detail-kicker {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
}
.detail-id {
  font-size: 1.2rem;
  font-weight: 600;
  margin-top: 0.2rem;
  color: var(--text);
}
.detail-close {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.25rem;
}
.detail-close:hover { color: var(--text); }
.detail-body {
  padding: 0.75rem 1.2rem 2rem;
}
.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}
.detail-row > span:first-child {
  color: var(--text-muted);
}
.detail-body .rssi-track {
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
  margin: 0.15rem 0 0.5rem;
}
.detail-body .rssi-fill {
  height: 100%;
  background: linear-gradient(90deg, #c45c26, #f5a524 70%, #3dd6c6);
  width: 0%;
  transition: width 0.25s ease;
}
body.drawer-open { overflow: hidden; }

@media (max-width: 640px) {
  .detail-panel { width: 100vw; }
}

/* Tendencias comerciales */
.filters-card h2 { margin-bottom: 0.85rem; }
.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}
.filters-grid .field span {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.filters-grid .input,
.filters-grid select.input,
select.input, input.input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  font: inherit;
}
.weekday-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.9rem;
}
.wd-chip {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  font-size: 0.82rem;
  cursor: pointer;
}
.wd-chip.on {
  background: rgba(245, 165, 36, 0.15);
  border-color: rgba(245, 165, 36, 0.5);
  color: var(--accent);
  font-weight: 600;
}
.filters-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.headline-card {
  background: linear-gradient(135deg, rgba(245,165,36,0.12), rgba(61,214,198,0.08));
  border-color: rgba(245,165,36,0.25);
}
.headline-main {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.headline-sub { margin-top: 0.35rem; }
.insights-list {
  margin: 0;
  padding-left: 1.15rem;
  line-height: 1.55;
}
.insights-list li { margin-bottom: 0.45rem; }

.heat-grid {
  display: grid;
  grid-template-columns: 42px repeat(24, minmax(10px, 1fr));
  gap: 2px;
  align-items: center;
}
.heat-corner { height: 14px; }
.heat-hlabel {
  font-size: 0.62rem;
  color: var(--text-muted);
  text-align: center;
  font-family: var(--mono);
}
.heat-dlabel {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
}
.heat-cell {
  aspect-ratio: 1;
  border-radius: 3px;
  min-height: 12px;
  background: rgba(13,148,136,0.08);
}
.heatmap-wrap { overflow-x: auto; padding-bottom: 0.5rem; }

/* ========== UX 0.4 — claridad comercial ========== */
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.brand-text strong { font-size: 1.05rem; }
.brand-text small {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.02em;
}
.nav a.nav-muted {
  opacity: 0.72;
  font-size: 0.88rem;
}
.nav a.nav-muted.active { opacity: 1; }

.ux-page { max-width: 1080px; }
.ux-hero {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-end;
  margin-bottom: 1.25rem;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid var(--border);
}
.ux-eyebrow {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  font-weight: 700;
}
.ux-title {
  margin: 0;
  font-size: clamp(1.55rem, 3vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.03em;
}
.ux-lead {
  margin: 0.55rem 0 0;
  font-size: 1.15rem;
  color: var(--text);
  max-width: 36rem;
  line-height: 1.4;
}
.ux-hero-meta {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
}

.ux-filters {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem 1.1rem 1.1rem;
  margin-bottom: 1.35rem;
  box-shadow: var(--shadow);
}
.ux-filters-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.65rem;
  margin-bottom: 0.75rem;
}
.ux-field span {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.28rem;
}

.ux-scoreboard {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.ux-score {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem 1.05rem 1.05rem;
  position: relative;
  overflow: hidden;
}
.ux-score::after {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--phones);
}
.ux-score-accent::after { background: var(--accent); }
.ux-score-label {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
}
.ux-score-value {
  margin: 0.35rem 0 0.15rem;
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--text);
}
.ux-score-hint {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.ux-section { margin-bottom: 1.6rem; }
.ux-section-title {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.ux-help {
  margin: -0.35rem 0 0.65rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.ux-insights {
  display: grid;
  gap: 0.55rem;
}
.ux-insight {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  font-size: 0.98rem;
  line-height: 1.45;
}
.ux-insight.muted {
  border-left-color: var(--border);
  color: var(--text-muted);
}

.ux-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}
.ux-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem 1.1rem 1.1rem;
}
.ux-panel-title {
  margin: 0 0 0.85rem;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.ux-legend {
  display: flex;
  gap: 1rem;
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Barras horizontales legibles */
.ux-bars { display: grid; gap: 0.45rem; }
.ux-bar-row {
  display: grid;
  grid-template-columns: 4.2rem 1fr 2.6rem;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.86rem;
}
.ux-bar-lab {
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 0.78rem;
}
.ux-bar-track {
  height: 10px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
}
.ux-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #2a9d8f, var(--phones));
  min-width: 2px;
  transition: width 0.35s ease;
}
.ux-bar-fill.day {
  background: linear-gradient(90deg, #b7791f, var(--accent));
}
.ux-bar-val {
  text-align: right;
  font-family: var(--mono);
  font-weight: 600;
  font-size: 0.82rem;
}

.ux-pills { display: grid; gap: 0.85rem; }
.ux-pill-val {
  display: block;
  font-size: 1.45rem;
  font-weight: 600;
}
.ux-pill-lab {
  display: block;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0.1rem 0 0.35rem;
}
.ux-pill-track {
  height: 8px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
}
.ux-pill-track i {
  display: block;
  height: 100%;
  background: var(--phones);
  border-radius: 999px;
  transition: width 0.35s ease;
}
.ux-pill-track i.android { background: var(--devices); }
.ux-pill-track i.wear { background: var(--wearables); }

.ux-facts {
  margin: 0;
  display: grid;
  gap: 0.65rem;
}
.ux-facts .fact {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}
.ux-facts .fact dt { color: var(--text-muted); margin: 0; }
.ux-facts .fact dd {
  margin: 0;
  font-family: var(--mono);
  font-weight: 600;
}

@media (max-width: 900px) {
  .ux-filters-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ux-scoreboard { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ux-split { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .ux-filters-row { grid-template-columns: 1fr; }
  .ux-scoreboard { grid-template-columns: 1fr; }
  .ux-score-value { font-size: 1.7rem; }
}

.detail-actions {
  margin-top: 1.1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
}
.detail-actions-label {
  margin: 0 0 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.detail-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.btn-sm {
  padding: 0.4rem 0.7rem;
  font-size: 0.82rem;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}
.pager button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}
.form-row .field {
  flex: 1 1 140px;
}
.form-row .field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.form-row input[type="time"],
.form-row input[type="text"] {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  color: var(--text);
  font: inherit;
}
