/* ═══════════════════════════════════════════════════════════════
   ALIZIABOT REPORTES — Design System v2
   ═══════════════════════════════════════════════════════════════ */

:root {
  --bg:           #0d0f17;
  --bg-card:      #161924;
  --bg-hover:     #1e2235;
  --bg-input:     #111420;
  --border:       #252a3e;
  --border-light: #1e2436;
  --accent:       #5b73f5;
  --accent-dim:   rgba(91,115,245,.15);
  --accent-hover: #4a62e8;
  --green:        #22c55e;
  --green-dim:    rgba(34,197,94,.12);
  --red:          #ef4444;
  --red-dim:      rgba(239,68,68,.12);
  --yellow:       #f59e0b;
  --yellow-dim:   rgba(245,158,11,.12);
  --blue-dim:     rgba(91,115,245,.12);
  --sidebar-w:    240px;
  --topbar-h:     52px;
  --text:         #e2e8f0;
  --text-muted:   #5a6280;
  --text-dim:     #8892a4;
  --radius:       10px;
  --radius-lg:    14px;
  --radius-xl:    20px;
  --shadow:       0 4px 32px rgba(0,0,0,.5);
  --font:         'Inter', system-ui, -apple-system, sans-serif;
  --transition:   .15s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }

/* ══ App layout ════════════════════════════════════════════════ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ══ Sidebar ════════════════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform var(--transition);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.brand-icon { font-size: 18px; line-height: 1; }

.brand-text {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.3px;
}

.sidebar-nav {
  flex: 1;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-muted);
  padding: 14px 8px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  text-decoration: none;
  position: relative;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--accent-dim); color: var(--accent); }

.nav-icon {
  width: 18px; height: 18px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.nav-icon svg { width: 16px; height: 16px; }

.nav-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav-badge {
  position: absolute;
  right: 10px;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 6px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.user-info { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }

.user-avatar {
  width: 32px; height: 32px;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}

.user-meta { min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 12px; color: var(--text-muted); }

.btn-logout {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  transition: border-color var(--transition), color var(--transition), background var(--transition);
  flex-shrink: 0;
}
.btn-logout:hover { border-color: var(--red); color: var(--red); background: var(--red-dim); text-decoration: none; }

/* ══ Main area ══════════════════════════════════════════════════ */
.app-main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
  width: calc(100% - var(--sidebar-w));
}

/* ══ Topbar (mobile) ════════════════════════════════════════════ */
.topbar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.topbar-title { font-size: 15px; font-weight: 600; color: var(--text); flex: 1; }

.sidebar-toggle {
  background: none; border: none;
  color: var(--text-dim);
  padding: 6px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  min-width: 36px; min-height: 36px;
}
.sidebar-toggle:hover { color: var(--text); background: var(--bg-hover); }

/* Overlay para cerrar sidebar en mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 199;
}
.sidebar-overlay.active { display: block; }

/* ══ Page content ═══════════════════════════════════════════════ */
.page-content {
  flex: 1;
  padding: 32px 40px 64px;
  width: 100%;
}

/* ══ Page header ════════════════════════════════════════════════ */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 28px;
}

.page-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.page-header p { font-size: 13px; color: var(--text-dim); margin-top: 4px; }

/* ══ Cards ══════════════════════════════════════════════════════ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}
.card-sm { padding: 18px; }
.card + .card { margin-top: 16px; }
:where([style*="display:grid"],[style*="display: grid"],[style*="display:flex"],[style*="display: flex"]) > .card + .card { margin-top: 0; }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.card-title { font-size: 14px; font-weight: 600; color: var(--text); }

/* ══ Stat grid ══════════════════════════════════════════════════ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  transition: border-color var(--transition);
}

.stat-card .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 8px;
}

.stat-card .value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat-card .sub { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

.stat-card.accent { border-color: rgba(91,115,245,.3); background: rgba(91,115,245,.06); }
.stat-card.green  { border-color: rgba(34,197,94,.3);  background: rgba(34,197,94,.06);  }
.stat-card.yellow { border-color: rgba(245,158,11,.3); background: rgba(245,158,11,.06); }
.stat-card.red    { border-color: rgba(239,68,68,.3);  background: rgba(239,68,68,.06);  }

/* ══ Buttons ════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: opacity var(--transition), transform var(--transition), background var(--transition);
  white-space: nowrap;
  text-decoration: none;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.btn-primary  { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); text-decoration: none; }

.btn-danger   { background: var(--red); color: #fff; }
.btn-danger:hover:not(:disabled) { opacity: .85; }

.btn-success  { background: var(--green); color: #fff; }
.btn-success:hover:not(:disabled) { opacity: .85; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--text); text-decoration: none; }

.btn-sm  { padding: 5px 12px; font-size: 13px; }
.btn-xs  { padding: 3px 9px;  font-size: 12px; }
.btn-icon { padding: 7px; }

/* ══ Inputs ═════════════════════════════════════════════════════ */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="url"],
input[type="number"],
input[type="date"],
input[type="time"],
select,
textarea {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-family: var(--font);
  padding: 9px 12px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
  -webkit-appearance: none;
  -moz-appearance: textfield;
  appearance: none;
}
input[type="number"] { -moz-appearance: textfield !important; }
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91,115,245,.15);
}
input::placeholder { color: var(--text-muted); }
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator { filter: invert(.6); cursor: pointer; }
textarea { resize: vertical; min-height: 80px; }
select { cursor: pointer; }
select option { background: var(--bg-card); }

.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.form-row   { display: grid; grid-template-columns: 1fr 1fr;       gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr;   gap: 14px; }
.form-hint  { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

.input-group { display: flex; gap: 0; }
.input-group input { border-radius: 8px 0 0 8px; }
.input-group .btn  { border-radius: 0 8px 8px 0; flex-shrink: 0; white-space: nowrap; }

/* ══ Tables ══════════════════════════════════════════════════════ */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }

thead { position: sticky; top: 0; background: var(--bg-card); z-index: 1; }

th {
  text-align: left;
  padding: 10px 14px;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-dim);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-hover); color: var(--text); }

td.num, th.num    { text-align: right; font-variant-numeric: tabular-nums; }
td.center, th.center { text-align: center; }
td strong { color: var(--text); font-weight: 600; }

/* ══ Badges ══════════════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-green  { background: var(--green-dim);          color: var(--green); }
.badge-red    { background: var(--red-dim);            color: var(--red); }
.badge-yellow { background: var(--yellow-dim);         color: var(--yellow); }
.badge-orange { background: rgba(249,115,22,.12);      color: #f97316; }
.badge-blue   { background: var(--blue-dim);           color: var(--accent); }
.badge-gray   { background: rgba(90,98,128,.15);       color: var(--text-muted); }

/* ══ Tooltips ═══════════════════════════════════════════════════ */
.th-hint {
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px; border-radius: 50%;
  background: rgba(90,98,128,.25); color: var(--text-muted);
  font-size: 9px; font-weight: 700; cursor: default;
  margin-left: 4px; vertical-align: middle;
  position: relative;
}
.th-hint::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 6px);
  left: 50%; transform: translateX(-50%);
  background: #0d111e;
  color: var(--text);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 6px;
  padding: 7px 11px;
  font-size: 11px; font-weight: 400;
  width: max-content; max-width: 200px;
  white-space: normal; text-align: center; line-height: 1.5;
  opacity: 0; pointer-events: none;
  transition: opacity .15s ease;
  z-index: 200;
}
.th-hint:hover::after { opacity: 1; }

/* ══ Filas inactivas ══════════════════════════════════════════════ */
tr.inactive-row td { opacity: .45; }
tr.inactive-row td:last-child { opacity: 1; }

/* ══ Alerts ══════════════════════════════════════════════════════ */
.alerts { margin-bottom: 20px; }
.alert {
  padding: 10px 16px;
  border-radius: var(--radius);
  margin-bottom: 8px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.alert-error   { background: var(--red-dim);    border: 1px solid rgba(239,68,68,.3); }
.alert-success { background: var(--green-dim);  border: 1px solid rgba(34,197,94,.3); }
.alert-warning { background: var(--yellow-dim); border: 1px solid rgba(245,158,11,.3); }
.alert-info    { background: var(--blue-dim);   border: 1px solid rgba(91,115,245,.3); }

/* ══ Toast notifications ════════════════════════════════════════ */
#toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: calc(100vw - 48px);
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text);
  box-shadow: var(--shadow);
  animation: toast-in .2s ease;
  pointer-events: auto;
  max-width: 340px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.toast.success { border-color: rgba(34,197,94,.4);  color: var(--green); }
.toast.error   { border-color: rgba(239,68,68,.4);  color: var(--red); }
.toast.warn    { border-color: rgba(245,158,11,.4); color: var(--yellow); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ══ Modal ═══════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn .15s ease;
  overflow-y: auto;
}
.modal-overlay.hidden { display: none; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow);
  animation: slideUp .2s ease;
  margin: auto;
}

@keyframes slideUp {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.modal-title { font-size: 16px; font-weight: 700; color: var(--text); flex: 1; min-width: 0; }

.modal-close {
  background: none; border: none;
  color: var(--text-muted);
  font-size: 20px; line-height: 1;
  padding: 4px;
  border-radius: 6px;
  transition: color var(--transition), background var(--transition);
  flex-shrink: 0;
}
.modal-close:hover { color: var(--text); background: var(--bg-hover); }

/* ══ Empty / loading states ═════════════════════════════════════ */
.empty-state {
  text-align: center;
  padding: 64px 32px;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 40px; margin-bottom: 14px; line-height: 1; }
.empty-state svg  { display: block; margin: 0 auto 12px; }
.empty-state p     { font-size: 14px; }
.empty-state .hint { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 48px;
  color: var(--text-muted);
  font-size: 13px;
}
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ══ Progress log (SSE) ═════════════════════════════════════════ */
.progress-log {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 12px;
  font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  max-height: 300px;
  overflow-y: auto;
  line-height: 1.8;
}
.log-line         { display: flex; gap: 8px; }
.log-line.info    { color: var(--text-dim); }
.log-line.success { color: var(--green); }
.log-line.warn    { color: var(--yellow); }
.log-line.error   { color: var(--red); }
.log-line .ts     { color: var(--text-muted); flex-shrink: 0; }

/* ══ Status dots ════════════════════════════════════════════════ */
.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.green  { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.yellow { background: var(--yellow); }
.status-dot.red    { background: var(--red); }
.status-dot.gray   { background: var(--text-muted); }

/* ══ Section divider ════════════════════════════════════════════ */
.section-divider { border: none; border-top: 1px solid var(--border); margin: 24px 0; }

/* ══ Radio group ════════════════════════════════════════════════ */
.radio-group { display: flex; gap: 10px; flex-wrap: wrap; }
.radio-option {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  font-size: 13px;
  color: var(--text-dim);
  user-select: none;
  flex: 1;
  min-width: 160px;
}
.radio-option input[type="radio"] { width: auto; accent-color: var(--accent); flex-shrink: 0; }
.radio-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--text);
}

/* ══ API key field ══════════════════════════════════════════════ */
.key-field {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
}
.key-preview { font-family: monospace; font-size: 13px; color: var(--text-dim); flex: 1; }
.key-set     { color: var(--green); font-size: 11px; font-weight: 600; }
.key-unset   { color: var(--text-muted); font-size: 11px; }

/* ══ Toggle switch ══════════════════════════════════════════════ */
.toggle-wrap { display: flex; align-items: center; gap: 10px; }
.toggle { position: relative; width: 40px; height: 22px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: background var(--transition);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 2px; top: 2px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: transform var(--transition), background var(--transition);
}
.toggle input:checked + .toggle-slider { background: var(--accent-dim); border-color: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); background: var(--accent); }

/* ══ Days picker ════════════════════════════════════════════════ */
.days-picker { display: flex; gap: 6px; flex-wrap: wrap; }
.day-btn {
  width: 36px; height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-color var(--transition), background var(--transition), color var(--transition);
  touch-action: manipulation;
}
.day-btn.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }

/* ══ Account chips (dashboard filter) ══════════════════════════ */
.account-chip {
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), color var(--transition);
  touch-action: manipulation;
  white-space: nowrap;
}
.account-chip:hover { border-color: var(--accent); color: var(--text); }
.account-chip.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* ══ Thresholds grid (settings) ════════════════════════════════ */
.thresholds-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}
.threshold-row {
  display: grid;
  grid-template-columns: 1fr 110px auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
}
.threshold-currency { min-width: 0; }
.threshold-code  { font-weight: 700; font-size: 13px; color: var(--text); margin-right: 6px; }
.threshold-label { font-size: 11px; color: var(--text-dim); }
.threshold-input { text-align: right; font-size: 13px; }
.threshold-hint  { font-size: 11px; color: var(--text-muted); white-space: nowrap; }

/* ══ Info banner ════════════════════════════════════════════════ */
.info-banner {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 14px;
  background: var(--blue-dim);
  border: 1px solid rgba(91,115,245,.2);
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--text-dim);
}
.info-banner strong { color: var(--text); }

/* ══ ROAS / progress bar ════════════════════════════════════════ */
.progress-bar-wrap { display: flex; align-items: center; gap: 8px; }
.progress-bar {
  height: 5px;
  border-radius: 3px;
  background: var(--accent);
  min-width: 4px;
  max-width: 96px;
}

/* ══ Reporte Día ════════════════════════════════════════════════ */
.rd-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
}
.rd-controls { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.rd-controls #fecha-input { width: 160px; flex-shrink: 0; }

.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 28px;
}
.stat-pill {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  min-width: 130px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.stat-pill .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-dim);
  font-weight: 600;
  margin-bottom: 6px;
}
.stat-pill .value { font-size: 22px; font-weight: 700; color: var(--text); line-height: 1.2; }
.stat-pill .sub   { font-size: 11px; color: var(--text-dim); margin-top: 4px; }

.account-section { margin-bottom: 16px; }
.account-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 22px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  cursor: pointer;
  user-select: none;
  transition: background var(--transition);
}
.account-header:hover  { background: var(--bg-hover); }
.account-header.collapsed { border-radius: var(--radius-lg); }
.account-name {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.account-dot  { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.account-kpis { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.account-kpi  { text-align: right; }
.account-kpi .kpi-label { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); }
.account-kpi .kpi-value { font-size: 15px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.chevron { color: var(--text-muted); font-size: 18px; transition: transform .2s; }
.account-header.collapsed .chevron { transform: rotate(-90deg); }
.account-body {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  overflow: hidden;
}
.account-body.hidden { display: none; }
.section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-muted);
  padding: 14px 22px 8px;
}

/* ══ Login ═══════════════════════════════════════════════════════ */
.main-content {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
}
.login-card h1 { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.login-card .subtitle { color: var(--text-muted); font-size: 13px; margin-bottom: 28px; }
.login-card .btn-primary { width: 100%; justify-content: center; padding: 11px; font-size: 14px; }

/* ══ Scrollbar personalizado ════════════════════════════════════ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ══ Responsive — Tablet (≤1024px) ═════════════════════════════ */
@media (max-width: 1024px) {
  :root { --sidebar-w: 220px; }
  .page-content { padding: 28px 28px 56px; }
  .stat-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}

/* ══ Responsive — Mobile (≤768px) ══════════════════════════════ */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: 260px;
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 8px 0 40px rgba(0,0,0,.6);
  }
  .app-main {
    margin-left: 0;
    width: 100%;
  }
  .topbar { display: flex; }
  .page-content { padding: 20px 16px 48px; }

  .form-row, .form-row-3 { grid-template-columns: 1fr; }

  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }

  .account-header { flex-direction: column; align-items: flex-start; }
  .account-kpis   { gap: 12px; }

  .stat-row { gap: 8px; }
  .stat-pill { min-width: calc(50% - 4px); }

  .page-header { margin-bottom: 20px; }
  .page-header h1 { font-size: 20px; }

  .modal { padding: 22px 18px; border-radius: var(--radius-lg); }
  .modal-overlay { padding: 12px; align-items: flex-end; }
  .modal { border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-width: 100%; margin: 0; animation: slideUpMobile .25s ease; }

  @keyframes slideUpMobile {
    from { transform: translateY(100%); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
  }

  .card { padding: 18px 16px; }
  .card-header { flex-direction: column; align-items: flex-start; }

  table { font-size: 12px; }
  th, td { padding: 10px 10px; }

  .rd-header { flex-direction: column; align-items: flex-start; }
  .rd-controls { width: 100%; }
  .rd-controls #fecha-input { width: 100%; flex: 1; }

  .btn-xs, .btn-sm { min-height: 32px; }
}

/* ══ Responsive — Small mobile (≤480px) ════════════════════════ */
@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-pill { min-width: 0; }
  .form-actions { flex-direction: column; }
  .form-actions .btn { justify-content: center; }
  #toast-container { left: 12px; right: 12px; top: 12px; max-width: none; }
  .toast { max-width: 100%; }
}
