/* CESCAC FIADO — Mobile-First, tenderos cobrando por WhatsApp */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap');

:root {
  --brand: #025338;
  --brand-light: #037a4f;
  --brand-soft: #e3f3ec;
  --accent: #025338;
  --accent-soft: #d1fae5;
  --whatsapp: #25D366;
  --whatsapp-dark: #128C7E;
  --negative: #b91c1c;
  --negative-soft: #fee2e2;
  --positive: #047857;
  --positive-soft: #d1fae5;
  --surface: #ffffff;
  --bg: #f1f5f9;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow-sm: 0 1px 2px rgba(2, 83, 56, 0.06);
  --shadow: 0 4px 12px rgba(2, 83, 56, 0.08);
  --shadow-lg: 0 10px 28px rgba(2, 83, 56, 0.10);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-full: 9999px;
  --touch: 44px;
}

* { box-sizing: border-box; }

.skip-link {
  position: absolute; top: -3rem; left: 0.75rem; z-index: 100;
  padding: 0.5rem 0.75rem; background: var(--brand); color: #fff; font-weight: 600;
  border-radius: var(--radius-sm); text-decoration: none; transition: top 0.2s;
}
.skip-link:focus { top: 0.5rem; outline: 2px solid #fff; outline-offset: 2px; }

body.fiado-app {
  font-family: 'Century Gothic', CenturyGothic, 'DM Sans', Arial, sans-serif;
  margin: 0; padding: 0; background: var(--bg); color: var(--text); line-height: 1.5;
  -webkit-tap-highlight-color: transparent; min-height: 100vh;
}

.app-header {
  position: relative;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-light) 100%);
  color: #fff; padding: 0.75rem 1rem; display: flex; align-items: center; gap: 0.75rem;
  flex-wrap: wrap; box-shadow: var(--shadow);
}
.app-header a {
  color: rgba(255,255,255,0.95); text-decoration: none; min-height: var(--touch); min-width: var(--touch);
  display: inline-flex; align-items: center; justify-content: center; padding: 0.35rem 0.6rem;
  border-radius: var(--radius-sm); font-weight: 500; transition: background 0.2s, color 0.2s;
}
.app-header a:hover { background: rgba(255,255,255,0.14); color: #fff; }
.app-header .logo-link { display: flex; align-items: center; }
.app-header .logo-img { height: 32px; width: auto; filter: brightness(0) invert(1); }
.login-page .login-main .logo-img { filter: none; }
.app-header .brand-text { white-space: nowrap; font-weight: 700; letter-spacing: 0.02em; }
.app-header .user { margin-left: auto; font-size: 0.9rem; opacity: 0.95; display: flex; align-items: center; gap: 0.4rem; }
.badge-pro { background: #fbbf24; color: #78350f; font-size: 0.65rem; font-weight: 800; padding: 0.15rem 0.5rem; border-radius: var(--radius-full); letter-spacing: 0.03em; }

.nav-toggle { display: none; }
.nav-toggle-label {
  display: none; padding: 0.5rem 0.75rem; min-height: var(--touch); align-items: center; justify-content: center;
  cursor: pointer; font-weight: 600; border-radius: var(--radius-sm); background: rgba(255,255,255,0.15);
}
.nav-links { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; }
@media (max-width: 768px) {
  .nav-toggle-label { display: inline-flex; margin-left: auto; }
  .nav-links {
    display: none; position: absolute; top: 100%; left: 0; right: 0; background: var(--brand-light);
    flex-direction: column; padding: 0.75rem; gap: 0.25rem; box-shadow: var(--shadow-lg); z-index: 20;
  }
  .nav-toggle:checked ~ .nav-links { display: flex; }
  .app-header .user { margin-left: 0; width: 100%; text-align: center; order: -1; padding-bottom: 0.5rem; border-bottom: 1px solid rgba(255,255,255,0.2); justify-content: center; }
}

main { max-width: 960px; margin: 0 auto; padding: 1.25rem 1rem; min-height: calc(100vh - 140px); }
@media (min-width: 768px) { main { padding: 1.75rem 1.5rem; } }

main > h1:first-of-type { font-size: 1.75rem; font-weight: 700; color: var(--text); margin: 0 0 0.35rem 0; letter-spacing: -0.02em; }
.page-subtitle { font-size: 1rem; color: var(--text-muted); margin: 0 0 1.25rem 0; font-weight: 400; }

.app-footer { text-align: center; padding: 1rem; color: var(--text-muted); font-size: 0.8rem; border-top: 1px solid var(--border); background: var(--surface); }
.app-footer a { color: var(--brand); font-weight: 600; text-decoration: none; }

.error { color: var(--negative); background: var(--negative-soft); padding: 0.6rem 0.9rem; border-radius: var(--radius-sm); margin-bottom: 1rem; }
.positive { color: var(--positive); background: var(--positive-soft); padding: 0.6rem 0.9rem; border-radius: var(--radius-sm); margin-bottom: 1rem; }

.login-page .login-main {
  margin: 2.5rem auto; max-width: 380px; background: var(--surface); padding: 2rem;
  border-radius: var(--radius); box-shadow: var(--shadow-lg); border: 1px solid var(--border);
}
.login-page .login-main h1 { margin-top: 0; margin-bottom: 0.35rem; font-size: 1.5rem; font-weight: 700; }
.login-hint { font-size: 0.85rem; color: var(--text-muted); margin-top: 1rem; line-height: 1.5; }
.login-main a { color: var(--brand); font-weight: 600; min-height: var(--touch); display: inline-flex; align-items: center; }
.login-main a:hover { text-decoration: underline; }
.login-main form label { display: block; margin-bottom: 0.6rem; font-weight: 500; color: var(--text); }
.login-main input, main input[type=text], main input[type=tel], main input[type=password], main input[type=number], main textarea, main select {
  width: 100%; padding: 0.65rem 0.85rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 1rem; min-height: var(--touch); transition: border-color 0.2s, box-shadow 0.2s; font-family: inherit;
}
.login-main input:focus, main input:focus, main textarea:focus, main select:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(2, 83, 56, 0.14);
}
.login-main button, main button[type=submit] {
  margin-top: 0.75rem; padding: 0.65rem 1.25rem; min-height: var(--touch); width: 100%; font-weight: 700;
  font-size: 1rem; border-radius: var(--radius-sm); border: none;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-light) 100%); color: #fff;
  cursor: pointer; transition: transform 0.15s, box-shadow 0.15s; font-family: inherit;
}
.login-main button:hover, main button[type=submit]:hover { box-shadow: var(--shadow); transform: translateY(-1px); }

.dashboard-cards { display: grid; grid-template-columns: 1fr; gap: 1rem; margin: 1.25rem 0; }
@media (min-width: 480px) { .dashboard-cards { grid-template-columns: repeat(3, 1fr); } }
.card { background: var(--surface); padding: 1.5rem; border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); }
.card h2 { margin: 0 0 0.5rem 0; font-size: 0.85rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.card .amount { font-size: 1.75rem; font-weight: 800; letter-spacing: -0.02em; margin: 0; }
.card .amount.negative { color: var(--negative); }
.card .amount.positive { color: var(--positive); }
.card-note { font-size: 0.85rem; color: var(--text-muted); margin: 0.5rem 0 0 0; line-height: 1.4; }

.btn-primary, .btn-secondary, .btn-wa, .btn-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
  margin-top: 0.5rem; margin-right: 0.5rem; margin-bottom: 0.25rem; padding: 0.65rem 1.2rem;
  min-height: var(--touch); border-radius: var(--radius-full); font-size: 0.9rem; font-weight: 700;
  text-decoration: none; transition: transform 0.15s, box-shadow 0.15s; border: none; cursor: pointer;
}
.btn-primary { background: linear-gradient(135deg, var(--brand) 0%, var(--brand-light) 100%); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.btn-secondary { background: var(--surface); color: var(--brand); border: 1.5px solid var(--border); }
.btn-secondary:hover { background: var(--brand-soft); border-color: var(--brand); }
.btn-wa { background: var(--whatsapp); color: #fff; box-shadow: var(--shadow-sm); }
.btn-wa:hover { background: var(--whatsapp-dark); box-shadow: var(--shadow); transform: translateY(-1px); }
.btn-danger { background: var(--negative-soft); color: var(--negative); }
*:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.cliente-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.75rem; }
.cliente-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.1rem; box-shadow: var(--shadow-sm); display: flex; flex-wrap: wrap;
  align-items: center; justify-content: space-between; gap: 0.6rem;
}
.cliente-item .nombre { font-weight: 700; font-size: 1.02rem; }
.cliente-item .tel { color: var(--text-muted); font-size: 0.82rem; }
.cliente-item .saldo { font-weight: 800; font-size: 1.1rem; color: var(--negative); }
.cliente-item .saldo.al-dia { color: var(--positive); }
.cliente-item .acciones { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.cliente-item .acciones a, .cliente-item .acciones button { margin: 0; padding: 0.45rem 0.9rem; font-size: 0.82rem; min-height: 38px; }

.quick-add { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); margin-bottom: 1.5rem; }
.quick-add h2 { margin-top: 0; font-size: 1.1rem; }
.quick-add .row { display: grid; grid-template-columns: 1fr; gap: 0.75rem; }
@media (min-width: 640px) { .quick-add .row { grid-template-columns: repeat(4, 1fr); align-items: end; } }
.quick-add label { font-size: 0.82rem; font-weight: 600; color: var(--text-muted); margin-bottom: 0.25rem; display: block; }
@media (min-width: 640px) { .row--movimiento { grid-template-columns: 1fr 1fr 2fr auto; } }

table.tabla-mov { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
table.tabla-mov th, table.tabla-mov td { padding: 0.65rem 0.85rem; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
table.tabla-mov th { background: var(--brand-soft); color: var(--brand); font-weight: 700; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.02em; }
table.tabla-mov tr:last-child td { border-bottom: none; }
.tipo-cargo { color: var(--negative); font-weight: 700; }
.tipo-abono { color: var(--positive); font-weight: 700; }

.pill-limit { display: inline-block; background: #fef3c7; color: #92400e; font-size: 0.78rem; font-weight: 700; padding: 0.3rem 0.85rem; border-radius: var(--radius-full); margin-bottom: 1rem; }
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--text-muted); }
.opt-toggle { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.8rem; color: var(--text-muted); }
