/* ════════════════════════════════════════════════════
   SIPresupuestos — Versión Lite (armar presupuesto + WhatsApp)
   Un solo CSS autónomo. Mismos colores/tipografías que el sistema completo.
   ════════════════════════════════════════════════════ */
:root {
  --brand: #1FC3E8;
  --brand-dark: #178FAE;
  --brand-light: #5ED6F0;
  --black: #0A1F38;
  --dark: #0F2A4A;
  --surface: #123A63;
  --surface2: #17436F;
  --border: #234F76;
  --border2: #2E5F89;
  --text: #ffffff;
  --text-bright: #ffffff;
  --muted: #C9D2DA;
  --muted2: #98A6B4;
  --white: #ffffff;
  --green: #16a34a;
  --green-dark: #15803d;
  --danger: #f87171;
  --radius-xs: 4px;
  --radius-sm: 5px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-pill: 20px;
  --font-d: 'Oswald', sans-serif;
  --font-b: 'Source Sans 3', sans-serif;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--black); color: var(--text); font-family: var(--font-b); min-height: 100vh; }

/* ════ TOPBAR + HEADER ════ */
.topbar { background: var(--brand-dark); padding: 7px 24px; font-family: var(--font-d); font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: rgba(255,255,255,.9); border-bottom: 1px solid var(--brand); }
.header { background: var(--dark); padding: 14px 32px; display: flex; align-items: center; justify-content: space-between; border-bottom: 3px solid var(--brand); }
.header-logo-img { height: 54px; width: auto; display: block; border-radius: var(--radius-xs); }
.header-right { display: flex; align-items: center; gap: 16px; }
.header-badge { background: var(--brand); color: var(--black); font-family: var(--font-d); font-size: 13px; letter-spacing: 2px; padding: 6px 16px; border-radius: var(--radius-xs); }
#logout-btn { display: none; background: none; border: 1px solid var(--border2); color: var(--muted); padding: 6px 14px; border-radius: var(--radius-xs); cursor: pointer; font-family: var(--font-b); font-size: 13px; transition: all .2s; }
#logout-btn:hover { border-color: var(--brand); color: var(--brand); }
#config-btn { display: none; background: none; border: 1px solid var(--border2); color: var(--muted); padding: 6px 14px; border-radius: var(--radius-xs); cursor: pointer; font-family: var(--font-b); font-size: 13px; transition: all .2s; }
#config-btn:hover { border-color: var(--brand); color: var(--brand); }

/* ════ LOGIN ════ */
#login-screen { display: none; flex-direction: column; align-items: center; justify-content: center; min-height: calc(100vh - 120px); padding: 40px 20px; }
.login-logo { width: 280px; max-width: 100%; margin-top: 60px; margin-bottom: 50px; display: block; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-top: 3px solid var(--brand); border-radius: var(--radius-lg); padding: 44px 40px; width: 360px; max-width: 100%; text-align: center; }
.login-card h2 { font-family: var(--font-d); font-size: 22px; letter-spacing: 3px; color: var(--brand-light); margin-bottom: 6px; }
.login-card p { font-size: 13px; color: var(--muted); margin-bottom: 28px; line-height: 1.5; }
.field { text-align: left; margin-bottom: 18px; }
.field label { font-size: 11px; color: var(--muted); letter-spacing: 1.5px; text-transform: uppercase; display: block; margin-bottom: 6px; }
.field input { width: 100%; background: var(--surface2); border: 1px solid var(--border); color: var(--text); padding: 11px 14px; border-radius: var(--radius-sm); font-size: 14px; font-family: var(--font-b); outline: none; transition: border-color .2s; }
.field input:focus { border-color: var(--brand-light); }
.btn-login { width: 100%; background: var(--brand); color: #fff; border: none; padding: 13px; border-radius: var(--radius-sm); font-family: var(--font-d); font-size: 16px; letter-spacing: 3px; cursor: pointer; transition: background .2s; margin-top: 8px; }
.btn-login:hover { background: var(--brand-light); }
.error-msg { color: var(--danger); font-size: 13px; margin-top: 10px; display: none; }

/* ════ CANDADO DE LICENCIA ════ */
#lock-screen { display: none; align-items: center; justify-content: center; min-height: calc(100vh - 120px); padding: 40px 20px; }
#lock-screen .login-card { border-top-color: var(--danger); }
#lock-screen h2 { color: var(--danger); }
#lock-screen p { color: var(--text); }

/* ════ CONTENEDOR ════ */
.wrap { display: none; padding: 28px 32px; max-width: 1100px; margin: 0 auto; }

/* ════ SECCIONES TIPO CARD ════ */
.card-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px 22px; margin-bottom: 20px; }
.card-section:hover { border-color: var(--border2); }
.section-title { font-family: var(--font-d); font-size: 13px; letter-spacing: 2.5px; text-transform: uppercase; color: var(--brand-light); margin-bottom: 18px; display: flex; align-items: center; gap: 8px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.section-title svg { width: 16px; height: 16px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.pfield label { font-size: 11px; color: var(--muted); letter-spacing: 1px; text-transform: uppercase; display: block; margin-bottom: 5px; }
.pfield input, .pfield select, .pfield textarea { width: 100%; background: var(--surface2); border: 1px solid var(--border); color: var(--text); padding: 9px 12px; border-radius: var(--radius-sm); font-size: 13px; font-family: var(--font-b); outline: none; transition: border-color .2s; }
.pfield input:focus, .pfield select:focus, .pfield textarea:focus { border-color: var(--brand-light); }
.pfield select option { background: var(--surface2); }
.pfield textarea { resize: vertical; min-height: 64px; }

/* ════ IVA ════ */
.iva-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; padding: 8px 14px; background: var(--surface2); border-radius: var(--radius-md); border: 1px solid var(--border); flex-wrap: wrap; }
.iva-bar svg { width: 15px; height: 15px; color: var(--brand-light); flex-shrink: 0; }
.iva-bar label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; white-space: nowrap; }
.iva-bar input[type="number"] { width: 52px; background: var(--surface); border: 1px solid var(--border); color: var(--text); padding: 4px 6px; border-radius: var(--radius-xs); font-size: 13px; font-family: var(--font-b); outline: none; text-align: center; }
.iva-bar input[type="number"]:focus { border-color: var(--brand-light); }
.iva-unit { font-size: 12px; color: var(--muted); }
.toggle-wrap { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.toggle-wrap span { font-size: 11px; color: var(--muted); }
.toggle { position: relative; width: 36px; height: 20px; cursor: pointer; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: var(--border2); border-radius: var(--radius-pill); transition: background .2s; }
.toggle-slider::after { content: ''; position: absolute; width: 14px; height: 14px; background: white; border-radius: 50%; top: 3px; left: 3px; transition: transform .2s; }
.toggle input:checked + .toggle-slider { background: var(--brand); }
.toggle input:checked + .toggle-slider::after { transform: translateX(16px); }

/* ════ TABLA DE ÍTEMS ════ */
.items-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.items-table th { font-size: 10px; color: var(--muted); letter-spacing: 1.5px; text-transform: uppercase; padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.items-table th:nth-child(1) { width: 36%; }
.items-table th:nth-child(2) { width: 24%; }
.items-table th:nth-child(3) { width: 10%; }
.items-table th:nth-child(4) { width: 10%; }
.items-table th:nth-child(5) { width: 14%; }
.items-table th:nth-child(6) { width: 11%; }
.items-table th:nth-child(7) { width: 4%; }
.items-table td { padding: 5px 6px; vertical-align: middle; }
.items-table input, .items-table select { background: var(--surface2); border: 1px solid var(--border); color: var(--text); padding: 7px 9px; border-radius: var(--radius-xs); font-size: 13px; font-family: var(--font-b); outline: none; width: 100%; transition: border-color .2s; }
.items-table input:focus, .items-table select:focus { border-color: var(--brand-light); }
.item-sub { font-weight: 600; color: var(--text-bright); font-size: 13px; text-align: right; white-space: nowrap; padding-right: 10px; }
.del-btn { background: none; border: 1px solid #3a2020; color: var(--danger); padding: 5px 8px; border-radius: var(--radius-xs); cursor: pointer; font-size: 13px; line-height: 1; transition: all .2s; }
.del-btn:hover { background: #3a2020; }
.add-item-btn { background: none; border: 1px dashed var(--border2); color: var(--muted); padding: 8px 18px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13px; font-family: var(--font-b); width: 100%; margin-top: 10px; transition: all .2s; display: flex; align-items: center; justify-content: center; gap: 6px; }
.add-item-btn:hover { border-color: var(--brand-light); color: var(--brand-light); }
.add-item-btn svg { width: 14px; height: 14px; }

/* ════ TOTALES ════ */
.totals-block { display: flex; justify-content: flex-end; gap: 32px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); align-items: flex-end; }
.total-item .tl { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 1.5px; }
.total-item .tv { font-family: var(--font-d); font-size: 18px; color: var(--text); margin-top: 2px; }
.total-item.grand .tv { font-size: 26px; color: var(--brand-light); }

/* ════ BOTONES DE ACCIÓN (WhatsApp / PDF) ════ */
.send-row { display: flex; gap: 12px; margin-top: 22px; flex-wrap: wrap; align-items: center; }
.btn-wa { background: var(--green); color: #fff; border: none; padding: 14px 28px; border-radius: var(--radius-md); cursor: pointer; font-size: 15px; font-family: var(--font-d); letter-spacing: 1.5px; display: flex; align-items: center; gap: 8px; transition: background .2s; }
.btn-wa:hover { background: var(--green-dark); }
.btn-wa svg { width: 18px; height: 18px; }
.btn-pdf { background: none; border: 1px solid var(--border2); color: var(--muted); padding: 14px 28px; border-radius: var(--radius-md); cursor: pointer; font-size: 15px; font-family: var(--font-d); letter-spacing: 1.5px; display: flex; align-items: center; gap: 8px; transition: all .2s; }
.btn-pdf:hover { border-color: var(--text); color: var(--text); }
.btn-pdf svg { width: 17px; height: 17px; }

/* ════ NOTIFICACIÓN ════ */
.notif { position: fixed; bottom: 28px; right: 28px; z-index: 9999; background: #1c2e1c; border: 1px solid #22c55e; border-left: 3px solid #22c55e; color: #86efac; padding: 12px 20px; border-radius: 7px; font-size: 13px; font-family: var(--font-b); display: none; max-width: 300px; box-shadow: 0 4px 20px rgba(0,0,0,.4); }

/* ════ MODAL DE CONFIGURACIÓN ════ */
.field textarea { width: 100%; background: var(--surface2); border: 1px solid var(--border); color: var(--text); padding: 11px 14px; border-radius: var(--radius-sm); font-size: 14px; font-family: var(--font-b); outline: none; transition: border-color .2s; resize: vertical; min-height: 70px; }
.field textarea:focus { border-color: var(--brand-light); }
.modal-bg { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.7); z-index: 1000; align-items: center; justify-content: center; padding: 20px; }
.modal-bg.open { display: flex; }
.modal { background: var(--surface); border: 1px solid var(--border); border-top: 3px solid var(--brand); border-radius: var(--radius-lg); padding: 36px 40px; max-width: 440px; width: 100%; max-height: 90vh; overflow-y: auto; position: relative; }
.modal.modal-wide { max-width: 520px; }
.modal-close { position: absolute; top: 14px; right: 14px; background: none; border: none; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; padding: 4px 8px; }
.modal-close:hover { color: var(--text); }
.modal h3 { font-family: var(--font-d); font-size: 18px; letter-spacing: 2px; color: var(--brand-light); margin: 0 0 18px; text-transform: uppercase; }
.color-row { display: flex; align-items: center; gap: 10px; }
.color-row input[type="color"] { width: 44px; height: 40px; padding: 2px; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; }
.color-row input[type="text"] { flex: 1; background: var(--surface2); border: 1px solid var(--border); color: var(--text); padding: 11px 14px; border-radius: var(--radius-sm); font-size: 14px; font-family: var(--font-b); outline: none; transition: border-color .2s; }
.color-row input[type="text"]:focus { border-color: var(--brand-light); }
.modal .field input[type="number"] { width: 100%; background: var(--surface2); border: 1px solid var(--border); color: var(--text); padding: 11px 14px; border-radius: var(--radius-sm); font-size: 14px; font-family: var(--font-b); outline: none; }
.field input[type="file"] { width: 100%; background: var(--surface2); border: 1px dashed var(--border); color: var(--muted); padding: 9px 12px; border-radius: var(--radius-sm); font-size: 12.5px; font-family: var(--font-b); cursor: pointer; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.logo-preview { display: block; max-width: 140px; max-height: 70px; margin-top: 10px; border-radius: var(--radius-xs); background: #fff; padding: 4px; object-fit: contain; }

/* ── Pestañas dentro de la modal ── */
.modal-tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.modal-tab { background: none; border: none; color: var(--muted); padding: 9px 6px; font-family: var(--font-d); font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all .2s; }
.modal-tab:hover { color: var(--text); }
.modal-tab.active { color: var(--brand-light); border-bottom-color: var(--brand); }
.modal-tab-content { display: none; }
.modal-tab-content.active { display: block; }

.modal-actions { display: flex; gap: 10px; margin-top: 22px; }
.modal-btn { flex: 1; border: none; padding: 12px; border-radius: var(--radius-sm); cursor: pointer; font-family: var(--font-d); font-size: 14px; letter-spacing: 1.5px; transition: all .2s; }
.modal-btn-save { background: var(--brand); color: var(--black); }
.modal-btn-save:hover { background: var(--brand-light); }
.modal-btn-cancel { background: none; border: 1px solid var(--border2); color: var(--muted); }
.modal-btn-cancel:hover { border-color: var(--text); color: var(--text); }

/* ════ MOBILE ════ */
@media (max-width: 700px) {
  .topbar { font-size: 9px; letter-spacing: 1px; padding: 6px 14px; line-height: 1.4; }
  .header { padding: 10px 14px; gap: 10px; }
  .header-logo-img { height: 38px; }
  .header-badge { font-size: 10px; padding: 4px 8px; letter-spacing: 1px; }
  .header-right { gap: 8px; }
  #logout-btn { font-size: 11px; padding: 4px 9px; }
  #config-btn { font-size: 11px; padding: 4px 9px; }
  .wrap { padding: 18px 14px; }
  .grid-2 { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .modal { padding: 28px 20px; }
  .card-section { padding: 16px 14px; }
  /* La tabla de ítems no entra en el ancho de un celular: cada fila pasa
     a apilarse como una mini-tarjeta (sin scroll horizontal). */
  .items-table thead { display: none; }
  .items-table, .items-table tbody, .items-table tr, .items-table td { display: block; width: 100%; }
  .items-table tr { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; margin-bottom: 10px; }
  .items-table td { padding: 6px 2px; }
  .items-table td[data-label]::before { content: attr(data-label); display: block; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 4px; }
  .items-table .item-sub { text-align: left; }
  .items-table .del-btn { width: 100%; padding: 8px; }
  .totals-block { flex-wrap: wrap; gap: 18px; justify-content: space-between; }
  .send-row { flex-direction: column; align-items: stretch; }
  .send-row button { justify-content: center; }
}
