/* Layout: barra de marca arriba, navegación por pestañas, contenido a una columna.
   Colores: paleta violeta de Román Cifre Propiedades. Los valores exactos de marca se
   cambian SOLO acá (bloque :root); el resto del sistema usa estas variables. */
:root {
  --brand: #5b2a86;
  --brand-strong: #44206a;
  --brand-tint: #f1eaf8;
  --on-brand: #ffffff;
  --bg: #f8f6fb;
  --surface: #ffffff;
  --surface-2: #f3eff8;
  --ink: #1f1a2b;
  --muted: #6a6378;
  --line: #e3dcec;
  --ok: #1b7a4b;       --ok-bg: #e4f4ea;
  --warn: #9a6200;     --warn-bg: #fdf0d6;
  --bad: #b3261e;      --bad-bg: #fbe5e3;
  --neutral-bg: #ece8f2;
  --focus: #8a4fd0;
  --shadow: 0 1px 2px rgba(40, 20, 70, .06), 0 4px 14px rgba(40, 20, 70, .05);
  --font: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #b98cf0; --brand-strong: #d3b5f7; --brand-tint: #2b2040; --on-brand: #1a1226;
    --bg: #15111d; --surface: #1e1829; --surface-2: #261f33; --ink: #efeaf6; --muted: #a89fb8; --line: #372e48;
    --ok: #6fd09b; --ok-bg: #153325; --warn: #f0be5c; --warn-bg: #3a2b0c; --bad: #ff8d84; --bad-bg: #3d1a18;
    --neutral-bg: #2d2640; --focus: #b98cf0; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --brand: #b98cf0; --brand-strong: #d3b5f7; --brand-tint: #2b2040; --on-brand: #1a1226;
  --bg: #15111d; --surface: #1e1829; --surface-2: #261f33; --ink: #efeaf6; --muted: #a89fb8; --line: #372e48;
  --ok: #6fd09b; --ok-bg: #153325; --warn: #f0be5c; --warn-bg: #3a2b0c; --bad: #ff8d84; --bad-bg: #3d1a18;
  --neutral-bg: #2d2640; --focus: #b98cf0; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.45;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 0 48px;
}
h1, h2, h3 { margin: 0; line-height: 1.2; text-wrap: balance; }
h1 { font-size: 1.5rem; font-weight: 800; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; font-weight: 700; }
h3 { font-size: .95rem; font-weight: 700; }
a { color: var(--brand); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.wrap { max-width: 1120px; margin: 0 auto; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.num { font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.spacer { height: 18px; }

/* Barra de marca */
.topbar { background: var(--brand); color: var(--on-brand); margin: 0 calc(-1 * max(16px, env(safe-area-inset-left, 0px)));
  padding: 10px max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px)); }
:root[data-theme="dark"] .topbar, :root:not([data-theme="light"]) .topbar { }
.topbar .wrap { display: flex; flex-direction: column; gap: 6px; }
.brandrow { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; min-width: 0; }
.logo svg { flex: none; }
.logo b { font-size: 1.02rem; font-weight: 800; letter-spacing: .01em; }
.logo small { display: block; font-size: .72rem; opacity: .8; letter-spacing: .08em; text-transform: uppercase; }
.userchip { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: .85rem; flex-wrap: wrap; }
.userchip .who { text-align: right; line-height: 1.2; }
.userchip .who span { opacity: .8; font-size: .75rem; display: block; }
.btn-ghost { background: transparent; border: 1px solid color-mix(in srgb, var(--on-brand) 45%, transparent); color: var(--on-brand);
  border-radius: 8px; padding: 5px 10px; cursor: pointer; font-size: .82rem; }
.btn-ghost:hover { background: color-mix(in srgb, var(--on-brand) 14%, transparent); }
.nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; margin-top: 4px; }
.nav::-webkit-scrollbar { display: none; }
.nav a { color: var(--on-brand); opacity: .78; text-decoration: none; padding: 9px 14px; border-radius: 8px 8px 0 0; font-weight: 600;
  font-size: .9rem; white-space: nowrap; }
.nav a:hover { opacity: 1; }
.nav a[aria-current="page"] { background: var(--bg); color: var(--brand); opacity: 1; }
.banner { background: var(--warn-bg); color: var(--warn); border-radius: 10px; padding: 9px 14px; margin-top: 14px; font-size: .88rem; }
.banner b { font-weight: 800; }

main { padding-top: 22px; }
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.pagehead p { margin: 4px 0 0; color: var(--muted); }

/* Controles */
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 9px; padding: 8px 14px; cursor: pointer; font-weight: 600; font-size: .9rem; }
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.btn.sm { padding: 4px 10px; font-size: .8rem; border-radius: 7px; }
.btn.danger { color: var(--bad); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], select, textarea {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; min-width: 0; }
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); }
input.invalid { border-color: var(--bad); background: var(--bad-bg); }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: .8rem; font-weight: 600; color: var(--muted); min-width: 0; }
label.field input, label.field select, label.field textarea { font-weight: 400; color: var(--ink); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar > * { flex: 0 1 auto; }
.toolbar select, .toolbar input[type=text], .row select { width: auto; min-width: 150px; }
.monthnav { display: inline-flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.monthnav button { border: 0; background: transparent; cursor: pointer; width: 34px; height: 34px; border-radius: 8px; font-size: 1.1rem; color: var(--brand); }
.monthnav button:hover:not([disabled]) { background: var(--brand-tint); }
.monthnav button[disabled] { opacity: .3; cursor: default; }
.monthnav strong { min-width: 150px; text-align: center; font-weight: 700; }

/* Chips de estado */
.chip { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 2px 9px; font-size: .75rem; font-weight: 700; background: var(--neutral-bg); color: var(--muted); white-space: nowrap; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.brand { background: var(--brand-tint); color: var(--brand); }

/* Tablero */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; }
.kpi .label { font-size: .78rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.kpi .big { font-size: 2rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.kpi .big small { font-size: .95rem; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.kpi.bad .big { color: var(--bad); }
.kpi.warn .big { color: var(--warn); }
.bar { height: 8px; border-radius: 99px; background: var(--neutral-bg); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--ok); border-radius: 99px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.card > header { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.card .body { padding: 6px 0; }
.grid2 > * { min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px; margin-top: 14px; }
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 9px 18px; font-weight: 700; white-space: nowrap; }
td { padding: 10px 18px; border-top: 1px solid var(--line); vertical-align: middle; }
td.r, th.r { text-align: right; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
.empty { padding: 28px 18px; text-align: center; color: var(--muted); }

/* Control mensual */
.prop { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 10px; box-shadow: var(--shadow); }
.prop > .head { display: flex; gap: 14px; align-items: center; padding: 12px 16px; cursor: pointer; flex-wrap: wrap; }
.prop .addr { font-weight: 700; }
.prop .sub { font-size: .8rem; color: var(--muted); }
.prop .chev { width: 20px; text-align: center; color: var(--muted); transition: transform .15s; flex: none; }
.prop.open .chev { transform: rotate(90deg); }
.prop .meta { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.prop .prog { font-weight: 700; font-size: .85rem; min-width: 70px; text-align: right; }
.prop .prog.done { color: var(--ok); }
.svcs { border-top: 1px solid var(--line); }
.svc { display: grid; grid-template-columns: minmax(180px, 1.2fr) minmax(250px, 1.5fr) minmax(190px, 1fr); gap: 10px 18px; padding: 12px 16px; border-bottom: 1px solid var(--line); align-items: start; }
.svc:last-child { border-bottom: 0; }
.svc.off { opacity: .55; }
.svc .name { font-weight: 700; }
.svc .acct { font-size: .8rem; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 3px; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.seg button { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 6px 10px; font-size: .82rem; font-weight: 600; cursor: pointer; color: var(--muted); }
.seg button:hover { border-color: var(--brand); color: var(--ink); }
.seg button[aria-pressed="true"].al_dia { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }
.seg button[aria-pressed="true"].deuda { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }
.seg button[aria-pressed="true"].no_vencio { background: var(--brand-tint); border-color: var(--brand); color: var(--brand); }
.seg button[aria-pressed="true"].no_aplica { background: var(--neutral-bg); border-color: var(--muted); color: var(--ink); }
.debtbox { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.stamp { font-size: .75rem; color: var(--muted); margin-top: 6px; }
.check { display: flex; gap: 8px; align-items: center; font-size: .88rem; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }
.attach { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 6px; font-size: .82rem; }
.attach input[type=file] { display: none; }
.svc .notes { margin-top: 8px; }
.svc .notes input { font-size: .85rem; padding: 6px 9px; }
.propfoot { display: flex; gap: 8px; padding: 10px 16px; background: var(--surface-2); border-radius: 0 0 14px 14px; flex-wrap: wrap; }

/* Modales / formularios */
.overlay { position: fixed; inset: 0; background: rgba(20, 10, 40, .55); display: flex; align-items: flex-start; justify-content: center; padding: 4vh 12px; overflow-y: auto; z-index: 50; }
.modal { background: var(--surface); border-radius: 16px; width: min(860px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal > header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); gap: 10px; }
.modal .content { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.modal > footer { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.formgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs button { border: 0; background: transparent; padding: 8px 14px; cursor: pointer; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; }
.tabs button[aria-selected="true"] { color: var(--brand); border-color: var(--brand); }
.svcedit { border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 10px; background: var(--surface-2); }
.svcedit.off { opacity: .6; }
.svcedit .top { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.warnnote { color: var(--warn); background: var(--warn-bg); border-radius: 8px; padding: 6px 10px; font-size: .8rem; }
.hist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.hist li { border-left: 3px solid var(--brand-tint); padding: 2px 0 2px 12px; font-size: .88rem; }
.hist .when { color: var(--muted); font-size: .78rem; }
.hist .chg { color: var(--ink); }
.hist .chg s { color: var(--muted); }

/* Reclamos */
.navbadge { display: inline-block; margin-left: 6px; min-width: 18px; padding: 0 5px; border-radius: 99px; background: var(--bad); color: var(--surface); font-size: .72rem; font-weight: 800; text-align: center; }
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.steps button { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 5px 12px; font-size: .8rem; font-weight: 600; color: var(--muted); cursor: pointer; }
.steps button:hover { border-color: var(--brand); color: var(--ink); }
.steps button.done { background: var(--ok-bg); border-color: transparent; color: var(--ok); }
.steps button.now { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.steps button.picked { border: 2px dashed var(--brand); background: var(--brand-tint); color: var(--brand); }
.nowbox { border: 1px solid var(--brand); background: var(--brand-tint); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.nowbox a.btn { text-decoration: none; color: var(--ink); }
.nowbox a.btn.primary { color: var(--on-brand); }
.modal input[type=file] { max-width: 100%; min-width: 0; }
.claimdata summary { cursor: pointer; font-weight: 700; color: var(--brand); }
input[type=date] { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; width: 100%; min-width: 0; font: inherit; color: inherit; }

/* Login */
.login { max-width: 420px; margin: 8vh auto 0; }
.login .card { padding: 26px; display: flex; flex-direction: column; gap: 14px; }
.userpick { display: flex; flex-direction: column; gap: 8px; }
.userpick button { text-align: left; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
.userpick button:hover { border-color: var(--brand); background: var(--brand-tint); }

/* Arrastrar boletas y pagos */
.dropzone { border: 2px dashed var(--line); border-radius: 16px; padding: 28px 18px; text-align: center; background: var(--surface); cursor: pointer; transition: background .15s, border-color .15s; }
.dropzone:hover, .dropzone.over { border-color: var(--brand); background: var(--brand-tint); }
.dropzone .dz-title { font-weight: 800; font-size: 1.1rem; margin-bottom: 4px; }
.dropstrip { border: 1.5px dashed var(--line); border-radius: 10px; padding: 8px 14px; margin-bottom: 12px; font-size: .88rem; color: var(--muted); background: var(--surface); }
.dropstrip.over { border-color: var(--brand); background: var(--brand-tint); }
.readgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 16px; padding: 12px 16px; border-top: 1px solid var(--line); }
.pickList { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }

.toast { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 10px; font-weight: 600; font-size: .9rem; z-index: 99; box-shadow: 0 8px 30px rgba(0,0,0,.3); max-width: 92vw; }
.toast.err { background: var(--bad); color: #fff; }

@media (max-width: 780px) {
  .svc { grid-template-columns: 1fr; }
  .prop > .head { display: grid; grid-template-columns: 20px 1fr; gap: 6px 10px; }
  .prop .meta { grid-column: 2; margin-left: 0; }
  .userchip .who { text-align: left; }
  .userchip { margin-left: 0; }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
}
@media print {
  .topbar, .toolbar, .banner, .noprint, .toast { display: none !important; }
  body { background: #fff; color: #000; padding: 0; }
  .card, .prop { box-shadow: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
