/* ServiFix Admin — azul y blanco, pensado para el dedo (objetivos de 48 px o más). */

:root {
  --blue-900: #1e3a8a;
  --blue-800: #1e40af;
  --blue-700: #1d4ed8;
  --blue-600: #2563eb;
  --blue-100: #dbeafe;
  --blue-50: #eff6ff;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --field: #cbd5e1;
  --bg: #f4f7fd;
  --white: #ffffff;
  --red: #dc2626;
  --red-ink: #b91c1c;
  --red-bg: #fee2e2;
  --amber: #d97706;
  --amber-ink: #92400e;
  --amber-bg: #fef3c7;
  --green: #16a34a;
  --green-ink: #166534;
  --green-bg: #dcfce7;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 6px 20px rgba(29, 78, 216, 0.07);
  --head-h: 60px;
  --nav-h: 68px;
  color-scheme: light;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}

h1,
h2 {
  margin: 0;
  line-height: 1.2;
}

h1 {
  font-size: 1.5rem;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 1.05rem;
}

p {
  margin: 0;
}

a {
  color: var(--blue-700);
}

.muted {
  color: var(--muted);
}

.hint {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.85rem;
}

.error {
  margin-top: 6px;
  color: var(--red-ink);
  font-size: 0.9rem;
  font-weight: 500;
}

.info {
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--blue-50);
  color: var(--blue-800);
  font-size: 0.95rem;
}

.negative {
  color: var(--red) !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

[hidden] {
  display: none !important;
}

.icon {
  width: 20px;
  height: 20px;
  flex: none;
}

.icon-sm {
  width: 16px;
  height: 16px;
}

/* ─── Controles ─────────────────────────────────────────── */

input,
select,
textarea {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid var(--field);
  border-radius: 12px;
  background: var(--white);
  color: var(--ink);
  font: inherit;
  font-size: 16px; /* evita el zoom automático en iOS */
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(37, 99, 235, 0.28);
  border-color: var(--blue-600);
}

button {
  font: inherit;
  cursor: pointer;
}

:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.45);
  outline-offset: 2px;
}

.field {
  display: block;
  margin-bottom: 14px;
}

.field > span {
  display: block;
  margin-bottom: 6px;
  color: var(--ink-2);
  font-size: 0.9rem;
  font-weight: 600;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 12px;
}

.stack {
  display: grid;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  transition: background-color 0.15s, transform 0.05s;
  user-select: none;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--blue-700);
  color: var(--white);
}

.btn-primary:hover {
  background: var(--blue-800);
}

.btn-secondary {
  border-color: var(--blue-100);
  background: var(--blue-50);
  color: var(--blue-700);
}

.btn-ghost {
  border-color: var(--line);
  background: var(--white);
  color: var(--ink);
}

.btn-danger {
  background: var(--red);
  color: var(--white);
}

.btn-danger-text {
  color: var(--red-ink);
}

.btn-block {
  width: 100%;
}

.btn-xl {
  min-height: 58px;
  font-size: 1.1rem;
}

.btn-sm {
  min-height: 44px;
  padding: 0 14px;
  font-size: 0.95rem;
}

.btn.is-copied {
  background: var(--green);
  color: var(--white);
}

.link-btn {
  display: block;
  margin: 14px auto 0;
  padding: 10px;
  border: 0;
  background: none;
  color: var(--blue-700);
  font-weight: 600;
}

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 6px;
  scrollbar-width: none;
}

.chip {
  flex: none;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--white);
  color: var(--ink-2);
  font-weight: 600;
  white-space: nowrap;
}

.chip[aria-pressed='true'] {
  border-color: var(--blue-700);
  background: var(--blue-700);
  color: var(--white);
}

/* ─── Estatus ───────────────────────────────────────────── */

.st-en_curso {
  --st: var(--amber);
  --st-ink: var(--amber-ink);
  --st-bg: var(--amber-bg);
}

.st-aceptado {
  --st: var(--blue-600);
  --st-ink: var(--blue-800);
  --st-bg: var(--blue-100);
}

.st-rechazado {
  --st: var(--red);
  --st-ink: var(--red-ink);
  --st-bg: var(--red-bg);
}

.st-terminado {
  --st: var(--green);
  --st-ink: var(--green-ink);
  --st-bg: var(--green-bg);
}

.status-select {
  width: auto;
  min-height: 42px;
  padding: 6px 34px 6px 12px;
  border-color: transparent;
  background-color: var(--st-bg);
  color: var(--st-ink);
  font-weight: 700;
}

/* ─── Acceso ────────────────────────────────────────────── */

.auth {
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
  place-items: center;
  padding: 24px 16px;
  background: linear-gradient(160deg, var(--blue-700), var(--blue-900));
}

.auth-card {
  width: min(100%, 420px);
  padding: 28px 22px;
  border-radius: 24px;
  background: var(--white);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.35);
}

.auth-card > p {
  margin-top: 10px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.auth-brand strong {
  display: block;
  font-size: 1.15rem;
}

.auth-brand small {
  color: var(--muted);
}

.auth-logo,
.brand-logo {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 12px;
  background: var(--blue-700);
  color: var(--white);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.auth-form h1 {
  margin-bottom: 8px;
}

.auth-form > .muted,
.auth-form > .info {
  margin-bottom: 18px;
}

.auth-form .error {
  margin: 0 0 12px;
}

.pw-wrap {
  position: relative;
}

.pw-wrap input {
  padding-right: 52px;
}

.pw-toggle {
  position: absolute;
  top: 2px;
  right: 2px;
  display: grid;
  width: 46px;
  height: 44px;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--muted);
}

.notice {
  display: flex;
  gap: 10px;
  margin: 4px 0 16px;
  padding: 12px;
  border-radius: 12px;
  background: var(--amber-bg);
  color: var(--amber-ink);
  font-size: 0.9rem;
}

/* ─── Estructura ────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: calc(var(--head-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 16px 0;
  background: var(--blue-700);
  color: var(--white);
}

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

.brand .brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--white);
  color: var(--blue-700);
  font-size: 0.9rem;
}

.brand strong {
  display: block;
  line-height: 1.1;
}

.brand small {
  display: block;
  overflow: hidden;
  max-width: 40vw;
  color: var(--blue-100);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: var(--white);
  font-weight: 600;
}

.idle-banner {
  position: sticky;
  top: calc(var(--head-h) + env(safe-area-inset-top));
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--amber-bg);
  color: var(--amber-ink);
  font-weight: 600;
}

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 16px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom));
}

main:focus {
  outline: none;
}

.view-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  margin: 4px 0 14px;
}

.view-head select {
  width: auto;
}

.bottomnav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(8px);
}

.navbtn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: var(--nav-h);
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.navbtn[aria-current='page'] {
  color: var(--blue-700);
}

.navicon {
  display: grid;
  width: 40px;
  height: 32px;
  place-items: center;
  border-radius: 999px;
}

.navbtn[aria-current='page'] .navicon {
  background: var(--blue-50);
}

.navbtn-primary .navicon,
.navbtn-primary[aria-current='page'] .navicon {
  width: 46px;
  height: 46px;
  margin-top: -14px;
  background: var(--blue-700);
  box-shadow: 0 6px 16px rgba(29, 78, 216, 0.35);
  color: var(--white);
}

/* ─── Paneles y formulario ─────────────────────────────── */

.panel {
  margin-bottom: 14px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: var(--shadow);
}

.panel-title {
  margin-bottom: 12px;
  color: var(--blue-800);
}

.folio-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.switch {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin-bottom: 8px;
  color: var(--ink-2);
  font-weight: 600;
  cursor: pointer;
}

.switch input[type='checkbox'] {
  width: 22px;
  height: 22px;
  min-height: 0;
  flex: none;
  padding: 0;
  accent-color: var(--blue-700);
}

.label {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.folio-big,
.folio {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.folio-big {
  display: block;
  color: var(--blue-800);
  font-size: 1.15rem;
  white-space: nowrap;
}

.money-input {
  display: flex;
  align-items: center;
  border: 1px solid var(--field);
  border-radius: 12px;
  background: var(--white);
}

.money-input > span {
  padding-left: 14px;
  color: var(--muted);
  font-weight: 600;
}

.money-input input {
  border: 0;
}

.money-input:focus-within {
  outline: 3px solid rgba(37, 99, 235, 0.28);
  border-color: var(--blue-600);
}

.money-input input:focus {
  outline: none;
}

.form-submit {
  position: sticky;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 8px);
  z-index: 5;
  margin-top: 6px;
}

/* ─── Guardado ──────────────────────────────────────────── */

.saved {
  display: grid;
  gap: 14px;
}

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

.saved-icon {
  display: grid;
  width: 48px;
  height: 48px;
  flex: none;
  place-items: center;
  border-radius: 999px;
  background: var(--green-bg);
  color: var(--green-ink);
}

.copytext {
  margin: 0;
  padding: 16px;
  border: 1px dashed #93c5fd;
  border-radius: 14px;
  background: var(--white);
  font: 15px/1.5 ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

.saved-actions {
  gap: 10px;
}

.saved-actions .btn {
  padding: 0 10px;
  white-space: nowrap;
}

/* ─── Lista ─────────────────────────────────────────────── */

.toolbar {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.search {
  position: relative;
}

.search .icon {
  position: absolute;
  top: 14px;
  left: 14px;
  color: var(--muted);
}

.search input {
  padding-left: 44px;
}

.card {
  margin-bottom: 12px;
  padding: 14px 16px 12px;
  border-left: 5px solid var(--st);
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: var(--shadow);
}

.card > p {
  margin-top: 6px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.card .folio {
  color: var(--blue-800);
  font-size: 1.02rem;
}

.card-when {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  color: var(--ink-2);
  font-weight: 600;
}

.card-when .when {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.pill {
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--blue-50);
  color: var(--blue-800);
  font-size: 0.85rem;
  font-weight: 600;
}

.card-client a {
  text-decoration: none;
  white-space: nowrap;
}

.card-equip {
  color: var(--ink-2);
}

.card-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.card-actions .btn {
  padding: 0 8px;
  white-space: nowrap;
}

.money {
  margin-top: 12px;
  border-top: 1px solid var(--line);
}

.money summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  color: var(--ink-2);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.money summary::-webkit-details-marker {
  display: none;
}

.money summary::after {
  content: '▾';
  margin-left: 8px;
  color: var(--muted);
}

.money[open] summary::after {
  content: '▴';
}

.summary-profit {
  margin-left: auto;
  color: var(--green-ink);
}

.money-body {
  padding-bottom: 6px;
}

.money-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 12px;
}

.money-grid .field:first-child {
  grid-column: 1 / -1;
}

.profit-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 4px 0 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--blue-50);
  font-weight: 600;
}

.profit {
  color: var(--green-ink);
  font-size: 1.2rem;
  font-weight: 800;
}

.empty {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 40px 16px;
  color: var(--muted);
  text-align: center;
}

.counter {
  font-weight: 600;
}

/* ─── Resumen ───────────────────────────────────────────── */

.tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 12px 0 14px;
}

.tile {
  display: grid;
  padding: 14px;
  border-radius: 14px;
  background: var(--st-bg);
  color: var(--st-ink);
}

.tile-num {
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1;
}

.tile-label {
  margin-top: 4px;
  font-weight: 600;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.stat-total {
  border-bottom: 0;
  color: var(--green-ink);
  font-size: 1.15rem;
}

/* ─── Datos ─────────────────────────────────────────────── */

.action-head {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
}

.action-head h2 {
  margin-bottom: 4px;
}

.action-icon {
  display: grid;
  width: 44px;
  height: 44px;
  flex: none;
  place-items: center;
  border-radius: 12px;
  background: var(--blue-50);
  color: var(--blue-700);
}

.security {
  border: 1px solid var(--blue-100);
}

.danger-zone h2 {
  margin-bottom: 12px;
  color: var(--red-ink);
}

/* ─── Diálogos y avisos ─────────────────────────────────── */

.dialog {
  width: min(92vw, 420px);
  padding: 22px;
  border: 0;
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.3);
  color: var(--ink);
}

.dialog::backdrop {
  background: rgba(15, 23, 42, 0.5);
}

.dialog h2 {
  margin-bottom: 10px;
  font-size: 1.2rem;
}

.dialog-text {
  margin-bottom: 16px;
  color: var(--ink-2);
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 8px;
}

.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom));
  left: 50%;
  z-index: 60;
  max-width: min(92vw, 480px);
  padding: 12px 18px;
  border-radius: 14px;
  background: var(--ink);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.3);
  color: var(--white);
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 0.2s, transform 0.2s;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast[data-kind='error'] {
  background: var(--red-ink);
}

.noscript {
  padding: 24px;
  text-align: center;
}

@media (min-width: 640px) {
  .tiles {
    grid-template-columns: repeat(4, 1fr);
  }

  .money-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .money-grid .field:first-child {
    grid-column: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

/* ─── Fase 2: servidor, roles y usuarios ───────────────── */

.view-head small {
  display: block;
  margin-top: 2px;
}

.head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-meta {
  color: var(--muted);
  font-size: 0.85rem;
}

.card-actions.card-actions-2 {
  grid-template-columns: repeat(2, 1fr);
}

.status-select.is-busy {
  opacity: 0.6;
}

.notice-info {
  background: var(--blue-50);
  color: var(--blue-800);
}

.users {
  display: grid;
  gap: 10px;
}

.user-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.user-row.is-disabled {
  opacity: 0.6;
}

.user-info {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.user-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.bullets {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 20px;
  color: var(--ink-2);
}

/* Encabezado en pantallas angostas: nombre recortado y botón en una línea. */
.topbar {
  gap: 10px;
}

.brand strong {
  overflow: hidden;
  max-width: 38vw;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout {
  flex: none;
  padding: 0 12px;
  font-size: 0.9rem;
  white-space: nowrap;
}
