:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-2: #f4f4f5;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;

  --text: #18181b;
  --text-2: #3f3f46;
  --muted: #71717a;
  --muted-2: #a1a1aa;

  --accent: #18181b;
  --brand: #005a70;
  --brand-2: #087f93;
  --brand-soft: #e7f6f8;
  --brand-line: #38bdf8;
  --tai: #475569;
  --pabli: #92400e;
  --cobro: #166534;
  --danger: #b91c1c;

  --tai-soft: #f1f5f9;
  --pabli-soft: #fef3c7;
  --cobro-soft: #dcfce7;
  --danger-soft: #fee2e2;

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
}

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

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: linear-gradient(180deg, #edfafa 0, var(--bg) 280px, var(--bg) 100%);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.bg-grid, .bg-glow { display: none; }

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 24px 80px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ===== HEADER ===== */
.hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(0, 90, 112, 0.18);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 12px;
  box-shadow: 0 10px 24px -14px rgba(0, 90, 112, 0.75);
  overflow: hidden;
}

.logo img { width: 100%; height: 100%; display: block; }

.brand-text h1 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0;
  color: var(--text);
  line-height: 1.2;
}

.brand-text p {
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
  margin-top: 2px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  padding: 5px 10px 5px 8px;
  border-radius: 999px;
}

.user-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.user-pill[data-user="tai"] .user-dot { background: var(--tai); }
.user-pill[data-user="pabli"] .user-dot { background: var(--pabli); }
.user-pill[data-user="tai"] { border-color: var(--tai); }
.user-pill[data-user="pabli"] { border-color: var(--pabli); }

.sync-badge {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 5px 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.sync-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
}

.sync-badge[data-state="saving"] .sync-dot { background: #f59e0b; animation: blink 0.9s infinite; }
.sync-badge[data-state="error"] { color: var(--danger); border-color: #fecaca; }
.sync-badge[data-state="error"] .sync-dot { background: var(--danger); }
.sync-badge[data-state="loading"] .sync-dot { background: var(--muted-2); animation: blink 0.9s infinite; }

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.logout-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
}

.logout-btn:hover { color: var(--text); background: var(--surface-2); }
.logout-btn svg { width: 14px; height: 14px; }

/* ===== PIN OVERLAY ===== */
.pin-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg);
}

.pin-overlay.hidden { display: none; }

.pin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: 0 16px 40px -16px rgba(0, 0, 0, 0.1);
}

.pin-logo {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
}

.pin-logo svg { width: 100%; height: 100%; }

.pin-card h2 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
  color: var(--text);
}

.pin-card p {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 18px;
}

.pin-card input {
  width: 100%;
  text-align: left;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0;
  padding: 14px;
  margin-bottom: 12px;
  font-variant-numeric: tabular-nums;
}

.pin-error {
  font-size: 13px;
  color: var(--danger);
  min-height: 18px;
  margin-bottom: 12px;
}

/* ===== SUMMARY ===== */
.summary {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.stat {
  background: var(--surface);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: background 0.15s;
}

.stat:hover { background: var(--surface-2); }

.stat-icon { display: none; }

.stat-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.stat-value {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.5px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.stat-sub {
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
  margin-top: 2px;
  line-height: 1.4;
}

.stat-sub strong {
  color: var(--text-2);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.stat-tai .stat-label::before,
.stat-pabli .stat-label::before,
.stat-cobros .stat-label::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}
.stat-tai .stat-label::before { background: var(--tai); }
.stat-pabli .stat-label::before { background: var(--pabli); }
.stat-cobros .stat-label::before { background: var(--cobro); }

/* ===== BALANCE POR PERSONA ===== */
.balance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}
.paypal-balance .dot-paypal { width: 8px; height: 8px; }

.balance-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}

.balance-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
}

.balance-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  color: var(--muted);
  padding: 3px 0;
}

.balance-line-val {
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
  font-weight: 500;
}

.balance-sep {
  height: 1px;
  background: var(--border);
  margin: 10px 0;
}

.balance-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.balance-total-label {
  font-size: 13px;
  color: var(--text-2);
  font-weight: 500;
}

.balance-total-val {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--cobro);
  font-variant-numeric: tabular-nums;
}

.balance-total-val.neg { color: var(--danger); }

.balance-note {
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.4;
  min-height: 14px;
}

.caja-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}

.caja-header {
  margin-bottom: 14px;
}

.caja-header h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.2px;
}

.caja-grid {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.caja-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--surface);
}

.caja-who {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-2);
}

.caja-amount {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.hero-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.info-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--muted-2);
  cursor: pointer;
  padding: 0;
  margin-left: 4px;
  width: 18px;
  height: 18px;
  vertical-align: middle;
  transition: color 0.15s;
}

.info-btn:hover { color: var(--text); }
.info-btn svg { width: 14px; height: 14px; }

.hero-detail {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}

.liquidacion {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-top: 16px;
}

.liquidacion-title {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

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

.liquidacion-body strong { font-weight: 700; }

.liquidacion-detail {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.5;
}

.hero-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
}

.hero-label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

.hero-value {
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -1px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.hero-divider {
  height: 1px;
  background: var(--border);
  margin: 18px 0 16px;
}

.hero-split {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.hero-sub-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 2px;
}

.hero-sub-value {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.hero-balance {
  font-size: 13px;
  color: var(--text-2);
  font-weight: 500;
  background: var(--surface-2);
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.hero-balance strong { font-weight: 600; }

/* ===== CARDS ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.card-header {
  margin-bottom: 18px;
}

.card-header.with-action {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.card-header h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.2px;
}

.card-subtitle {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  display: block;
  font-weight: 400;
}

/* ===== SEGMENTED ===== */
.segmented {
  display: flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 2px;
  margin-bottom: 16px;
}

.seg {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: 5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s;
}

.seg svg { width: 14px; height: 14px; }
.seg:hover { color: var(--text-2); }

.seg.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}
.dot-tai { background: var(--tai); }
.dot-pabli { background: var(--pabli); }

/* ===== FORM ===== */
.field { margin-bottom: 14px; }

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field-row .field { margin-bottom: 14px; }

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 6px;
}

.optional {
  color: var(--muted);
  font-weight: 400;
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="url"],
input[type="email"],
input[type="password"],
input[type="file"],
select,
textarea {
  width: 100%;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
  color-scheme: light;
}

input::placeholder, textarea::placeholder { color: var(--muted-2); }

input[type="file"] {
  padding: 8px 10px;
}

input[type="file"]::file-selector-button {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 10px;
  margin-right: 10px;
  cursor: pointer;
}

.file-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  margin-top: 6px;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(24, 24, 27, 0.08);
}

textarea {
  resize: vertical;
  min-height: 60px;
  line-height: 1.5;
}

input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.6;
}

.amount-input {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.amount-input:focus-within {
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(24, 24, 27, 0.08);
}

.amount-input .currency {
  color: var(--muted);
  font-weight: 500;
  font-size: 14px;
  flex-shrink: 0;
  white-space: nowrap;
}

.amount-input input {
  border: none !important;
  background: transparent;
  padding: 10px 0;
  flex: 1;
  width: auto;
  min-width: 0;
  font-variant-numeric: tabular-nums;
  box-shadow: none !important;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; }

/* ===== BUTTONS ===== */
.btn-primary {
  width: 100%;
  background: var(--text);
  color: var(--surface);
  border: 1px solid var(--text);
  padding: 11px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 4px;
  transition: opacity 0.15s;
}

.btn-primary svg { width: 14px; height: 14px; }
.btn-primary:hover { opacity: 0.85; }

.btn-finalize {
  width: 100%;
  margin-top: 18px;
  background: var(--surface);
  color: var(--text-2);
  border: 1px solid var(--border-strong);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s;
}

.btn-finalize svg { width: 14px; height: 14px; }
.btn-finalize:hover { background: var(--surface-2); border-color: var(--text); color: var(--text); }
.btn-finalize:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-finalize:disabled:hover { background: var(--surface); border-color: var(--border-strong); color: var(--text-2); }

.btn-ghost {
  flex: 1;
  background: var(--surface);
  color: var(--text-2);
  border: 1px solid var(--border);
  padding: 9px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s;
}

.btn-ghost svg { width: 14px; height: 14px; }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-ghost.danger { color: var(--danger); }
.btn-ghost.danger:hover { background: #fef2f2; border-color: #fecaca; }

/* ===== FILTERS ===== */
.filters {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.filter {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}

.filter:hover { color: var(--text-2); border-color: var(--border-strong); }

.filter.active {
  background: var(--text);
  color: var(--surface);
  border-color: var(--text);
}

/* ===== MOVEMENTS ===== */
.movements {
  list-style: none;
  display: flex;
  flex-direction: column;
}

.movement {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.movement:last-child { border-bottom: none; }
.movement:first-child { padding-top: 0; }

.mov-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
  letter-spacing: -0.3px;
}

.mov-avatar.tai { background: var(--tai-soft); color: var(--tai); }
.mov-avatar.pabli { background: var(--pabli-soft); color: var(--pabli); }
.mov-avatar.cobro { background: var(--cobro-soft); color: var(--cobro); }

.mov-info { flex: 1; min-width: 0; }

.mov-title {
  font-weight: 500;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mov-desc {
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}

.mov-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted-2);
  font-weight: 400;
  flex-wrap: wrap;
}

.mov-cat {
  display: inline-flex;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
}

.mov-by {
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
}

.mov-amount {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.mov-amount.cobro { color: var(--cobro); }

.mov-delete {
  background: transparent;
  color: var(--muted-2);
  border: none;
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
  opacity: 0;
}

.movement:hover .mov-delete { opacity: 1; }

.mov-delete:hover {
  background: var(--surface-2);
  color: var(--danger);
}

.mov-delete svg { width: 14px; height: 14px; }

/* ===== EMPTY ===== */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px 20px;
  color: var(--muted);
}

.empty svg {
  width: 28px;
  height: 28px;
  color: var(--muted-2);
  margin-bottom: 10px;
  opacity: 0.6;
}

.empty p {
  color: var(--text-2);
  font-weight: 500;
  font-size: 14px;
  margin-bottom: 2px;
}

.empty span {
  color: var(--muted);
  font-size: 13px;
}

/* ===== HISTORY ===== */
.history-list {
  display: flex;
  flex-direction: column;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}

.history-item:last-child { border-bottom: none; }
.history-item:first-child { padding-top: 0; }

.history-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.history-icon svg { width: 14px; height: 14px; }

.history-info { flex: 1; min-width: 0; }

.history-title {
  font-weight: 500;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 1px;
}

.history-meta {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  gap: 6px;
}

.history-amount {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.history-arrow { color: var(--muted-2); flex-shrink: 0; }
.history-arrow svg { width: 14px; height: 14px; }

/* ===== MODAL ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.15s;
}

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

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
}

.modal-content {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 520px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 16px 40px -12px rgba(0, 0, 0, 0.15);
  animation: slideUp 0.18s ease-out;
}

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

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: transparent;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  padding: 0;
}

.modal-close:hover { background: var(--surface-2); color: var(--text); }
.modal-close svg { width: 14px; height: 14px; }

.modal h3 {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.3px;
  margin-bottom: 4px;
  padding-right: 36px;
  color: var(--text);
}

.modal-date {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 20px;
}

.modal-totals {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 16px;
}

.modal-stat {
  background: var(--surface);
  padding: 12px 14px;
}

.modal-stat-label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}

.modal-stat-value {
  font-size: 16px;
  font-weight: 600;
  margin-top: 2px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.modal-balance {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  text-align: center;
  font-weight: 500;
  font-size: 13px;
  margin-bottom: 20px;
  color: var(--text-2);
}

.modal-section-title {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 8px;
}

.modal-mov-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.modal-mov {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.modal-mov:last-child { border-bottom: none; }

.modal-mov-info { flex: 1; min-width: 0; }
.modal-mov-title { font-size: 13px; font-weight: 500; color: var(--text); }
.modal-mov-meta { font-size: 11px; color: var(--muted); margin-top: 1px; }
.modal-mov-amount {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.modal-mov-amount.cobro { color: var(--cobro); }

.modal-mov-del {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  padding: 0;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s, background 0.15s;
}
.modal-mov-del svg { width: 14px; height: 14px; }
.modal-mov:hover .modal-mov-del { opacity: 1; }
.modal-mov-del:hover { color: var(--danger); background: #fef2f2; }

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
}

/* ===== CONFIRM ===== */
.confirm-text {
  color: var(--text-2);
  margin-bottom: 16px;
  line-height: 1.5;
  font-size: 13px;
}

.confirm-summary {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text-2);
}

.confirm-summary > div { margin-bottom: 2px; }
.confirm-summary > div:last-child { margin-bottom: 0; }
.confirm-summary strong { color: var(--text); font-weight: 600; }

.btn-confirm {
  flex: 1;
  background: var(--text);
  color: var(--surface);
  border: 1px solid var(--text);
  padding: 9px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-confirm:hover { opacity: 0.85; }

/* ===== FOOTER ===== */
footer {
  display: flex;
  gap: 8px;
}

/* ===== HOW IT WORKS ===== */
.howto h3 { margin-bottom: 14px; }

.howto-section {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 10px;
}

.howto-section h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.howto-section p {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.55;
}

.howto-section code {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-family: ui-monospace, monospace;
  color: var(--text);
}

/* ===== RESPONSIVE ===== */
/* ===== TABS ===== */
.tabs {
  display: flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 2px;
  overflow-x: auto;
}

.tab {
  flex: 1 1 82px;
  min-width: 0;
  background: transparent;
  border: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 10px;
  border-radius: 5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  line-height: 1.15;
  transition: all 0.15s;
}

.tab svg { width: 16px; height: 16px; }
.tab:hover { color: var(--text-2); }

.tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

#viewCuentas, #viewCrm, #viewClientes, #viewCalidad, #viewTareas, #viewPruebas {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

#viewCuentas[hidden], #viewCrm[hidden], #viewClientes[hidden], #viewCalidad[hidden], #viewTareas[hidden], #viewPruebas[hidden] { display: none; }

/* ===== CLIENTES ===== */
.btn-inline {
  width: auto;
  padding: 9px 16px;
  font-size: 13px;
}

/* ===== CRM ===== */
.crm-panel {
  --surface: #ffffff;
  --surface-2: #f4f8fa;
  --border: #d9e5ea;
  --border-strong: #b8cbd3;
  --text: #111827;
  --text-2: #374151;
  --muted: #6b7280;
  --muted-2: #9ca3af;
  --brand-soft: #e7f6f8;
  --tai-soft: #eef3f7;
  --pabli-soft: #fff3d6;
  --cobro-soft: #e0f8e8;
  --danger-soft: #ffe4e6;
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbfc 100%);
  border-color: rgba(0, 90, 112, 0.16);
  box-shadow: 0 22px 60px -42px rgba(0, 90, 112, 0.65);
}

.crm-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: linear-gradient(90deg, var(--brand), #22c7d9, #fbbf24);
}

.crm-panel .card-header {
  position: relative;
  z-index: 1;
}

.crm-panel .btn-primary {
  width: auto;
  margin-top: 0;
  background: #073f4b;
  color: #ffffff;
  border-color: #073f4b;
  box-shadow: 0 12px 26px -18px rgba(0, 90, 112, 0.9);
}

.crm-panel .btn-primary:hover {
  opacity: 1;
  transform: translateY(-1px);
}

.crm-scoreboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  gap: 8px;
  margin: 14px 0 12px;
}

.crm-score {
  --score-accent: var(--brand);
  appearance: none;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #ffffff;
  padding: 9px 10px 9px 13px;
  min-height: 58px;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 10px 26px -25px rgba(15, 23, 42, 0.9);
  transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s, background 0.12s;
}

.crm-score::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--score-accent);
}

.crm-score:hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
  box-shadow: 0 14px 30px -24px rgba(15, 23, 42, 0.72);
}

.crm-score.active {
  border-color: var(--brand);
  background: #eaf8fb;
  box-shadow: 0 0 0 2px rgba(0, 90, 112, 0.16), 0 14px 30px -26px rgba(0, 90, 112, 0.75);
}

.crm-score span {
  display: block;
  font-size: 9px;
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.crm-score strong {
  display: block;
  margin-top: 3px;
  font-size: 20px;
  line-height: 1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.crm-score.hot { --score-accent: #ef4444; border-color: rgba(185, 28, 28, 0.22); background: #fff8f8; }
.crm-score.warm { --score-accent: #d97706; border-color: rgba(146, 64, 14, 0.22); background: #fffbeb; }
.crm-score.cold { --score-accent: #475569; border-color: rgba(71, 85, 105, 0.22); background: #f8fafc; }
.crm-score.influencer { --score-accent: #16a34a; border-color: rgba(22, 101, 52, 0.22); background: #f0fdf4; }
.crm-score.micro { --score-accent: #0e7490; border-color: rgba(14, 116, 144, 0.2); background: #ecfeff; }
.crm-score.muted strong { color: var(--muted); }

.crm-toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 12px 0 18px;
  padding: 12px;
  border: 1px solid rgba(0, 90, 112, 0.14);
  border-radius: var(--radius-md);
  background: #edf6f8;
}

.crm-toolbar-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(0, 90, 112, 0.12);
  border-radius: var(--radius-md);
  background: #ffffff;
}

.crm-toolbar-eyebrow {
  display: block;
  color: var(--brand);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.crm-toolbar-head strong {
  display: block;
  margin-top: 2px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.3;
}

.crm-clear-filters {
  flex-shrink: 0;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: #ffffff;
  color: var(--text-2);
  padding: 7px 12px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.crm-clear-filters:hover:not(:disabled) {
  border-color: var(--brand);
  color: var(--brand);
  box-shadow: 0 8px 18px -16px rgba(0, 90, 112, 0.8);
}

.crm-clear-filters:disabled {
  cursor: default;
  opacity: 0.45;
}

.crm-toolbar .clientes-filter-row {
  display: block;
}

.crm-toolbar .filters-label {
  display: block;
  padding-top: 0;
  margin-bottom: 6px;
  color: var(--brand);
  font-size: 11px;
  letter-spacing: 0.08em;
}

.crm-toolbar .filters {
  gap: 6px;
}

.crm-toolbar .filter {
  background: #ffffff;
  border-color: #d7e2e8;
  color: #526071;
  min-height: 30px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.02);
}

.crm-toolbar .filter:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.crm-panel .filter.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #ffffff;
  box-shadow: 0 8px 18px -15px rgba(0, 90, 112, 0.85);
}

.crm-toolbar .filter span {
  margin-left: 6px;
  color: inherit;
  opacity: 0.68;
  font-variant-numeric: tabular-nums;
}

.crm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  align-items: start;
  gap: 12px;
}

.crm-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
  box-shadow: 0 14px 34px -31px rgba(15, 23, 42, 0.82);
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.crm-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--brand-line);
}

.crm-card.lead-caliente::before { background: var(--danger); }
.crm-card.lead-tibio::before { background: var(--pabli); }
.crm-card.lead-frio::before { background: var(--tai); }
.crm-card.lead-caliente { border-color: rgba(185, 28, 28, 0.24); }
.crm-card.lead-tibio { border-color: rgba(146, 64, 14, 0.2); }
.crm-card.lead-frio { border-color: rgba(71, 85, 105, 0.2); }
.crm-card.lead-due { box-shadow: 0 0 0 2px rgba(185, 28, 28, 0.07), 0 18px 38px -32px rgba(185, 28, 28, 0.55); }
.crm-card:hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
  box-shadow: 0 18px 40px -32px rgba(15, 23, 42, 0.92);
}

.crm-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.crm-title-block { min-width: 0; }

.crm-kicker {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.crm-name {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
}

.crm-subline {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.lead-temp,
.lead-type,
.lead-country,
.lead-influence,
.lead-source,
.crm-alert,
.crm-link-badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
  line-height: 1;
}

.lead-temp.caliente { background: var(--danger-soft); color: var(--danger); }
.lead-temp.tibio { background: var(--pabli-soft); color: var(--pabli); }
.lead-temp.frio { background: var(--tai-soft); color: var(--tai); }
.lead-type { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.lead-type.compra { background: var(--cobro-soft); color: var(--cobro); border-color: transparent; }
.lead-type.tecnica { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.lead-type.estrategico { background: var(--pabli-soft); color: var(--pabli); border-color: transparent; }
.lead-type.frio { background: var(--tai-soft); color: var(--tai); border-color: transparent; }
.lead-country { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.lead-country.unknown { color: var(--muted); }
.lead-influence { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.lead-influence.alto,
.lead-influence.influencer { background: #d9fbe5; color: #11632f; border-color: rgba(22, 101, 52, 0.12); }
.lead-influence.micro { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.lead-source { background: var(--brand-soft); color: var(--brand); }
.crm-alert { background: var(--danger); color: #ffffff; }
.crm-link-badge { background: var(--cobro-soft); color: var(--cobro); }

.estado-badge.lead-nuevo { background: var(--brand-soft); color: var(--brand); }
.estado-badge.lead-responder { background: var(--danger-soft); color: var(--danger); }
.estado-badge.lead-contactado { background: var(--tai-soft); color: var(--tai); }
.estado-badge.lead-interesado { background: var(--pabli-soft); color: var(--pabli); }
.estado-badge.lead-cotizado { background: #dff3ff; color: #0369a1; }
.estado-badge.lead-esperando { background: var(--surface-2); color: var(--muted); }
.estado-badge.lead-ganado { background: var(--cobro-soft); color: var(--cobro); }
.estado-badge.lead-perdido { background: var(--danger-soft); color: var(--danger); }

.crm-info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.crm-info-grid div {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px;
  background: #f8fbfc;
}

.crm-info-grid span {
  display: block;
  font-size: 10px;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.crm-info-grid strong {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-2);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.crm-note {
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 9px 10px;
  font-size: 12px;
  line-height: 1.45;
}

.crm-meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.crm-meta-line span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 11px;
  font-weight: 700;
}

.crm-comment {
  border-left: 3px solid var(--brand-line);
  padding: 8px 10px;
  background: var(--surface-2);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.crm-comment span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 3px;
}

.crm-comment p {
  color: var(--text-2);
  font-size: 12.5px;
  line-height: 1.45;
}

.crm-last {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-left: 3px solid var(--brand-line);
  padding-left: 9px;
  color: var(--text-2);
  font-size: 12px;
}

.crm-last span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.crm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.crm-action {
  flex: 1 1 92px;
  min-height: 34px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text-2);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.crm-action:hover { background: var(--surface-2); border-color: var(--border-strong); color: var(--text); }
.crm-action[href*="instagram"],
.crm-action[href*="wa.me"] {
  color: var(--brand);
  border-color: rgba(0, 90, 112, 0.18);
  background: #f3fbfc;
}
.crm-action.danger:hover { color: var(--danger); border-color: var(--danger); }

.lead-historial-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.lead-history-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 9px;
  background: var(--surface-2);
}

.lead-history-item strong {
  display: block;
  color: var(--text-2);
  font-size: 12px;
}

.lead-history-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.lead-history-empty {
  color: var(--muted);
  font-size: 12px;
  padding: 8px 0 14px;
}

.lead-add-history {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px;
  background: #fbfbfb;
}

.clientes-board {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 18px 0 18px;
  padding: 14px;
  border: 1px solid rgba(0, 90, 112, 0.14);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(231, 246, 248, 0.72), rgba(255, 255, 255, 0.9));
}

.tandas-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.section-kicker,
.filters-label {
  display: block;
  color: var(--brand);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tandas-head strong {
  display: block;
  color: var(--text);
  font-size: 15px;
  font-weight: 800;
  margin-top: 2px;
}

.tandas-hint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.tanda-selector {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.tanda-filter {
  min-height: 88px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text-2);
  text-align: left;
  box-shadow: 0 10px 30px -24px rgba(0, 0, 0, 0.35);
}

.tanda-filter:hover { border-color: rgba(0, 90, 112, 0.35); background: #fbfdfe; }

.tanda-filter.active {
  background: var(--brand);
  color: #ffffff;
  border-color: var(--brand);
}

.tanda-filter-title {
  font-size: 12px;
  font-weight: 800;
}

.tanda-filter strong {
  font-size: 26px;
  line-height: 1;
  letter-spacing: 0;
}

.tanda-filter span:last-child {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.25;
}

.tanda-filter.active span:last-child { color: rgba(255, 255, 255, 0.82); }

.tanda-divider {
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand-line), var(--brand), rgba(0, 90, 112, 0.08));
}

.cobro-rapido {
  display: grid;
  grid-template-columns: minmax(190px, 0.8fr) minmax(0, 1.6fr);
  gap: 12px;
  align-items: stretch;
  padding: 12px;
  border: 1px solid rgba(0, 90, 112, 0.14);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.78);
}

.cobro-total {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  min-width: 0;
}

.cobro-total strong {
  color: var(--danger);
  font-size: 28px;
  line-height: 1;
  letter-spacing: 0;
}

.cobro-total span:not(.section-kicker),
.cobro-total small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.cobro-lista {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.cobro-deudores {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.deudor-chip,
.deudor-more,
.deudor-empty {
  min-height: 38px;
  border: 1px solid rgba(0, 90, 112, 0.14);
  border-radius: 999px;
  background: #ffffff;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 700;
  max-width: 100%;
}

.deudor-chip strong {
  color: var(--text);
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.deudor-chip span {
  color: var(--danger);
  white-space: nowrap;
}

.deudor-chip small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.deudor-more {
  color: var(--brand);
  background: rgba(0, 90, 112, 0.07);
}

.deudor-empty {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.62);
}

.clientes-filter-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.clientes-filter-row .filters { flex: 1; min-width: 240px; }

.clientes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.cliente-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
  box-shadow: 0 12px 34px -30px rgba(0, 0, 0, 0.45);
}

.cliente-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 5px;
  background: var(--brand-line);
}

.cliente-card.cliente-tanda-2::before {
  background: linear-gradient(90deg, var(--brand-line), var(--brand));
}

.cliente-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.cliente-badges {
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  gap: 6px;
  flex-wrap: wrap;
}

.cliente-title-block {
  min-width: 0;
}

.cliente-kicker {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.cliente-nombre {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0;
  line-height: 1.25;
}

.cliente-atendio {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.estado-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 99px;
  white-space: nowrap;
  flex-shrink: 0;
}
.estado-badge.pendiente { background: var(--surface-2); color: var(--muted); }
.estado-badge.produccion { background: var(--pabli-soft); color: var(--pabli); }
.estado-badge.listo { background: var(--tai-soft); color: var(--tai); }
.estado-badge.enviado { background: var(--cobro-soft); color: var(--cobro); }

.tanda-badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
  vertical-align: middle;
}
.tanda-badge.tanda-1 { background: var(--brand-soft); color: var(--brand); }
.tanda-badge.tanda-2 { background: #dff3ff; color: #0369a1; }

.cliente-montos {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-2);
}
.cliente-montos .label { color: var(--muted); }
.cliente-montos strong { font-variant-numeric: tabular-nums; }

.cliente-falta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
}
.cliente-falta .label { color: var(--muted); }
.cliente-falta .monto {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.4px;
}
.cliente-falta.debe .monto { color: var(--danger); }
.cliente-falta.pagado .monto { color: var(--cobro); }

.pago-bar {
  height: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.pago-bar-fill { height: 100%; background: var(--cobro); transition: width 0.2s; }

.cliente-seña {
  font-size: 12px;
  color: var(--muted);
}
.cliente-seña strong { color: var(--text-2); }

.cliente-envio {
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.cliente-envio .envio-line { display: flex; gap: 6px; align-items: center; }
.cliente-envio svg { width: 13px; height: 13px; flex-shrink: 0; opacity: 0.7; }

.cliente-actions {
  display: flex;
  gap: 8px;
  margin-top: 2px;
}
.cliente-actions button {
  flex: 1;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 8px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: all 0.15s;
}
.cliente-actions button svg { width: 13px; height: 13px; }
.cliente-actions button:hover { background: var(--surface-2); border-color: var(--border-strong); }
.cliente-actions .act-del:hover { color: var(--danger); border-color: var(--danger); }

/* ===== CALIDAD ===== */
.estado-badge.aprobado,
.estado-badge.calidad-aprobado { background: var(--cobro-soft); color: var(--cobro); }
.estado-badge.revisar,
.estado-badge.calidad-revisar { background: var(--danger-soft); color: var(--danger); }
.estado-badge.calidad-pendiente { background: var(--surface-2); color: var(--muted); }

.calidad-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.calidad-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-left: 3px solid var(--border-strong);
}
.calidad-card.estado-aprobado { border-left-color: var(--cobro); }
.calidad-card.estado-revisar { border-left-color: var(--danger); border-color: #fecaca; }

.calidad-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.calidad-producto {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.2px;
}

.calidad-meta,
.calidad-ident,
.cal-video,
.cal-more {
  font-size: 12px;
  color: var(--muted);
}

.calidad-ident {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  color: var(--text-2);
}

.cal-pasos-mini {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.cal-paso-mini {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-2);
}
.cal-paso-mini .check-box {
  width: 16px;
  height: 16px;
  border-radius: 4px;
}
.cal-paso-mini.done .check-box {
  background: var(--cobro);
  border-color: var(--cobro);
  color: #fff;
}
.cal-paso-mini.done span:last-child {
  color: var(--muted);
  text-decoration: line-through;
}

.cal-video-link,
.cal-video-file {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  background: var(--tai-soft);
  border: 1px solid var(--border);
  color: var(--tai);
  padding: 5px 9px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cal-video-link:hover {
  background: var(--surface-2);
  color: var(--text);
}

.calidad-actions {
  display: flex;
  gap: 8px;
  margin-top: 2px;
}
.calidad-actions button {
  flex: 1;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 8px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: all 0.15s;
}
.calidad-actions button svg { width: 13px; height: 13px; }
.calidad-actions button:hover { background: var(--surface-2); border-color: var(--border-strong); }
.calidad-actions .cal-del:hover { color: var(--danger); border-color: var(--danger); }

.cal-pasos-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.cal-paso-row {
  display: grid;
  grid-template-columns: 30px 1fr 30px;
  align-items: center;
  gap: 8px;
}

.cal-check {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cal-check svg { width: 15px; height: 15px; }
.cal-paso-row.done .cal-check {
  background: var(--cobro);
  border-color: var(--cobro);
  color: #fff;
}
.cal-paso-row.done .cal-paso-input {
  color: var(--muted);
  text-decoration: line-through;
}

/* ===== CLIENTE MODAL — pagos ===== */
.pagos-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}
.pago-item {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-size: 13px;
}
.pago-quien-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-top: 6px; border-top: 1px solid var(--border); }
.pago-quien-row .field-label { font-size: 11px; color: var(--muted); white-space: nowrap; }
.pago-quien-seg { flex: 1; min-width: 0; }
.pago-item-info { display: flex; flex-direction: column; gap: 1px; }
.pago-item-amount { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--cobro); }
.pago-item-meta { font-size: 11px; color: var(--muted); }
.pago-del {
  background: transparent;
  border: none;
  color: var(--muted-2);
  cursor: pointer;
  padding: 4px;
  display: flex;
}
.pago-del svg { width: 15px; height: 15px; }
.pago-del:hover { color: var(--danger); }

.add-pago-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }
.add-pago-row .field { margin-bottom: 0; }

/* ===== TAREAS ===== */
.stat-trabadas .stat-label::before { background: var(--danger); }

.tareas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.tarea-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-left: 3px solid var(--border-strong);
}
.tarea-card.resp-tai { border-left-color: var(--tai); }
.tarea-card.resp-pabli { border-left-color: var(--pabli); }
.tarea-card.trabado { border-left-color: var(--danger); border-color: var(--danger); }

.tarea-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.tarea-titulo {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.2px;
}
.tarea-desc {
  font-size: 13px;
  color: var(--muted);
  margin-top: 3px;
  line-height: 1.4;
}

.estado-badge.en_curso { background: var(--tai-soft); color: var(--tai); }
.estado-badge.trabado { background: var(--danger-soft); color: var(--danger); }
.estado-badge.completada { background: var(--cobro-soft); color: var(--cobro); }

.tarea-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  font-size: 12px;
  color: var(--muted);
}
.tarea-meta .resp {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 500;
  color: var(--text-2);
}

.tarea-bloqueo {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  background: var(--danger-soft);
  border: 1px solid var(--danger);
  border-radius: var(--radius-md);
  padding: 9px 11px;
  font-size: 12.5px;
  color: var(--danger);
  line-height: 1.4;
}
.tarea-bloqueo svg { width: 15px; height: 15px; flex-shrink: 0; margin-top: 1px; }
.tarea-bloqueo strong { font-weight: 700; }

.tarea-progress-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 12px;
  color: var(--muted);
}
.tarea-progress-head .pct {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
}
.tarea-card.trabado .tarea-progress-head .pct { color: var(--danger); }

.checklist {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.check-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 4px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13.5px;
  color: var(--text-2);
  transition: background 0.12s;
}
.check-item:hover { background: var(--surface-2); }
.check-box {
  width: 18px;
  height: 18px;
  border: 1.8px solid var(--border-strong);
  border-radius: 5px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  transition: all 0.12s;
}
.check-box svg { width: 12px; height: 12px; }
.check-item.done .check-box {
  background: var(--cobro);
  border-color: var(--cobro);
  color: #fff;
}
.check-item.done .check-text {
  text-decoration: line-through;
  color: var(--muted-2);
}

.tarea-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
}
.tarea-actions button {
  flex: 1 1 auto;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: all 0.15s;
  white-space: nowrap;
}
.tarea-actions button svg { width: 13px; height: 13px; }
.tarea-actions button:hover { background: var(--surface-2); border-color: var(--border-strong); }
.tarea-actions .t-complete:hover { color: var(--cobro); border-color: var(--cobro); }
.tarea-actions .t-del:hover { color: var(--danger); border-color: var(--danger); }

/* Baúl */
.baul-stats { margin: 16px 0 4px; }
.baul-stats .stat { cursor: default; }
.baul-stats .stat:hover { background: var(--surface); }

.baul-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-2);
  margin: 22px 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.baul-section-title .count {
  font-weight: 500;
  color: var(--muted);
}

.baul-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 11px 13px;
  margin-bottom: 8px;
}
.baul-item-info { flex: 1; min-width: 0; }
.baul-item-title { font-size: 13.5px; font-weight: 600; color: var(--text); }
.baul-item-meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.baul-item-actions { display: flex; gap: 6px; flex-shrink: 0; }
.baul-item-actions button {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  display: flex;
  transition: all 0.15s;
}
.baul-item-actions button svg { width: 14px; height: 14px; }
.baul-item-actions button:hover { color: var(--text); border-color: var(--border-strong); }
.baul-item-actions .b-del:hover { color: var(--danger); border-color: var(--danger); }
.baul-empty { font-size: 12.5px; color: var(--muted-2); padding: 4px 2px 8px; }

/* Checklist editor (modal) */
.subt-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.subt-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-2);
}
.subt-item span { flex: 1; }
.subt-del { background: transparent; border: none; color: var(--muted-2); cursor: pointer; padding: 4px; display: flex; }
.subt-del svg { width: 15px; height: 15px; }
.subt-del:hover { color: var(--danger); }
.add-subt-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; }
.add-subt-row .field { margin-bottom: 0; }

@media (max-width: 540px) {
  .app { padding: 24px 16px 48px; }
  .summary-grid { grid-template-columns: 1fr; }
  .balance-grid { grid-template-columns: 1fr; }
  .tanda-selector { grid-template-columns: 1fr; }
  .tandas-head { flex-direction: column; }
  .tandas-hint { white-space: normal; }
  .cobro-rapido { grid-template-columns: 1fr; }
  .cobro-total strong { font-size: 24px; }
  .deudor-chip { width: 100%; justify-content: space-between; border-radius: var(--radius-md); }
  .deudor-chip strong { max-width: 52%; }
  .cliente-alerta-chip { width: 100%; border-radius: var(--radius-md); }
  .cliente-costos { grid-template-columns: 1fr; }
  .cliente-costos strong { text-align: left; }
  .cliente-mini-item { align-items: flex-start; flex-wrap: wrap; }
  .cliente-mini-info { flex-basis: 100%; }
  .mini-action { flex: 1; }
  .clientes-board { padding: 12px; }
  .clientes-grid { grid-template-columns: 1fr; }
  .tareas-grid { grid-template-columns: 1fr; }
  .baul-stats { grid-template-columns: repeat(3, 1fr); }
  .tab { font-size: 13px; padding: 9px 8px; }
  .stat { padding: 14px 16px; }
  .brand-text h1 { font-size: 18px; }
  .hero-value { font-size: 26px; }
  .hero-card { padding: 20px; }
  .card { padding: 18px; }
  .hero-row { align-items: flex-start; }
  .card-header.with-action { flex-direction: column; }
  .filters { width: 100%; }
  .crm-scoreboard { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .crm-toolbar-head { align-items: stretch; flex-direction: column; }
  .crm-clear-filters { width: 100%; }
  .crm-grid { grid-template-columns: 1fr; }
  .crm-info-grid { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .modal-content { padding: 20px; }
  .mov-delete { opacity: 1; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #f7fafb;
    --surface: #ffffff;
    --surface-2: #f1f6f8;
    --border: #dce7eb;
    --border-strong: #c3d3da;

    --text: #111827;
    --text-2: #374151;
    --muted: #6b7280;
    --muted-2: #9ca3af;

    --tai: #475569;
    --pabli: #92400e;
    --cobro: #166534;
    --danger: #b91c1c;

    --tai-soft: #f1f5f9;
    --pabli-soft: #fef3c7;
    --cobro-soft: #dcfce7;
    --danger-soft: #fee2e2;
  }

  input[type="text"],
  input[type="number"],
  input[type="date"],
  input[type="url"],
  input[type="email"],
  input[type="password"],
  select,
  textarea { color-scheme: light; }

  .btn-primary { background: var(--text); color: var(--bg); border-color: var(--text); }
  .btn-confirm { background: var(--text); color: var(--bg); border-color: var(--text); }
  .filter.active { background: var(--text); color: var(--bg); border-color: var(--text); }
  .clientes-board { background: linear-gradient(180deg, rgba(231, 246, 248, 0.96), rgba(255, 255, 255, 0.92)); border-color: rgba(0, 90, 112, 0.16); }
  .tanda-filter { background: var(--surface); }
  .tanda-filter:hover { background: var(--surface-2); }
  .tanda-filter.active { background: var(--brand); color: #fff; border-color: var(--brand); }
  .tanda-badge.tanda-1 { background: rgba(56, 189, 248, 0.18); color: #7dd3fc; }
  .tanda-badge.tanda-2 { background: rgba(8, 127, 147, 0.26); color: #67e8f9; }
  .btn-ghost.danger:hover { background: rgba(248, 113, 113, 0.08); border-color: rgba(248, 113, 113, 0.3); }
  .modal-backdrop { background: rgba(0, 0, 0, 0.6); }
}

/* ===== DÓLAR / CONVERSOR ===== */
.dolar-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  background: linear-gradient(135deg, var(--cobro-soft), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
}
.dolar-main { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.dolar-label { font-size: 13px; font-weight: 600; color: var(--cobro); text-transform: uppercase; letter-spacing: 0.5px; }
.dolar-value { font-size: 30px; font-weight: 700; letter-spacing: -1px; color: var(--text); font-variant-numeric: tabular-nums; }
.dolar-unit { font-size: 12px; color: var(--muted); }
.dolar-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.dolar-blue { font-size: 12px; color: var(--muted); }
.dolar-blue strong { color: var(--text-2); font-variant-numeric: tabular-nums; }
.dolar-edit { display: flex; gap: 6px; align-items: center; }
.dolar-edit input { width: 100px; padding: 7px 10px; font-size: 13px; font-variant-numeric: tabular-nums; }
.btn-mini {
  font-family: inherit; font-size: 12px; font-weight: 600;
  padding: 7px 12px; border-radius: var(--radius-md);
  background: var(--text); color: var(--bg); border: 1px solid var(--text);
  cursor: pointer; white-space: nowrap;
}
.btn-mini.ghost { background: var(--surface); color: var(--text-2); border-color: var(--border-strong); }
.btn-mini:hover { opacity: 0.88; }

/* Equivalente USD bajo montos en pesos */
.stat-usd { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin-top: 2px; }
.balance-usd { font-size: 12px; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; text-align: right; }

/* ===== PAYPAL CARD ===== */
.paypal-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px 18px;
}
.paypal-icon {
  width: 38px; height: 38px; flex-shrink: 0; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: #e6f0fb; color: #0070ba;
}
.paypal-icon svg { width: 20px; height: 20px; }
.paypal-body { display: flex; flex-direction: column; }
.paypal-label { font-size: 13px; color: var(--text-2); font-weight: 500; }
.paypal-sub { color: var(--muted); font-weight: 400; font-size: 11px; }
.paypal-value { font-size: 20px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; letter-spacing: -0.4px; }

.dot-paypal { background: #0070ba; }

/* ===== TARJETA DE CLIENTE: moneda, estado de pago, faltante ===== */
.moneda-badge {
  font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 5px;
  vertical-align: middle; letter-spacing: 0.3px;
}
.moneda-badge.ars { background: var(--surface-2); color: var(--muted); }
.moneda-badge.usd { background: #e6f0fb; color: #0070ba; }

.pago-tag { font-size: 11px; font-weight: 600; }
.pago-tag.completo { color: var(--cobro); }
.pago-tag.sena { color: var(--pabli); }
.pago-tag.sinpagar { color: var(--muted); }

.cliente-falta.debe { background: #fef2f2; border-radius: var(--radius-md); padding: 8px 10px; }
.cliente-falta.debe .monto { font-size: 22px; }
.falta-eq { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 4px; }
.cliente-comision { color: var(--muted); font-weight: 400; }

/* Hint de faltante en el modal */
.falta-hint { font-size: 13px; color: var(--muted); margin: 4px 0 10px; min-height: 18px; }
.falta-hint strong { color: var(--danger); font-variant-numeric: tabular-nums; }

@media (prefers-color-scheme: dark) {
  .paypal-icon { background: #0b2540; color: #4aa3e0; }
  .moneda-badge.usd { background: #0b2540; color: #4aa3e0; }
  .cliente-falta.debe { background: rgba(248,113,113,0.08); }
  .dolar-card { background: linear-gradient(135deg, rgba(74,222,128,0.08), var(--surface)); }
}

/* ===== BARRA DÓLAR GLOBAL (arriba, visible en toda la app) ===== */
.dolar-bar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 10px 14px;
}
.dolar-bar-left { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.dolar-mainline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dolar-chip { font-size: 11px; font-weight: 800; color: var(--brand); background: var(--brand-soft); padding: 3px 8px; border-radius: 6px; letter-spacing: 0.3px; }
.dolar-bar .dolar-value { font-size: 18px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; letter-spacing: -0.3px; }
.dolar-bar .dolar-unit { font-size: 12px; color: var(--muted); }
.dolar-bar .dolar-blue { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 11px; color: var(--muted); }
.dolar-bar .dolar-blue strong { color: var(--cobro); font-variant-numeric: tabular-nums; }
.dolar-bar .dolar-blue span,
.dolar-bar .dolar-blue em {
  font-style: normal;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 7px;
}
.dolar-bar .dolar-blue em {
  color: var(--brand);
  font-weight: 700;
}
.dolar-bar .dolar-edit { display: flex; gap: 6px; align-items: center; }
.dolar-bar .dolar-edit input { width: 92px; padding: 6px 9px; font-size: 13px; font-variant-numeric: tabular-nums; }

@media (max-width: 540px) {
  .dolar-bar { padding: 10px 12px; }
  .dolar-bar .dolar-edit input { width: 72px; }
  .dolar-chip { font-size: 10px; }
}
@media (prefers-color-scheme: dark) {
  .dolar-chip { background: rgba(56, 189, 248, 0.18); color: #7dd3fc; }
  .dolar-bar .dolar-blue em { color: #7dd3fc; }
}

/* Observaciones del cliente en la tarjeta */
.cliente-notas {
  display: flex; gap: 7px; align-items: flex-start;
  font-size: 12px; color: var(--text-2);
  background: var(--surface-2); border-radius: var(--radius-md);
  padding: 8px 10px;
}
.cliente-notas svg { width: 14px; height: 14px; flex-shrink: 0; margin-top: 1px; opacity: 0.7; }
.cliente-notas span { white-space: pre-wrap; word-break: break-word; }

.cliente-alertas {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.cliente-alerta-chip,
.cliente-alerta-more {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  border: 1px solid #fde68a;
  border-radius: 999px;
  background: #fffbeb;
  color: #92400e;
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.2;
}

.cliente-alerta-chip.alta {
  border-color: #fecaca;
  background: #fef2f2;
  color: #b91c1c;
}

.cliente-alerta-chip svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.cliente-alerta-chip span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cliente-alerta-chip small {
  color: currentColor;
  opacity: 0.72;
  font-size: 10px;
  white-space: nowrap;
}

.cliente-alerta-more {
  color: var(--brand);
  border-color: rgba(0, 90, 112, 0.18);
  background: rgba(0, 90, 112, 0.07);
}

.cliente-costos {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 2px 10px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: var(--radius-md);
  background: #f8fafc;
  padding: 9px 10px;
  font-size: 12px;
}

.cliente-costos span {
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.cliente-costos strong {
  color: var(--text);
  font-size: 14px;
  text-align: right;
}

.cliente-costos small {
  grid-column: 1 / -1;
  color: var(--muted);
  font-weight: 650;
}

.cliente-form-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: #fbfdfe;
  padding: 12px;
  margin-top: 8px;
}

.cliente-mini-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.cliente-mini-item {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 9px 10px;
}

.cliente-mini-item.done {
  opacity: 0.68;
  background: var(--surface-2);
}

.cliente-mini-item.done strong {
  text-decoration: line-through;
}

.cliente-mini-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cliente-mini-info strong {
  color: var(--text);
  font-size: 13px;
  line-height: 1.25;
}

.cliente-mini-info span,
.cliente-mini-info em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  line-height: 1.35;
}

.mini-action {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.mini-action:hover {
  border-color: rgba(0, 90, 112, 0.25);
  color: var(--brand);
}

.cliente-costos-resumen strong { color: var(--text); }
.cliente-costos-resumen span { color: var(--muted); }

/* ===== Pruebas pasturómetro ===== */
.pruebas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}

.prueba-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--cobro);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.prueba-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.prueba-titulo { font-size: 15px; font-weight: 600; color: var(--text); line-height: 1.3; }
.prueba-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.prueba-vs { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.prueba-vs::first-letter { text-transform: none; }

.prueba-actions { display: flex; gap: 6px; flex-shrink: 0; }
.prueba-actions button {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
}
.prueba-actions button svg { width: 14px; height: 14px; }
.prueba-actions button:hover { background: var(--surface-2); border-color: var(--border-strong); }
.prueba-actions .b-del:hover { color: var(--danger); border-color: var(--danger); }

.entorno-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.entorno-chip {
  font-size: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  color: var(--text-2);
  white-space: nowrap;
}

.prueba-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 8px;
  background: var(--surface-2);
  border-radius: var(--radius-md);
  padding: 10px;
}
.pr-stat { display: flex; flex-direction: column; gap: 2px; }
.pr-stat-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
.pr-stat-val { font-size: 16px; font-weight: 600; color: var(--text); }
.pr-stat-dif .pr-stat-val { color: var(--cobro); }

.prueba-tabla-wrap { overflow-x: auto; }
.prueba-tabla { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.prueba-tabla th {
  text-align: left; font-weight: 600; color: var(--muted);
  padding: 5px 8px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.prueba-tabla td { padding: 5px 8px; border-bottom: 1px solid var(--border); color: var(--text-2); }
.prueba-tabla tr:last-child td { border-bottom: none; }

/* ----- Modal de prueba ----- */
.entorno-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.entorno-grid .field { margin-bottom: 0; }

.cols-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.col-row { display: flex; align-items: center; gap: 8px; }
.col-row .col-nombre {
  flex: 1 1 auto; min-width: 0;
  font-family: inherit; font-size: 14px;
  padding: 9px 11px;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface); color: var(--text);
}
.col-tipo { flex-shrink: 0; width: auto; }
.col-tipo .seg { padding: 7px 10px; font-size: 12px; }
.col-row .subt-del { flex-shrink: 0; }

.med-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-md); }
.med-table { width: 100%; border-collapse: collapse; }
.med-table th {
  text-align: left; font-size: 11px; font-weight: 600; color: var(--muted);
  padding: 7px 8px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.med-table td { padding: 4px 6px; border-bottom: 1px solid var(--border); }
.med-table tr:last-child td { border-bottom: none; }
.med-input {
  width: 100%; min-width: 80px;
  font-family: inherit; font-size: 13.5px;
  padding: 7px 8px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
}
.med-input:focus { outline: none; border-color: var(--border-strong); background: var(--surface-2); }
.med-table .subt-del { margin: 0 auto; }
.med-table .med-idx { color: var(--muted); font-size: 11px; text-align: center; width: 28px; }

/* Botón "Empezar/Cargar medición" en la tarjeta */
.prueba-med-btn {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  width: 100%;
  font-family: inherit; font-size: 13px; font-weight: 600;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}
.prueba-med-btn svg { width: 15px; height: 15px; }
.prueba-med-btn:hover { background: var(--surface); border-color: var(--border-strong); }

/* El modal de mediciones es ancho en compu/iPad para que entren todas las
   columnas sin scroll lateral; en el celu se adapta al ancho de pantalla. */
#medicionModal .modal-content { max-width: min(96vw, 1100px); }

/* Header del modal de mediciones */
.medicion-head { margin-bottom: 14px; }
.medicion-head h3 { margin-bottom: 2px; }
.medicion-head .prueba-vs { font-size: 13px; color: var(--muted); }
#medicionResumen { margin-bottom: 14px; }
#medicionResumen .prueba-stats { margin-bottom: 10px; }

/* Editor de cálculos (modal de prueba) */
.modal-hint { font-size: 12px; color: var(--muted); margin: -4px 0 10px; line-height: 1.4; }
.calcs-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.calc-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.calc-sel {
  flex: 1 1 90px; min-width: 0;
  font-family: inherit; font-size: 13px;
  padding: 8px 9px;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface); color: var(--text);
  cursor: pointer;
}
.calc-sel.calc-op { flex: 1 1 100%; }
.calc-vs { font-size: 12px; color: var(--muted); flex-shrink: 0; }
.calc-row .subt-del { flex-shrink: 0; }

/* Cálculos en la tarjeta y en el modal de mediciones */
.prueba-calcs { display: flex; flex-direction: column; gap: 6px; }
.pr-calc {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 8px 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.pr-calc.ganador { border-color: var(--cobro); background: var(--cobro-soft); }
.pr-calc-label { font-size: 12.5px; color: var(--text-2); }
.pr-calc-label i { font-style: normal; color: var(--muted); }
.pr-calc-label em { font-style: normal; color: var(--muted); font-size: 11px; }
.pr-calc-val { font-size: 14px; font-weight: 700; color: var(--text); white-space: nowrap; }
.pr-calc.ganador .pr-calc-val { color: var(--cobro); }

@media (max-width: 540px) {
  .pruebas-grid { grid-template-columns: 1fr; }
  .entorno-grid { grid-template-columns: 1fr 1fr; }
}
