@import url("vendor/tabler-icons.min.css");

/* Tipografías self-hosted (variable fonts, subset latin) */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("vendor/fonts/inter-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-weight: 500 800;
  font-display: swap;
  src: url("vendor/fonts/bricolage-grotesque-latin.woff2") format("woff2");
}

/* ============ Design tokens · estética "Apple light" ============ */
:root {
  --bg: #f5f5f7;            /* gris claro de fondo */
  --surface: #ffffff;       /* tarjetas / paneles */
  --surface-2: #f0f0f2;     /* hover / inputs rellenos */
  --line: rgba(0, 0, 0, 0.08);
  --text: #1d1d1f;
  --muted: #6e6e73;
  --accent: #2F6FED;        /* azul corporativo */
  --accent-2: #2456c9;      /* azul oscuro (hover) */
  --accent-soft: rgba(47, 111, 237, 0.09);
  --danger: #E5392E;        /* rojo corporativo */
  --ok: #1FA463;            /* verde corporativo */
  --amber: #9a6b00;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.04);
  --shadow-lift: 0 4px 12px rgba(0, 0, 0, 0.06), 0 16px 40px rgba(0, 0, 0, 0.10);
  --radius: 16px;
  --radius-sm: 12px;
  --maxw: 560px;
  --font-display: "Inter", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
  font-size: 16px;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-display); letter-spacing: -0.02em; font-weight: 650; }
#app { max-width: var(--maxw); margin: 0 auto; min-height: 100vh; background: var(--bg); }

/* Banner de instalación PWA (en flujo, bajo la topbar; no tapa nada) */
.pwa-banner {
  display: flex; align-items: center; gap: 10px;
  max-width: var(--maxw); margin: 0 auto;
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top));
}
.pwa-banner .pwa-ico { font-size: 22px; color: var(--accent); flex: 0 0 auto; }
.pwa-banner .pwa-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.pwa-banner .pwa-txt b { font-size: 13px; color: var(--text); }
.pwa-banner .pwa-txt span { font-size: 12px; color: var(--muted); }
.pwa-banner .pwa-cta {
  flex: 0 0 auto; background: var(--accent); color: #fff; border: 0;
  border-radius: 999px; padding: 8px 16px; font-size: 13px; font-weight: 600;
  cursor: pointer; white-space: nowrap; min-height: 36px;
}
.pwa-banner .pwa-x {
  flex: 0 0 auto; background: none; border: 0; color: var(--muted);
  font-size: 16px; cursor: pointer; padding: 6px;
}
@media (min-width: 820px) { .pwa-banner { max-width: none; } }

/* Topbar — vidrio esmerilado */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  background: rgba(245, 245, 247, 0.78);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
  padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
}
.topbar .brand-logo { height: 30px; width: auto; display: block; }
.topbar h1 { font-size: 17px; font-weight: 650; margin: 0; letter-spacing: -0.02em; }
.topbar .sub { font-size: 12px; color: var(--muted); margin-left: auto; }
.iconbtn { background: none; border: 0; color: var(--muted); font-size: 22px; padding: 4px; cursor: pointer; display: inline-flex; }
.iconbtn:hover { color: var(--text); }

/* Content */
.content { padding: 16px 16px 96px; }
.label { font-size: 13px; color: var(--muted); margin: 0 0 6px; }
.section-title {
  font-size: 12px; letter-spacing: 0.6px; text-transform: uppercase;
  font-weight: 600; color: var(--muted); margin: 24px 0 10px;
}

/* Cards — planas, sin borde visible, sombra mínima */
.card {
  background: var(--surface); border: 1px solid transparent;
  border-radius: var(--radius); padding: 16px; margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.card.tap { cursor: pointer; transition: box-shadow .25s var(--ease), transform .25s var(--ease); }
.card.tap:hover { transform: translateY(-1px); box-shadow: var(--shadow-lift); }
.card.tap:active { transform: scale(0.99); box-shadow: var(--shadow); }
.row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.row + .row { margin-top: 6px; }
.strong { font-weight: 600; }
.muted { color: var(--muted); font-size: 13px; }
.big { font-size: 22px; font-weight: 650; font-family: var(--font-display); letter-spacing: -0.02em; }
.pill {
  display: inline-block; font-size: 12px; font-weight: 500; padding: 3px 10px; border-radius: 20px;
  background: var(--accent-soft); color: var(--accent);
}
.pill.gray  { background: var(--surface-2); color: var(--muted); }
.pill.amber { background: rgba(184, 134, 11, .10); color: var(--amber); }
.pill.green { background: rgba(31, 164, 99, .10); color: var(--ok); }
.pill.red   { background: rgba(229, 57, 46, .10); color: var(--danger); }

/* Forms */
.field { margin-bottom: 14px; }
label.fl { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
input, select, textarea {
  width: 100%; font-size: 16px; font-family: inherit; color: var(--text);
  background: var(--surface); border: 1px solid rgba(0, 0, 0, 0.12); border-radius: var(--radius-sm);
  padding: 11px 12px; outline: none;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}
input::placeholder, textarea::placeholder { color: #a1a1a6; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3.5px var(--accent-soft); }
textarea { resize: vertical; min-height: 64px; }
.inline { display: flex; gap: 8px; }
.inline > * { flex: 1; }

/* Buttons */
.btn {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 15.5px; font-weight: 500; padding: 13px; border-radius: var(--radius-sm);
  border: 1px solid rgba(0, 0, 0, 0.10); background: var(--surface); color: var(--text);
  cursor: pointer; text-decoration: none;
  transition: background .18s var(--ease), border-color .18s var(--ease), transform .18s var(--ease);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}
.btn:hover { background: #fafafa; border-color: rgba(0, 0, 0, 0.18); }
.btn:active { transform: scale(0.98); }
.btn.primary {
  background: var(--accent);
  border: 0; color: #fff; font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}
.btn.primary:hover { background: var(--accent-2); }
.btn.ghost { background: none; box-shadow: none; border-color: transparent; }
.btn.danger { color: var(--danger); border-color: rgba(229, 57, 46, .30); }
.btn + .btn { margin-top: 10px; }
.btn[disabled] { opacity: 0.4; pointer-events: none; }

/* Líneas editor */
.linea { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 8px; box-shadow: 0 1px 2px rgba(0,0,0,.03); }
.linea .del { color: var(--danger); font-size: 13px; background: none; border: 0; padding: 0; cursor: pointer; }
.adder { border: 1px dashed rgba(0, 0, 0, 0.18); color: var(--muted); background: none; box-shadow: none; }
.adder:hover { color: var(--accent); border-color: var(--accent); background: none; }

/* Totals */
.totals {
  background: var(--surface-2);
  border: 0;
  border-radius: var(--radius-sm); padding: 14px 16px; margin: 14px 0;
}
.totals .row { color: var(--text); }
.totals .big { color: var(--text); }

/* Tareas rápidas (chips) */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  font-size: 12.5px; font-weight: 500; padding: 5px 11px; border-radius: 16px;
  border: 0; background: var(--surface-2); color: var(--accent); cursor: pointer;
  transition: background .15s var(--ease);
}
.chip:hover { background: var(--accent-soft); }
.chip:active { background: var(--accent-soft); }

/* Bottom nav (móvil) — vidrio esmerilado */
.nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  max-width: var(--maxw); margin: 0 auto;
  display: flex;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav a {
  flex: 1; text-align: center; padding: 9px 0 8px; color: var(--muted);
  text-decoration: none; font-size: 11px; font-weight: 500;
  transition: color .18s var(--ease);
}
.nav a.active { color: var(--accent); }
.nav a i { font-size: 22px; display: block; line-height: 1.1; }
.nav .desk-only { display: none; }
.nav .side-logo { display: none; }
.nav.only-desk { display: none; }

/* Login */
.login { padding: 0 22px; display: flex; flex-direction: column; justify-content: center; min-height: 100vh; }
.brand { text-align: center; margin-bottom: 28px; }
.brand .brand-logo-img { width: 200px; max-width: 70%; height: auto; display: inline-block; }
.brand h2 { font-family: var(--font-display); font-size: 24px; font-weight: 700; margin: 16px 0 2px; color: var(--text); letter-spacing: -0.02em; }
.brand p { color: var(--muted); margin: 0; font-size: 14px; }
.error { color: var(--danger); font-size: 14px; margin: 4px 0 0; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.spin { text-align: center; color: var(--muted); padding: 30px; }

/* ============ Escritorio: menú lateral ============ */
@media (min-width: 820px) {
  #app { max-width: none; margin: 0; }

  .nav {
    top: 0; bottom: 0; left: 0; right: auto;
    width: 240px; max-width: none; margin: 0;
    flex-direction: column; align-items: stretch; gap: 4px;
    border-top: 0; border-right: 1px solid var(--line);
    background: #fbfbfd;
    backdrop-filter: none; -webkit-backdrop-filter: none;
    padding: 18px 12px;
  }
  .nav .side-logo {
    display: block; height: 52px; width: auto; max-width: calc(100% - 20px);
    object-fit: contain; margin: 8px auto 22px;
  }
  .nav a {
    flex: none; display: flex; flex-direction: row; align-items: center; gap: 12px;
    text-align: left; font-size: 14.5px; padding: 11px 12px; border-radius: 10px;
    transition: background .18s var(--ease), color .18s var(--ease);
  }
  .nav a.desk-only { display: flex; }
  .nav a i { display: inline-block; font-size: 20px; line-height: 1; }
  .nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
  .nav a.active i { color: var(--accent); }
  .nav a:not(.active):hover { background: rgba(0, 0, 0, 0.045); color: var(--text); }
  .nav.only-desk { display: flex; }

  .topbar { padding: 16px 40px; }
  .topbar .brand-logo { display: none; }
  .content { padding: 26px 40px 64px; max-width: 1500px; }
  /* dejar hueco al menú lateral SOLO en las páginas que lo muestran */
  div:has(> .nav) > .topbar,
  div:has(> .nav) > .content { margin-left: 240px; }

  .login { max-width: 400px; margin: 0 auto; }
}

/* ---------- Rendimientos: KPIs + barras ---------- */
.kpis {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 18px;
}
.kpi {
  background: var(--surface); border: 0;
  border-radius: var(--radius); padding: 15px 16px; box-shadow: var(--shadow);
}
.kpi .k-label { color: var(--muted); font-size: 12.5px; margin-bottom: 6px; }
.kpi .k-value { font-size: 21px; font-weight: 650; color: var(--text); font-family: var(--font-display); letter-spacing: -0.02em; }
.bar-row {
  display: grid; grid-template-columns: 92px 1fr auto; align-items: center;
  gap: 10px; padding: 8px 0;
}
.bar-row + .bar-row { border-top: 1px solid var(--line); }
.bar-row .lbl { color: var(--muted); font-size: 13px; }
.bar-row .track {
  height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden;
}
.bar-row .fill {
  display: block; height: 100%; border-radius: 999px; min-width: 2px;
  background: var(--accent);
}
.bar-row .fill.neg { background: var(--danger); }
.bar-row .val { font-size: 13.5px; font-weight: 600; color: var(--text); white-space: nowrap; font-variant-numeric: tabular-nums; }
@media (min-width: 640px) {
  .kpis { grid-template-columns: repeat(4, 1fr); }
}

/* ---------- Menú de usuario (topbar) ---------- */
.usermenu { position: relative; margin-left: auto; }
.userbtn {
  display: inline-flex; align-items: center; gap: 4px;
  background: none; border: 0; color: var(--muted); cursor: pointer;
  font-size: 12px; padding: 4px 6px; border-radius: 8px;
}
.userbtn:hover { color: var(--text); background: rgba(0, 0, 0, 0.05); }
.userbtn .sub { margin-left: 0; }
.userbtn i { font-size: 15px; }
.usermenu-pop {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 40;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 8px; min-width: 175px; box-shadow: var(--shadow-lift);
}
.um-rol {
  font-size: 11px; color: var(--muted); text-transform: capitalize;
  padding: 6px 8px 8px; border-bottom: 1px solid var(--line); margin-bottom: 6px;
}
.um-logout {
  width: 100%; display: flex; align-items: center; gap: 8px;
  background: none; border: 0; color: var(--danger); cursor: pointer;
  font-size: 14px; padding: 8px; border-radius: 8px; text-align: left;
}
.um-logout:hover { background: var(--surface-2); }

/* Beneficio neto (Rendimientos) */
.neto-card { margin-bottom: 14px; }
.neto-card .neto-value { font-family: var(--font-display); font-size: 32px; font-weight: 700; letter-spacing: -0.03em; color: var(--ok); margin: 4px 0; font-variant-numeric: tabular-nums; }
.neto-card .neto-value.neg { color: var(--danger); }

/* "Más" solo en móvil */
@media (min-width: 820px) {
  .nav a.mobile-only { display: none; }
}

/* Bloqueo del parte cuando la obra está finalizada */
.lock-fs { border: 0; padding: 0; margin: 0; min-width: 0; }
.lock-fs:disabled { opacity: 0.6; }

/* ---------- Escritorio ancho: listas a 2 columnas ---------- */
@media (min-width: 1100px) {
  .content.list {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 10px; align-content: start;
  }
  .content.list > .btn,
  .content.list > .spin,
  .content.list > .empty,
  .content.list > .section-title { grid-column: 1 / -1; }
  .content.list > .card { margin-bottom: 0; }
}

/* ============ Feedback + carga + savebar ============ */

/* Skeleton de carga (sustituye al texto "Cargando…") */
.skeleton { padding: 4px 0; }
.skeleton .sk {
  height: 72px; border-radius: var(--radius); margin-bottom: 10px;
  background: linear-gradient(100deg, var(--surface) 40%, var(--surface-2) 50%, var(--surface) 60%);
  background-size: 200% 100%;
  border: 0;
  animation: sk-shimmer 1.2s linear infinite;
}
.skeleton .sk.sm { height: 44px; }
@keyframes sk-shimmer { from { background-position: 130% 0; } to { background-position: -30% 0; } }

/* Toast global (éxito / error) */
.toast {
  position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 90;
  transform: translateX(-50%) translateY(16px);
  background: rgba(29, 29, 31, 0.94); color: #fff;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  padding: 12px 18px; border-radius: 14px;
  font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-lift);
  display: flex; align-items: center; gap: 8px;
  max-width: calc(100vw - 32px);
  opacity: 0; pointer-events: none;
  transition: opacity .25s var(--ease), transform .25s var(--ease);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok i { color: #5ee1a3; }
.toast.err { background: var(--danger); }
@media (min-width: 820px) { .toast { bottom: 28px; } }

/* Modal de confirmación (sustituye a confirm() nativo) */
.modal-mask {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(0, 0, 0, 0.32); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 16px; padding-bottom: max(16px, env(safe-area-inset-bottom));
}
.modal-box {
  background: var(--surface); border-radius: 20px;
  padding: 22px; width: 100%; max-width: 420px;
  box-shadow: var(--shadow-lift);
  animation: modal-in .22s var(--ease);
}
@keyframes modal-in { from { transform: translateY(16px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-box h3 { margin: 0 0 6px; font-size: 17px; }
.modal-box p { margin: 0 0 16px; color: var(--muted); font-size: 14.5px; line-height: 1.45; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { margin: 0; }
.modal-actions .btn.danger { background: var(--danger); border: 0; color: #fff; box-shadow: none; }
@media (min-width: 820px) { .modal-mask { align-items: center; } }

/* Barra de guardado sticky en formularios largos (móvil) */
.savebar {
  /* Los formularios ocultan la nav inferior en móvil: pegar casi al borde */
  position: sticky; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 15;
  background: linear-gradient(to top, var(--bg) 65%, transparent);
  padding: 12px 0 6px; margin-top: 4px;
}
.savebar .btn { margin: 0; }
@media (min-width: 820px) { .savebar { position: static; background: none; padding: 0; margin-top: 10px; } }

/* Objetivos táctiles cómodos */
.iconbtn { min-width: 40px; min-height: 40px; align-items: center; justify-content: center; }

/* ============ Resumen (dashboard) ============ */

/* Transición entre páginas */
.page-enter-active, .page-leave-active { transition: opacity .18s var(--ease), transform .18s var(--ease); }
.page-enter-from { opacity: 0; transform: translateY(8px); }
.page-leave-to { opacity: 0; transform: translateY(-6px); }

/* Hero del Resumen: tarjeta protagonista, limpia */
.hero {
  position: relative; border-radius: 20px; padding: 0; margin-bottom: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.hero-inner {
  background: none;
  border-radius: 20px; padding: 22px 20px 20px;
}
.hero .h-label { font-size: 12px; letter-spacing: 0.6px; text-transform: uppercase; font-weight: 600; color: var(--muted); }
.hero .h-value {
  font-family: var(--font-display); font-size: 38px; font-weight: 700; letter-spacing: -0.03em;
  margin: 6px 0 2px; color: var(--text); font-variant-numeric: tabular-nums;
}
.hero .h-value.neg { color: var(--danger); }
.hero .h-sub { color: var(--muted); font-size: 13px; }
.hero .h-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

/* Stat-chips: neutros, con el color solo en la cifra */
.stat-chip {
  flex: 1; min-width: 130px;
  border-radius: 13px; padding: 10px 13px; border: 0;
  background: var(--surface-2);
  transition: transform .2s var(--ease), background .2s var(--ease);
}
.stat-chip .sc-l { font-size: 11px; color: var(--muted); font-weight: 500; }
.stat-chip .sc-v { font-family: var(--font-display); font-size: 17px; font-weight: 650; margin-top: 1px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-chip:hover { transform: translateY(-1px); }
.stat-chip.azul .sc-v { color: var(--accent); }
.stat-chip.verde .sc-v { color: var(--ok); }
.stat-chip.ambar .sc-v { color: var(--amber); }
.stat-chip.rojo .sc-v { color: var(--danger); }

/* Accesos rápidos del Resumen */
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 4px 0 6px; }
.quick .qbtn {
  display: flex; align-items: center; gap: 10px; padding: 14px;
  border-radius: 14px; border: 0; background: var(--surface);
  font-size: 14px; font-weight: 600; color: var(--text); cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
.quick .qbtn i { font-size: 20px; color: var(--accent); }
.quick .qbtn:hover { transform: translateY(-1px); box-shadow: var(--shadow-lift); }
.quick .qbtn:active { transform: scale(.98); }

/* Barras animadas (Resumen y Rendimientos) */
.bar-row .fill { transition: width .7s var(--ease); }

/* Botón primario: transición limpia, sin glow */
.btn.primary { transition: background .18s var(--ease), transform .18s var(--ease); }

/* Lista compacta del Resumen */
.mini-list .card { padding: 12px 14px; margin-bottom: 8px; }
.mini-list .card .row + .row { margin-top: 3px; }

/* Rejilla del dashboard: 1 columna en móvil, 2 en escritorio ancho */
.dash-grid { display: flex; flex-direction: column; }
@media (min-width: 1100px) {
  .dash-grid { display: grid; grid-template-columns: 1.05fr 0.95fr; gap: 0 18px; align-items: start; }
  .dash-grid > div > .section-title:first-child { margin-top: 0; }
}

/* Sin animaciones si el usuario lo pide */
@media (prefers-reduced-motion: reduce) {
  .skeleton .sk { animation: none; }
  .page-enter-active, .page-leave-active, .stat-chip, .quick .qbtn, .bar-row .fill,
  .card.tap, .btn, .toast { transition: none; }
}

/* Cabecera de línea del presupuesto: nº + acciones (subir/bajar/duplicar/quitar) */
.linea-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: -2px 0 8px; padding-bottom: 7px; border-bottom: 1px dashed var(--line);
}
.linea-head .ln { font-size: 11px; letter-spacing: 0.8px; font-weight: 600; color: var(--muted); text-transform: uppercase; }
.linea-acts { display: flex; gap: 6px; }
.ordbtn {
  width: 34px; height: 30px; border-radius: 9px; border: 0;
  background: var(--surface-2); color: var(--muted); cursor: pointer;
  display: grid; place-items: center; font-size: 15px; padding: 0;
  transition: color .15s var(--ease), background .15s var(--ease), transform .15s var(--ease);
}
.ordbtn:hover { color: var(--accent); background: var(--accent-soft); }
.ordbtn:active { transform: scale(.94); }
.ordbtn:disabled { opacity: .3; pointer-events: none; }
.ordbtn.rojo:hover { color: var(--danger); background: rgba(229, 57, 46, .10); }

/* Fase dentro de una línea: acciones compactas */
.fase-acts { display: flex; gap: 5px; align-items: center; }
.fase-acts .ordbtn { width: 28px; height: 26px; font-size: 13px; }

/* Feedback al mover una línea */
.linea.moved { animation: linea-pop .3s var(--ease); }
@keyframes linea-pop { 0% { box-shadow: 0 0 0 2px rgba(47,111,237,.35); } 100% { box-shadow: 0 1px 2px rgba(0,0,0,.03); } }

/* Fotos de líneas de presupuesto (miniaturas) */
.foto-mini { width: 54px; height: 54px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line, #d3d9e4); cursor: pointer; }

/* ---- Prevención de errores: selector de cuenta y resumen de confirmación ---- */
.cuenta-pick { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cuenta-pick .cp-label { font-size: 13px; flex-basis: 100%; }
.cuenta-pick .cp-btn { margin: 0; padding: 10px 14px; flex: 1 1 0; width: auto; min-width: 0; }
.cuenta-pick .cp-btn.sel-caja { background: #b7791f; border-color: #b7791f; color: #fff; }
.cuenta-pick .cp-btn.sel-banco { background: var(--accent); border-color: var(--accent); color: #fff; }
.cuenta-pick .cp-btn.sel-iva { background: var(--ok); border-color: var(--ok); color: #fff; }
.cuenta-pick .cp-falta { font-size: 13px; color: var(--amber); flex-basis: 100%; }
.confirm-filas { background: var(--bg); border-radius: var(--radius-sm); padding: 8px 12px; margin: 0 0 14px; }
.confirm-filas .cf-row { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; font-size: 14.5px; }
.confirm-filas .cf-row + .cf-row { border-top: 1px solid var(--line); }
.confirm-filas .cf-row > span:last-child { text-align: right; }
.confirm-filas .cta-caja { color: #b7791f; }
.confirm-filas .cta-banco { color: var(--accent); }
.confirm-filas .cta-iva { color: var(--ok); }
.modal-box p.confirm-aviso { color: var(--amber); background: rgba(154, 107, 0, 0.08); border-radius: 10px; padding: 8px 10px; margin: 0 0 14px; }

/* Fases comunes del presupuesto (proceso de trabajo) */
.fases-comun { border-left: 3px solid var(--accent); }
.check-fila { display: flex; align-items: center; gap: 8px; font-size: 14px; margin: 2px 0 6px; cursor: pointer; }
.check-fila input { width: auto; margin: 0; }
.fases-resumen { font-size: 13px; }
.fase-obs { margin-top: 4px; font-size: 13px; line-height: 1.35; color: var(--text); cursor: pointer; overflow-wrap: anywhere; }
.fase-obs .ti { color: var(--muted); font-size: 13px; }
.fase-obs.vacia { color: var(--muted); font-style: italic; }

/* Calculadora de medidas y sugerencias de precio (líneas de presupuesto) */
.calc { margin-top: 8px; padding: 10px; border-style: dashed; }
.seg { display: inline-flex; border: 1px solid var(--line, #d9dce3); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 6px 12px; font: inherit; font-size: 13px; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.calc-fila { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.calc-fila input { margin: 0; }
.calc-fila .c-uds { width: 52px; flex: 0 0 52px; }
.calc-fila .c-med { flex: 1 1 64px; min-width: 64px; }
.calc-fila .c-caras { flex: 0 0 auto; width: auto; }
.calc-fila .c-res { margin-left: auto; font-weight: 600; font-size: 13px; white-space: nowrap; }
.sugs { margin-top: 6px; }
.chip.sug { font-size: 12px; }

/* Editor de líneas: borrador recuperable, descripción plegada, copiar de otro presupuesto */
.aviso-borrador { border-left: 3px solid var(--amber); }
.enlace { background: none; border: 0; padding: 4px 0 0; color: var(--accent); font: inherit; font-size: 13px; cursor: pointer; }
.copia-linea { margin: 8px 0 0; font-size: 14px; }

/* Calendario de obras */
.cal-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.cal-nav { display: flex; align-items: center; gap: 6px; }
.cal-dia { padding: 10px 12px; }
.cal-dia.hoy { outline: 2px solid var(--accent); }
.cal-dia.finde { background: var(--surface-2); }
.cal-obra { border-left: 4px solid var(--accent); padding: 6px 0 6px 10px; margin-top: 8px; }
.cal-edit { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); }
.chip.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.plan { border-style: dashed; }
.cal-mes { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; margin-top: 4px; }
.cal-cab { text-align: center; font-size: 11px; color: var(--muted); text-transform: uppercase; padding: 2px 0; }
.cal-celda { min-height: 62px; background: var(--surface); border-radius: 8px; padding: 3px; cursor: pointer; overflow: hidden; box-shadow: 0 0 0 1px var(--line); }
.cal-celda.fuera { opacity: .45; }
.cal-celda.hoy { box-shadow: 0 0 0 2px var(--accent); }
.cal-num { font-size: 12px; font-weight: 600; margin-bottom: 2px; }
.cal-tag { color: #fff; font-size: 10px; line-height: 1.5; border-radius: 4px; padding: 0 3px; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-mas { font-size: 10px; color: var(--muted); }
.hoy-obra { border-left: 4px solid var(--accent); padding-left: 10px; margin-top: 6px; }

/* Almacén general */
.calc-ok { margin: 0 0 8px; font-size: 13px; color: var(--ok); }
.row.mov { align-items: center; font-size: 13px; }

/* Dirección de la obra y semana del inicio */
.dir-obra { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--accent); text-decoration: none; margin-top: 2px; }
.lista-dir { font-size: 13px; margin: 2px 0; }
.semana-inicio { padding: 12px 14px; }
.si-dia { display: flex; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); }
.si-dia.hoy .si-fecha { color: var(--accent); font-weight: 700; }
.si-dia.finde { opacity: .7; }
.si-fecha { flex: 0 0 64px; font-size: 13px; color: var(--muted); padding-top: 2px; }
.si-obras { flex: 1; min-width: 0; }
.si-obra { border-left: 3px solid var(--accent); padding-left: 8px; margin-bottom: 4px; cursor: pointer; }

/* ============ Repaso de usabilidad (móvil, tablet y ordenador) ============ */
.chip { white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
/* En pantallas táctiles, nada pulsable por debajo de ~40-44 px */
@media (pointer: coarse), (max-width: 819px) {
  .chip { min-height: 40px; padding: 8px 13px; font-size: 13.5px; }
  .userbtn, .pwa-x, .pwa-cta { min-height: 40px; min-width: 40px; }
  .ordbtn { width: 40px; height: 40px; font-size: 17px; }
  .fase-acts .ordbtn { width: 36px; height: 36px; }
  .enlace { min-height: 40px; padding: 8px 0; }
  .check-fila { min-height: 44px; }
  .seg button { min-height: 40px; }
}
/* Formularios y fichas: ancho cómodo en pantallas grandes, centrado */
/* Centrado en el hueco que deja el menú lateral (240px), nunca debajo de él */
@media (min-width: 1000px) {
  .content.estrecho { max-width: 880px; width: auto; }
  div:has(> .nav) > .content.estrecho { margin-left: max(240px, calc(240px + (100vw - 240px - 880px) / 2)); }
}
/* En escritorio el menú lateral fijo tapaba el principio del aviso de instalar */
@media (min-width: 820px) { .pwa-banner { padding-left: 254px; } }
/* Barra de guardar que se queda a la vista también en el ordenador */
@media (min-width: 820px) {
  .savebar.fija { position: sticky; bottom: 12px; background: linear-gradient(to top, var(--bg) 70%, transparent); padding: 12px 0 4px; }
}
.savebar .sb-total { display: flex; justify-content: space-between; align-items: baseline; margin: 0 2px 6px; font-size: 14px; }
.savebar .sb-total b { font-size: 18px; }
.savebar .inline .btn { margin: 0; }
/* Barra de acciones de una ficha: la principal destacada, las demás compactas */
.acciones { margin: 0 0 12px; }
.acciones .secundarias { display: grid; grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); gap: 8px; margin-top: 8px; }
.acciones .secundarias .btn { margin: 0; flex-direction: column; gap: 2px; font-size: 13px; padding: 8px 6px; min-height: 56px; }
.acciones .secundarias .btn i { font-size: 19px; }
/* Pestañas de una ficha */
.tabs { display: flex; gap: 4px; background: var(--surface-2); border-radius: 12px; padding: 4px; margin: 4px 0 12px; overflow-x: auto; }
.tabs button { flex: 1; border: 0; background: transparent; border-radius: 9px; padding: 9px 8px; min-height: 40px; font: inherit; font-size: 14px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tabs button.on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
/* Tesorería: saldos compactos */
.saldos { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.saldos button { border: 0; background: var(--surface-2); border-radius: 12px; padding: 10px 8px; text-align: left; cursor: pointer; font: inherit; min-height: 64px; }
.saldos button.on { outline: 2px solid var(--accent); background: var(--accent-soft); }
.saldos .s-nom { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.saldos .s-val { font-size: clamp(15px, 4.2vw, 20px); font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; }
.quick.cuatro { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.quick.cuatro .qbtn { flex-direction: column; justify-content: center; text-align: center; gap: 4px; font-size: 13px; padding: 10px 4px; }
.quick .qbtn.on { outline: 2px solid var(--accent); }
.zona-peligro { margin-top: 22px; padding-top: 12px; border-top: 1px dashed var(--line); }
.resumen-fases { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
/* Sugerencias con texto largo (obra + cliente + motivo): parten línea en vez de salirse */
.chip.largo { white-space: normal; text-align: left; line-height: 1.3; max-width: 100%; }
.pwa-banner .pwa-cta { min-height: 40px; }
@media (pointer: coarse), (max-width: 819px) { .dir-obra { min-height: 36px; } }
