/* ===== Botones ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 15px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink); font-weight: 600; font-size: 14px; cursor: pointer; transition: background .15s, border-color .15s, box-shadow .15s, transform .05s; white-space: nowrap; min-height: 40px; }
.btn:hover { background: var(--surface-2); border-color: var(--faint); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 2px 6px rgba(200,86,74,.28); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--border)); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.danger.solid { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.sm { padding: 5px 10px; font-size: 13px; min-height: 32px; }
.btn.lg { padding: 14px 20px; font-size: 16px; min-height: 52px; border-radius: 12px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; transform: none; }
.icon-btn { width: 40px; height: 40px; padding: 0; }
.icon-btn.sm { width: 32px; height: 32px; }

/* ===== Formularios ===== */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span.lbl { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.field .hint { font-size: 12px; color: var(--faint); }
input, select, textarea { font: inherit; font-size: 14.5px; color: var(--ink); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 9px 11px; width: 100%; min-height: 40px; transition: border-color .15s, box-shadow .15s; }
input::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent); }
input:disabled, select:disabled { background: var(--surface-2); color: var(--muted); }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; min-height: 0; accent-color: var(--primary); padding: 0; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; min-height: 40px; }
.input-icon { position: relative; }
.input-icon svg.i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.input-icon input { padding-left: 38px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px; }
.filters .field { flex: 1 1 150px; }
.filters .field.wide { flex: 2 1 240px; }
.filters .btn { flex: 0 0 auto; }

/* ===== Tarjetas, KPIs ===== */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); }
.card > h3:first-child { margin-bottom: 12px; }
.card.flush { padding: 0; overflow: hidden; }
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(188px, 1fr)); }
.cols-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); }
.kpi { display: block; }
.kpi-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.kpi .chip { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); flex-shrink: 0; }
.kpi .chip.ok { background: var(--ok-soft); color: var(--ok); } .kpi .chip.warn { background: var(--warn-soft); color: var(--warn); } .kpi .chip.bad { background: var(--bad-soft); color: var(--bad); } .kpi .chip.info { background: var(--info-soft); color: var(--info); }
.kpi .label { font-size: 13px; color: var(--muted); }
.kpi .value { font-size: 26px; font-weight: 750; letter-spacing: -.02em; line-height: 1.2; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi .sub { font-size: 12.5px; color: var(--faint); }

/* ===== Tablas (en celular se convierten en tarjetas) ===== */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; box-shadow: var(--shadow-sm); }
table.table { width: 100%; border-collapse: collapse; }
.table th { background: var(--surface-2); color: var(--muted); font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table th.num, .table td.num { text-align: right; }
.table td.actions { text-align: right; white-space: nowrap; }
.table .name { font-weight: 600; } .table .sub { color: var(--muted); font-size: 12.5px; }
.table-foot { display: flex; justify-content: space-between; align-items: center; padding: 10px 4px; color: var(--muted); font-size: 13px; }

/* ===== Etiquetas de estado ===== */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 650; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); } .pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); } .pill.off { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.pill.info { background: var(--info-soft); color: var(--info); } .pill.brand { background: var(--primary-soft); color: var(--primary-ink); }

/* ===== Modal ===== */
.overlay { position: fixed; inset: 0; background: rgba(15,18,28,.55); backdrop-filter: blur(3px); z-index: 60; display: flex; align-items: flex-start; justify-content: center; padding: 28px 16px; overflow-y: auto; animation: fade .15s ease; }
.modal { background: var(--surface); border-radius: 18px; width: 100%; max-width: 780px; margin: auto; box-shadow: var(--shadow-lg); animation: pop .18s ease; display: flex; flex-direction: column; max-height: calc(100vh - 56px); }
.modal.sm { max-width: 440px; } .modal.md { max-width: 600px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 18px 22px 12px; }
.modal-head h3 { font-size: 18px; }
.modal-body { padding: 4px 22px 8px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px 20px; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0 } } @keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98) } }

/* ===== Avisos ===== */
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; max-width: min(380px, calc(100vw - 32px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; background: var(--ink); color: var(--bg); padding: 12px 14px; border-radius: 12px; box-shadow: var(--shadow-lg); animation: pop .2s ease; font-size: 14px; }
.toast.ok { background: var(--ok); color: #fff; } .toast.err { background: var(--bad); color: #fff; }
.alert { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm); font-size: 13.5px; background: var(--info-soft); color: var(--info); }
.alert.warn { background: var(--warn-soft); color: var(--warn); } .alert.bad { background: var(--bad-soft); color: var(--bad); } .alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert b { font-weight: 650; }
.empty { text-align: center; padding: 38px 16px; color: var(--muted); }
.empty svg { color: var(--faint); margin-bottom: 8px; }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.3s infinite; border-radius: 10px; }
@keyframes shimmer { 0% { background-position: 100% 50% } 100% { background-position: 0 50% } }
.spinner { width: 18px; height: 18px; border: 2.5px solid var(--border-strong); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg) } }
.tabs { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; }
.tabs button { border: 0; background: transparent; padding: 6px 14px; border-radius: 8px; font-weight: 600; font-size: 13.5px; color: var(--muted); cursor: pointer; }
.tabs button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* Tablas: que números, códigos y acciones no se partan; el nombre conserva ancho legible */
.table td.num, .table td.actions, .table td .code, .table td .pill, .table td .nowrap { white-space: nowrap; }
.table td.main-cell { min-width: 190px; }
.table td, .table th { padding-left: 12px; padding-right: 12px; }
.txt-m { display: none; }
@media (max-width: 640px) { .txt-m { display: inline; } }

/* Filtros plegables en celular */
.mobile-only { display: none; }
@media (max-width: 640px) {
  .mobile-only { display: inline-flex; }
  .filters.collapsible:not(.open) > .field:not(.wide), .filters.collapsible:not(.open) > .check { display: none; }
  .filters.collapsible > .field.wide { flex: 1 1 calc(100% - 118px); }
}
