/* ============================================================
   TodoControl — sistema de diseño
   Gama ROJO · GRIS · NEGRO sobre tema oscuro.
   Poppins para títulos, Inter para datos.

   Nota sobre los colores semánticos: la marca es roja, así que el
   rojo NO puede significar "error" por sí solo. Por eso:
     · --primary  → rojo de marca (acciones, resaltados)
     · --danger   → rojo claro y brillante, solo para destruir/alertar
     · --warning  → ámbar, para vencimientos y saldos
     · --success  → verde discreto, para ingresos y estados al día
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@500;600;700;800&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --primary:        #E03131;
  --primary-dark:   #B02525;
  --primary-light:  #FF5C5C;
  --primary-soft:   rgba(224,49,49,.14);
  --bg-dark:        #0B0B0C;
  --bg-card:        #17181A;
  --bg-sidebar:     #101011;
  --surface:        #212225;
  --surface-2:      #2B2C30;
  --border:         #2F3134;
  --border-light:   #3D4045;
  --text-main:      #FFFFFF;
  --text-muted:     #A8ABB0;
  --text-dim:       #6A6E73;
  --success:        #3BA55D;
  --danger:         #FF5252;
  --warning:        #E8A33D;
  --info:           #8C8F94;
  --sidebar-w:      258px;
  --header-h:       60px;
  --radius:         8px;
  --radius-sm:      4px;
  --shadow:         0 4px 20px rgba(0,0,0,0.55);
  --shadow-sm:      0 2px 8px rgba(0,0,0,0.35);
  --transition:     all 0.25s ease;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg-dark);
  color: var(--text-main);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, h4, .font-title { font-family: 'Poppins', sans-serif; font-weight: 600; margin: 0; }

a { color: var(--primary-light); text-decoration: none; }
a:hover { color: #FF8787; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ============================================================
   LOGIN
   ============================================================ */
.login-screen {
  position: fixed; inset: 0; z-index: 500;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: radial-gradient(1000px 620px at 20% 0%, #1E0E0E 0%, var(--bg-dark) 62%);
  overflow-y: auto;
}

.login-card {
  width: 100%; max-width: 430px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 30px 26px 24px;
  text-align: center;
  margin: auto;
}

.login-mark {
  width: 76px; height: 76px; margin: 0 auto 14px;
  border-radius: 17px;
  background: #141416;
  border: 1px solid #2A2B2E;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-family: 'Poppins', sans-serif; font-weight: 800; font-size: 27px;
  color: var(--primary); letter-spacing: 0.5px;
  box-shadow: var(--shadow-sm);
}
.login-mark span { display: block; width: 34px; height: 4px; border-radius: 2px; background: var(--primary); margin-top: 3px; }

.login-card h1 { font-size: 25px; font-weight: 700; margin-bottom: 6px; }
.login-card h1 em { font-style: normal; color: var(--primary); }
.login-card > p { color: var(--text-muted); font-size: 13.5px; margin: 0 0 20px; }

.login-note { color: var(--text-dim); font-size: 11.5px; margin-top: 14px; line-height: 1.55; }

.setup-banner {
  background: rgba(232,163,61,.12);
  border: 1px solid rgba(232,163,61,.4);
  color: #F3D3A0;
  border-radius: var(--radius);
  padding: 12px 14px; font-size: 12.5px; text-align: left; line-height: 1.6;
  margin-bottom: 14px;
}
.setup-banner code { background: rgba(0,0,0,.35); padding: 1px 5px; border-radius: 3px; font-size: 11.5px; }

.plan-gratis-banner {
  background: rgba(59,165,93,.12);
  border: 1px solid rgba(59,165,93,.35);
  color: #9FE0B4;
  border-radius: var(--radius);
  padding: 10px 14px; font-size: 12.5px; text-align: center; line-height: 1.5;
  margin-bottom: 14px;
}

.google-btn {
  width: 100%; min-height: 46px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: #FFFFFF; color: #202124;
  border: none; border-radius: var(--radius);
  font-family: 'Inter', sans-serif; font-weight: 600; font-size: 14.5px;
  cursor: pointer; transition: var(--transition);
}
.google-btn:hover { background: #F1F3F4; }
.google-btn:disabled { cursor: default; }

.login-progress {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin-top: 14px; color: var(--text-muted); font-size: 13px;
}

.spinner {
  width: 18px; height: 18px; flex: none;
  border: 2.4px solid rgba(224,49,49,.25);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   LAYOUT: sidebar + topbar + contenido
   ============================================================ */
#app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex: none;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; inset: 0 auto 0 0; z-index: 60;
  transition: transform .25s ease;
}

.brand { display: flex; align-items: center; gap: 11px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.brand-mark {
  width: 38px; height: 38px; flex: none; border-radius: 9px;
  background: #141416; border: 1px solid #2A2B2E;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Poppins', sans-serif; font-weight: 800; font-size: 14px; color: var(--primary);
}
.brand-name { font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 17px; }
.brand-name span { color: var(--primary); }

.nav-group-label {
  padding: 15px 18px 6px; font-size: 10.5px; letter-spacing: 1.1px;
  text-transform: uppercase; color: var(--text-dim); font-weight: 600;
}

.nav-list { list-style: none; margin: 0; padding: 0 10px 10px; overflow-y: auto; flex: 1; }
.nav-list li { margin-bottom: 2px; }

.nav-item {
  width: 100%; display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border: none; background: none;
  color: var(--text-muted); font-family: 'Inter', sans-serif; font-size: 13.5px; font-weight: 500;
  border-radius: var(--radius-sm); cursor: pointer; text-align: left;
  transition: var(--transition);
}
.nav-item:hover { background: var(--surface); color: var(--text-main); }
.nav-item.active { background: var(--primary-soft); color: var(--primary-light); font-weight: 600; box-shadow: inset 2px 0 0 var(--primary); }
.nav-ico { width: 20px; flex: none; text-align: center; font-size: 14.5px; }

.nav-user {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-top: 1px solid var(--border);
}
.nav-user img { width: 34px; height: 34px; border-radius: 50%; flex: none; background: var(--surface-2); object-fit: cover; }
.nav-user-info { min-width: 0; flex: 1; }
.nav-user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-user-email { font-size: 11px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-signout {
  background: none; border: none; color: var(--text-dim); cursor: pointer;
  padding: 6px; border-radius: var(--radius-sm); flex: none; font-size: 15px;
}
.nav-signout:hover { color: var(--danger); background: var(--surface); }

.sidebar-overlay {
  display: none; position: fixed; inset: 0; z-index: 55;
  background: rgba(0,0,0,.62); backdrop-filter: blur(2px);
}
.sidebar-overlay.open { display: block; }

.main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; }

.topbar {
  height: var(--header-h); flex: none;
  display: flex; align-items: center; gap: 12px;
  padding: 0 18px;
  background: var(--bg-card); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 40;
}
.topbar-title { font-family: 'Poppins', sans-serif; font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-spacer { flex: 1; }

.hamburger {
  display: none; background: none; border: none; color: var(--text-main);
  cursor: pointer; padding: 6px; border-radius: var(--radius-sm); font-size: 19px;
}
.hamburger:hover { background: var(--surface); }

/* Selector de proyecto activo */
.proy-switch {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border-light);
  border-radius: 20px; padding: 4px 6px 4px 12px; max-width: 340px;
}
.proy-switch-label { font-size: 10.5px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .7px; white-space: nowrap; }
.proy-select {
  background: none; border: none; color: var(--text-main);
  font-family: 'Inter', sans-serif; font-size: 13px; font-weight: 600;
  cursor: pointer; outline: none; max-width: 220px; padding: 4px;
}
.proy-select option { background: var(--bg-card); color: var(--text-main); }

.sync-pill { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--text-dim); white-space: nowrap; }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); flex: none; }
.sync-dot.syncing { background: var(--warning); animation: pulse 1s infinite; }
.sync-dot.offline { background: var(--danger); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

.content { flex: 1; padding: 22px; max-width: 1500px; width: 100%; }

/* ============================================================
   TARJETAS Y BLOQUES
   ============================================================ */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
}
.card + .card { margin-top: 16px; }
.card-title {
  font-family: 'Poppins', sans-serif; font-weight: 600; font-size: 15px;
  margin: 0 0 14px; display: flex; align-items: center; gap: 8px;
}
.card-sub { color: var(--text-muted); font-size: 12.5px; margin: -8px 0 14px; }
.card-click { cursor: pointer; transition: var(--transition); }
.card-click:hover { border-color: var(--primary); transform: translateY(-1px); }

.section-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 16px;
}
.section-head h2 { font-size: 19px; font-weight: 700; }
.section-head .text-muted { font-size: 12.5px; }

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-row { display: flex; align-items: center; }
.wrap { flex-wrap: wrap; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.text-muted { color: var(--text-muted); }
.text-dim { color: var(--text-dim); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-primary { color: var(--primary-light); }
.nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0; } .mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }
.hidden { display: none !important; }
.mono { font-variant-numeric: tabular-nums; }

/* KPI */
.kpi {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 15px 16px;
  display: flex; flex-direction: column; gap: 3px;
  border-left: 3px solid var(--primary);
}
.kpi.ok { border-left-color: var(--success); }
.kpi.bad { border-left-color: var(--danger); }
.kpi.warn { border-left-color: var(--warning); }
.kpi.info { border-left-color: var(--info); }
.kpi-label { font-size: 11px; text-transform: uppercase; letter-spacing: .7px; color: var(--text-dim); font-weight: 600; }
.kpi-value { font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 21px; line-height: 1.25; }
.kpi-sub { font-size: 11.5px; color: var(--text-muted); }

/* ============================================================
   BOTONES
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 38px; padding: 8px 15px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif; font-size: 13.5px; font-weight: 600;
  cursor: pointer; transition: var(--transition); white-space: nowrap;
  background: var(--surface); color: var(--text-main);
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #FFF; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-light); }
.btn-outline { background: transparent; border-color: var(--border-light); color: var(--text-main); }
.btn-outline:hover { background: var(--surface); border-color: var(--primary); }
.btn-danger { background: var(--danger); color: #2A0000; }
.btn-danger:hover { background: #FF7373; }
.btn-success { background: var(--success); color: #04240F; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface); color: var(--text-main); }
/* "Explorar en modo demo": es la 2ª puerta de entrada, se le da algo más
   de peso que a los otros botones secundarios del login. */
#demoModeBtn { font-size: 15.5px; font-weight: 700; color: var(--text-main); min-height: 44px; }
.btn-sm { min-height: 30px; padding: 5px 11px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn-icon { min-height: 32px; width: 32px; padding: 0; font-size: 14px; }

.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 14px; font-size: 12px; font-weight: 600;
  background: var(--surface); color: var(--text-muted); border: 1px solid var(--border);
  cursor: pointer; transition: var(--transition);
}
.chip:hover { border-color: var(--border-light); color: var(--text-main); }
.chip.active { background: var(--primary-soft); color: var(--primary-light); border-color: rgba(224,49,49,.45); }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 11px; font-size: 11.5px; font-weight: 600;
  background: var(--surface); color: var(--text-muted);
}
.badge-ok   { background: rgba(59,165,93,.16); color: var(--success); }
.badge-bad  { background: rgba(255,82,82,.16); color: var(--danger); }
.badge-warn { background: rgba(232,163,61,.16); color: var(--warning); }
.badge-info { background: rgba(140,143,148,.20); color: #C9CCD1; }
.badge-dim  { background: var(--surface-2); color: var(--text-dim); }

.dot-color { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }

/* ============================================================
   FORMULARIOS
   ============================================================ */
.field { margin-bottom: 13px; }
.field label, .lbl {
  display: block; font-size: 12px; font-weight: 600; color: var(--text-muted);
  margin-bottom: 5px;
}
.field label .req { color: var(--primary-light); }

.input, .select, .textarea {
  width: 100%; min-height: 38px; padding: 8px 11px;
  background: var(--surface); color: var(--text-main);
  border: 1px solid var(--border-light); border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif; font-size: 13.5px;
  transition: var(--transition); outline: none;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(224,49,49,.18); }
.input::placeholder, .textarea::placeholder { color: var(--text-dim); }
.textarea { min-height: 78px; resize: vertical; line-height: 1.55; }
.select option { background: var(--bg-card); }
.input:disabled, .select:disabled { opacity: .55; cursor: not-allowed; }
.input.err, .select.err { border-color: var(--danger); }

.input-num { text-align: right; font-variant-numeric: tabular-nums; }

.field-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.check { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--primary); cursor: pointer; flex: none; }

.hint { font-size: 11.5px; color: var(--text-dim); margin-top: 4px; line-height: 1.5; }

/* Autocompletado de terceros (proveedor / pagador) */
.autocomplete-wrap { position: relative; }
.autocomplete-list {
  position: absolute; z-index: 30; left: 0; right: 0; top: 100%;
  background: var(--surface); border: 1px solid var(--border-light);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
  max-height: 240px; overflow-y: auto; margin-top: 3px;
}
.autocomplete-list div { padding: 9px 11px; cursor: pointer; font-size: 13px; border-bottom: 1px solid var(--border); }
.autocomplete-list div:last-child { border-bottom: none; }
.autocomplete-list div:hover, .autocomplete-list div.sel { background: var(--primary-soft); color: var(--primary-light); }
.autocomplete-list .ac-sub { display: block; font-size: 11px; color: var(--text-dim); }

/* ============================================================
   TABLAS
   ============================================================ */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); border: 1px solid var(--border); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--bg-card); }
table.tbl th {
  text-align: left; padding: 10px 11px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .6px; color: var(--text-dim);
  background: var(--surface); border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.tbl td { padding: 9px 11px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl tbody tr:hover { background: rgba(255,255,255,.025); }
table.tbl tfoot td { padding: 10px 11px; font-weight: 700; background: var(--surface); border-top: 2px solid var(--border-light); }
table.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.tbl .acciones { text-align: right; white-space: nowrap; }
table.tbl tr.grupo td { background: var(--surface); font-weight: 700; }
table.tbl tr.sub td { background: rgba(255,255,255,.02); }
table.tbl tr.alerta td { background: rgba(232,163,61,.10); }
table.tbl tr.ok td { background: rgba(59,165,93,.08); }

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-dim); }
.empty-state .ico { font-size: 40px; opacity: .5; display: block; margin-bottom: 10px; }
.empty-state h3 { font-size: 15px; color: var(--text-muted); margin-bottom: 5px; }
.empty-state p { font-size: 13px; margin: 0 0 14px; }

/* Barras de progreso */
.bar { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--primary); border-radius: 4px; transition: width .4s ease; }
.bar-fill.ok { background: var(--success); }
.bar-fill.bad { background: var(--danger); }
.bar-fill.warn { background: var(--warning); }
.bar-mini { height: 6px; }

/* Barras horizontales simples de informe */
.hbar-row { display: grid; grid-template-columns: minmax(110px, 1.3fr) 3fr minmax(90px, auto); gap: 10px; align-items: center; margin-bottom: 8px; font-size: 12.5px; }
.hbar { height: 16px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.hbar > div { height: 100%; background: var(--primary); }

/* ============================================================
   MODALES
   ============================================================ */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 900;
  background: rgba(0,0,0,.74); backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 24px 16px; overflow-y: auto;
}
.modal {
  background: var(--bg-card); border: 1px solid var(--border-light);
  border-radius: 12px; box-shadow: var(--shadow);
  width: 100%; max-width: 540px; margin: auto;
}
.modal-wide { max-width: 900px; }
.modal-xl { max-width: 1200px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--text-dim); font-size: 22px; cursor: pointer; line-height: 1; padding: 2px 6px; border-radius: var(--radius-sm); }
.modal-close:hover { color: var(--danger); background: var(--surface); }
.modal-body { padding: 18px; }
.modal-foot { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; gap: 9px; justify-content: flex-end; flex-wrap: wrap; }

/* Anuncios */
.anuncio-overlay {
  position: fixed; inset: 0; z-index: 100000;
  background: rgba(0,0,0,.88);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.anuncio-modal { position: relative; max-width: 520px; width: 100%; background: var(--bg-card); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
.anuncio-modal img { width: 100%; max-height: 66vh; object-fit: contain; display: block; background: #000; }
.anuncio-body { padding: 16px; }
.anuncio-body h3 { font-size: 16px; margin-bottom: 12px; }
.anuncio-close {
  position: absolute; top: 8px; right: 10px; z-index: 2;
  background: rgba(0,0,0,.6); border: none; color: #fff;
  width: 32px; height: 32px; border-radius: 50%; font-size: 20px; cursor: pointer; line-height: 1;
}

/* Toasts */
#toast-host { position: fixed; bottom: 20px; right: 20px; z-index: 100010; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast {
  background: var(--surface); color: var(--text-main);
  border: 1px solid var(--border-light); border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm); padding: 11px 15px; font-size: 13px;
  box-shadow: var(--shadow); max-width: 340px; animation: toastIn .22s ease;
}
.toast.ok  { border-left-color: var(--success); }
.toast.err { border-left-color: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }

/* Badge "Guardando…" del outbox */
.outbox-badge {
  position: fixed; bottom: 20px; left: 20px; z-index: 100005;
  display: none; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border-light);
  border-radius: 18px; padding: 7px 14px; font-size: 12.5px; color: var(--text-muted);
  box-shadow: var(--shadow);
}
.outbox-badge.on { display: flex; }
.outbox-badge .spinner { width: 13px; height: 13px; border-width: 2px; }

/* Soportes (fotos y PDF) */
.foto-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.foto-thumb {
  position: relative; aspect-ratio: 1; border-radius: var(--radius-sm); overflow: hidden;
  background: var(--surface); border: 1px solid var(--border);
}
.foto-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
/* Quitar un soporte ya guardado, desde el mismo formulario. */
.foto-quitar {
  position: absolute; top: 4px; right: 4px; width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  border: 0; border-radius: 50%; cursor: pointer; font-size: 12px; line-height: 1;
  background: rgba(0,0,0,.62); color: #FFF; backdrop-filter: blur(2px);
}
.foto-quitar:hover { background: var(--primary); }
/* Separador para partir un formulario largo (datos ↑ / soporte ↓). */
.sep { height: 1px; background: var(--border); margin: 18px 0 14px; }
/* Un PDF no tiene miniatura: se muestra la ficha del archivo. */
.foto-pdf {
  width: 100%; height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 5px; padding: 8px; text-align: center;
  background: rgba(224,49,49,.08); color: var(--text-muted);
}
.foto-pdf .ico { font-size: 26px; line-height: 1; }
.foto-pdf .nom {
  font-size: 10.5px; line-height: 1.25; word-break: break-word;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.foto-drop {
  border: 1.5px dashed var(--border-light); border-radius: var(--radius);
  padding: 18px; text-align: center; color: var(--text-dim); font-size: 12.5px; cursor: pointer;
  transition: var(--transition);
}
.foto-drop:hover { border-color: var(--primary); color: var(--primary-light); }

/* Semáforo de cuentas por pagar */
.semaforo { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.semaforo.rojo { background: var(--danger); }
.semaforo.naranja { background: var(--warning); }
.semaforo.verde { background: var(--success); }

/* Gráficos */
.chart-box { position: relative; height: 260px; }
.chart-box.tall { height: 320px; }

/* Tabbar móvil */
.mobile-tabbar { display: none; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 980px) {
  .proy-switch { max-width: 200px; }
  .proy-switch-label { display: none; }
  .sync-pill span:not(.sync-dot) { display: none; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .hamburger { display: inline-flex; }
  .content { padding: 15px 13px 80px; }

  /* En móvil la barra superior solo tiene sitio para el menú y el selector
     de proyecto. El título sobra: cada pantalla ya lo repite en su <h2>. */
  .topbar { padding: 0 10px; gap: 8px; overflow: hidden; }
  .topbar-title { display: none; }
  .proy-switch { flex: 1; min-width: 0; max-width: none; }
  .proy-select { flex: 1; min-width: 0; max-width: none; }

  /* Botones cómodos para el dedo */
  .btn { min-height: 44px; padding: 10px 16px; }
  .btn-sm { min-height: 38px; }
  .btn-icon { min-height: 38px; width: 38px; }
  .input, .select, .textarea { min-height: 44px; font-size: 15px; } /* 15px evita el zoom de iOS */
  .field-row { grid-template-columns: 1fr; }

  .modal-backdrop { padding: 10px; }
  .modal-body { padding: 14px; }
  .grid-4, .grid-3 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .kpi-value { font-size: 18px; }

  .mobile-tabbar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
    background: var(--bg-sidebar); border-top: 1px solid var(--border);
    padding: 4px 2px calc(4px + env(safe-area-inset-bottom));
  }
  .mobile-tabbar button {
    flex: 1; background: none; border: none; color: var(--text-dim);
    font-family: 'Inter', sans-serif; font-size: 10px; font-weight: 600;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 7px 2px; cursor: pointer; min-height: 50px;
  }
  .mobile-tabbar button .ico { font-size: 17px; }
  .mobile-tabbar button.active { color: var(--primary-light); }
  #toast-host { bottom: 74px; right: 10px; left: 10px; align-items: stretch; }
  .toast { max-width: none; }
  .outbox-badge { bottom: 74px; left: 10px; }
}

/* ============================================================
   IMPRESIÓN (informes en PDF vía window.print)
   ============================================================ */
.print-doc { display: none; }

@media print {
  @page { size: A4; margin: 12mm 10mm 14mm; }

  body { background: #fff !important; color: #000 !important; font-size: 10.5pt; }
  #app, .login-screen, .modal-backdrop, .anuncio-overlay, #toast-host,
  .sidebar, .topbar, .mobile-tabbar, .outbox-badge, .no-print { display: none !important; }

  .print-doc { display: block !important; }

  .print-doc * { color: #000 !important; }
  .print-doc .pd-head {
    display: flex; justify-content: space-between; align-items: flex-start;
    border-bottom: 2px solid #E03131; padding-bottom: 8px; margin-bottom: 14px;
  }
  .print-doc .pd-logo { max-height: 60px; max-width: 190px; }
  .print-doc h1 { font-size: 16pt; margin: 0 0 2px; }
  .print-doc h2 { font-size: 12.5pt; margin: 16px 0 7px; border-bottom: 1px solid #ccc; padding-bottom: 3px; }
  .print-doc .pd-meta { font-size: 9pt; color: #444 !important; }
  .print-doc table { width: 100%; border-collapse: collapse; font-size: 9pt; margin-bottom: 12px; }
  .print-doc th {
    background: #FBE0E0 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact;
    border: 1px solid #999; padding: 5px 6px; text-align: left; font-size: 8.5pt;
  }
  .print-doc td { border: 1px solid #bbb; padding: 4px 6px; }
  .print-doc td.num, .print-doc th.num { text-align: right; }
  .print-doc tfoot td { font-weight: 700; background: #F2F2F2 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-doc tr.grupo td { background: #EFEFEF !important; font-weight: 700; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-doc .pd-foot { margin-top: 18px; border-top: 1px solid #ccc; padding-top: 6px; font-size: 8pt; color: #555 !important; }
  .print-doc .pd-break { page-break-before: always; }
  .print-doc .pd-avoid { page-break-inside: avoid; }
  .print-doc .pd-firma { margin-top: 40px; display: flex; gap: 60px; }
  .print-doc .pd-firma div { flex: 1; border-top: 1px solid #000; padding-top: 5px; font-size: 9pt; text-align: center; }
  /* Gráficos del informe: PNG generados con tema claro y fondo blanco */
  .print-doc .pd-graficos { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 14px; margin-bottom: 6px; }
  .print-doc .pd-graficos figure { margin: 0; page-break-inside: avoid; border: 1px solid #ddd; padding: 6px; }
  .print-doc .pd-graficos img { width: 100%; height: auto; display: block; }
  .print-doc .pd-graficos figcaption {
    font-size: 9pt; font-weight: 700; padding: 0 0 4px; border-bottom: 1px solid #eee; margin-bottom: 5px;
  }
  .print-doc .pd-graf-nota { font-size: 7.5pt; color: #555 !important; padding-top: 4px; }
  /* Un solo gráfico no debe quedar como una estampilla en media hoja */
  .print-doc .pd-graficos figure:only-child { grid-column: 1 / -1; }

  .print-doc .pd-fotos { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .print-doc .pd-fotos figure { margin: 0; page-break-inside: avoid; }
  .print-doc .pd-fotos img { width: 100%; height: 55mm; object-fit: cover; border: 1px solid #999; }
  .print-doc .pd-fotos figcaption { font-size: 8pt; padding-top: 3px; }
  thead { display: table-header-group; }
  tr { page-break-inside: avoid; }
}
