/* Presucam. Temas: data-theme elige la paleta (el color de acento tiñe todo lo demás) y data-mode elige claro u
   oscuro (sin data-mode, sigue al sistema). Se cambian en Ajustes › Apariencia y quedan guardados en el aparato. */
:root { --a-l: #0f6e56; --a-d: #3cc59b; --on-l: #fff; --on-d: #04261c; }              /* verde (app de banco) */
:root[data-theme="azul"] { --a-l: #1d4ed8; --a-d: #7aa2ff; --on-l: #fff; --on-d: #0a1a40; }
:root[data-theme="terracota"] { --a-l: #c2410c; --a-d: #f0773d; --on-l: #fff; --on-d: #2a0f03; }
:root[data-theme="violeta"] { --a-l: #6d28d9; --a-d: #a98bff; --on-l: #fff; --on-d: #1d0b45; }
:root[data-theme="cian"] { --a-l: #0e7490; --a-d: #5dd3e6; --on-l: #fff; --on-d: #04262e; }
:root[data-theme="amarillo"] { --a-l: #e0a400; --a-d: #ffc72c; --on-l: #1e2124; --on-d: #1e2124; }
:root[data-theme="grafito"] { --a-l: #2b3036; --a-d: #d6dbe0; --on-l: #fff; --on-d: #15181b; }

:root {
  --accent: var(--a-l); --on-accent: var(--on-l);
  --accent-2: color-mix(in srgb, var(--accent) 82%, #000); --accent-soft: color-mix(in srgb, var(--accent) 11%, transparent);
  --paper: color-mix(in srgb, var(--accent) 5%, #f4f5f5); --surface: #ffffff;
  --surface-2: color-mix(in srgb, var(--accent) 3%, #fafafa); --sunk: color-mix(in srgb, var(--accent) 7%, #ececec);
  --ink: color-mix(in srgb, var(--accent) 16%, #121414); --ink-2: color-mix(in srgb, var(--accent) 12%, #555b5c);
  --ink-3: color-mix(in srgb, var(--accent) 8%, #8c9293); --line: color-mix(in srgb, var(--accent) 7%, #e5e7e7);
  --line-2: color-mix(in srgb, var(--accent) 9%, #d4d8d8);
  --s-proceso: #6b7678; --s-enviado: #b7791f; --s-aprobado: #1a7f5a; --s-rechazado: #c0392b; --s-archivado: #8c9293;
  --wa: #1fa855; --danger: #c0392b; --danger-soft: rgba(192, 57, 43, .09);
  --shadow: 0 1px 2px rgba(0, 0, 0, .04); --shadow-lg: 0 8px 24px rgba(0, 0, 0, .13);
  --r: 18px; --r-sm: 12px;
  color-scheme: light;
}
:root[data-mode="dark"] {
  --accent: var(--a-d); --on-accent: var(--on-d); --accent-2: color-mix(in srgb, var(--accent) 80%, #fff);
  --paper: color-mix(in srgb, var(--accent) 5%, #0f1112); --surface: color-mix(in srgb, var(--accent) 6%, #171a1b);
  --surface-2: color-mix(in srgb, var(--accent) 7%, #1c2021); --sunk: color-mix(in srgb, var(--accent) 4%, #131617);
  --ink: color-mix(in srgb, var(--accent) 8%, #eef1f1); --ink-2: color-mix(in srgb, var(--accent) 10%, #a9b0b1);
  --ink-3: color-mix(in srgb, var(--accent) 8%, #737b7c); --line: color-mix(in srgb, var(--accent) 10%, #262b2c);
  --line-2: color-mix(in srgb, var(--accent) 12%, #323839);
  --s-proceso: #a9b0b1; --s-enviado: #e0a845; --s-aprobado: #4cc38a; --s-rechazado: #f07267; --s-archivado: #737b7c;
  --danger: #f07267; --danger-soft: rgba(240, 114, 103, .13); --shadow: none; --shadow-lg: 0 8px 24px rgba(0, 0, 0, .5);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-mode="light"]) {
    --accent: var(--a-d); --on-accent: var(--on-d); --accent-2: color-mix(in srgb, var(--accent) 80%, #fff);
    --paper: color-mix(in srgb, var(--accent) 5%, #0f1112); --surface: color-mix(in srgb, var(--accent) 6%, #171a1b);
    --surface-2: color-mix(in srgb, var(--accent) 7%, #1c2021); --sunk: color-mix(in srgb, var(--accent) 4%, #131617);
    --ink: color-mix(in srgb, var(--accent) 8%, #eef1f1); --ink-2: color-mix(in srgb, var(--accent) 10%, #a9b0b1);
    --ink-3: color-mix(in srgb, var(--accent) 8%, #737b7c); --line: color-mix(in srgb, var(--accent) 10%, #262b2c);
    --line-2: color-mix(in srgb, var(--accent) 12%, #323839);
    --s-proceso: #a9b0b1; --s-enviado: #e0a845; --s-aprobado: #4cc38a; --s-rechazado: #f07267; --s-archivado: #737b7c;
    --danger: #f07267; --danger-soft: rgba(240, 114, 103, .13); --shadow: none; --shadow-lg: 0 8px 24px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { background: var(--paper); }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 500 15.5px/1.45 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
  font-variant-numeric: tabular-nums;
}
.ic { flex: none; display: block; }
a { color: var(--accent); text-decoration: none; }

/* --- barra superior y navegación --- */
header#top {
  position: sticky; top: 0; z-index: 6; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 18px; padding-top: max(12px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--paper) 82%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}
.brand { display: flex; align-items: center; gap: 9px; color: var(--ink); font-weight: 800; font-size: 17px; letter-spacing: -.02em; }
.mark { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; color: #fff; font-size: 15px; font-weight: 800;
  background: var(--accent); }
#who { color: var(--ink-2); font-size: 13px; font-weight: 600; max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.pruebas header#top { box-shadow: inset 0 -3px 0 #e8a33d; }
body.home header#top { display: none; }
body.pruebas .brand::after { content: 'PRUEBAS'; font-size: 10px; font-weight: 800; letter-spacing: .08em; color: #8a5a00; background: #fbe3b4; padding: 3px 7px; border-radius: 6px; }

nav#nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; justify-content: center;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line);
}
nav#nav a { flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px 0; color: var(--ink-3); font-size: 11px; font-weight: 700; }
nav#nav a .ic { padding: 4px 16px; box-sizing: content-box; border-radius: 99px; transition: background .15s; }
nav#nav a.on { color: var(--accent); }
nav#nav a.on .ic { background: var(--accent-soft); }

/* --- estructura --- */
main { max-width: 820px; margin: 0 auto; padding: 18px 16px 90px; }
body.home main { padding-top: 0; } /* abajo: lugar para el botón + flotante */
.page-head { display: flex; align-items: center; gap: 10px; margin: 2px 0 16px; }
.page-head h1 { flex: 1; min-width: 0; }
h1 { font-size: 24px; font-weight: 800; letter-spacing: -.03em; margin: 0; line-height: 1.15; }
h2 { font-size: 15px; font-weight: 800; color: var(--ink); margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.sub { color: var(--ink-2); font-size: 13.5px; margin: -8px 0 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.row > * { flex: 1 1 140px; min-width: 0; }
.row > .narrow { flex: 0 1 110px; }
.muted { color: var(--ink-2); font-size: 13px; }
.spacer { height: 12px; }
.center { max-width: 400px; margin: 7vh auto 0; }
.empty { text-align: center; color: var(--ink-3); padding: 40px 12px; font-weight: 600; }

/* --- formularios --- */
label { display: block; font-size: 12.5px; font-weight: 700; color: var(--ink-2); margin-bottom: 10px; }
label > input, label > select, label > textarea { margin-top: 5px; }
input, select, textarea {
  width: 100%; font: inherit; font-size: 16px; font-weight: 500; color: var(--ink);
  padding: 10px 12px; min-height: 44px; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--surface-2);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input::placeholder, textarea::placeholder { color: var(--ink-3); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 4px var(--accent-soft); }
input.zero { border-color: var(--danger); background: var(--danger-soft); }
textarea { resize: vertical; field-sizing: content; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%);
  background-position: calc(100% - 17px) 52%, calc(100% - 12px) 52%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
input[type=checkbox] { width: 20px; height: 20px; min-height: 0; accent-color: var(--accent); flex: none; }
.search { position: relative; }
.search .ic { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.search input { padding-left: 40px; border-radius: 14px; background: var(--surface); }

/* --- botones --- */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-size: 14.5px; font-weight: 700;
  min-height: 42px; padding: 9px 15px; border-radius: 12px; border: 1px solid transparent; cursor: pointer; white-space: nowrap;
  background: var(--sunk); color: var(--ink); transition: transform .08s, background .15s, box-shadow .15s, opacity .15s;
}
button:active, .btn:active { transform: scale(.97); }
button:focus-visible, .btn:focus-visible, a:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft), 0 0 0 1px var(--accent); }
button:disabled { opacity: .45; pointer-events: none; }
.primary { background: var(--accent); color: var(--on-accent); }
.primary:hover { background: var(--accent-2); }
.tonal { background: var(--accent-soft); color: var(--accent); }
.ghost { background: transparent; color: var(--ink-2); }
.ghost:hover { background: var(--sunk); }
.danger { background: var(--danger-soft); color: var(--danger); }
.wa { background: var(--wa); color: #fff; }
.icon-btn { width: 40px; min-height: 40px; padding: 0; border-radius: 12px; }
.small { min-height: 34px; padding: 5px 11px; font-size: 13.5px; border-radius: 10px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 0; }
.fab { position: fixed; right: max(18px, calc(50% - 392px)); bottom: calc(82px + env(safe-area-inset-bottom)); z-index: 5;
  width: 56px; height: 56px; border-radius: 18px; padding: 0; box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 40%, transparent); }

/* Mosaico de acciones del presupuesto */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.tile { flex-direction: column; gap: 6px; min-height: 76px; padding: 10px 6px; border-radius: 14px; font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink); }
.tile .ic { color: var(--accent); }
.tile.wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.tile.wa .ic { color: #fff; }
.tile.danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.tile.danger .ic { color: var(--danger); }

/* Selector de estado */
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 4px; background: var(--sunk); border-radius: 14px; }
.seg button { min-height: 38px; padding: 6px 4px; font-size: 12.5px; background: transparent; color: var(--ink-2); border-radius: 10px; }
.seg button.on { background: var(--surface); color: var(--st); box-shadow: var(--shadow); }

/* --- pestañas --- */
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; margin: -4px -16px 16px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.tabs::-webkit-scrollbar { display: none; }
.tabs a, .tabs button { position: relative; flex: none; display: inline-flex; align-items: center; min-height: 42px; padding: 8px 12px; background: none; border: 0; border-radius: 10px 10px 0 0;
  color: var(--ink-2); font: inherit; font-size: 14px; font-weight: 700; white-space: nowrap; cursor: pointer; }
.tabs a.on, .tabs button.on { color: var(--ink); }
.tabs a.on::after, .tabs button.on::after { content: ''; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--accent); }
.tabs button:active { transform: none; }

/* --- hoja (diálogo) --- */
dialog.sheet { border: 0; padding: 0 18px 18px; margin: auto auto 0; width: 100%; max-width: 560px; max-height: 88vh; overflow: auto;
  background: var(--surface); color: var(--ink); border-radius: 22px 22px 0 0; box-shadow: var(--shadow-lg);
  padding-bottom: calc(18px + env(safe-area-inset-bottom)); animation: up .22s ease-out; }
dialog.sheet::backdrop { background: rgba(10, 14, 13, .5); }
.sheet-head { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; padding: 14px 0 8px; background: var(--surface); z-index: 1; }
.sheet-head h2 { margin: 0; }
@media (min-width: 700px) { dialog.sheet { margin: auto; border-radius: 22px; } }

/* --- fila de artículo --- */
.item.arow { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 0; }
.arow .main { flex: 1; min-width: 0; display: block; text-align: left; white-space: normal; background: none; border: 0; min-height: 0; padding: 6px 4px 6px 14px; font-weight: 500; color: inherit; }
.arow .main:active { transform: none; }
.arow .t { font-size: 14.5px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.arow .code { display: inline-block; font-size: 11.5px; font-weight: 800; color: var(--accent); background: var(--accent-soft); padding: 1px 6px; border-radius: 6px; margin-right: 6px; }
.arow .price { text-align: right; white-space: nowrap; }
.arow .price b { display: block; font-size: 14.5px; }
.arow .price small { color: var(--ink-3); font-size: 11.5px; font-weight: 600; }

/* --- chips y estados --- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px; border-radius: 99px; font-size: 12px; font-weight: 700; white-space: nowrap;
  color: var(--st, var(--ink-2)); background: color-mix(in srgb, var(--st, var(--ink-2)) 12%, transparent); }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.flat::before { display: none; }
.pill.flat { padding: 3px 9px; }
.st-proceso { --st: var(--s-proceso); } .st-enviado { --st: var(--s-enviado); } .st-aprobado { --st: var(--s-aprobado); }
.st-rechazado { --st: var(--s-rechazado); } .st-archivado { --st: var(--s-archivado); } .st-alert { --st: var(--danger); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 6px; margin: 12px -2px 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button { min-height: 36px; padding: 6px 14px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); color: var(--ink-2); font-size: 13.5px; }
.chips button.on { background: var(--ink); border-color: var(--ink); color: var(--paper); }

/* --- listas --- */
.list { display: flex; flex-direction: column; gap: 10px; }
.item { display: block; position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 13px 15px; color: inherit; box-shadow: var(--shadow); transition: transform .1s, box-shadow .15s; }
a.item:active { transform: scale(.99); }
.item .t { font-weight: 700; font-size: 15.5px; }
.item .s { color: var(--ink-2); font-size: 13px; margin-top: 2px; }
.item .r { float: right; text-align: right; margin-left: 10px; }

/* Tarjeta de presupuesto */
.bcard { padding: 0; overflow: hidden; }
.bcard .main { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 14px 15px 10px 15px; color: inherit; }
.bcard .num { grid-column: 1; grid-row: 1; font-size: 12px; font-weight: 700; color: var(--ink-3); letter-spacing: .02em; }
.bcard .who { grid-column: 1; grid-row: 2; font-weight: 800; font-size: 16.5px; letter-spacing: -.01em; line-height: 1.25; min-width: 0; overflow-wrap: anywhere; }
.bcard .amt { grid-column: 2; grid-row: 1 / span 2; align-self: center; text-align: right; white-space: nowrap; }
.bcard .amt b { display: block; font-size: 17px; font-weight: 800; letter-spacing: -.01em; }
.bcard .amt small { color: var(--ink-3); font-size: 12px; font-weight: 600; }
.bcard .meta { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; color: var(--ink-2); font-size: 12.5px; }
.bcard .bar { display: flex; gap: 6px; padding: 8px 10px 10px 13px; border-top: 1px solid var(--line); }
.bcard .bar button { min-height: 36px; padding: 6px 11px; font-size: 13px; border-radius: 10px; }
.bcard .bar .grow { flex: 1; }

/* --- editor de presupuesto --- */
.line { background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 10px; margin-bottom: 10px; }
.line textarea { min-height: 44px; background: var(--surface); }
.line .nums { display: grid; grid-template-columns: 58px 96px 1fr 1fr 36px; gap: 6px; align-items: end; margin-top: 8px; }
.line .nums label, .line .nums .muted { font-size: 11.5px; margin-bottom: 0; white-space: nowrap; }
.line .nums input { display: block; padding: 8px 7px; min-height: 40px; }
.line .nums .muted, .line .nums .v { text-align: right; }
.line .nums .v { padding: 9px 0; font-weight: 700; font-size: 14.5px; }
.line .foot { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12px; color: var(--danger); font-weight: 600; }
.results { border: 1px solid var(--line); border-radius: 14px; margin-top: 6px; max-height: 340px; overflow: auto; background: var(--surface); box-shadow: var(--shadow-lg); }
.results button { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; min-height: 0; padding: 10px 12px; background: transparent; white-space: normal; font-weight: 600; }
.results button:last-child { border-bottom: 0; }
.results button:hover { background: var(--surface-2); }
.totals { margin-left: auto; max-width: 340px; margin-top: 14px; }
.totals div { display: flex; justify-content: space-between; padding: 4px 0; color: var(--ink-2); font-weight: 600; }
.totals .big { color: var(--ink); font-weight: 800; font-size: 21px; letter-spacing: -.02em; border-top: 1px solid var(--line); padding-top: 10px; margin-top: 4px; }
.savebar { position: fixed; left: 12px; right: 12px; bottom: calc(78px + env(safe-area-inset-bottom)); z-index: 7; max-width: 540px; margin: 0 auto;
  display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 16px; border-radius: 16px; background: var(--ink); color: var(--paper); box-shadow: var(--shadow-lg);
  font-size: 14px; font-weight: 700; animation: up .2s ease-out; }
.savebar span { flex: 1; }
@keyframes up { from { transform: translateY(16px); opacity: 0; } }
.check { display: flex; align-items: center; gap: 10px; padding: 8px 0; margin: 0; color: var(--ink); font-size: 15px; font-weight: 600; }
.check.done span { text-decoration: line-through; color: var(--ink-3); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
td, th { padding: 8px 4px; border-bottom: 1px solid var(--line); text-align: left; }
.dup { border: 1px solid var(--line); border-radius: 14px; padding: 6px 12px; margin-bottom: 10px; background: var(--surface-2); }
.dup .check { border-bottom: 1px dashed var(--line); }
.dup .check:last-of-type { border-bottom: 0; }

#toast { position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translate(-50%, 10px); z-index: 10;
  background: var(--ink); color: var(--paper); padding: 11px 18px; border-radius: 14px; font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: 90vw; box-shadow: var(--shadow-lg); }
#toast.on { opacity: 1; transform: translate(-50%, 0); }
.logo-prev { max-width: 160px; max-height: 90px; display: block; margin: 6px 0 10px; border-radius: 8px; }
@media (min-width: 700px) {
  .line .nums { grid-template-columns: 90px 140px 1fr 1fr 38px; }
  body { padding-bottom: 100px; }
}

/* --- inicio (estilo app de banco) --- */
.hero { margin: 0 -16px; padding: max(18px, env(safe-area-inset-top)) 20px 52px; background: var(--accent); color: var(--on-accent); border-radius: 0 0 26px 26px; }
@media (min-width: 852px) { .hero { margin: 0; } }
.hero .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 600; }
.hero .hi { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.hero .hi .mark { background: rgba(255, 255, 255, .2); box-shadow: none; width: 28px; height: 28px; font-size: 14px; color: inherit; }
.hero .rate { opacity: .9; }
.hero .lbl { font-size: 13px; font-weight: 600; opacity: .85; margin-top: 22px; }
.hero .big { font-size: 34px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; }
.hero .sub2 { font-size: 13px; font-weight: 600; opacity: .85; margin-top: 4px; }
body.pruebas .hero .hi::after { content: 'PRUEBAS'; font-size: 10px; font-weight: 800; color: #8a5a00; background: #fbe3b4; padding: 3px 7px; border-radius: 6px; }
.quick { position: relative; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: -34px 4px 4px; padding: 12px 6px; background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow-lg); }
.quick a, .quick button { display: flex; flex-direction: column; align-items: center; gap: 6px; min-height: 0; padding: 4px 0; background: none; border: 0; color: var(--ink); font-size: 12px; font-weight: 700; }
.quick .qi { width: 46px; height: 46px; border-radius: 15px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.quick .main-q .qi { background: var(--accent); color: var(--on-accent); }

/* Lista agrupada: filas dentro de un mismo bloque blanco */
.group { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.group > * + * { border-top: 1px solid var(--line); }
.brow { display: flex; align-items: center; gap: 2px; padding-right: 4px; }
.brow > a { flex: 1; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 12px 4px 12px 16px; color: inherit; }
.brow .who { font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brow .amt { text-align: right; font-weight: 800; font-size: 15px; white-space: nowrap; }
.brow .st { font-size: 12.5px; font-weight: 700; color: var(--st); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brow .st span { color: var(--ink-3); font-weight: 600; }
.brow .ars { text-align: right; color: var(--ink-3); font-size: 12px; font-weight: 600; white-space: nowrap; }
.section-title { display: flex; justify-content: space-between; align-items: center; margin: 22px 2px 10px; }
.section-title h2 { margin: 0; }
.menu-list { display: flex; flex-direction: column; gap: 8px; }
.menu-list button { justify-content: flex-start; min-height: 52px; background: var(--surface-2); border: 1px solid var(--line); font-size: 15px; }
.menu-list button .ic { color: var(--accent); }
.menu-list button.wa-item .ic { color: var(--wa); }
.menu-list button.danger { background: var(--danger-soft); border-color: transparent; }
.menu-list button.danger .ic { color: var(--danger); }

/* --- apariencia --- */
.seg.seg3 { grid-template-columns: repeat(3, 1fr); }
.seg.seg3 button { gap: 6px; font-size: 13.5px; }
.seg.seg3 button.on { color: var(--accent); }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 10px; }
.swatches button { flex-direction: column; gap: 8px; min-height: 0; padding: 10px 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; font-size: 13px; }
.swatches button.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.swatches .sw { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; color: #fff; }

/* --- hoja del presupuesto (como el PDF): siempre papel blanco y tinta negra, en cualquier tema --- */
.viewbar { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 14px; }
.paper { background: #fff; color: #111; border-radius: 6px; padding: 22px 18px 20px; box-shadow: 0 1px 2px rgba(0,0,0,.06), 0 10px 30px rgba(0,0,0,.08);
  font-size: 13px; line-height: 1.4; max-width: 720px; margin: 0 auto 18px; color-scheme: light; }
.paper header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.paper header img { max-width: 110px; max-height: 64px; object-fit: contain; }
.paper .co { text-align: right; font-size: 11.5px; color: #333; }
.paper .co b { display: block; font-size: 13px; color: #111; }
.paper .title { display: block; text-align: center; font-size: 17px; font-weight: 800; margin: 18px 0 14px; color: #111; }
.paper .fields { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; margin-bottom: 14px; }
.paper .kv { display: grid; grid-template-columns: 76px 1fr; gap: 6px; font-size: 12.5px; }
.paper .kv b { font-weight: 800; }
.paper table.items { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.paper .items th, .paper .items td { border: 1px solid #222; padding: 5px 6px; vertical-align: top; color: #111; }
.paper .items th { font-size: 11px; font-weight: 800; text-align: left; }
.paper .items th:nth-child(n+2), .paper .items td:nth-child(n+2) { text-align: right; white-space: nowrap; }
.paper .items th:nth-child(2), .paper .items td:nth-child(2) { text-align: center; }
.paper .sum { margin: 14px 0 0 auto; max-width: 240px; }
.paper .sum div { display: flex; justify-content: space-between; border: 1px solid #222; border-top-width: 0; padding: 4px 8px; font-size: 12.5px; }
.paper .sum div:first-child { border-top-width: 1px; }
.paper .sum .tot span:first-child { font-weight: 800; }
.paper .note { border: 1px solid #222; padding: 7px 9px; margin: 14px 0 0; font-size: 12px; color: #111; }
@media (max-width: 420px) { .paper .fields { grid-template-columns: 1fr; } .paper { padding: 18px 12px; } }

/* --- cambio de estado de un toque (menú ⋯ de la lista) --- */
.st-curso { --st: #2563eb; } .st-finalizado { --st: #6b7678; }
:root[data-mode="dark"] .st-curso { --st: #7aa2ff; }
.states { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.states button { min-height: 46px; padding: 6px; font-size: 13.5px; border-radius: 12px; color: var(--st); background: color-mix(in srgb, var(--st) 10%, transparent); border: 1.5px solid transparent; }
.states button.on { border-color: var(--st); background: color-mix(in srgb, var(--st) 18%, transparent); }
.states button.on::before { content: '✓ '; }

/* Botón de WhatsApp en cada fila de la lista */
.wa-btn.icon-btn { color: var(--wa); background: color-mix(in srgb, var(--wa) 12%, transparent); width: 38px; min-height: 38px; border-radius: 12px; }
.wa-btn:disabled { opacity: .3; filter: grayscale(1); pointer-events: auto; cursor: not-allowed; }
.tile.wa:disabled { opacity: .35; pointer-events: auto; cursor: not-allowed; }

.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0 12px; }

/* Archivar a mano en cada fila; en el celular los tres botones se achican para dejar lugar al nombre y al monto */
.brow .arch-btn { color: var(--ink-2); background: var(--sunk); width: 38px; min-height: 38px; border-radius: 12px; }
@media (max-width: 420px) { .brow { gap: 0; } .brow .icon-btn { width: 34px; min-height: 34px; } .brow > a { padding-left: 12px; gap: 2px 8px; } .brow .who, .brow .amt { font-size: 14.5px; } }

/* Volver con nombre, encima del título: «‹ Presupuestos» */
.back { display: inline-flex; align-items: center; gap: 4px; margin: 0 0 6px -6px; padding: 7px 12px 7px 6px; border-radius: 99px;
  color: var(--accent); font-size: 14.5px; font-weight: 700; }
.back:hover, .back:active { background: var(--accent-soft); }
/* Inicio: un solo botón grande para crear; el resto de las secciones está en la barra de abajo */
.new-big { position: relative; width: calc(100% - 8px); margin: -26px 4px 4px; min-height: 54px; font-size: 16px; border-radius: 16px; box-shadow: var(--shadow-lg); }

/* --- celular: nada se pasa de ancho ni se corre de costado --- */
html, body { overflow-x: hidden; overflow-x: clip; }
.line .nums { grid-template-columns: 52px minmax(0, 90px) minmax(0, 1fr) minmax(0, 1fr) 34px; }
.line .nums .icon-btn { width: 34px; min-height: 34px; }
.line .nums .v { overflow: hidden; text-overflow: ellipsis; }
.paper td, .paper th { overflow-wrap: anywhere; }
@media (min-width: 700px) { .line .nums { grid-template-columns: 90px 140px 1fr 1fr 38px; } }
/* Con el teclado abierto la barra de abajo se esconde (si no, sube junto con el teclado y tapa lo que se escribe) */
body.typing nav#nav, body.typing .fab, body.typing .savebar { display: none; }

/* Resumen de la portada de presupuestos: tres datos en una tarjeta común (igual que el resto de las pantallas) */
.stats { display: grid; grid-template-columns: 1.4fr 1fr 1fr; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); margin: 0 0 14px; }
.stats .stat { padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stats .stat + .stat { border-left: 1px solid var(--line); }
.stats span { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.stats b { font-size: 17px; font-weight: 800; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stats .stat:first-child b { color: var(--accent); }
@media (max-width: 360px) { .stats b { font-size: 15px; } .stats .stat { padding: 10px; } }

/* --- todas las secciones con la franja verde de Presupuestos --- */
.hero.flat { padding-bottom: 22px; margin-bottom: 14px; }
.hero .big { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hero + .tabs, .new-big + .tabs { margin-top: 12px; }
.section-title .small { min-height: 34px; }
/* Las listas, como la de presupuestos: un solo bloque blanco con renglones */
.list { gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.list > * + * { border-top: 1px solid var(--line); }
.list > .item { border: 0; border-radius: 0; box-shadow: none; }
.list > .empty { padding: 32px 16px; }

/* --- integrantes y reparto --- */
.members { display: flex; flex-direction: column; gap: 8px; }
.member { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) 84px 34px; gap: 6px; align-items: center; }
.member .pct { display: flex; align-items: center; gap: 4px; }
.member .pct span { color: var(--ink-2); font-weight: 700; }
@media (max-width: 480px) { .member { grid-template-columns: minmax(0, 1fr) 84px 34px; } .member > input[type=tel] { grid-column: 1 / -1; grid-row: 2; } }
.totals.split { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 6px; }
.totals .sub-h { color: var(--ink); font-weight: 800; }
.totals .sub-h a { font-size: 13px; }

/* --- reparto: automático / a mano, y la fila propia --- */
.mini-seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--sunk); border-radius: 10px; }
.mini-seg button { min-height: 30px; padding: 3px 10px; font-size: 12.5px; background: transparent; color: var(--ink-2); border-radius: 8px; }
.mini-seg button.on { background: var(--surface); color: var(--accent); box-shadow: var(--shadow); }
.totals .sub-h { align-items: center; gap: 8px; flex-wrap: wrap; }
.totals .mine { color: var(--accent); font-weight: 800; background: var(--accent-soft); border-radius: 8px; padding: 4px 8px; margin: 0 -8px; }
.totals .left { color: var(--s-enviado); font-weight: 700; }
.mline { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 0; color: var(--ink); }
.mline .pct { display: flex; align-items: center; gap: 6px; }
.mline .pct span { color: var(--ink-2); font-weight: 700; }
.mline input { width: 130px; text-align: right; }
.member .login { grid-column: 1 / -1; }

.mline select.unit { width: 64px; min-height: 40px; padding: 6px 22px 6px 8px; background-position: calc(100% - 13px) 52%, calc(100% - 8px) 52%; }

.co-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* --- ayuda --- */
.helpbox { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.help + .help { border-top: 1px solid var(--line); }
.help summary { list-style: none; cursor: pointer; padding: 14px 16px; font-weight: 800; font-size: 15.5px; display: flex; justify-content: space-between; align-items: center; }
.help summary::-webkit-details-marker { display: none; }
.help summary::after { content: '+'; color: var(--accent); font-size: 20px; font-weight: 600; }
.help[open] summary::after { content: '−'; }
.help p { margin: 0 16px 10px; color: var(--ink-2); font-size: 14.5px; line-height: 1.5; }
.help p.li { position: relative; padding-left: 14px; }
.help p.li::before { content: ''; position: absolute; left: 0; top: .6em; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.help[open] { padding-bottom: 6px; }

.help-link { display: inline-flex; align-items: center; gap: 6px; color: inherit; font-weight: 800; font-size: 14px; padding: 5px 12px 5px 6px; border-radius: 99px; background: rgba(255,255,255,.18); }
.help-link .q { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.25); font-size: 13px; }

/* Condición de inicio en la obra */
.start { display: flex; align-items: center; gap: 8px; padding: 10px 12px; margin: 0 0 12px; border-radius: 12px; font-size: 14px; font-weight: 700;
  color: var(--s-enviado); background: color-mix(in srgb, var(--s-enviado) 12%, transparent); }
.start.ok { color: var(--s-aprobado); background: color-mix(in srgb, var(--s-aprobado) 12%, transparent); }

/* --- renglones de gastos, pagos y compras (antes tabla: en celulares angostos se pisaban) --- */
.ledger { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; margin-bottom: 10px; }
.lrow { display: flex; align-items: center; gap: 8px; padding: 8px 4px 8px 12px; }
.lrow + .lrow { border-top: 1px solid var(--line); }
.lrow .ld { flex: 1; min-width: 0; }
.lrow .lt { font-weight: 700; font-size: 14.5px; overflow-wrap: anywhere; }
.lrow .ls { color: var(--ink-3); font-size: 12.5px; }
.lrow .la { font-weight: 800; white-space: nowrap; font-size: 14.5px; }
.pay-kinds { display: flex; width: 100%; margin: 4px 0 10px; }
.pay-kinds button { flex: 1; }
/* Estado: en dos filas en celulares angostos */
@media (max-width: 400px) { .seg:not(.seg3) { grid-template-columns: repeat(2, 1fr); } }
.sub-h2 { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.earn .totals { margin-top: 0; }
/* Totales: el monto nunca se parte; si no entra, se achica la etiqueta */
.totals div { gap: 10px; align-items: baseline; }
.totals div > span:last-child { white-space: nowrap; text-align: right; }
.totals div > span:first-child { min-width: 0; }
@media (max-width: 400px) { .totals .big { font-size: 17px; } .pay-kinds button { font-size: 12px; padding: 3px 4px; white-space: normal; line-height: 1.15; } }

/* Nombre o local del presupuesto debajo del cliente en la lista */
.brow .ref { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brow .who { white-space: normal; }

.place + .place { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; }
