/* ───────────────────────────────────────────────────────────
   Componentes reutilizables
   ─────────────────────────────────────────────────────────── */

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; min-height: 40px;
  font-weight: 600; font-size: 14px; line-height: 1.2; white-space: nowrap;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none;
  transition: background .15s var(--ease), border-color .15s var(--ease), transform .1s var(--ease);
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 17px; height: 17px; flex: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.sm { min-height: 32px; padding: 5px 11px; font-size: 13px; }
.btn.block { width: 100%; min-height: 46px; font-size: 15px; }
.btn:disabled, .btn[aria-busy="true"] { opacity: .55; cursor: default; pointer-events: none; }

.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0;
  border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 19px; height: 19px; }

/* Formularios */
.field { display: grid; gap: 6px; margin: 0; min-width: 0; }
.field > .label { font-size: 13px; font-weight: 500; color: var(--muted); }
.field .hint { font-size: 12px; color: var(--muted); }
.field .err { font-size: 12.5px; color: var(--danger); min-height: 0; }
.input, .select, .textarea {
  width: 100%; padding: 10px 12px; min-height: 42px;
  font: inherit; font-size: 15px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); outline: none;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.textarea { min-height: 84px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field.invalid .input, .field.invalid .select, .field.invalid .textarea { border-color: var(--danger); }
.select {
  appearance: none; padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236a7285' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
}
.input-group { position: relative; }
.input-group .input { padding-right: 44px; }
.input-group .icon-btn { position: absolute; right: 3px; top: 3px; width: 36px; height: 36px; }
.input-affix { position: relative; }
.input-affix .input { padding-right: 38px; }
.input-affix .affix { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; font-size: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-error { color: var(--danger); font-size: 14px; background: var(--danger-soft); padding: 10px 12px; border-radius: var(--radius-sm); }
.form-note { font-size: 14px; background: var(--accent-soft); color: var(--text); padding: 10px 12px; border-radius: var(--radius-sm); }
.form-note.ok { background: var(--ok-soft); }
.form-note.warn { background: var(--warn-soft); }

/* Interruptor y casilla */
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { flex: none; width: 42px; height: 24px; border-radius: 99px; background: var(--border-strong); position: relative; transition: background .2s var(--ease); }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s var(--ease); box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Tarjetas */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.card-head h2 { font-size: 18px; }
.card.flush .card-head { padding: 18px 20px 0; margin-bottom: 8px; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.main-side { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }

.kpi .value { font-size: 28px; font-weight: 600; letter-spacing: -.02em; margin-top: 6px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi .sub { font-size: 13px; color: var(--muted); margin-top: 6px; }
.kpi .value.ok { color: var(--ok); }

.hero { background: var(--ink); color: var(--ink-text); border-color: transparent; padding: 26px; }
.hero .eyebrow { color: var(--ink-muted); }
.hero .big { font-family: var(--font-display); font-size: clamp(36px, 6vw, 52px); font-weight: 600; letter-spacing: -.02em; margin: 8px 0 4px; font-variant-numeric: tabular-nums; line-height: 1.05; }
.hero .sub { color: var(--ink-muted); font-size: 14px; }
.hero .btn { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.18); color: var(--ink-text); }
.hero .btn:hover { background: rgba(255,255,255,.18); }

/* Chips de estado */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.danger { background: var(--danger-soft); color: var(--danger); }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.chip.plain::before { display: none; }

/* Avatar con iniciales */
.avatar { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 14px; background: var(--accent-soft); color: var(--accent); letter-spacing: .02em; }
.avatar.lg { width: 60px; height: 60px; font-size: 20px; font-family: var(--font-display); }
.avatar.muted { background: var(--surface-2); color: var(--muted); }

/* Listas */
.list { display: grid; }
.item { display: flex; align-items: center; gap: 14px; padding: 14px 20px; border-top: 1px solid var(--border); min-width: 0; }
.item:first-child { border-top: 0; }
.item.clickable { cursor: pointer; transition: background .12s var(--ease); }
.item.clickable:hover { background: var(--surface-2); }
.item .main { flex: 1; min-width: 0; }
.item .title { font-weight: 600; }
.item .meta { font-size: 13px; color: var(--muted); }
.item .end { text-align: right; flex: none; }
.item .amount { font-weight: 600; font-variant-numeric: tabular-nums; }
.item .time { flex: none; width: 54px; font-variant-numeric: tabular-nums; }
.item .time b { display: block; font-size: 15px; }
.item .time span { font-size: 12px; color: var(--muted); }
.item.is-cancelled .title, .item.is-cancelled .amount { text-decoration: line-through; color: var(--muted); }
.day-head { padding: 10px 20px; background: var(--surface-2); font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); border-top: 1px solid var(--border); }
.day-head.today { color: var(--accent); background: var(--accent-soft); }
.day-head:first-child { border-top: 0; }

/* Pestañas segmentadas */
.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border-radius: 12px; max-width: 100%; overflow-x: auto; }
.segmented button { border: 0; background: transparent; padding: 7px 14px; border-radius: 9px; font-size: 14px; font-weight: 500; color: var(--muted); cursor: pointer; white-space: nowrap; }
.segmented button:hover { color: var(--text); }
.segmented button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(10, 16, 40, .12); }

/* Estados vacíos y carga */
.empty { display: grid; justify-items: center; gap: 10px; text-align: center; padding: 44px 20px; color: var(--muted); }
.empty svg { width: 34px; height: 34px; color: var(--border-strong); }
.empty h3 { color: var(--text); font-family: var(--font-display); font-size: 18px; }
.empty p { max-width: 36ch; font-size: 14px; }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Barras de ingresos */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 140px; padding-top: 8px; }
.bars .bar { flex: 1; display: grid; grid-template-rows: 1fr auto; justify-items: center; gap: 8px; height: 100%; min-width: 0; }
.bars .bar-fill { align-self: end; width: 100%; max-width: 44px; min-height: 3px; border-radius: 8px 8px 3px 3px; background: var(--border-strong); transition: height .5s var(--ease); }
.bars .bar.current .bar-fill { background: var(--accent); }
.bars .bar-label { font-size: 12px; color: var(--muted); text-transform: capitalize; }
.bars .bar-value { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Diálogos */
dialog.modal { padding: 0; border: 0; border-radius: 18px; background: var(--surface); color: var(--text); width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); box-shadow: 0 24px 80px rgba(8, 12, 30, .35); overflow: hidden; }
dialog.modal[open] { display: flex; flex-direction: column; animation: pop .22s var(--ease); }
dialog.modal::backdrop { background: rgba(10, 14, 28, .5); backdrop-filter: blur(3px); }
dialog.modal.narrow { width: min(420px, calc(100vw - 24px)); }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px 8px; }
.modal-head h2 { font-size: 21px; }
.modal-body { padding: 10px 22px 6px; overflow-y: auto; display: grid; gap: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px 20px; flex-wrap: wrap; }

/* Aviso emergente */
.toasts { position: fixed; z-index: 100; left: 50%; bottom: 24px; transform: translateX(-50%); display: grid; gap: 8px; justify-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 24px); }
.toast { background: var(--ink); color: var(--ink-text); padding: 11px 18px; border-radius: 12px; font-size: 14px; box-shadow: 0 10px 30px rgba(8, 12, 30, .3); animation: pop .22s var(--ease); display: flex; gap: 10px; align-items: center; }
.toast.error { background: var(--danger); color: #fff; }
.toast.leaving { opacity: 0; transition: opacity .25s; }

/* Aviso / banner */
.banner { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--radius-sm); background: var(--warn-soft); color: var(--text); font-size: 14px; flex-wrap: wrap; }
.banner .grow { min-width: 200px; }
.banner { margin-bottom: 14px; }
