:root {
  --navy: #1d2a3b;
  --navy-2: #26364b;
  --teal: #0e756e;
  --teal-2: #0b5f59;
  --teal-soft: #f3f9f8;
  --teal-line: #cfe6e2;
  --ink: #1d2a3b;
  --ink-2: #46505e;
  --ink-3: #8a929c;
  --line: #e6e9ed;
  --line-2: #eef1f4;
  --bg: #f6f7f9;
  --card: #ffffff;
  --red: #c0392b;
  --amber: #b7791f;
  --radius: 10px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: var(--bg); color: var(--ink); font: 14px/1.45 'Helvetica Neue', Arial, sans-serif; }
a { color: var(--teal); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { padding: 40px; color: var(--ink-3); }

/* ---------- logo ---------- */
.logo { font-weight: 800; letter-spacing: -0.5px; color: var(--navy); font-size: 22px; }
.logo .m { color: var(--teal); }
.side .logo { color: #fff; }
.side .logo .m { color: #5fc4ba; }
.brandbar { display: flex; align-items: center; gap: 10px; }
.logo-ico { width: 42px; height: auto; flex: none; }
.auth-logo { display: block; width: 150px; margin: 0 auto 6px; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--navy); color: #c9d2dd; padding: 22px 14px; display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100vh; }
.side .tag { font-size: 10px; letter-spacing: 1.6px; color: #7f8ea1; font-weight: 700; margin-top: 2px; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { color: #c9d2dd; padding: 9px 12px; border-radius: 8px; font-weight: 500; display: flex; align-items: center; gap: 10px; }
.side nav a:hover { background: var(--navy-2); color: #fff; }
.side nav a.on { background: var(--teal); color: #fff; }
.side .new { background: #fff; color: var(--navy); font-weight: 700; text-align: center; padding: 10px; border-radius: 8px; }
.side .new:hover { background: var(--teal-soft); }
.side .foot { margin-top: auto; font-size: 12px; color: #7f8ea1; }
.side .foot button { background: none; border: 0; color: #c9d2dd; cursor: pointer; padding: 0; text-decoration: underline; }
main { padding: 26px 32px 60px; min-width: 0; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.crumb { font-size: 12px; color: var(--ink-3); }
h1 { font-size: 22px; font-weight: 800; letter-spacing: -0.3px; }
h2 { font-size: 13px; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase; color: var(--ink-2); margin-bottom: 14px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- buttons ---------- */
.btn { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 8px 14px; cursor: pointer; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { border-color: #c7ccd3; }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.primary:hover { background: var(--teal-2); }
.btn.dark { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.danger { color: var(--red); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: 0; color: var(--teal); cursor: pointer; font-weight: 600; padding: 0; }

/* ---------- cards & forms ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.span3 { grid-column: span 3; }
label.f { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); }
label.f .req { color: var(--red); }
label.f > input, label.f > select, label.f > textarea, label.f > div { margin-top: 5px; }
input, select, textarea { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--teal-line); border-color: var(--teal); }
textarea { resize: vertical; min-height: 38px; }
.hint { font-size: 12px; color: var(--ink-3); font-weight: 400; }
.chips { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 3px 10px; font-size: 12px; cursor: pointer; }
.chip:hover { border-color: var(--teal); color: var(--teal); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 11px; letter-spacing: .8px; text-transform: uppercase; color: var(--ink-3); font-weight: 700; padding: 10px; border-bottom: 1.5px solid var(--line); white-space: nowrap; }
table.list td { padding: 11px 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.list tr.click { cursor: pointer; }
table.list tr.click:hover td { background: var(--teal-soft); }
table.list .r { text-align: right; white-space: nowrap; }
table.list tfoot td { font-weight: 800; border-bottom: 0; border-top: 1.5px solid var(--line); }
.empty { padding: 34px; text-align: center; color: var(--ink-3); }
.mono { font-variant-numeric: tabular-nums; }
.code { font-weight: 700; color: var(--navy); }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; }
.badge.draft { background: #eef1f4; color: var(--ink-2); }
.badge.pending { background: #fff4e0; color: var(--amber); }
.badge.paid { background: #e3f4f1; color: var(--teal); }
.badge.overdue { background: #fde8e6; color: var(--red); }
.badge.invoiced { background: #e6ecf5; color: var(--navy, #1d3557); }
select.btn { appearance: auto; padding-right: 8px; width: auto; }

/* ---------- filters ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.filters select, .filters input { width: auto; }
.filters input[type=search] { min-width: 240px; }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.kpi .l { font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--ink-3); font-weight: 700; }
.kpi .v { font-size: 24px; font-weight: 800; margin-top: 6px; letter-spacing: -.3px; }
.kpi .s { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.kpi.accent .v { color: var(--teal); }

/* ---------- invoice lines editor ---------- */
table.lines { width: 100%; border-collapse: collapse; }
table.lines th { font-size: 11px; letter-spacing: .8px; text-transform: uppercase; color: var(--ink-3); text-align: left; padding: 0 6px 8px; font-weight: 700; }
table.lines td { padding: 4px 6px; vertical-align: top; }
table.lines td.amt { text-align: right; font-weight: 700; padding-top: 12px; white-space: nowrap; }
table.lines .w-price { width: 120px; }
table.lines .w-qty { width: 90px; }
table.lines .w-disc { width: 80px; }
table.lines .w-tax { width: 96px; }
table.lines .w-amt { width: 110px; }
table.lines .w-x { width: 34px; }
@media (max-width: 960px) {
  table.lines .w-price { width: 84px; } table.lines .w-qty { width: 60px; } table.lines .w-disc { width: 56px; }
  table.lines .w-tax { width: 76px; } table.lines .w-amt { width: 84px; } table.lines td, table.lines th { padding-left: 3px; padding-right: 3px; }
}
.x { border: 0; background: none; color: var(--ink-3); cursor: pointer; font-size: 18px; padding: 6px; }
.x:hover { color: var(--red); }
.sum { margin-left: auto; width: 320px; margin-top: 16px; }
.sum .row { display: flex; justify-content: space-between; padding: 5px 0; }
.sum .row.igic { color: var(--teal); font-weight: 700; }
.sum .row.tot { border-top: 1.5px solid var(--line); margin-top: 6px; padding-top: 10px; font-size: 18px; font-weight: 800; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth .box { width: 100%; max-width: 380px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 30px; }
.auth .box .logo { font-size: 28px; }
.auth .box p { color: var(--ink-3); margin: 6px 0 22px; }
.auth form { display: grid; gap: 12px; }
.auth .switch { margin-top: 14px; font-size: 13px; color: var(--ink-3); text-align: center; }
.err { color: var(--red); font-size: 13px; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 10px 18px; border-radius: 8px; font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,.18); z-index: 50; }
.toast.bad { background: var(--red); }

/* ---------- invoice document (mismo diseño que los presupuestos) ---------- */
.doc-wrap { display: flex; justify-content: center; }
.doc { --py: 18mm; --px: 16mm; width: 210mm; min-height: 297mm; background: #fff; padding: var(--py) var(--px); -webkit-print-color-adjust: exact; print-color-adjust: exact; color: #1d2a3b; font-size: 11px; box-shadow: 0 2px 18px rgba(29,42,59,.08); border: 1px solid var(--line); position: relative; }
.doc .header { display: flex; justify-content: space-between; align-items: flex-start; }
.doc .logo { font-size: 30px; }
.doc .company { margin-top: 8px; color: #46505e; font-size: 10.5px; line-height: 1.55; }
.doc .doc-title { font-size: 30px; font-weight: 800; color: var(--teal); text-align: right; letter-spacing: .5px; }
.doc .doc-meta { text-align: right; margin-top: 6px; font-size: 11px; line-height: 1.6; }
.doc .doc-meta .num { font-weight: 700; }
.doc .rule { height: 3px; background: var(--teal); margin: 16px 0 0; border-radius: 2px; }
.doc .cliente { display: flex; justify-content: space-between; align-items: flex-start; margin-top: 22px; gap: 20px; }
.doc .lbl { font-size: 9px; letter-spacing: 1.5px; color: #8a929c; font-weight: 700; }
.doc .cliente .name { font-size: 14px; font-weight: 700; margin-top: 5px; }
.doc .cliente .sub { color: #5b646f; margin-top: 3px; font-size: 10.5px; line-height: 1.55; }
.doc .cliente .right { text-align: right; color: #5b646f; font-size: 10.5px; line-height: 1.6; padding-top: 14px; }
.doc table { width: 100%; border-collapse: collapse; margin-top: 26px; }
.doc thead th { font-size: 9.5px; letter-spacing: 1px; color: #8a929c; font-weight: 700; text-align: left; padding-bottom: 14px; border-bottom: 1.5px solid #e6e9ed; }
.doc th.c, .doc td.c { text-align: center; }
.doc th.r { text-align: right; }
.doc tbody td { padding: 13px 0; border-bottom: 1px solid #eef1f4; font-size: 10.5px; color: #46505e; vertical-align: top; white-space: pre-line; }
.doc tbody td.r { text-align: right; font-weight: 700; color: #1d2a3b; white-space: nowrap; }
.doc tbody td.n { text-align: right; white-space: nowrap; }
.doc .totals { margin-top: 22px; margin-left: 42%; }
.doc .totals .row { display: flex; justify-content: space-between; padding: 5px 0; font-size: 12px; font-weight: 700; }
.doc .totals .row.igic { color: var(--teal); }
.doc .total-box { display: flex; justify-content: space-between; align-items: center; background: #f3f9f8; border: 1px solid #cfe6e2; border-radius: 10px; padding: 18px 24px; margin-top: 14px; }
.doc .total-box .l { font-size: 11px; font-weight: 800; letter-spacing: .5px; line-height: 1.25; }
.doc .total-box .v { font-size: 34px; font-weight: 800; color: var(--teal); font-style: italic; letter-spacing: -.5px; }
.doc .dashed { border-top: 1.5px dashed #c7ccd3; margin: 34px 0 0; }
.doc .pay { display: flex; gap: 16px; margin-top: 18px; }
.doc .pay .box { flex: 1; border: 1px solid #e3e7ec; border-radius: 10px; padding: 14px 16px; line-height: 1.6; font-size: 10.5px; color: #46505e; }
.doc .pay .box b { color: #1d2a3b; }
.doc .pay .lbl { color: var(--teal); margin-bottom: 4px; }
.doc .notes { margin-top: 16px; color: #46505e; font-size: 10.5px; line-height: 1.6; white-space: pre-line; }
.doc .footer { margin-top: 34px; text-align: center; color: #9aa2ab; font-size: 9px; letter-spacing: .3px; white-space: pre-line; }
.doc .totals { position: relative; }
.doc .stamp { position: absolute; top: 18px; left: -62%; transform: rotate(-12deg); border: 3px solid var(--teal); color: var(--teal); font-weight: 800; letter-spacing: 2px; padding: 6px 14px; border-radius: 8px; font-size: 18px; opacity: .55; }
.doc .stamp.draft { border-color: #8a929c; color: #8a929c; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px 16px; gap: 10px; }
  .side nav { flex-direction: row; flex-wrap: wrap; }
  .side .foot { margin: 0; }
  main { padding: 18px 16px 50px; }
  .kpis, .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g2 { grid-template-columns: 1fr; }
  .span2, .span3 { grid-column: auto; }
  .doc { --py: 22px; --px: 18px; width: 100%; min-height: 0; }
  .doc .totals { margin-left: 0; }
  .doc .stamp { position: static; display: inline-block; margin-bottom: 12px; }
}

@media print {
  @page { size: A4; margin: 0; }
  body { background: #fff; }
  .side, .topbar, .no-print, .toast { display: none !important; }
  .shell { display: block; }
  main { padding: 0; }
  .doc { box-shadow: none; border: 0; width: 210mm; min-height: 297mm; }
}

/* ---------- ventana de la Facturae ---------- */
dialog.modal { margin: auto; max-height: calc(100vh - 32px); overflow: auto; border: 0; border-radius: 14px; padding: 0; width: min(620px, calc(100vw - 32px)); box-shadow: 0 24px 60px rgba(0,0,0,.25); }
dialog.modal::backdrop { background: rgba(15, 30, 28, .45); }
dialog.modal form { padding: 22px; display: grid; gap: 14px; }
dialog.modal h2 { margin: 0; }
dialog.modal .hint { margin: 0; }
dialog.modal .seg { display: flex; gap: 8px; flex-wrap: wrap; }
dialog.modal .seg label { flex: 1; min-width: 200px; display: flex; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer; font-weight: 600; font-size: 14px; }
dialog.modal .seg label:has(input:checked) { border-color: var(--teal); background: var(--teal-soft); }
dialog.modal .seg input, dialog.modal .check input { width: auto; }
dialog.modal #fx { display: grid; gap: 12px; }
dialog.modal #fx[hidden] { display: none; }
dialog.modal .check { display: flex; gap: 8px; align-items: center; font-size: 13px; }
dialog.modal .actions.end { justify-content: flex-end; }
dialog.modal input[data-o] { margin-top: 6px; }
dialog.modal input[hidden] { display: none; }
dialog.modal .err { margin: 0; color: var(--red); font-weight: 600; font-size: 13px; }

/* ---------- diseños del documento ---------- */
/* Colores de marca sacados del logo de JLOPEZ.MEDIA */
.doc { --brand: #00c5ba; --brand-dark: #006053; }
.doc .lockup { display: flex; align-items: center; gap: 12px; }
.doc .lockup img { height: 58px; width: auto; }
.doc .lockup .logo { font-size: 28px; }
.doc .lockup .logo .m { color: var(--brand); }

/* Clásico: el de siempre con tu logo */
.d-clasico .company { margin-top: 10px; }

/* Moderno: cabecera a sangre con degradado de marca */
.d-moderno .band { margin: calc(-1 * var(--py)) calc(-1 * var(--px)) 0; padding: calc(var(--py) * .8) var(--px); background: linear-gradient(115deg, #0b3d36 0%, var(--brand-dark) 45%, var(--brand) 100%); color: #fff; display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.d-moderno .brand { display: flex; align-items: center; gap: 14px; }
.d-moderno .brand img { height: 52px; width: auto; background: #fff; border-radius: 12px; padding: 7px 9px; box-shadow: 0 4px 14px rgba(0,0,0,.18); }
.d-moderno .wm { font-size: 26px; font-weight: 800; letter-spacing: -.5px; color: #fff; }
.d-moderno .wm span { color: #7fe6dd; }
.d-moderno .doc-title { color: #fff; }
.d-moderno .doc-meta { color: #dff5f2; }
.d-moderno > .company { margin-top: 14px; }
.d-moderno > .company .sep { margin: 0 8px; color: var(--brand); font-weight: 700; }
.d-moderno .cliente { background: #f3f9f8; border-radius: 10px; padding: 14px 18px; margin-top: 18px; }
.d-moderno thead th { background: var(--brand-dark); color: #fff; padding: 9px 10px; border: 0; }
.d-moderno thead th:first-child { border-radius: 6px 0 0 6px; }
.d-moderno thead th:last-child { border-radius: 0 6px 6px 0; }
.d-moderno tbody td { padding: 11px 10px; }
.d-moderno tbody tr:nth-child(even) td { background: #f7fbfa; }
.d-moderno .total-box { background: linear-gradient(115deg, var(--brand-dark), var(--brand)); border: 0; color: #fff; }
.d-moderno .total-box .v { color: #fff; }
.d-moderno .totals .row.igic { color: var(--brand-dark); }

/* Minimal: logo centrado, gris y sin cajas */
.d-minimal { color: #2b2f33; }
.d-minimal .mini-logo { display: flex; justify-content: center; margin-bottom: 22px; }
.d-minimal .lockup { flex-direction: column; gap: 6px; }
.d-minimal .lockup img { height: 72px; }
.d-minimal .lockup .logo { font-size: 20px; letter-spacing: 3px; font-weight: 600; color: #2b2f33; }
.d-minimal .header { align-items: flex-end; }
.d-minimal .doc-title { color: #2b2f33; font-weight: 300; letter-spacing: 6px; font-size: 26px; }
.d-minimal .rule { height: 1px; background: #d7dbe0; }
.d-minimal thead th { border-bottom: 1px solid #2b2f33; color: #2b2f33; }
.d-minimal tbody td { border-bottom: 1px solid #eef0f2; }
.d-minimal .totals .row.igic { color: #2b2f33; }
.d-minimal .total-box { background: none; border: 0; border-top: 2px solid #2b2f33; border-radius: 0; padding: 14px 0 0; }
.d-minimal .total-box .v { color: var(--brand-dark); font-style: normal; font-weight: 700; }
.d-minimal .dashed { border-top: 1px solid #e6e9ed; }
.d-minimal .pay .box { border: 0; padding: 0; }
.d-minimal .pay .lbl { color: #8a929c; }

/* Lateral: franja de marca a la izquierda con el logo */
.d-lateral { padding-left: calc(var(--px) + 34mm); }
.d-lateral .lat-band { position: absolute; left: 0; top: 0; bottom: 0; width: 34mm; background: linear-gradient(180deg, #f3f9f8, #e2f3f1); border-right: 3px solid var(--brand); display: flex; justify-content: center; align-items: flex-start; padding-top: var(--py); }
.d-lateral .lat-band { flex-direction: column; align-items: center; justify-content: flex-start; gap: 14mm; }
.d-lateral .lat-band img { width: 24mm; height: auto; }
.d-lateral .vwm { writing-mode: vertical-rl; transform: rotate(180deg); font-size: 26px; font-weight: 800; letter-spacing: 2px; color: var(--brand-dark); }
.d-lateral .vwm span { color: var(--brand); }
.d-lateral .doc-title { color: var(--brand-dark); }
.d-lateral .rule { background: linear-gradient(90deg, var(--brand-dark), var(--brand)); }
.d-lateral thead th { color: var(--brand-dark); border-bottom-color: var(--brand); }
.d-lateral .totals { margin-left: 36%; }
@media (max-width: 760px) { .d-lateral { padding-left: calc(var(--px) + 70px); } .d-lateral .lat-band { width: 60px; } .d-lateral .lat-band img { width: 46px; } .d-lateral .vwm { font-size: 18px; } }

/* Miniaturas de Ajustes */
.designs { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.design { display: grid; gap: 4px; cursor: pointer; border: 2px solid var(--line); border-radius: 12px; padding: 10px; }
.design.on { border-color: var(--teal); background: var(--teal-soft); }
.design input { display: none; }
.design .thumb { aspect-ratio: 210 / 297; overflow: hidden; border-radius: 6px; border: 1px solid var(--line); background: #fff; position: relative; container-type: inline-size; }
.design .scale { width: 794px; transform-origin: 0 0; position: absolute; top: 0; left: 0; pointer-events: none; }
.design .doc-wrap { display: block; }
.design .doc { box-shadow: none; border: 0; }

/* ---------- propuesta de contrato menor ---------- */
.doc .sec-title { margin-top: 22px; background: linear-gradient(90deg, var(--brand-dark), #0e756e 70%, var(--brand)); color: #fff; font-weight: 800; font-size: 12px; letter-spacing: .6px; padding: 9px 14px; border-radius: 6px; text-transform: uppercase; }
.doc .intro { display: flex; gap: 26px; margin-top: 14px; }
.doc .intro .col { flex: 1; color: #46505e; line-height: 1.6; font-size: 10.5px; text-align: justify; }
.doc .intro b { color: #1d2a3b; }
.doc tbody td.inc { color: #0e756e; font-weight: 700; }
.doc .phases { display: flex; gap: 12px; margin-top: 12px; }
.doc .phase { flex: 1; border: 1px solid #d6ece9; border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; background: #fbfefd; break-inside: avoid; }
.doc .ph-head { background: var(--brand-dark); color: #fff; display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 11px 13px; border-bottom: 3px solid var(--brand); }
.doc .ph-name { font-size: 9.5px; font-weight: 800; letter-spacing: .4px; line-height: 1.35; text-transform: uppercase; }
.doc .ph-amt { font-size: 14px; font-weight: 800; white-space: nowrap; }
.doc .ph-desc { padding: 11px 13px 0; color: #5b646f; line-height: 1.55; font-size: 9.5px; flex: 1; }
.doc .ph-base { padding: 10px 13px 12px; font-size: 9px; font-weight: 800; color: #0e756e; letter-spacing: .3px; }
.doc .ph-act { padding: 0 13px 12px; }
.badge.cm { background: #e3f6f4; color: #006053; }
.phases-ed textarea { min-height: 52px; }
.phase-sum { margin-top: 10px; font-size: 13px; font-weight: 600; }
.phase-sum .ok { color: var(--teal); }
.phase-sum .bad { color: var(--red); }
@media (max-width: 760px) { .doc .phases, .doc .intro { flex-direction: column; } }

/* La propuesta de contrato menor cabe en un folio, como la que mandas a los ayuntamientos */
.doc.cm-doc { --py: 12mm; --px: 14mm; }
.cm-doc .lockup img { height: 46px; }
.cm-doc .lockup .logo { font-size: 24px; }
.cm-doc .doc-title { font-size: 26px; }
.cm-doc .company { margin-top: 6px; font-size: 9.5px; line-height: 1.45; }
.cm-doc .rule { margin-top: 10px; }
.cm-doc .cliente { margin-top: 12px; }
.cm-doc .cliente .right { padding-top: 10px; font-size: 9.5px; }
.cm-doc .sec-title { margin-top: 14px; padding: 7px 12px; font-size: 11px; }
.cm-doc .intro { margin-top: 10px; }
.cm-doc .intro .col { font-size: 9.5px; line-height: 1.5; }
.cm-doc table { margin-top: 12px; }
.cm-doc thead th { padding-bottom: 7px; }
.cm-doc tbody td { padding: 6px 0; font-size: 9.5px; }
.cm-doc .totals { margin-top: 10px; }
.cm-doc .totals .row { padding: 3px 0; font-size: 11px; }
.cm-doc .total-box { padding: 10px 18px; margin-top: 8px; }
.cm-doc .total-box .v { font-size: 26px; }
.cm-doc .phases { margin-top: 10px; }
.cm-doc .ph-desc { font-size: 9px; line-height: 1.45; padding-top: 8px; }
.cm-doc .ph-base { padding: 7px 13px 9px; }
.cm-doc .dashed { margin-top: 16px; }
.cm-doc .pay { margin-top: 10px; }
.cm-doc .pay .box { padding: 9px 14px; font-size: 9.5px; line-height: 1.5; }
.cm-doc .notes { margin-top: 10px; font-size: 9.5px; }
.cm-doc .footer { margin-top: 14px; }
.d-moderno.cm-doc .band { padding-top: 9mm; padding-bottom: 9mm; }
.d-minimal.cm-doc .mini-logo { margin-bottom: 10px; }
.d-minimal.cm-doc .lockup img { height: 54px; }
.cm-doc .ph-head { padding: 8px 11px; }
.cm-doc .doc-meta { line-height: 1.45; }
.d-lateral.cm-doc { padding-left: calc(var(--px) + 24mm); }
.d-lateral.cm-doc .lat-band { width: 24mm; gap: 10mm; }
.d-lateral.cm-doc .lat-band img { width: 17mm; }
.d-lateral.cm-doc .vwm { font-size: 20px; }
.d-lateral.cm-doc .totals { margin-left: 42%; }
.d-minimal.cm-doc .lockup { flex-direction: row; gap: 10px; }
.d-minimal.cm-doc .lockup img { height: 40px; }

/* Pestañas de tipo en Presupuestos */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.tabs button { border: 0; background: none; padding: 10px 14px; font: inherit; font-weight: 600; font-size: 14px; color: var(--ink-3); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--teal); border-bottom-color: var(--teal); }
.tabs .n { font-size: 12px; font-weight: 600; background: var(--teal-line); color: var(--teal-2); border-radius: 99px; padding: 1px 7px; margin-left: 4px; }
/* Diálogo de vincular factura a una fase */
dialog.modal .link-list { max-height: 320px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
dialog.modal .link-list tr { cursor: pointer; }
dialog.modal .link-list input { width: auto; }
.doc .ph-act { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
/* Aviso de presupuesto rellenado desde PDF */
.pdf-note { border-left: 3px solid var(--teal); display: grid; gap: 6px; }
.pdf-note p { margin: 0; }
.pdf-note .ok { color: var(--teal); }
.pdf-note .bad { color: var(--red); }
.pdf-note .check { display: flex; gap: 8px; align-items: center; }
.pdf-note .check input { width: auto; }
label.btn { cursor: pointer; }
dialog.modal .link-list td.code, dialog.modal .link-list td.mono, dialog.modal .link-list .badge { white-space: nowrap; }

/* Panel: pendiente de cobrar y de facturar */
.kpis.k3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.money2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.mcard { display: grid; gap: 14px; align-content: start; position: relative; overflow: hidden; }
.mcard::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 4px; background: #00c5ba; }
.mcard.facturar::before { background: #006053; }
.mhead { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.mcard .l { font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--ink-3); font-weight: 700; }
.mcard .v { font-size: 30px; font-weight: 800; letter-spacing: -.5px; margin-top: 4px; color: #0e756e; }
.mcard.facturar .v { color: #006053; }
.mcard .s { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.ring { display: flex; align-items: center; gap: 8px; flex: none; }
.ring svg { width: 64px; height: 64px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 7; }
.ring .trk { stroke: #e3f1ef; }
.ring .val { stroke: #00c5ba; stroke-linecap: round; transition: stroke-dasharray .8s ease; }
.facturar .ring .val { stroke: #006053; }
.ring div { display: grid; line-height: 1.15; }
.ring b { font-size: 17px; color: var(--ink); }
.ring span { font-size: 11px; color: var(--ink-3); }
.stack { display: flex; height: 12px; border-radius: 99px; overflow: hidden; background: #e3f1ef; }
.stack .ov { background: var(--red); }
.stack .ok { background: #00c5ba; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend i.ov { background: var(--red); } .legend i.ok { background: #00c5ba; }
.legend i.done, .segs i.done { background: #006053; }
.legend i.draft, .segs i.draft { background: repeating-linear-gradient(45deg, #00c5ba 0 4px, #8fe3dc 4px 8px); }
.legend i.todo, .segs i.todo { background: #e3f1ef; box-shadow: inset 0 0 0 1px #cfe6e2; }
.mlist { list-style: none; margin: 0; padding: 0; display: grid; }
.mlist li + li { border-top: 1px solid var(--line-2); }
.mlist a { display: grid; grid-template-columns: 1fr auto auto; gap: 4px 12px; align-items: center; padding: 9px 4px; color: inherit; text-decoration: none; border-radius: 8px; }
.mlist a:hover { background: var(--teal-soft); }
.mlist .who { display: grid; min-width: 0; }
.mlist .who b { font-size: 13px; }
.mlist .who span { font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mlist .amt { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.mlist.bills a { grid-template-columns: 1fr auto; }
.segs { grid-column: 1 / -1; display: flex; gap: 3px; height: 10px; }
.segs i { border-radius: 3px; min-width: 6px; }
.seglbl { grid-column: 1 / -1; font-size: 11.5px; color: var(--ink-3); }
.chip-s { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: #e3f6f4; color: #006053; white-space: nowrap; }
.chip-s.bad { background: #fde8e6; color: var(--red); }
.mcard .more { font-size: 12.5px; font-weight: 600; color: var(--teal); text-decoration: none; }
.mcard .clear { font-size: 13px; color: var(--teal); font-weight: 600; padding: 6px 0; }
@media (max-width: 900px) { .money2, .kpis.k3 { grid-template-columns: 1fr; } }
/* Panel: filtro de periodo y barras por mes */
.trend { font-weight: 700; margin-left: 4px; white-space: nowrap; }
.trend.up { color: #0e756e; } .trend.down { color: var(--red); }
.bars-card h2 { margin-bottom: 8px; }
.bars { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 8px; height: 170px; align-items: end; }
.bars.b3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px; padding: 0 12%; }
.bar { height: 100%; display: grid; grid-template-rows: auto 1fr auto; align-items: end; text-align: center; gap: 4px; }
.bar i { display: block; width: 100%; min-height: 3px; border-radius: 6px 6px 2px 2px; background: linear-gradient(180deg, #00c5ba, #0e9f96); align-self: end; transition: height .6s ease; }
.bar.now i { background: linear-gradient(180deg, #0e756e, #006053); }
.bar .bv { font-size: 10.5px; font-weight: 700; color: var(--ink-2); white-space: nowrap; }
.bar .bl { font-size: 11px; color: var(--ink-3); font-weight: 600; }
@media (max-width: 700px) { .bars { gap: 3px; } .bar .bv { display: none; } }
.mlist.bills li { display: grid; grid-template-columns: 1fr auto; align-items: center; }
.mlist .unt { border: 0; background: none; color: var(--ink-3); font-size: 18px; cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.mlist .unt:hover { background: #fde8e6; color: var(--red); }
.mcard #trackAdd { justify-self: start; }
dialog.modal.wide { width: min(860px, calc(100vw - 32px)); }
/* Interruptor con/sin IGIC */
.seg-t { display: inline-flex; margin-left: 8px; background: #e3f1ef; border-radius: 99px; padding: 2px; vertical-align: middle; }
.seg-t button { border: 0; background: none; font: inherit; font-size: 10.5px; letter-spacing: .5px; font-weight: 700; color: var(--ink-3); padding: 3px 9px; border-radius: 99px; cursor: pointer; text-transform: uppercase; }
.seg-t button.on { background: #006053; color: #fff; }
/* Acceso: contraseña visible y avisos */
.auth .pw { position: relative; display: block; }
.auth .pw input { padding-right: 64px; }
.auth .eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; font: inherit; font-size: 12px; font-weight: 600; color: var(--teal); cursor: pointer; padding: 4px 6px; }
.auth .ok-msg { background: var(--teal-soft); border: 1px solid var(--teal-line); color: var(--teal-2); border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.auth .switch { line-height: 2; }
button.link { border: 0; background: none; padding: 0; font: inherit; color: var(--teal); font-weight: 600; cursor: pointer; text-decoration: underline; }

/* Verificación en dos pasos */
input.otp { font-family: var(--mono, ui-monospace, monospace); font-size: 20px; letter-spacing: 6px; text-align: center; max-width: 170px; }
.auth input.otp { max-width: none; }
.mfa-setup { display: flex; gap: 22px; align-items: flex-start; flex-wrap: wrap; }
.mfa-setup img { border: 1px solid var(--line); border-radius: 10px; padding: 8px; background: #fff; }
.mfa-setup > div { flex: 1; min-width: 240px; }
.mfa-setup p { margin: 0 0 10px; }
.mfa-setup code { font-size: 12px; word-break: break-all; background: var(--teal-soft); padding: 2px 6px; border-radius: 4px; }
.mfa-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
