/* ============================================================
   Cuentitas · app.css — layout & componentes de la aplicación
   (usa los tokens de ../styles.css)
   ============================================================ */

html, body { height: 100%; }
body { background: var(--bg-app); color: var(--text-primary); }
button { font-family: inherit; color: inherit; }
.muted { color: var(--text-secondary); }
.icon { width: 18px; height: 18px; stroke-width: 2px; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100vh; overflow: hidden; }
.app--noauth { display: block; }

.sidebar {
  background: var(--bg-surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 0;
}
.sb__brand { display: flex; align-items: center; gap: 10px; padding: 16px 18px 12px; }
.sb__brand img { width: 30px; height: 30px; }
.sb__brand b { font-family: var(--font-display); font-weight: 800; font-size: 19px; letter-spacing: -0.03em; }
.sb__brand b span { color: var(--accent); }

.space-switch {
  margin: 4px 12px 10px; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--bg-app); cursor: pointer; display: flex; align-items: center; gap: 10px; width: calc(100% - 24px);
  transition: border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.space-switch:hover { border-color: var(--border-strong); background: var(--bg-hover); }
.space-switch__avatar { width: 26px; height: 26px; border-radius: var(--radius-sm); background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.space-switch__meta { flex: 1; min-width: 0; text-align: left; }
.space-switch__name { font-size: 14px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.space-switch--static { cursor: default; }
.space-switch--static:hover { border-color: var(--border); background: var(--bg-app); }
.space-switch__sub { font-size: 11px; color: var(--text-tertiary); }
.space-switch .icon { color: var(--text-tertiary); width: 16px; }

.nav { flex: 1; overflow-y: auto; padding: 4px 12px 12px; }
.nav__group { margin-top: 14px; }
.nav__label { font-size: 10px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--text-tertiary); padding: 0 10px 6px; }
.nav__item {
  display: flex; align-items: center; gap: 11px; width: 100%; padding: 8px 10px; border: none; background: none;
  border-radius: var(--radius-sm); color: var(--text-secondary); font-size: 14px; font-weight: 500; cursor: pointer; text-align: left;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.nav__item .icon { width: 18px; color: var(--text-tertiary); flex: none; }
.nav__item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav__item.is-active { background: var(--accent-subtle); color: var(--accent-pressed); font-weight: 600; }
.nav__item.is-active .icon { color: var(--accent); }
.nav__badge { margin-left: auto; font-size: 11px; font-weight: 700; background: var(--negative); color: #fff; border-radius: var(--radius-full); padding: 1px 7px; }

.sb__foot { border-top: 1px solid var(--border); padding: 10px 12px; display: flex; align-items: center; gap: 10px; }
.sb__user { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; }
.sb__avatar { width: 30px; height: 30px; border-radius: var(--radius-full); background: var(--neutral-200); color: var(--neutral-700);
  display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
[data-theme="dark"] .sb__avatar { background: var(--neutral-700); color: var(--neutral-100); }
.avatar-img { object-fit: cover; flex: none; display: block; background: var(--neutral-200); border: 1px solid var(--border); }
.sb__uname { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb__umail { font-size: 11px; color: var(--text-tertiary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Main ---------- */
.main { overflow-y: auto; min-height: 0; }
.main__inner { max-width: var(--container-max); margin: 0 auto; padding: 28px 36px 64px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-title { font-size: 28px; font-weight: 700; }
.page-sub { margin: 4px 0 0; color: var(--text-secondary); font-size: 14px; }
.page-actions { display: flex; gap: 10px; align-items: center; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px;
  font-size: 15px; font-weight: 600; border-radius: var(--radius-md); border: 1px solid transparent; cursor: pointer; white-space: nowrap;
  transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast), transform var(--dur-fast), color var(--dur-fast); }
.btn .icon { width: 17px; }
.btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.btn:active { transform: translateY(0.5px) scale(.985); }
.btn--sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn--lg { height: 48px; padding: 0 22px; font-size: 16px; }
.btn--full { width: 100%; }
.btn--primary { background: var(--accent); color: var(--on-accent); }
.btn--primary:hover { background: var(--accent-hover); }
.btn--secondary { background: var(--bg-surface); color: var(--text-primary); border-color: var(--border-strong); }
.btn--secondary:hover { background: var(--bg-hover); border-color: var(--text-tertiary); }
.btn--ghost { background: transparent; color: var(--text-secondary); }
.btn--ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn--danger { background: var(--negative); color: #fff; }
.btn--danger:hover { filter: brightness(.93); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.icon-btn { width: 36px; height: 36px; display: inline-grid; place-items: center; border: none; background: transparent;
  border-radius: var(--radius-sm); color: var(--text-tertiary); cursor: pointer; transition: background var(--dur-fast), color var(--dur-fast); }
.icon-btn .icon { width: 18px; }
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.icon-btn:active { transform: scale(.92); }

/* ---------- Cards / surfaces ---------- */
.card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card--pad { padding: 20px; }
.card--clickable { transition: border-color var(--dur-fast), box-shadow var(--dur-fast), transform var(--dur-fast); }
.card--clickable:hover { border-color: var(--accent); box-shadow: var(--shadow-md, var(--shadow-sm)); }
.section { margin-bottom: 28px; }
.section__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section__title { font-family: var(--font-display); font-size: 17px; font-weight: 700; }
.grid { display: grid; gap: 16px; }
.grid--stats { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid--cards { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

/* ---------- Stat tile ---------- */
.stat { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.stat--accent { background: var(--accent); border-color: transparent; color: var(--on-accent); }
.stat--accent .stat__label, .stat--accent .stat__sub { color: color-mix(in oklab, var(--on-accent) 80%, transparent); }
.stat__label { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .04em; }
.stat__icon { width: 15px; }
.stat__value { margin-top: 8px; font-size: 26px; font-weight: 600; font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat--accent .stat__value { color: var(--on-accent); }
.stat__sub { margin-top: 4px; font-size: 12px; color: var(--text-tertiary); }

/* ---------- Money ---------- */
.money { font-family: var(--font-mono); font-variant-numeric: tabular-nums lining-nums; letter-spacing: -.01em; white-space: nowrap; }
.money--sm { font-size: 13px; } .money--md { font-size: 15px; } .money--lg { font-size: 20px; font-weight: 600; } .money--xl { font-size: 32px; font-weight: 600; }
.money--pos { color: var(--positive); } .money--neg { color: var(--negative); } .money--muted { color: var(--text-tertiary); }

/* ---------- Badge ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; line-height: 1; padding: 4px 9px; border-radius: var(--radius-full); border: 1px solid transparent; white-space: nowrap; }
.badge__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--neutral { background: var(--bg-sunken); color: var(--text-secondary); border-color: var(--border); }
.badge--accent { background: var(--accent-subtle); color: var(--accent-pressed); border-color: var(--accent-border); }
.badge--positive { background: var(--positive-subtle); color: var(--positive); border-color: var(--positive-border); }
.badge--negative { background: var(--negative-subtle); color: var(--negative); border-color: var(--negative-border); }
.badge--warning { background: var(--warning-subtle); color: var(--warning); border-color: var(--warning-border); }
.badge--info { background: var(--info-subtle); color: var(--info); border-color: var(--info-border); }

/* ---------- Table ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-tertiary); padding: 0 14px 10px; border-bottom: 1px solid var(--border); }
.table th.num, .table td.num { text-align: right; }
.table td { padding: 13px 14px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background var(--dur-fast); }
.table tbody tr:hover { background: var(--bg-hover); }
.table .row-actions { display: flex; gap: 2px; justify-content: flex-end; opacity: 0; transition: opacity var(--dur-fast); }
.table tr:hover .row-actions { opacity: 1; }
.cell-title { font-weight: 600; color: var(--text-primary); }
.cell-sub { font-size: 12px; color: var(--text-tertiary); margin-top: 1px; }

/* ---------- Meter ---------- */
.meter { height: 8px; border-radius: var(--radius-full); background: var(--bg-sunken); overflow: hidden; }
.meter__fill { height: 100%; border-radius: var(--radius-full); background: var(--accent); transition: width var(--dur-slow) var(--ease-out); }
.meter--warning .meter__fill { background: var(--warning); }
.meter--negative .meter__fill { background: var(--negative); }
.meter--complete .meter__fill { background: var(--positive); }

/* ---------- Empty ---------- */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 48px 24px; }
.empty__icon { width: 54px; height: 54px; border-radius: var(--radius-lg); background: var(--accent-subtle); color: var(--accent); display: grid; place-items: center; margin-bottom: 14px; }
.empty__icon .icon { width: 26px; }
.empty__title { font-family: var(--font-display); font-size: 18px; font-weight: 700; }
.empty__desc { font-size: 14px; color: var(--text-secondary); max-width: 340px; margin-top: 4px; }
.empty__action { margin-top: 18px; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field.f-full, .form-check.f-full { grid-column: 1 / -1; }
.form-field label { font-size: 13px; font-weight: 600; display: flex; gap: 6px; align-items: baseline; }
.field-hint { font-size: 11px; font-weight: 400; color: var(--text-tertiary); }
.form-warn { display: flex; gap: 7px; align-items: flex-start; margin-top: 7px; padding: 8px 10px;
  font-size: 12.5px; line-height: 1.4; color: var(--warning); background: var(--warning-subtle, color-mix(in srgb, var(--warning) 12%, transparent));
  border: 1px solid color-mix(in srgb, var(--warning) 35%, transparent); border-radius: var(--radius-sm); }
.form-warn__icon { width: 15px; height: 15px; flex-shrink: 0; margin-top: 1px; }
.inp { height: 42px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-md); background: var(--bg-surface);
  font-family: var(--font-text); font-size: 15px; color: var(--text-primary); width: 100%; transition: border-color var(--dur-fast), box-shadow var(--dur-fast); }
textarea.inp { height: auto; padding: 10px 12px; line-height: 1.5; resize: vertical; }
.inp:focus { outline: none; border-color: var(--accent); box-shadow: var(--shadow-focus); }
select.inp { appearance: none; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2393a0ad' stroke-width='2.2' stroke-linecap='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 16px; padding-right: 36px; }
.inp-wrap { display: flex; align-items: center; border: 1px solid var(--border-strong); border-radius: var(--radius-md); background: var(--bg-surface); padding-left: 12px; transition: border-color var(--dur-fast), box-shadow var(--dur-fast); }
.inp-wrap:focus-within { border-color: var(--accent); box-shadow: var(--shadow-focus); }
.inp-wrap .inp { border: none; box-shadow: none; padding-left: 6px; }
.inp-prefix { color: var(--text-tertiary); font-family: var(--font-mono); font-size: 14px; }
.form-check { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; }
.chk { width: 19px; height: 19px; accent-color: var(--accent); cursor: pointer; }

/* ---------- Modal ---------- */
.modal-ov { position: fixed; inset: 0; background: var(--overlay); backdrop-filter: blur(2px); display: grid; place-items: center; z-index: 100; opacity: 0; transition: opacity var(--dur-base); padding: 24px; }
.modal-ov.is-open { opacity: 1; }
.modal { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); width: 100%; max-width: 480px; max-height: 90vh; display: flex; flex-direction: column; transform: translateY(8px) scale(.98); transition: transform var(--dur-base) var(--ease-out); }
.modal--wide { max-width: 720px; }
.modal-ov.is-open .modal { transform: none; }
.modal__head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 14px; border-bottom: 1px solid var(--border); }
.modal__title { font-family: var(--font-display); font-size: 18px; font-weight: 700; }
.modal__x { width: 32px; height: 32px; display: grid; place-items: center; border: none; background: none; color: var(--text-tertiary); border-radius: var(--radius-sm); cursor: pointer; }
.modal__x:hover { background: var(--bg-hover); color: var(--text-primary); }
.modal__body { padding: 20px; overflow-y: auto; }
.modal__foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- Toast ---------- */
.toast-host { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast { display: flex; align-items: center; gap: 11px; background: var(--bg-elevated); border: 1px solid var(--border); border-left: 3px solid var(--text-tertiary); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); padding: 12px 16px; min-width: 260px; max-width: 360px; transform: translateX(120%); transition: transform var(--dur-base) var(--ease-out); }
.toast.is-in { transform: none; }
.toast__icon { width: 19px; flex: none; }
.toast__msg { font-size: 14px; font-weight: 500; }
.toast--success { border-left-color: var(--positive); } .toast--success .toast__icon { color: var(--positive); }
.toast--error { border-left-color: var(--negative); } .toast--error .toast__icon { color: var(--negative); }
.toast--warning { border-left-color: var(--warning); } .toast--warning .toast__icon { color: var(--warning); }
.toast--info { border-left-color: var(--info); } .toast--info .toast__icon { color: var(--info); }

/* ---------- Dropdown menu ---------- */
.menu { position: absolute; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); padding: 6px; min-width: 200px; z-index: 150; }
.menu__item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: none; background: none; border-radius: var(--radius-sm); font-size: 14px; color: var(--text-primary); cursor: pointer; text-align: left; }
.menu__item .icon { width: 16px; color: var(--text-tertiary); }
.menu__item:hover { background: var(--bg-hover); }
.menu__item.is-danger { color: var(--negative); } .menu__item.is-danger .icon { color: var(--negative); }
.menu__sep { height: 1px; background: var(--border); margin: 6px 4px; }

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background:
  radial-gradient(1200px 600px at 80% -10%, var(--accent-subtle), transparent 60%), var(--bg-app); }
.auth__card { width: 100%; max-width: 400px; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-2xl); box-shadow: var(--shadow-lg); padding: 32px; }
.auth__brand { display: flex; align-items: center; gap: 11px; justify-content: center; margin-bottom: 8px; }
.auth__brand img { width: 40px; height: 40px; }
.auth__brand b { font-family: var(--font-display); font-weight: 800; font-size: 26px; letter-spacing: -.03em; }
.auth__brand b span { color: var(--accent); }
.auth__tag { text-align: center; color: var(--text-secondary); font-size: 14px; margin: 0 0 24px; }
.auth__fields { display: flex; flex-direction: column; gap: 14px; }
.auth__switch { text-align: center; font-size: 13px; color: var(--text-secondary); margin-top: 18px; }
.auth__switch button { background: none; border: none; color: var(--accent); font-weight: 600; cursor: pointer; font-size: 13px; }
.auth__demo { margin-top: 14px; text-align: center; font-size: 12px; color: var(--text-tertiary); }

/* chips row */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: var(--radius-full); border: 1px solid var(--border-strong); background: var(--bg-surface); color: var(--text-primary); font-size: 13px; font-weight: 500; cursor: pointer; transition: all var(--dur-fast); }
.chip:hover { border-color: var(--text-tertiary); }
.chip.is-active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* misc layout helpers */
.row { display: flex; align-items: center; gap: 10px; }
.row--between { justify-content: space-between; }
.row--wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.list-clean { list-style: none; margin: 0; padding: 0; }
.divide > * + * { border-top: 1px solid var(--border); }
.text-sm { font-size: 13px; } .text-xs { font-size: 12px; }
.fade-in { animation: fade-in var(--dur-base) var(--ease-out); }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 252px; z-index: 90; transform: translateX(-100%); transition: transform var(--dur-base) var(--ease-out); }
  .app.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .scrim { position: fixed; inset: 0; background: var(--overlay); z-index: 80; }
  .main__inner { padding: 20px; }
  .form-grid { grid-template-columns: 1fr; }
}
.topbar-mobile { display: none; }

/* ---------- Credenciales (consola) ---------- */
.cred { display: flex; flex-direction: column; gap: 0; margin-top: 10px; border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.cred__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 14px; background: var(--bg-sunken); border-bottom: 1px solid var(--border); }
.cred__row:last-child { border-bottom: none; }
.cred__label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-tertiary); }
.cred__val { font-family: var(--font-mono); font-size: 14px; color: var(--text-primary); }
@media (max-width: 860px) {
  .topbar-mobile { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--bg-surface); position: sticky; top: 0; z-index: 50; }
}

/* ============================================================
   Listas de compra · vehículos · scroll de tablas
   ============================================================ */
.shop-layout { display: grid; gap: 16px; grid-template-columns: 240px 1fr; align-items: start; }
.inp--mini { height: 36px; padding: 0 10px; font-size: 14px; font-family: var(--font-mono); }
.shop-item .chk { flex: none; }
.table-card { overflow: hidden; overflow-x: auto; }

/* ============================================================
   Responsive — teléfonos y tablets
   ============================================================ */
@media (max-width: 860px) {
  .shop-layout { grid-template-columns: 1fr; }
  .page-title { font-size: 23px; }
  .page-head { margin-bottom: 18px; }
  /* en táctil no hay hover: las acciones de fila quedan siempre visibles */
  .table .row-actions { opacity: 1; }
  .grid { gap: 12px; }
  .modal-ov { padding: 14px; }
  .modal__body { padding: 16px; }
}
@media (max-width: 560px) {
  .main__inner { padding: 16px 14px 56px; }
  .page-title { font-size: 20px; }
  .page-sub { font-size: 13px; }
  .stat__value { font-size: 22px; }
  .auth__card { padding: 24px 20px; }
  .btn { height: 42px; }
  .btn--sm { height: 34px; }
}
