/* Estilo P&S: mismos colores que P&S Finanzas y el portal. */
:root {
  --azul: #5A93C9;
  --azul-d: #3f74a6;
  --azul-bg: #e7f0f9;
  --oscuro: #242734;
  --oscuro-2: #131521;
  --gris: #727176;
  --gris-cl: #f4f6f9;
  --linea: #e3e7ee;
  --verde: #2e9e6b;
  --verde-bg: #e6f5ee;
  --amar: #c9962b;
  --amar-bg: #fbf3e0;
  --rojo: #c0453b;
  --rojo-bg: #f8e7e5;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--gris-cl);
  color: var(--oscuro);
}
a { color: var(--azul-d); }

/* ---------- barra superior ---------- */
.bar { background: var(--oscuro); color: #cfd4de; }
.bar-inner, .tabs-inner, main { max-width: 1160px; margin: 0 auto; padding: 0 22px; }
.bar-inner { display: flex; align-items: center; gap: 16px; min-height: 64px; flex-wrap: wrap; padding-top: 10px; padding-bottom: 10px; }
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; }
.logo { width: 36px; height: 36px; border-radius: 8px; background: var(--azul); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 14px; flex: none; }
.brand b { display: block; color: #fff; font-size: 16px; }
.brand small { display: block; color: #9aa0af; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; margin-top: 2px; }
.top-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.top-actions label { flex-direction: row; align-items: center; gap: 6px; color: #9aa0af; }
.top-actions select { background: #31344a; color: #fff; border-color: #3a3d4c; font-weight: bold; max-width: 240px; }
.top-actions .note { color: #9aa0af; }
.top-actions button.ghost { color: #fff; border-color: #4a4e60; background: transparent; }
.top-actions button.ghost:hover { background: #31344a; }

.tabs { background: #fff; border-bottom: 1px solid var(--linea); margin-bottom: 22px; }
.tabs-inner { display: flex; gap: 2px; overflow-x: auto; }
.tab { background: none; color: var(--gris); border: 0; border-bottom: 3px solid transparent; border-radius: 0; padding: 14px 14px 11px; white-space: nowrap; }
.tab:hover { color: var(--oscuro); background: none; }
.tab.active { color: var(--azul-d); border-bottom-color: var(--azul); background: none; }

main { padding-bottom: 48px; }

/* ---------- controles ---------- */
h2 { margin: 0 0 12px; font-size: 16px; }
h3 { margin: 22px 0 8px; font-size: 13px; color: var(--azul-d); text-transform: uppercase; letter-spacing: .04em; }
.row, .form-grid { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.row.between { justify-content: space-between; align-items: center; margin: 4px 0 10px; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: bold; color: var(--gris); }
input, select, textarea, button {
  font: inherit;
  font-size: 14px;
  border: 1px solid var(--linea);
  background: #fff;
  border-radius: 8px;
  padding: 9px 11px;
  color: var(--oscuro);
}
label input, label select, label textarea { font-weight: normal; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--azul); outline-offset: -1px; border-color: var(--azul); }
textarea { min-height: 72px; width: 100%; }
button { cursor: pointer; background: var(--azul); color: #fff; border: 0; font-weight: bold; }
button:hover { background: var(--azul-d); }
button:disabled { opacity: .55; cursor: progress; }
button.ghost { background: #fff; color: var(--azul-d); border: 1px solid var(--azul); }
button.ghost:hover { background: #eef5fc; }
button.warn { background: var(--rojo); }
button.ghost.warn { background: #fff; color: var(--rojo); border-color: #e6b8b3; }
button.ghost.warn:hover { background: var(--rojo-bg); }
button.small { padding: 5px 10px; font-size: 12px; }

/* ---------- tarjetas y tablas ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin-bottom: 18px; }
.card, .panel { background: #fff; border: 1px solid var(--linea); border-radius: 12px; }
.card { padding: 14px 16px; }
.panel { padding: 18px 20px; margin-bottom: 18px; }
.card span { color: var(--gris); font-size: 12px; }
.card strong { display: block; font-size: 24px; margin: 4px 0; font-variant-numeric: tabular-nums; }
.card.alert { background: var(--rojo-bg); border-color: #efc9c4; }
.card.alert strong { color: var(--rojo); }
.note { color: var(--gris); font-size: 12px; }
.note.error { color: var(--rojo); }
.panel.narrow { max-width: 380px; margin: 0 auto; }
.form-grid label { flex: 1 1 180px; }
.form-grid label.wide { flex: 2 1 320px; }
.form-grid label.full { flex: 1 1 100%; }
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--linea); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--linea); font-size: 13px; vertical-align: top; }
thead th { background: var(--gris-cl); font-size: 11px; color: var(--gris); text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafcff; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.neg { color: var(--rojo); }
.breakdown-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px 28px; }
.breakdown h3 { margin: 4px 0 10px; }
.bd-row { margin-bottom: 10px; }
.bd-label, .bd-meta { display: flex; justify-content: space-between; gap: 10px; }
.bd-label { font-size: 13px; font-weight: bold; }
.bd-label span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bd-meta { font-size: 11px; color: var(--gris); margin-top: 3px; }
.bd-bar { height: 7px; background: var(--gris-cl); border-radius: 4px; overflow: hidden; margin-top: 4px; }
.bd-bar span { display: block; height: 100%; background: var(--azul); border-radius: 4px; }
.actions { white-space: nowrap; text-align: right; }
.actions button + button { margin-left: 6px; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; background: var(--amar-bg); color: var(--amar); font-size: 11px; font-weight: bold; white-space: nowrap; }
.badge.late { background: var(--rojo-bg); color: var(--rojo); }
.badge.ok { background: var(--verde-bg); color: var(--verde); }

.section-title { margin: 0; }
.attachment { display: inline-flex; align-items: center; gap: 2px; margin: 0 6px 3px 0; font-size: 12px; white-space: nowrap; }
.attachment a { color: var(--azul-d); text-decoration: none; }
.attachment a:hover { text-decoration: underline; }
.link-x { background: none; color: var(--gris); padding: 0 3px; font-size: 11px; font-weight: normal; }
.link-x:hover { background: none; color: var(--rojo); }
.small-upload { display: inline-flex; flex-direction: row; align-items: center; cursor: pointer; padding: 5px 10px; font-size: 12px; font-weight: bold; color: var(--azul-d); border: 1px solid var(--azul); border-radius: 8px; background: #fff; margin-right: 6px; }
.small-upload:hover { background: #eef5fc; }
.small-upload.busy { opacity: .5; pointer-events: none; }
.group-title { flex: 1 1 100%; margin: 10px 0 -4px; padding-top: 10px; border-top: 1px solid var(--linea); font-size: 11px; font-weight: bold; color: var(--azul-d); text-transform: uppercase; letter-spacing: .05em; }
.form-grid .group-title:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.full-row { flex: 1 1 100%; margin: 0; }
.img-preview { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.img-preview img { max-height: 54px; max-width: 140px; border: 1px solid var(--linea); border-radius: 6px; background: #fff; padding: 3px; }
.img-preview small { font-size: 10px; color: var(--gris); }
tr.active-row td { background: var(--azul-bg); }
.new-foundation { border-top: 4px solid var(--azul); }

/* ---------- memoria ---------- */
.report header { border-bottom: 3px solid var(--azul); padding-bottom: 10px; margin-bottom: 6px; }
.report header h2 { font-size: 20px; margin-bottom: 4px; }
.report header p { margin: 3px 0; }
.report table.compact td, .report table.compact th { padding: 5px 8px; font-size: 13px; }
.report table.compact thead th { background: none; }
.report tr.total td { font-weight: bold; border-top: 2px solid var(--oscuro); }
.signatures { display: flex; gap: 48px; margin-top: 72px; flex-wrap: wrap; }
.signatures div { flex: 1 1 200px; font-size: 13px; }
.signatures span { display: block; border-top: 1px solid var(--oscuro); margin-bottom: 6px; }

/* ---------- ingreso ---------- */
/* Igual que el portal de clientes P&S. */
body.is-login { min-height: 100vh; background: linear-gradient(135deg, #242734 0%, #5A93C9 100%); }
body.is-login .bar { display: none; }
body.is-login main { max-width: none; min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
body.is-login main > .panel { max-width: 460px; width: 100%; }
.login-box { display: flex; width: 100%; max-width: 930px; align-items: stretch; gap: 28px; }
.login-box.single { justify-content: center; }
.forgot { margin: 6px 0 0; text-align: right; font-size: 13px; }
.forgot a { color: var(--azul-d); }
.forgot-form { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; padding: 14px; background: #f4f7fc; border-radius: 10px; }
.forgot-form[hidden] { display: none; }
.login-promo { flex: 1; color: #fff; display: flex; flex-direction: column; justify-content: center; padding: 20px 6px; }
.promo-logo { background: #fff; border-radius: 14px; padding: 12px 16px; width: fit-content; margin-bottom: 22px; }
.promo-logo img { height: 92px; width: auto; display: block; }
.login-promo h2 { font-size: 25px; line-height: 1.2; margin: 0 0 10px; }
.login-promo .lead { font-size: 14.5px; opacity: .92; line-height: 1.6; margin: 0 0 22px; max-width: 430px; }
.promo-serv { list-style: none; display: flex; flex-direction: column; gap: 10px; margin: 0 0 24px; padding: 0; }
.promo-serv li { display: flex; align-items: center; gap: 11px; font-size: 14px; opacity: .96; }
.promo-serv .ic { width: 30px; height: 30px; border-radius: 8px; background: rgba(255, 255, 255, .16); display: flex; align-items: center; justify-content: center; font-size: 15px; flex-shrink: 0; }
.promo-badges { display: inline-block; width: fit-content; background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .25); border-radius: 9px; padding: 9px 14px; font-size: 12.5px; font-weight: bold; margin-bottom: 22px; }
.promo-contact { font-size: 13px; opacity: .9; line-height: 1.85; border-top: 1px solid rgba(255, 255, 255, .22); padding-top: 15px; }
.promo-contact a { color: #fff; text-decoration: underline; text-underline-offset: 2px; }
.login-card { background: #fff; border-radius: 18px; width: 100%; max-width: 400px; flex-shrink: 0; padding: 42px 38px; box-shadow: 0 24px 60px rgba(20, 40, 70, .32); }
.login-tag { display: inline-block; background: var(--azul); color: #fff; font-size: 12px; font-weight: bold; letter-spacing: 1.5px; text-transform: uppercase; padding: 5px 13px; border-radius: 8px; margin-bottom: 14px; }
.login-card h1 { font-size: 21px; margin: 0 0 4px; }
.login-card .sub { color: var(--gris); font-size: 13.5px; margin: 0 0 22px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; }
.login-card label { font-size: 13px; font-weight: normal; color: var(--gris); }
.login-card input { width: 100%; padding: 12px 14px; background: #f4f7fc; border-color: #e2e8f2; }
.pwd-wrap { position: relative; display: block; }
.pwd-wrap input { padding-right: 44px; }
.pwd-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: none; color: var(--gris); padding: 6px 8px; font-size: 16px; }
.pwd-toggle:hover { background: none; color: var(--oscuro); }
.login-btn { width: 100%; padding: 13px; font-size: 15px; border-radius: 10px; margin-top: 4px; }
.login-card .error { min-height: 14px; margin: 10px 0 0; }
.hint { margin-top: 10px; background: #f4f7fc; border-radius: 10px; padding: 12px 14px; font-size: 13px; color: var(--gris); line-height: 1.55; }
.hint b { color: var(--oscuro); }
.wa-btn { display: flex; align-items: center; justify-content: center; gap: 9px; width: 100%; margin-top: 14px; padding: 12px; border-radius: 10px; background: #25D366; color: #fff; font-weight: bold; font-size: 14px; text-decoration: none; box-shadow: 0 4px 14px rgba(37, 211, 102, .3); }
.wa-btn:hover { background: #1eb85a; }
.privacidad { margin: 16px 0 0; text-align: center; font-size: 11.5px; color: var(--gris); }
@media (max-width: 800px) {
  .login-box { flex-direction: column-reverse; max-width: 440px; gap: 22px; }
  .login-promo { padding: 6px 8px; text-align: center; align-items: center; }
  .login-promo .lead { max-width: none; }
  .promo-serv { align-items: flex-start; text-align: left; }
  .promo-contact { width: 100%; }
  .login-card { padding: 32px 22px; }
}

/* Logo en la barra oscura */
.logo-img { background: #fff; border-radius: 8px; padding: 2px; display: flex; }
.logo-img img { height: 40px; width: auto; display: block; }

@media (max-width: 640px) {
  .bar-inner, .tabs-inner, main { padding: 0 16px; }
  .bar-inner { padding-top: 10px; padding-bottom: 10px; }
}
@media print {
  .bar, .tabs, form, button, .noprint { display: none !important; }
  body { background: #fff; }
  .report { border: 0; padding: 0; }
}
