/* Presupuestos Pro — Portal CSS — Standalone page, no theme conflicts */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body.ppp-standalone {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
  color: #1e293b;
  background: #f1f5f9;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* HEADER */
.ppp-standalone-header {
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 14px 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.ppp-standalone-header-inner {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
}
.ppp-standalone-logo { max-height: 36px; display: block; }
.ppp-standalone-company { color: #fff; font-weight: 700; font-size: 16px; }

/* BODY */
.ppp-standalone-body {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px 16px 120px;
}

/* CARDS */
.ppp-portal-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  border: 1px solid #e8eaed;
}
.ppp-portal-card h3 {
  font-size: 15px;
  font-weight: 700;
  color: #1a3c5e;
  margin-bottom: 16px;
}
.ppp-portal-card h4 {
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  margin: 16px 0 10px;
}

/* FIELDS */
.ppp-portal-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 100%;
}
.ppp-portal-field label {
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.ppp-portal-field input,
.ppp-portal-field select,
.ppp-portal-field textarea {
  width: 100%;
  padding: 12px 14px;
  font-size: 15px;
  color: #1e293b;
  background: #fff;
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  font-family: inherit;
}
.ppp-portal-field input:focus,
.ppp-portal-field select:focus,
.ppp-portal-field textarea:focus {
  border-color: #1a3c5e;
  box-shadow: 0 0 0 3px rgba(26,60,94,.1);
}

/* SELECT arrow */
.ppp-portal-field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath fill='%2364748b' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
  cursor: pointer;
}

/* ROW — single column on mobile, 2 col on tablet+ */
.ppp-portal-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 12px;
}
@media(min-width: 600px) {
  .ppp-portal-row { flex-direction: row; flex-wrap: wrap; }
  .ppp-portal-row .ppp-portal-field { flex: 1; min-width: 140px; }
  .ppp-portal-row .ppp-fw { flex: 2; }
  .ppp-portal-row .ppp-sm { flex: 0 0 100px; }
}

.ppp-portal-check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  margin-top: 8px;
  cursor: pointer;
}
.ppp-portal-check input[type=checkbox] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  -webkit-appearance: checkbox;
  appearance: checkbox;
}

/* SAVE BAR */
.ppp-portal-save-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 200;
  background: #1a3c5e;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 -4px 12px rgba(0,0,0,.2);
}
#ppp-portal-save-status {
  flex: 1;
  font-size: 13px;
  color: rgba(255,255,255,.85);
  min-width: 0;
}

/* BUTTONS */
.ppp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  white-space: nowrap;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}
.ppp-btn-primary   { background: #2563eb; color: #fff; }
.ppp-btn-secondary { background: rgba(255,255,255,.15); color: #fff; border: 1px solid rgba(255,255,255,.3); }
.ppp-btn-outline   { background: #fff; color: #1a3c5e; border: 2px solid #1a3c5e; }
.ppp-btn-whatsapp  { background: #25d366; color: #fff; }
.ppp-btn-email     { background: #ea4335; color: #fff; }
.ppp-btn-danger    { background: #fee2e2; color: #dc2626; }
.ppp-btn-sm        { padding: 7px 12px; font-size: 13px; }
.ppp-btn-full      { width: 100%; padding: 14px; font-size: 16px; margin-top: 10px; border-radius: 10px; }

/* PORTAL HEADER BAR */
.ppp-portal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  gap: 12px;
  flex-wrap: wrap;
}
.ppp-portal-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ppp-portal-header-left h2 {
  font-size: 18px;
  font-weight: 700;
  color: #1a3c5e;
}
.ppp-portal-header-right {
  display: flex;
  gap: 8px;
}

/* TABS */
.ppp-portal-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.ppp-portal-tab {
  padding: 8px 18px;
  border-radius: 20px;
  border: 2px solid #e2e8f0;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  font-family: inherit;
}
.ppp-portal-tab.active { background: #1a3c5e; color: #fff; border-color: #1a3c5e; }

/* CATEGORY TABS */
.ppp-portal-cat-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}
.ppp-portal-cat-tab {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  border: 2px solid #e2e8f0;
  background: #fff;
  cursor: pointer;
  color: #64748b;
  font-family: inherit;
}
.ppp-portal-cat-tab.active { background: #1a3c5e; color: #fff; border-color: #1a3c5e; }
.ppp-portal-cat-panel { display: none; }
.ppp-portal-cat-panel.active { display: block; }
.ppp-portal-cat-subtotal { text-align: right; padding: 8px 0; font-size: 13px; color: #64748b; }
.ppp-portal-cat-subtotal strong { color: #1a3c5e; font-size: 15px; }

/* LINES TABLE */
.ppp-portal-table-wrap { overflow-x: auto; margin-bottom: 8px; -webkit-overflow-scrolling: touch; }
.ppp-portal-lines-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 480px; }
.ppp-portal-lines-table th {
  background: #f8fafc;
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 8px 6px;
  border-bottom: 2px solid #e2e8f0;
  white-space: nowrap;
  letter-spacing: .04em;
}
.ppp-portal-lines-table td { padding: 6px 4px; border-bottom: 1px solid #f0f0f0; vertical-align: middle; }
.ppp-portal-lines-table input {
  width: 100%;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 7px 8px;
  font-size: 13px;
  background: #fff;
  font-family: inherit;
  outline: none;
}
.ppp-portal-lines-table input:focus { border-color: #1a3c5e; }
.ppp-portal-lines-table .subtotal-cell { font-weight: 700; text-align: right; color: #1a3c5e; white-space: nowrap; }
.ppp-portal-lines-table .btn-delete-line {
  background: none;
  border: none;
  color: #dc2626;
  cursor: pointer;
  font-size: 18px;
  padding: 4px 8px;
  border-radius: 4px;
  font-family: inherit;
}
.ppp-portal-lines-table .btn-delete-line:active { background: #fee2e2; }

/* TOTALS */
.ppp-portal-totals-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.ppp-portal-totals-table td { padding: 8px 4px; border-bottom: 1px solid #f0f0f0; }
.ppp-portal-totals-table td:last-child { text-align: right; font-weight: 600; color: #1a3c5e; }
.ppp-total-sep td { border-top: 2px solid #e2e8f0; padding-top: 10px; }
.ppp-total-grand td { font-size: 18px !important; color: #1a3c5e; }

/* SHARE */
.ppp-portal-share { margin-top: 16px; padding-top: 16px; border-top: 1px solid #e2e8f0; }
.ppp-portal-share p { font-size: 12px; color: #64748b; margin-bottom: 6px; }
.ppp-portal-share input { width: 100%; font-size: 12px; padding: 8px 10px; border: 1px solid #e2e8f0; border-radius: 6px; margin-bottom: 6px; font-family: inherit; outline: none; }

/* LIST */
.ppp-portal-list { display: flex; flex-direction: column; gap: 10px; }
.ppp-portal-doc-card {
  background: #fff;
  border: 1px solid #e8eaed;
  border-radius: 12px;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.ppp-doc-info h4 { font-size: 15px; font-weight: 700; color: #1a3c5e; margin-bottom: 4px; }
.ppp-doc-info p { font-size: 13px; color: #64748b; }
.ppp-doc-total { font-size: 20px; font-weight: 700; color: #1a3c5e; text-align: right; }
.ppp-doc-total small { display: block; font-size: 11px; color: #64748b; font-weight: 400; }
.ppp-doc-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* BADGES */
.ppp-badge { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 11px; font-weight: 700; text-transform: uppercase; margin-left: 6px; }
.ppp-badge-quote    { background: #dbeafe; color: #1e40af; }
.ppp-badge-invoice  { background: #fef3c7; color: #92400e; }
.ppp-badge-draft    { background: #f1f5f9; color: #475569; }
.ppp-badge-sent     { background: #dbeafe; color: #1e40af; }
.ppp-badge-accepted { background: #dcfce7; color: #166534; }
.ppp-badge-rejected { background: #fee2e2; color: #991b1b; }

/* LOADING */
.ppp-portal-loading { text-align: center; padding: 40px; }
.ppp-spinner { width: 32px; height: 32px; border: 3px solid #e2e8f0; border-top-color: #1a3c5e; border-radius: 50%; animation: ppp-spin .8s linear infinite; margin: 0 auto 12px; }
@keyframes ppp-spin { to { transform: rotate(360deg); } }

/* PAGINATION */
.ppp-portal-pagination { display: flex; gap: 6px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.ppp-portal-pagination button { padding: 8px 14px; border: 1px solid #e2e8f0; border-radius: 6px; background: #fff; cursor: pointer; font-size: 13px; font-family: inherit; }
.ppp-portal-pagination button.active { background: #1a3c5e; color: #fff; border-color: #1a3c5e; }

/* EMPTY STATE */
.ppp-portal-empty { text-align: center; padding: 60px 20px; color: #64748b; }
.ppp-portal-empty p { font-size: 16px; margin-bottom: 16px; }

/* LOGIN */
.ppp-portal-login { max-width: 380px; margin: 40px auto; background: #fff; border-radius: 16px; overflow: hidden; box-shadow: 0 4px 24px rgba(0,0,0,.1); }
.ppp-portal-logo { padding: 32px 24px; text-align: center; color: #fff; }
.ppp-portal-logo img { max-height: 60px; margin: 0 auto 12px; display: block; }
.ppp-portal-logo h1 { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.ppp-portal-logo p { opacity: .8; font-size: 13px; }
.ppp-login-form { padding: 24px; }
.ppp-portal-error { background: #fee2e2; color: #991b1b; padding: 12px 16px; font-size: 13px; border-left: 4px solid #dc2626; }

/* EDITOR LAYOUT */
.ppp-portal-editor { display: flex; flex-direction: column; gap: 0; }
.ppp-portal-totals { margin-top: 0; }

@media(min-width: 900px) {
  .ppp-portal-editor { display: grid; grid-template-columns: 1fr 280px; gap: 16px; align-items: start; }
  .ppp-portal-totals { position: sticky; top: 80px; }
}

/* Mobile save bar */
@media(max-width: 480px) {
  .ppp-portal-save-bar { flex-wrap: wrap; padding: 10px 12px; gap: 6px; }
  .ppp-btn { padding: 9px 12px; font-size: 13px; }
  #ppp-portal-save-status { order: -1; width: 100%; font-size: 12px; }
}

/* Line item cards - each field on its own row */
.ppp-line-card {
  border: 1px solid #94a3b8;
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 12px;
  background: #f8fafc;
}
.ppp-line-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}
.ppp-line-field:last-child { margin-bottom: 0; }
.ppp-line-label {
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.ppp-line-field input {
  width: 100%;
  padding: 10px 12px;
  font-size: 15px;
  border: 1.5px solid #94a3b8;
  border-radius: 7px;
  background: #fff;
  font-family: inherit;
  outline: none;
}
.ppp-line-field input:focus { border-color: #1a3c5e; box-shadow: 0 0 0 3px rgba(26,60,94,.1); }
.ppp-line-subtotal .subtotal-cell {
  font-size: 18px;
  font-weight: 700;
  color: #1a3c5e;
  padding: 6px 0;
  display: block;
}
.ppp-line-delete .btn-delete-line {
  background: #fee2e2;
  color: #dc2626;
  border: none;
  border-radius: 7px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  font-family: inherit;
}

/* Hide old table */
.ppp-portal-table-wrap { display: none !important; }

/* Company info in header - right side */
.ppp-standalone-header-inner { justify-content: space-between; }
.ppp-standalone-company-info { 
  text-align: right; 
  color: rgba(255,255,255,.9); 
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-left: auto;
}
.ppp-standalone-company { font-size: 16px; }
@media(max-width:600px) {
  .ppp-standalone-company-info { display: none; }
}