/* ===== App Jose · estilos base ===== */
:root {
  --bg: #f2f5f9;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #5d6b7e;
  --border: #dbe2ec;
  --primary: #1554c4;
  --primary-dark: #0f43a0;
  --primary-soft: #e7effd;
  --ok: #15803d;   --ok-soft: #dcfce7;
  --warn: #a16207; --warn-soft: #fef3c7;
  --info: #1d4ed8; --info-soft: #dbeafe;
  --danger: #b91c1c; --danger-soft: #fee2e2;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 14px rgba(0,0,0,.05);
  --sidebar-w: 230px;
  --tabbar-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141b; --surface: #18202a; --text: #eef2f7; --muted: #9aa8ba;
    --border: #2a3442; --primary: #6ea1ff; --primary-dark: #4f88f5; --primary-soft: #13284f;
    --ok-soft: #14532d; --ok: #86efac; --warn-soft: #422006; --warn: #fcd34d;
    --info-soft: #1e3a8a; --info: #bfdbfe; --danger-soft: #450a0a; --danger: #fca5a5;
  }
}
:root[data-theme="dark"] {
    --bg: #0f141b; --surface: #18202a; --text: #eef2f7; --muted: #9aa8ba;
    --border: #2a3442; --primary: #6ea1ff; --primary-dark: #4f88f5; --primary-soft: #13284f;
    --ok-soft: #14532d; --ok: #86efac; --warn-soft: #422006; --warn: #fcd34d;
    --info-soft: #1e3a8a; --info: #bfdbfe; --danger-soft: #450a0a; --danger: #fca5a5;
  }


* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 4px; }
h2 { font-size: 1.1rem; margin: 0 0 12px; }
.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 12px 0; }

/* ---------- Estructura ---------- */
.main { padding: 20px 16px calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom)); max-width: 1100px; margin: 0 auto; }

.sidebar { display: none; }
.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 20;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: var(--surface); border-top: 1px solid var(--border);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); font-size: .72rem; text-decoration: none;
}
.tabbar a.active { color: var(--primary); }
.tabbar svg, .sidebar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

@media (min-width: 900px) {
  .tabbar { display: none; }
  .sidebar {
    display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
    background: var(--surface); border-right: 1px solid var(--border); padding: 20px 12px;
  }
  .sidebar nav { display: flex; flex-direction: column; gap: 4px; margin-top: 24px; }
  .sidebar nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--text); text-decoration: none; }
  .sidebar nav a:hover { background: var(--bg); }
  .sidebar nav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
  .sidebar-foot { margin-top: auto; display: flex; justify-content: space-between; font-size: .9rem; padding: 0 8px; color: var(--muted); }
  .main { margin-left: var(--sidebar-w); padding: 32px 40px; }
  body:has(.login-wrap) .main { margin-left: auto; }
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 800; }
.brand-lg { font-size: 1.35rem; justify-content: center; }

/* ---------- Cabecera de página ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.back { display: inline-block; margin-bottom: 8px; font-size: .9rem; }

/* ---------- Tarjetas y rejillas ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.grid-2 { display: grid; gap: 16px; }
@media (min-width: 900px) { .grid-2 { grid-template-columns: 1fr 1fr; } .grid-2 > .card { margin-bottom: 0; } }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
@media (min-width: 900px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; }
.stat-num { font-size: 1.8rem; font-weight: 700; line-height: 1.1; }
.stat-lbl { color: var(--muted); font-size: .85rem; }

/* ---------- Listas ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); }
.list > li:first-child { border-top: 0; }
.list-time { font-weight: 700; color: var(--primary); min-width: 48px; }
.list-body { flex: 1; min-width: 0; }
.list-link { display: flex; justify-content: space-between; gap: 12px; width: 100%; color: inherit; }
.list-link:hover { text-decoration: none; }
.list-link:hover strong { color: var(--primary); }
.actions-inline { display: flex; gap: 16px; margin-top: 4px; font-size: .9rem; }

/* ---------- Tabla (PC) / tarjetas (móvil) ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--border); }
.table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.table tr:hover td { background: var(--bg); }
@media (max-width: 699px) {
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: 12px 0; border-bottom: 1px solid var(--border); }
  .table td { border: 0; padding: 2px 0; }
  .table td[data-hide-mobile] { display: none; }
}

/* ---------- Formularios ---------- */
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 14px; }
input, select, textarea {
  display: block; width: 100%; margin-top: 6px; padding: 12px; font: inherit; font-weight: 400;
  color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: transparent; }
textarea { min-height: 96px; resize: vertical; }
.form-grid { display: grid; gap: 0 16px; }
@media (min-width: 700px) { .form-grid { grid-template-columns: 1fr 1fr; } .form-grid .full { grid-column: 1 / -1; } }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.field-error { color: var(--danger); font-size: .85rem; font-weight: 400; }

.search { display: flex; gap: 8px; margin-bottom: 16px; }
.search input { margin: 0; }
.search { align-items: center; }
.search-n { white-space: nowrap; min-width: 52px; text-align: right; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 18px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { color: var(--danger); border-color: var(--danger-soft); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: .9rem; }

/* ---------- Avisos y etiquetas ---------- */
.flash { padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; }
.flash-ok { background: var(--ok-soft); color: var(--ok); }
.flash-error { background: var(--danger-soft); color: var(--danger); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; vertical-align: middle; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-muted { background: var(--border); color: var(--muted); }

/* ---------- Ficha ---------- */
.dl { display: grid; grid-template-columns: 120px 1fr; gap: 8px 12px; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; overflow-wrap: anywhere; }
.quick-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.quick-actions .btn { flex-direction: column; font-size: .85rem; padding: 12px 6px; }

/* ---------- Login ---------- */
.login-wrap { min-height: 80vh; display: grid; place-items: center; }
.login-card { width: 100%; max-width: 380px; text-align: center; }
.login-card label { text-align: left; }

.placeholder { text-align: center; padding: 48px 16px; }

/* =====================================================
   v0.2 · Visitas y Ajustes
   ===================================================== */
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.eyebrow { margin: 0 0 4px; font-size: .9rem; color: var(--muted); font-weight: 600; }
a.plain { color: inherit; }
h3 { font-size: 1rem; margin: 20px 0 10px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.alert { display: block; background: var(--warn-soft); color: var(--warn); padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; font-weight: 600; }
.warn-text { color: var(--warn); font-weight: 600; }
.empty-state { text-align: center; padding: 32px 16px; }
.empty-state p { color: var(--muted); }
.inline-form { display: inline-block; margin-top: 12px; }
.btn-xl { padding: 16px 22px; font-size: 1.05rem; width: 100%; }
@media (min-width: 700px) { .btn-xl { width: auto; } }
.section-title { font-size: 1.05rem; margin: 24px 0 10px; }

/* Pasos numerados */
.step { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--primary); color: #fff; font-size: .8rem; margin-right: 6px; vertical-align: 2px; }
.phase-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.phase-head h2 { margin: 0; }
.phase-next { border: 2px solid var(--primary); }
.note { background: var(--bg); border-radius: 10px; padding: 12px 14px; margin-top: 14px; white-space: normal; }

/* Selector de cliente */
.picked { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 10px; background: var(--primary-soft); }
.results { list-style: none; margin: 8px 0 12px; padding: 0; }
.results li button { display: block; width: 100%; text-align: left; padding: 12px; border: 0; border-bottom: 1px solid var(--border); background: none; font: inherit; color: var(--text); cursor: pointer; }
.results li button:hover { background: var(--bg); }
.radio-list { display: grid; gap: 8px; margin-bottom: 12px; }
.radio { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border: 1px solid var(--border); border-radius: 10px; font-weight: 400; margin: 0; cursor: pointer; }
.radio:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.radio input { width: auto; margin: 3px 0 0; accent-color: var(--primary); }
.form-grid-3 { display: grid; gap: 0 12px; grid-template-columns: 1fr 1fr; }
.form-grid-3 label:first-child { grid-column: 1 / -1; }
@media (min-width: 700px) { .form-grid-3 { grid-template-columns: 2fr 1fr 1fr; } .form-grid-3 label:first-child { grid-column: auto; } }
.sticky-actions { position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); background: var(--bg); padding: 12px 0; margin: 0; z-index: 5; }
@media (min-width: 900px) { .sticky-actions { bottom: 0; } }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: -6px 0 14px; }
.chip { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px; padding: 7px 13px; font: inherit; font-size: .9rem; cursor: pointer; }
.chip:hover, .chip:active { border-color: var(--primary); color: var(--primary); }
.chip-sm { padding: 4px 10px; font-size: .8rem; }

/* Agenda */
.segmented { display: inline-flex; background: var(--border); border-radius: 10px; padding: 3px; margin-top: 6px; }
.segmented a { padding: 5px 14px; border-radius: 8px; color: var(--muted); font-size: .9rem; font-weight: 600; text-decoration: none; }
.segmented a.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.tabs { display: flex; gap: 4px; overflow-x: auto; margin-bottom: 16px; border-bottom: 1px solid var(--border); scrollbar-width: none; }
.tabs a { padding: 10px 12px; color: var(--muted); font-weight: 600; white-space: nowrap; border-bottom: 2px solid transparent; text-decoration: none; }
.tabs a.on { color: var(--primary); border-color: var(--primary); }
.count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--warn); color: #fff; font-size: .75rem; }
.day-title { font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 20px 0 8px; }
.day-title.today { color: var(--primary); }
.visit-list { padding: 0 18px; }
.visit { display: flex; gap: 14px; width: 100%; color: inherit; }
.visit:hover { text-decoration: none; }
.visit:hover strong { color: var(--primary); }
.visit-time { font-weight: 700; color: var(--primary); min-width: 52px; display: flex; flex-direction: column; }
.visit-time small { color: var(--muted); font-weight: 400; font-size: .75rem; }
.week-nav { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.week-nav strong { min-width: 130px; text-align: center; }
.week { display: grid; gap: 8px; }
@media (min-width: 900px) { .week { grid-template-columns: repeat(7, 1fr); } }
.week-day { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; min-height: 64px; }
@media (min-width: 900px) { .week-day { min-height: 300px; } }
.week-day.today { border-color: var(--primary); }
.week-head { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; color: var(--muted); font-size: .85rem; }
.week-day.today .week-head { color: var(--primary); }
.week-head strong { color: var(--text); font-size: 1.1rem; }
.week-add { margin-left: auto; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; color: var(--muted); font-size: 1.2rem; text-decoration: none; }
.week-add:hover { background: var(--primary-soft); color: var(--primary); text-decoration: none; }
.week-item { display: block; padding: 6px 8px; margin-bottom: 6px; border-radius: 8px; background: var(--primary-soft); color: var(--text); font-size: .85rem; border-left: 3px solid var(--primary); text-decoration: none; }
.week-item span { display: block; color: var(--muted); font-size: .75rem; }
.week-item.est-realizada { background: var(--ok-soft); border-color: var(--ok); }
.week-item:hover { text-decoration: none; filter: brightness(.97); }

/* Ficha de visita */
.quick-actions.qa-4 { grid-template-columns: repeat(4, 1fr); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; display: block; background: var(--border); }
.gallery figure { margin: 0; position: relative; }
.gallery figcaption { font-size: .72rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gallery-edit { margin-top: 16px; }
.photo-del { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; font-size: 1.1rem; line-height: 1; cursor: pointer; }
.table tfoot th { color: var(--text); text-transform: none; font-size: .9rem; }
@media (max-width: 699px) { .table tfoot { display: block; } .table tfoot tr { display: flex; gap: 12px; } .table tfoot th { padding: 8px 0; border: 0; } }

/* Pantalla en obra */
.onsite-bar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px; margin: -20px -16px 12px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
.onsite-bar .back { margin: 0; white-space: nowrap; }
.onsite-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.onsite-title > * { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (min-width: 900px) { .onsite-bar { margin: -32px -40px 16px; padding: 12px 40px; } }
.note-card summary { cursor: pointer; font-weight: 600; }
details.est { padding: 0; }
details.est > summary { list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 18px; cursor: pointer; }
details.est > summary::-webkit-details-marker { display: none; }
details.est[open] > summary { border-bottom: 1px solid var(--border); }
details.est .chev { font-size: 1.5rem; color: var(--muted); transition: transform .15s; }
details.est[open] .chev { transform: rotate(90deg); }
.est-form { padding: 16px 18px; }
.est-jobs { margin-top: 4px; }
.est-new { border-style: dashed; }
.est-new > summary strong { color: var(--primary); }
.measures { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.measures label { margin-bottom: 6px; }
.m2-out { min-height: 1.2em; margin: 0 0 12px; font-weight: 600; color: var(--primary); }
.btn-file { position: relative; overflow: hidden; margin: 4px 0 0; }
.btn-file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; }

/* Ajustes */
.theme-picker { display: grid; gap: 10px; }
@media (min-width: 700px) { .theme-picker { grid-template-columns: repeat(3, 1fr); } }
.theme-opt { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; margin: 0; font-weight: 400; cursor: pointer; }
.theme-opt:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.theme-opt input { position: absolute; opacity: 0; pointer-events: none; }
.theme-swatch { width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--border); flex: none; }
.theme-sistema .theme-swatch { background: linear-gradient(135deg, #f6f4f0 50%, #171412 50%); }
.theme-claro .theme-swatch { background: #fff; }
.theme-oscuro .theme-swatch { background: #171412; }
.stats-sm .stat-num { font-size: 1.3rem; }
.form-actions .inline-form { margin: 0; }
.photo-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn-file.disabled { opacity: .5; pointer-events: none; }

/* =====================================================
   v0.3 · Medición por huecos
   ===================================================== */
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.section-head .section-title { margin: 24px 0 10px; }
details.hueco > summary { justify-content: flex-start; }
.hueco-thumb { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; flex: none; background: var(--border); }
.hueco-thumb-empty { display: grid; place-items: center; font-size: 1.4rem; opacity: .6; }
.hueco-sum { flex: 1; min-width: 0; }
details.hueco .chev { margin-left: auto; }
.hueco-body { padding: 14px 18px 18px; }
.hueco-fotos { margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px dashed var(--border); }
.hueco-fotos .gallery-edit { margin: 0 0 10px; }
.hueco-form { padding: 0; }
.measures-2 { grid-template-columns: 1fr 1fr; }
.seg-radio { display: flex; width: 100%; margin: 0 0 14px; }
.seg-radio label { flex: 1; margin: 0; font-weight: 600; font-size: .9rem; text-align: center; cursor: pointer; }
.seg-radio input { position: absolute; opacity: 0; pointer-events: none; }
.seg-radio span { display: block; padding: 8px 6px; border-radius: 8px; color: var(--muted); }
.seg-radio input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.hint { font-size: .8rem; color: var(--muted); margin: -8px 0 14px; }
.chip.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.confirm-box { background: var(--warn-soft); border-radius: 10px; padding: 12px; margin: 4px 0 14px; }
.confirm-box .check { display: flex; align-items: center; gap: 10px; margin: 0 0 8px; color: var(--warn); }
.confirm-box .check input { width: 20px; height: 20px; margin: 0; accent-color: var(--warn); }
.confirm-box input[name=dudas] { margin: 0; }
.huecos-head { margin-top: 18px; }
.huecos-head h3 { margin: 0; }

/* Ajustes separado del resto de opciones */
.sidebar .sidebar-bottom { display: flex; flex-direction: column; gap: 4px; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }
.sidebar-bottom a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--text); text-decoration: none; }
.sidebar-bottom a:hover { background: var(--bg); }
.sidebar-bottom a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.sidebar-bottom + .sidebar-foot { margin-top: 12px; }
.tabbar-sep { width: 1px; margin: 14px 0; background: var(--border); flex: none; }
.tabbar a.tab-ajustes { flex: 0 0 64px; }

/* Agenda · vista mensual */
.month { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.month-dow { text-align: center; font-size: .75rem; font-weight: 600; color: var(--muted); padding: 4px 0; }
.month-day { display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 52px; padding: 6px 2px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); color: var(--text); text-decoration: none; overflow: hidden; }
.month-day:hover { text-decoration: none; border-color: var(--primary); }
.month-day.out { opacity: .45; }
.month-day.today .month-num { background: var(--primary); color: #fff; }
.month-day.sel { border: 2px solid var(--primary); }
.month-num { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; font-weight: 600; font-size: .9rem; }
.month-dots { display: flex; gap: 3px; }
.month-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--primary); }
.month-dots i.est-realizada { background: var(--ok); }
.month-items { display: none; }
.month-sel { margin-top: 18px; }
.month-sel h3 { margin: 0; }
@media (min-width: 900px) {
  .month-day { align-items: stretch; min-height: 110px; padding: 6px; }
  .month-num { align-self: flex-end; }
  .month-dots { display: none; }
  .month-items { display: flex; flex-direction: column; gap: 3px; }
  .month-item { font-size: .75rem; padding: 2px 5px; border-radius: 5px; background: var(--primary-soft); border-left: 3px solid var(--primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .month-item.est-realizada { background: var(--ok-soft); border-color: var(--ok); }
  .month-more { font-size: .72rem; color: var(--muted); padding-left: 4px; }
}

/* =====================================================
   v0.4 · Presupuestos
   ===================================================== */
.inline-form { display: inline-block; }
.head-actions .inline-form { margin: 0; }
.linea { border: 1px solid var(--border); border-radius: 10px; padding: 10px; margin-bottom: 8px; background: var(--surface); }
.linea.sin-precio { border-color: var(--warn); background: var(--warn-soft); }
.linea textarea { min-height: 54px; margin: 0 0 8px; }
.linea-nums { display: grid; grid-template-columns: 1fr 1fr 1.2fr; gap: 8px; align-items: end; }
.linea-nums label { margin: 0; font-size: .8rem; }
.linea-nums input, .linea-nums select { margin-top: 3px; padding: 9px; }
.linea-importe { display: flex; flex-direction: column; align-items: flex-end; grid-column: 1 / 3; }
.linea-del { justify-self: end; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--danger); font-size: 1.2rem; cursor: pointer; }
@media (min-width: 700px) {
  .linea { display: grid; grid-template-columns: 1fr 380px; gap: 10px; align-items: start; }
  .linea textarea { margin: 0; }
  .linea-nums { grid-template-columns: 70px 80px 90px 1fr 36px; }
  .linea-importe { grid-column: auto; }
}
.add-linea { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 4px; }
.add-linea select { width: auto; flex: 1; min-width: 200px; margin: 0; }
.totales { margin: 16px 0 0 auto; max-width: 360px; border-top: 1px solid var(--border); padding-top: 8px; }
.totales > div { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; gap: 12px; }
.totales .pct { display: inline-block; width: 62px; margin: 0 2px; padding: 5px 7px; text-align: right; }
.totales .total { border-top: 2px solid var(--text); margin-top: 4px; padding-top: 10px; font-size: 1.2rem; }
.cat-head, .cat-row { display: grid; grid-template-columns: 2fr 1.2fr 80px 100px 50px; gap: 8px; align-items: center; }
.cat-head { font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); padding: 0 0 6px; }
.cat-row { padding: 6px 0; border-top: 1px solid var(--border); }
.cat-row input, .cat-row select { margin: 0; padding: 9px; }
.cat-row .check { margin: 0; display: flex; justify-content: center; }
.cat-row .check input { width: 20px; height: 20px; accent-color: var(--primary); }
.cat-row.inactiva { opacity: .5; }
.cat-row.sin-precio input[name$="[precio]"] { border-color: var(--warn); background: var(--warn-soft); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
@media (max-width: 699px) {
  .cat-head { display: none; }
  .cat-row { grid-template-columns: 1fr 1fr; padding: 10px 0; }
  .cat-row input:first-child { grid-column: 1 / -1; font-weight: 600; }
}


/* =====================================================
   v0.5 · Fichas de medición (plantilla de Jose)
   ===================================================== */
.ico { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.desktop-only { display: none; }
@media (min-width: 900px) { .desktop-only { display: flex; } }
h1 { color: var(--primary); }
.page-head h1 .muted { font-size: 1rem; font-weight: 500; }

/* Navegación: "Nueva medición" destacada */
.sidebar nav a.nav-nueva { background: var(--primary); color: #fff; font-weight: 600; margin: 4px 0; }
.sidebar nav a.nav-nueva:hover, .sidebar nav a.nav-nueva.active { background: var(--primary-dark); color: #fff; }
.tabbar a.tab-nueva svg { background: var(--primary); color: #fff; border-radius: 50%; padding: 5px; width: 34px; height: 34px; margin-top: -6px; }
.tabbar a { font-size: .68rem; }

/* Cabecera de la ficha */
.ficha-cab { padding: 14px 16px; }
.cab-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.cab-grid label { margin-bottom: 10px; }
.cab-grid .cab-dir { grid-column: 1 / -1; }
@media (min-width: 900px) { .cab-grid { grid-template-columns: 1fr 1fr 170px 130px; } .cab-grid .cab-dir { grid-column: 1 / 3; } }
.input-ico { position: relative; display: block; }
.input-ico > .ico { position: absolute; left: 11px; top: 50%; transform: translateY(-40%); color: var(--primary); pointer-events: none; width: 20px; height: 20px; }
.input-ico > input, .input-ico > select { padding-left: 40px; }
.dir-row { display: flex; gap: 8px; align-items: stretch; }
.dir-row .input-ico { flex: 1; }
.btn-maps { margin-top: 6px; padding: 0 12px; white-space: nowrap; }
.btn-maps .ico { color: #1a9a4a; }
@media (max-width: 699px) { .btn-maps span { display: none; } }
.otro-input { margin-top: 6px; }

/* Filas de la ficha: icono + etiqueta | campos */
.ficha-med { padding: 4px 16px; }
.mrow { display: grid; grid-template-columns: 116px 1fr; gap: 10px; align-items: start; padding: 10px 0; border-top: 1px solid var(--border); }
.mrow:first-child { border-top: 0; }
.mlabel { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: .95rem; min-height: 44px; color: var(--text); }
.mlabel .ico { color: var(--primary); }
.mfield select, .mfield input, .mfield textarea { margin-top: 0; }
.mfield-obs { display: grid; gap: 6px; }
@media (min-width: 900px) {
  .mrow { grid-template-columns: 190px 1fr; }
  .mfield-obs { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
  .mrow-alto .mfield-obs { grid-template-columns: 1fr; }
  .mrow-simple .mfield { max-width: 320px; }
}
textarea.obs { min-height: 42px; height: 42px; resize: vertical; font-size: .9rem; }
.mrow-alto { background: var(--primary-soft); margin: 0 -16px; padding: 10px 16px; }
.num-cm { display: flex; align-items: stretch; }
.num-cm input { border-top-right-radius: 0; border-bottom-right-radius: 0; min-width: 0; }
.num-cm em { display: grid; place-items: center; padding: 0 10px; font-style: normal; color: var(--muted); background: var(--bg); border: 1px solid var(--border); border-left: 0; border-radius: 0 10px 10px 0; font-size: .85rem; }
.medida-line { display: grid; grid-template-columns: 130px 1fr; gap: 8px; }
.mrow-alto .medida-line { grid-template-columns: 1fr; }
@media (min-width: 900px) { .mrow-alto .medida-line { max-width: 260px; } }
.alto-tres { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 6px; }
.alto-tres label { margin: 0; font-size: .8rem; color: var(--primary); }
.alto-tres input { padding: 10px 8px; }
.alto-tres em { padding: 0 6px; }

/* Fotos de la medición */
.foto-zona { display: flex; gap: 10px; flex-wrap: wrap; align-items: stretch; }
.foto-main { margin: 0; position: relative; width: 150px; }
.foto-main img { width: 150px; height: 180px; object-fit: cover; border-radius: 8px; display: block; }
.foto-main.reemplazada { opacity: .35; }
.foto-preview { display: contents; }
.foto-preview img { width: 150px; height: 180px; object-fit: cover; border-radius: 8px; border: 2px solid var(--primary); }
.mas-fotos .foto-preview img { width: 92px; height: 92px; }
.foto-drop, .foto-add { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; border: 2px dashed var(--border); border-radius: 10px; color: var(--primary); font-size: .85rem; font-weight: 500; cursor: pointer; margin: 0; }
.foto-drop { width: 130px; min-height: 140px; padding: 10px; }
.foto-drop .ico { width: 30px; height: 30px; }
.foto-drop:hover, .foto-add:hover { border-color: var(--primary); background: var(--primary-soft); }
.foto-drop input, .foto-add input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.mas-fotos { display: flex; flex-wrap: wrap; gap: 8px; }
.mas-fotos figure { margin: 0; position: relative; }
.mas-fotos figure img { width: 92px; height: 92px; object-fit: cover; border-radius: 8px; display: block; }
.foto-add { width: 92px; height: 92px; }
.foto-add .plus { font-size: 1.8rem; line-height: 1; }
.medida-actions { justify-content: stretch; }
.medida-actions .btn { flex: 1; }
@media (min-width: 900px) { .medida-actions .btn { flex: 0 0 auto; } }

/* Ficha del proyecto */
.ficha-acciones { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.ficha-acciones .inline-form { margin: 0; }
.med-list { display: grid; gap: 10px; }
@media (min-width: 900px) { .med-list { grid-template-columns: 1fr 1fr; } }
.med-card { margin: 0; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.med-main { display: flex; gap: 12px; color: inherit; text-decoration: none; }
.med-main:hover { text-decoration: none; }
.med-main:hover strong { color: var(--primary); }
.med-thumb { width: 76px; height: 90px; object-fit: cover; border-radius: 8px; flex: none; background: var(--bg); }
.med-thumb-empty { display: grid; place-items: center; color: var(--muted); }
.med-info { min-width: 0; }
.med-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.med-actions .inline-form { margin: 0; margin-left: auto; }
.add-med { margin-top: 12px; }
.zona-peligro { display: flex; gap: 8px; margin-top: 24px; flex-wrap: wrap; }
.zona-peligro .inline-form { margin: 0; }

/* Listado de mediciones */
.filtros { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.filtros select, .filtros input { width: auto; margin: 0; }
.filtros input[type=search] { flex: 1; min-width: 180px; }
.filtro-cliente { position: relative; margin: 0; display: flex; align-items: center; }
.filtro-cliente .ico { position: absolute; left: 10px; color: var(--primary); width: 20px; height: 20px; pointer-events: none; }
.filtro-cliente select { padding-left: 38px; min-width: 210px; font-weight: 600; }
.leyenda { display: flex; gap: 16px; font-size: .8rem; color: var(--muted); margin: 0 0 12px; }
.leyenda span { display: flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-pend { background: var(--warn); }
.dot-ok { background: var(--ok); }
.cli-tag { display: inline-block; font-weight: 600; color: var(--primary); }
.month-dots i { background: var(--warn); }
.month-item { background: var(--warn-soft) !important; border-color: var(--warn) !important; }
.month-item.est-realizada { background: var(--ok-soft) !important; border-color: var(--ok) !important; }
.week-item { background: var(--warn-soft); border-color: var(--warn); }
.week-item.est-realizada { background: var(--ok-soft); border-color: var(--ok); }
a.stat { color: inherit; text-decoration: none; }
a.stat:hover { border-color: var(--primary); }
.users { display: grid; gap: 8px; margin-bottom: 12px; }
.user-row { display: grid; grid-template-columns: 1fr; gap: 8px; padding: 10px; border: 1px solid var(--border); border-radius: 10px; align-items: center; }
.user-row.inactiva { opacity: .55; }
.user-info { display: flex; flex-direction: column; }
.user-row select, .user-row input { margin: 0; }
.user-row .check { margin: 0; display: flex; gap: 6px; align-items: center; font-weight: 500; }
.user-row .check input { width: 18px; height: 18px; }
@media (min-width: 900px) { .user-row { grid-template-columns: 1.6fr 150px 90px 1fr auto; } }
.nuevo-usuario summary { list-style: none; display: inline-flex; }
.nuevo-usuario summary::-webkit-details-marker { display: none; }
.cab-grid > label, .cab-grid .input-ico, .cab-grid input, .cab-grid select { min-width: 0; }
.mfield, .mlabel { min-width: 0; }
.mlabel span { overflow-wrap: anywhere; hyphens: auto; line-height: 1.2; }
@media (max-width: 420px) { .mrow { grid-template-columns: 104px 1fr; } .mlabel { font-size: .88rem; gap: 6px; } .mlabel .ico { width: 20px; height: 20px; } }
.add-med { margin-bottom: 16px; }
@media (max-width: 520px) {
  .medida-line { grid-template-columns: 1fr; }
  .alto-tres em { display: none; }
  .alto-tres input { border-radius: 10px !important; padding: 10px 6px; text-align: center; }
  .alto-tres label::after { content: ''; }
  .medida-actions { gap: 6px; padding: 8px 0; }
  .medida-actions .btn { padding: 9px 6px; font-size: .88rem; }
}
.cab-grid .cab-notas { grid-column: 1 / -1; }
@media (max-width: 899px) { .tabbar a { font-size: .62rem; } .tabbar svg { width: 22px; height: 22px; } .tabbar a.tab-ajustes { flex: 0 0 52px; } }

/* Ayuda */
.ayuda-indice { display: flex; flex-wrap: wrap; gap: 8px; }
.ayuda-indice a { padding: 6px 12px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-size: .9rem; text-decoration: none; }
.ayuda-indice a:hover { background: var(--primary); color: #fff; }
.ayuda { scroll-margin-top: 16px; }
.ayuda h3 { margin: 18px 0 8px; font-size: 1rem; color: var(--primary); }
.ayuda p { line-height: 1.55; }
.ayuda-pasos { padding-left: 20px; line-height: 1.6; }
.ayuda-pasos li { margin-bottom: 6px; }
.ayuda-campos { display: grid; grid-template-columns: 190px 1fr; margin: 0; border-top: 1px solid var(--border); }
.ayuda-campos dt, .ayuda-campos dd { margin: 0; padding: 10px 8px; border-bottom: 1px solid var(--border); line-height: 1.5; }
.ayuda-campos dt { font-weight: 600; }
@media (max-width: 640px) {
  .ayuda-campos { grid-template-columns: 1fr; }
  .ayuda-campos dt { border-bottom: 0; padding-bottom: 2px; }
  .ayuda-campos dd { padding-top: 0; color: var(--muted); }
}

/* Desplegables */
.desp-nota { margin: -4px 0 14px; }
.desp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(400px, 1fr)); gap: 16px; align-items: start; }
.desp-grid .card { margin: 0; }
.desp h2 { display: flex; align-items: center; gap: 8px; }
.desp h2 svg { width: 20px; height: 20px; fill: none; stroke: var(--primary); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.desp-lista { list-style: none; margin: 8px 0 10px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.desp-item { display: flex; align-items: center; gap: 4px; }
.desp-item input[name="val[]"] { flex: 1; min-width: 0; margin: 0; }
.desp-usos { min-width: 48px; text-align: right; padding-right: 4px; white-space: nowrap; }
.desp-btn { width: 34px; height: 38px; flex: none; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px; cursor: pointer; font-size: 1rem; line-height: 1; }
.desp-btn:hover { background: var(--primary-soft); color: var(--primary); }
.desp-quitar:hover { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.desp-acciones { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.desp-restaurar { margin-left: auto; }
.desp-cambiado .btn-primary { box-shadow: 0 0 0 3px var(--primary-soft); }
.desp label.desp-check { display: flex; flex-direction: row; align-items: center; gap: 8px; font-weight: 400; color: var(--muted); margin: 0; }
.desp label.desp-check input { width: auto; margin: 0; flex: none; }
@media (max-width: 640px) { .desp-grid { grid-template-columns: 1fr; } .desp-usos { min-width: 0; } }

/* Clientes: subpestañas Empresas / Clientes finales */
.subtabs { margin-top: -4px; }
.subtabs a { font-size: 1rem; }
.tab-n { display: inline-block; min-width: 22px; padding: 0 6px; margin-left: 4px; border-radius: 999px; background: var(--border); color: var(--muted); font-size: .75rem; text-align: center; }
.subtabs a.on .tab-n { background: var(--primary-soft); color: var(--primary); }

/* Cabecera de medición: buscador de cliente final */
.cf-campo { position: relative; }
.cf-estado { display: block; min-height: 1.2em; margin-top: 3px; font-weight: 500; }
.cf-estado.ok { color: var(--ok); }
.cf-estado.nuevo { color: var(--primary); }
.cf-lista { position: absolute; z-index: 30; left: 0; right: 0; top: 100%; margin-top: -18px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.12); overflow: hidden; }
.cf-op { display: block; width: 100%; text-align: left; padding: 10px 12px; border: 0; border-bottom: 1px solid var(--border); background: none; color: var(--text); cursor: pointer; font: inherit; }
.cf-op:last-child { border-bottom: 0; }
.cf-op:hover, .cf-op:focus { background: var(--primary-soft); }
.cf-op span { display: block; font-weight: 400; }
.list-link > .badge, .list-link > .nowrap { align-self: center; }

/* Desplegables con buscador (app.js → buscable) */
.cbx { position: relative; }
.cbx-native { display: none !important; }
.cbx-btn { display: block; width: 100%; margin-top: 6px; padding: 12px 36px 12px 12px; font: inherit; font-weight: 400; text-align: left;
  color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 48px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%236b7a8f' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; }
.cbx-btn:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: transparent; }
.cbx-btn.cbx-vacio { color: var(--muted); }
.mfield .cbx-btn { margin-top: 0; }
.input-ico > .ico { z-index: 2; }
.input-ico > .cbx .cbx-btn { padding-left: 40px; }
.cbx.abierto .cbx-btn { outline: 2px solid var(--primary); border-color: transparent; }
.cbx-panel { position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 4px); min-width: 220px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.16); padding: 8px; font-weight: 400; }
.cbx-q { margin: 0 0 6px !important; padding: 10px 12px !important; }
.cbx-ops { max-height: 280px; overflow-y: auto; overscroll-behavior: contain; }
.cbx-op { display: block; width: 100%; text-align: left; padding: 10px 12px; border: 0; border-radius: 8px; background: none; color: var(--text); font: inherit; cursor: pointer; }
.cbx-op small { display: block; color: var(--muted); font-size: .8rem; }
.cbx-op:hover, .cbx-op.activo { background: var(--primary-soft); }
.cbx-op.sel { font-weight: 600; color: var(--primary); }
.cbx-op-vacia { color: var(--muted); }
.cbx-op-otro { color: var(--primary); font-weight: 600; border-top: 1px solid var(--border); border-radius: 0 0 8px 8px; margin-top: 4px; }
.cbx-nada { margin: 0; padding: 10px 12px; color: var(--muted); }

/* =====================================================
   v0.7 · Trabajos, selección múltiple y calendario
   ===================================================== */
.btn-outline { border-color: var(--primary); color: var(--primary); background: var(--surface); }
.btn-outline:hover { background: var(--primary-soft); }
.btn .ico { width: 18px; height: 18px; }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
:root[data-theme="dark"] .btn-ok { color: #0f141b; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-ok { color: #0f141b; } }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
:root[data-theme="dark"] .btn-danger-solid { color: #0f141b; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-danger-solid { color: #0f141b; } }
.count-danger { background: var(--danger); }
:root[data-theme="dark"] .count-danger { color: #0f141b; }
@media (min-width: 900px) { .stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); } }
h1 .badge { font-size: .8rem; vertical-align: middle; }
h2 .ico { width: 20px; height: 20px; vertical-align: -4px; color: var(--primary); }
strong .ico { width: 16px; height: 16px; vertical-align: -2px; color: var(--muted); }

/* --- Selección múltiple en listados --- */
.sel-col { width: 40px; }
.sel-col input { width: 20px; height: 20px; margin: 0; accent-color: var(--primary); cursor: pointer; }
.tabla-sel tr.sel-on td { background: var(--primary-soft); }
.sel-bar { position: sticky; top: 0; z-index: 6; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 10px 12px; margin: -6px -6px 10px; border-radius: 10px; background: var(--primary-soft); font-weight: 600; }
.sel-bar [data-sel-n] { margin-right: auto; color: var(--primary); }
@media (max-width: 699px) {
  .tabla-sel tr { position: relative; padding-left: 36px; }
  .tabla-sel td.sel-col { position: absolute; left: 0; top: 14px; width: auto; }
  .tabla-sel thead { display: block; }
  .tabla-sel thead tr { display: flex; align-items: center; gap: 8px; padding: 0 0 8px; border-bottom: 1px solid var(--border); }
  .tabla-sel thead th { display: none; padding: 0; border: 0; }
  .tabla-sel thead th.sel-col { display: block; position: static; }
  .tabla-sel thead th.sel-col::after { content: 'Seleccionar todo'; }
  .tabla-sel thead th.sel-col { display: flex; gap: 8px; align-items: center; width: auto; text-transform: none; letter-spacing: 0; font-size: .85rem; }
  .sel-bar { position: sticky; top: 0; }
}

/* --- Formulario de trabajo --- */
@media (min-width: 900px) {
  .cab-grid.tb-cab { grid-template-columns: 1fr 1fr 230px; }
  .cab-grid.tb-cab .cf-campo { grid-column: 2 / 4; }
  .cab-grid.tb-cab .cab-dir { grid-column: 1 / 3; }
}
.tb-cab .tb-precio, .tb-cab .tb-estado { min-width: 0; }
.cab-grid.tb-cab .tb-estado { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
@media (max-width: 899px) { .cab-grid.tb-cab .tb-precio { grid-column: 1 / -1; } }
.input-euro .ico-txt { position: absolute; left: 1px; top: 7px; bottom: 1px; width: 38px; display: grid; place-items: center; color: var(--primary); font-weight: 700; border-right: 1px solid var(--border); pointer-events: none; z-index: 2; }
.input-euro input { padding-left: 50px !important; font-weight: 600; }
.tb-lbl-strong { font-weight: 600; font-size: .9rem; }
.seg-radio { display: inline-flex; gap: 6px; }
.seg-radio label { margin: 0; cursor: pointer; flex: none; width: auto; }
.seg-radio input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg-radio span { display: inline-block; padding: 7px 16px; border-radius: 999px; border: 1px solid var(--border); font-weight: 600; color: var(--muted); }
.seg-radio input:focus-visible + span { outline: 2px solid var(--primary); }
.seg-pend input:checked + span { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.seg-ok input:checked + span { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }

.tb-dia { padding: 0; overflow: visible; }
.tb-dia-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; background: var(--primary-soft); border-radius: var(--radius) var(--radius) 0 0; border-bottom: 1px solid var(--border); }
.tb-fecha { position: relative; display: flex; align-items: center; gap: 10px; margin: 0; color: var(--primary); font-size: 1.05rem; font-weight: 700; cursor: pointer; min-width: 0; }
.tb-fecha .ico { color: var(--primary); width: 24px; height: 24px; }
.tb-fecha input[type=date] { position: absolute; inset: 0; opacity: 0; margin: 0; padding: 0; width: 100%; cursor: pointer; }
.tb-dia-ver .tb-fecha { cursor: default; }
.tb-del { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 8px; background: none; color: var(--danger); cursor: pointer; flex: none; }
.tb-del:hover { background: var(--danger-soft); }
.tb-del .ico { width: 20px; height: 20px; }
.tb-cols { display: none; }
.tb-bloques { padding: 6px 16px 0; }
.tb-bloque { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; padding: 12px; margin: 8px 0; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.tb-bloque label { margin: 0; font-weight: 500; }
.tb-bloque input, .tb-bloque textarea { margin-top: 4px; }
.tb-bloque-titulo { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; color: var(--primary); font-weight: 700; }
.tb-bloque-titulo .ico { width: 20px; height: 20px; }
.tb-bloque-titulo .tb-del { margin-left: auto; width: 30px; height: 30px; }
.tb-lbl { display: block; font-size: .85rem; color: var(--text); }
.tb-c-dur, .tb-c-obs { grid-column: 1 / -1; }
.tb-c-dur { display: grid; grid-template-columns: 110px 1fr; align-items: center; }
.tb-dur { display: block; padding: 10px 12px; border-radius: 10px; background: var(--bg); font-weight: 600; color: var(--text); white-space: nowrap; }
.tb-dur.tb-dur-mal { color: var(--danger); background: var(--danger-soft); }
.tb-del-row { display: none; }
.tb-bloque input[type=time] { min-width: 0; }
.tb-dia-foot { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; padding: 8px 16px 14px; }
.tb-total-dia { display: flex; align-items: center; gap: 10px; font-weight: 600; margin-left: auto; }
.tb-total-dia output { padding: 8px 16px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); font-size: 1.15rem; font-weight: 700; white-space: nowrap; }
.tb-add-dia { margin: 0 0 16px; }
@media (min-width: 900px) {
  .tb-cols, .tb-bloque { display: grid; grid-template-columns: 135px 135px 130px minmax(0, 1fr) 36px; gap: 12px; align-items: start; }
  .tb-cols { padding: 12px 16px 0; font-size: .85rem; font-weight: 600; }
  .tb-bloque { padding: 0; margin: 10px 0; border: 0; }
  .tb-bloque-titulo, .tb-lbl { display: none; }
  .tb-c-dur, .tb-c-obs { grid-column: auto; }
  .tb-c-dur { display: block; }
  .tb-dur { margin-top: 4px; padding: 11px 12px; text-align: center; }
  .tb-del-row { display: grid; margin-top: 8px; }
  .tb-bloque .input-ico > input { padding-left: 38px; padding-right: 6px; }
}
.tb-tabla td, .tb-tabla th { padding: 10px 16px; }
.tb-dia-ver .tb-tabla { margin-top: 4px; }
.tb-dia-ver .empty { padding: 12px 16px; margin: 0; }

.tb-resumen { padding: 8px 16px; background: var(--primary-soft); border-color: transparent; }
.tb-res-fila { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; }
.tb-res-lbl { display: flex; align-items: center; gap: 12px; font-weight: 600; }
.tb-res-lbl .ico { color: var(--primary); width: 26px; height: 26px; }
.ico-txt-big { display: inline-grid; place-items: center; width: 26px; color: var(--primary); font-size: 1.4rem; font-weight: 700; line-height: 1; }
.tb-res-val, .tb-res-input { width: min(260px, 48%); padding: 10px 14px; border-radius: 10px; background: var(--surface); text-align: center; font-size: 1.15rem; font-weight: 700; color: var(--primary); }
.tb-res-input { margin: 0; color: var(--text); border: 1px solid var(--border); }
.tb-res-val.tb-res-plano { color: var(--text); }
.tb-importe { font-size: 1.5rem; }
.tb-obs { padding: 14px 16px; }
.tb-obs-lbl { margin: 0; display: grid; gap: 10px; }
@media (min-width: 900px) { .tb-obs-lbl { grid-template-columns: 240px 1fr; align-items: start; } .tb-obs-lbl textarea { margin: 0; } }
.tabla-trabajos .num { text-align: right; }
@media (max-width: 699px) { .tabla-trabajos .num { text-align: left; } .tabla-trabajos td.num { display: inline-block; width: auto; margin-right: 12px; } }

/* --- Calendario: trabajos en rojo (por hacer) y verde (hecho) --- */
.dot-trab-pend, .dot-trab-ok { border-radius: 2px; }
.dot-trab-pend { background: var(--danger); }
.dot-trab-ok { background: var(--ok); }
.month-dots i.trab { border-radius: 1px; }
.month-dots i.trab-pendiente { background: var(--danger); }
.month-dots i.trab-hecho { background: var(--ok); }
.month-item.trab-pendiente, .week-item.trab-pendiente { background: var(--danger-soft) !important; border-color: var(--danger) !important; }
.month-item.trab-hecho, .week-item.trab-hecho { background: var(--ok-soft) !important; border-color: var(--ok) !important; }
.month-item.trab { border-left-width: 5px; font-weight: 600; }
.week-item.trab { border-left-width: 5px; }
.week-item .ico { width: 14px; height: 14px; vertical-align: -2px; }
.visit-time.trab-time-pendiente { color: var(--danger); }
.visit-time.trab-time-hecho { color: var(--ok); }

/* --- Barra del móvil: botón «Nuevo» con menú --- */
.tab-nuevo-wrap { flex: 1; position: relative; display: flex; }
.tabbar button.tab-nueva { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: 0; background: none; color: var(--muted); font: inherit; font-size: .62rem; cursor: pointer; padding: 0; }
.tabbar button.tab-nueva svg { background: var(--primary); color: #fff; border-radius: 50%; padding: 5px; width: 34px; height: 34px; margin-top: -6px; }
.tabbar button.tab-nueva.active { color: var(--primary); }
.tab-nuevo-menu { position: absolute; bottom: calc(100% + 8px); left: 4px; z-index: 30; min-width: 210px; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.18); }
.tabbar .tab-nuevo-menu a { flex-direction: row; justify-content: flex-start; gap: 10px; padding: 12px; border-radius: 8px; color: var(--text); font-size: .95rem; font-weight: 600; }
.tabbar .tab-nuevo-menu a:hover { background: var(--primary-soft); }
.tab-nuevo-menu .ico { color: var(--primary); }
.tb-bloque > * { min-width: 0; }
.tb-bloque .input-ico { min-width: 0; }
@media (max-width: 899px) { .tb-bloque input[type=time] { padding-right: 4px; } }

/* =====================================================
   v0.8 · Estados (por hacer / en proceso / terminado), Otros trabajos y Gastos
   ===================================================== */
.count-info { background: var(--info); }
.count-ok { background: var(--ok); }
:root[data-theme="dark"] .count-info, :root[data-theme="dark"] .count-ok { color: #0f141b; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .count-info, :root:not([data-theme="light"]) .count-ok, :root:not([data-theme="light"]) .count-danger { color: #0f141b; } }
.seg-radio { flex-wrap: wrap; }
.seg-danger input:checked + span, .seg-botones .seg-danger.on span { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.seg-info input:checked + span, .seg-botones .seg-info.on span { background: var(--info-soft); border-color: var(--info); color: var(--info); }
.seg-ok input:checked + span, .seg-botones .seg-ok.on span { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.seg-botones button { padding: 0; border: 0; background: none; font: inherit; cursor: pointer; }
.seg-botones button span { background: var(--surface); }
.seg-botones button:not(.on):hover span { border-color: var(--primary); color: var(--primary); }
.estado-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: -8px 0 16px; }
.dot-trab-proc { background: var(--info); border-radius: 2px; }
.month-dots i.trab-en_proceso { background: var(--info); }
.month-item.trab-en_proceso, .week-item.trab-en_proceso { background: var(--info-soft) !important; border-color: var(--info) !important; }
.visit-time.trab-time-en_proceso { color: var(--info); }

.tb-extras { padding: 0; }
.tb-extras-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--primary-soft); border-radius: var(--radius) var(--radius) 0 0; color: var(--primary); }
.tb-extras-head h2 { margin: 0; font-size: 1.05rem; color: var(--primary); }
.tb-extras-head .ico { width: 24px; height: 24px; }
.tb-extras-cols { display: none; }
[data-extras-lista] { padding: 6px 16px 0; }
.tb-extra { display: grid; grid-template-columns: minmax(0, 1fr) 130px 36px; gap: 8px; align-items: center; margin: 8px 0; }
.tb-extra input { margin: 0; }
.tb-extra .input-euro .ico-txt { top: 1px; }
.tb-extra .input-euro input { padding-left: 46px !important; text-align: right; }
@media (min-width: 900px) {
  .tb-extras-cols { display: grid; grid-template-columns: minmax(0, 1fr) 180px 36px; gap: 12px; padding: 12px 16px 0; font-size: .85rem; font-weight: 600; }
  .tb-extra { grid-template-columns: minmax(0, 1fr) 180px 36px; gap: 12px; }
}
.tb-res-total { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 12px; }
.tb-res-total .tb-res-lbl { font-size: 1.1rem; }
.tabla-trabajos td .badge { white-space: nowrap; }
@media (max-width: 899px) {
  .tb-extra { grid-template-columns: minmax(0, 1fr) 36px; padding-bottom: 8px; border-bottom: 1px dashed var(--border); }
  .tb-extra > input { grid-column: 1 / -1; }
}
@media (max-width: 699px) {
  .tb-tabla tr { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 10px 16px; }
  .tb-tabla td { width: auto; padding: 0 !important; }
  .tb-tabla td:last-child:not(.num) { flex-basis: 100%; }
  .tb-tabla td.num { margin-left: auto; font-weight: 600; }
}

/* v0.8 · Importar invitación (.ics) */
.imp-card { max-width: 720px; }
.imp-drop { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 32px 16px; margin: 0 0 14px; border: 2px dashed var(--border); border-radius: 12px; text-align: center; color: var(--primary); cursor: pointer; }
.imp-drop:hover, .imp-drop.sobre { border-color: var(--primary); background: var(--primary-soft); }
.imp-drop .ico { width: 36px; height: 36px; }
.imp-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.imp-nombre { font-weight: 600; color: var(--text); }
.imp-pegar { margin-bottom: 12px; }
.imp-pegar summary { cursor: pointer; color: var(--primary); font-weight: 600; font-size: .9rem; }
.imp-ev { max-width: 820px; }
.imp-ev .dl { grid-template-columns: 110px 1fr; }
.imp-acciones { margin-top: 16px; }

/* v0.9 · Otros trabajos / Gastos con observaciones y resumen al lado */
.tb-cols, .tb-extras-cols { text-transform: uppercase; letter-spacing: .03em; font-size: .75rem !important; color: var(--muted); }
.tb-extras-head .tb-del { margin-left: auto; }
.tb-extra { grid-template-columns: minmax(0, 1.3fr) 120px minmax(0, 1fr) 36px; }
.tb-extra .tb-extra-obs { font-size: .9rem; }
@media (min-width: 900px) {
  .tb-extras-cols { grid-template-columns: minmax(0, 1.3fr) 120px minmax(0, 1fr) 36px; }
  .tb-extra { grid-template-columns: minmax(0, 1.3fr) 120px minmax(0, 1fr) 36px; }
}
@media (max-width: 899px) {
  .tb-extra { grid-template-columns: minmax(0, 1fr) 36px; }
  .tb-extra > input:first-child, .tb-extra .tb-extra-obs { grid-column: 1 / -1; }
  .tb-extra .tb-extra-obs { order: 3; }
  .tb-extra .input-euro { order: 1; }
  .tb-extra > .tb-del { order: 2; }
}
.tb-res-sep { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 12px; }
.tb-final-der .tb-res-val, .tb-final-der .tb-res-input { width: min(170px, 48%); }
.tb-final-der .tb-res-lbl { gap: 10px; font-size: .95rem; }
@media (min-width: 1200px) {
  .tb-final { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr); gap: 16px; align-items: start; }
  .tb-final-der .tb-obs-lbl { grid-template-columns: 1fr; }
}
