/* Cestero Oficina: hoja de estilos unica.
   Un solo sistema: tokens, estructura, componentes y despues las pantallas.
   Las clases que usa el JavaScript se conservan; solo cambia como se ven. */

/* ---------- tokens ---------- */
:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --panel-soft: #f6f8fc;
  --line: #e4e8f1;
  --line-strong: #c9d1e0;
  --text: #1c2340;
  --muted: #6b7390;
  --accent: #2f6fed;
  --accent-dark: #2459c4;
  --accent-soft: #e9f0ff;
  --danger: #e0443c;
  --danger-soft: #fdecea;
  --ok: #16a37a;
  --ok-soft: #e3f7ef;
  --warn: #b7791f;
  --warn-soft: #fff7e0;
  --warn-line: #f0d58a;
  --side-bg: #151d35;
  --side-bg-2: #1b2544;
  --side-text: #c9d1e6;
  --side-muted: #8a95b8;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(20, 28, 51, 0.05), 0 1px 6px rgba(20, 28, 51, 0.04);
  --shadow-pop: 0 12px 32px rgba(20, 28, 51, 0.16);
  --sidebar: 244px;
  --control-h: 36px;
  --gap: 12px;
  --pad: 16px;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.45 "Inter", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { font-weight: 650; line-height: 1.3; margin: 0; }
p { margin: 0 0 10px; }
p:last-child { margin-bottom: 0; }
ul, ol { margin: 6px 0 10px; padding-left: 22px; }
dl { margin: 0 0 10px; }
dt { font-weight: 600; margin-top: 8px; }
dd { margin: 2px 0 0; color: var(--muted); }
pre { font-size: 12px; background: var(--panel-soft); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px; overflow: auto; }
small, .hint { color: var(--muted); font-size: 12px; line-height: 1.4; }
[hidden] { display: none !important; }
svg.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1:focus, h1:focus-visible, h2:focus, h2:focus-visible, [tabindex="-1"]:focus-visible { outline: none; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login {
  width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 32px 28px; box-shadow: 0 10px 30px rgba(16, 24, 40, 0.08);
}
.login img.logo { display: block; width: 190px; height: auto; margin: 0 auto 10px; }
.login h1 { margin: 0 0 4px; font-size: 22px; text-align: center; }
.login p.sub { margin: 0 0 22px; color: var(--muted); text-align: center; }
.login label.fl { margin-bottom: 14px; }
.login .btn { width: 100%; justify-content: center; margin-top: 6px; min-height: 40px; }
.login .error { color: var(--danger); margin: 0 0 12px; min-height: 18px; text-align: center; }
.login .status { color: var(--accent); margin: 0 0 12px; min-height: 18px; text-align: center; font-weight: 600; }
.boot { text-align: center; color: var(--muted); }
.boot img.logo { display: block; width: 190px; height: auto; margin: 0 auto 14px; }
.boot p { font-size: 16px; font-weight: 600; color: var(--text); margin: 0 0 4px; }
.boot p::after { content: ""; display: inline-block; width: 14px; height: 14px; margin-left: 8px; border: 2px solid var(--accent); border-right-color: transparent; border-radius: 50%; vertical-align: -2px; animation: boot-spin .8s linear infinite; }
@keyframes boot-spin { to { transform: rotate(360deg); } }

/* ---------- estructura: barra lateral oscura + contenido ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar); flex: none; background: var(--side-bg); color: var(--side-text);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { padding: 16px 16px 12px; border-bottom: 1px solid rgba(255, 255, 255, 0.08); flex-shrink: 0; }
.brand img.logo { display: block; width: 136px; height: auto; margin-bottom: 8px; background: #fff; border-radius: 8px; padding: 6px 10px; }
.brand .name { font-weight: 700; font-size: 15px; color: #fff; }
.brand .tag { color: var(--side-muted); font-size: 12px; }
.nav { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 10px; display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--side-text); font-weight: 500; line-height: 1.3;
}
.nav a svg.ic { color: var(--side-muted); }
.nav a:hover { background: rgba(255, 255, 255, 0.07); color: #fff; text-decoration: none; }
.nav a.active { background: var(--accent); color: #fff; box-shadow: 0 6px 16px rgba(47, 111, 237, 0.35); }
.nav a.active svg.ic { color: #fff; }
.nav a .t { min-width: 0; overflow-wrap: anywhere; }
.nav-group { display: flex; flex-direction: column; }
.nav-group-toggle {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; border: 0;
  border-radius: var(--radius-sm); padding: 9px 12px; margin-top: 6px; background: transparent; text-align: left;
  font-weight: 650; cursor: pointer; color: var(--side-text); letter-spacing: 0.1px;
}
.nav-group-toggle:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.nav-group-toggle[aria-expanded="true"] { color: #fff; }
.nav-chevron { font-size: 18px; line-height: 1; transition: transform .15s; color: var(--side-muted); }
.nav-group-toggle[aria-expanded="true"] .nav-chevron { transform: rotate(90deg); }
.nav-children { display: flex; flex-direction: column; gap: 1px; margin: 2px 0 4px 14px; padding-left: 6px; border-left: 2px solid rgba(255, 255, 255, 0.12); }
.nav-children a { font-size: 13px; padding: 7px 10px; }
.sidebar .user { flex-shrink: 0; margin-top: auto; padding: 12px 12px 12px 16px; border-top: 1px solid rgba(255, 255, 255, 0.08); display: flex; align-items: center; gap: 10px; background: var(--side-bg-2); }
.sidebar .user .who { flex: 1; min-width: 0; }
.sidebar .user .who b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #fff; }
.sidebar .user .who span { display: block; color: var(--side-muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar .user .who small { display: block; color: var(--side-muted); font-size: 11px; }
.sidebar .user .btn.icon { background: transparent; border-color: rgba(255, 255, 255, 0.2); color: var(--side-text); }
.sidebar .user .btn.icon:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.main { flex: 1; min-width: 0; padding: 22px 28px 40px; max-width: 1480px; }

/* ---------- cabecera de pantalla ---------- */
.crumb { color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.crumb a { color: var(--muted); }
.page-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; min-height: 40px; }
.page-head h1 { margin: 0; font-size: 22px; line-height: 1.3; overflow-wrap: anywhere; letter-spacing: -0.2px; }
.page-head .count { color: var(--muted); font-size: 13px; white-space: nowrap; }
.page-head > span[data-count] { color: var(--muted); font-size: 13px; }
.page-head .spacer { flex: 1; }
/* sin .spacer: todo lo que no sea titulo o contador se alinea a la derecha */
.page-head > .btn:first-child + h1 ~ .btn, .page-head > h1 ~ .btn, .page-head > h1 ~ .actions-bar, .page-head > h1 ~ details { margin-left: 0; }
.page-head > h1 + .btn, .page-head > h1 + .badge + .btn, .page-head > h1 + .actions-bar, .page-head > h1 + .quote-state, .page-head > h1 + button, .page-head > h1 + span[data-count] + .btn { margin-left: auto; }
.page-head > .spacer ~ * { margin-left: 0; }
.actions-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions-bar:empty { display: none; }

/* ---------- botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 14px; min-height: var(--control-h);
  border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--panel); color: var(--text);
  cursor: pointer; font-weight: 500; white-space: nowrap; line-height: 1.2; text-decoration: none;
}
.btn:hover { background: var(--panel-soft); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 4px 12px rgba(47, 111, 237, 0.25); }
.btn.primary:hover { background: var(--accent-dark); }
.btn.danger { color: var(--danger); border-color: #f1c4c1; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.small { min-height: 30px; padding: 0 10px; font-size: 13px; }
.btn.icon { padding: 0; width: var(--control-h); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: default; }
.btn:disabled:hover { background: var(--panel); }
.btn.primary:disabled:hover { background: var(--accent); }
button.link { border: 0; background: transparent; color: var(--accent); cursor: pointer; padding: 0; font-size: 12px; text-decoration: underline; }
button.link:disabled { color: var(--muted); cursor: default; }
.btn.choice { display: flex; width: 100%; justify-content: flex-start; text-align: left; margin: 4px 0; white-space: normal; }

/* ---------- tarjetas ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 14px; }
.card > h2, .card > h3 { font-size: 15px; margin: 0; padding: 12px var(--pad); border-bottom: 1px solid var(--line); }
.card > h3 { font-size: 14px; }
.card > p, .card > .row, .card > ul, .card > dl, .card > article, .card > details, .card > section:not(.card), .card > form:not(.card):not(.toolbar), .card > [data-supplier-contacts], .card > [data-fiscal-preview], .card > [data-result], .card > [data-message] { padding-left: var(--pad); padding-right: var(--pad); }
.card > p { padding-top: 10px; padding-bottom: 0; margin: 0; }
.card > p:last-child, .card > ul:last-child, .card > details:last-child, .card > section:last-child, .card > [data-supplier-contacts]:last-child, .card > [data-fiscal-preview]:last-child, .card > article:last-child { padding-bottom: 12px; }
.card > [data-supplier-contacts] > p:first-child { padding-top: 10px; }
.card > .row { padding-top: 10px; padding-bottom: 10px; }
.card > details > summary { padding: 10px 0; }
.card > .btn, .card > a.btn { margin: 10px var(--pad) 12px; }
.card > .btn + .btn { margin-left: 0; }
.card > table.grid, .card > .empty, .card > div > table.grid { margin: 0; }
.card > article { padding-top: 10px; }
.card > article h3 { font-size: 14px; margin-bottom: 4px; }
.card.section { background: var(--panel-soft); }
.card p.notice, .card .notice { margin-left: var(--pad); margin-right: var(--pad); width: auto; }
.card > details.card, .card .card { margin: 10px var(--pad); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); }
/* Un bloque de pantalla con titulo a la izquierda y acciones a la derecha */
.obra-section-head, .procurement-heading, .notice-section > h2 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.obra-section-head { justify-content: flex-start; padding: 12px var(--pad); border-bottom: 1px solid var(--line); }
.obra-section-head h2 { margin: 0; font-size: 15px; }
.obra-section-head .hint { margin-left: auto; }
.obra-section-head .btn { margin-left: auto; }
.obra-section-head .btn + .btn, .obra-section-head .hint + .btn, .obra-section-head .btn + .hint { margin-left: 0; }

/* ---------- avisos, etiquetas, chips, toasts ---------- */
.notice {
  display: flex; align-items: flex-start; gap: 8px; margin: 0 0 12px; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--warn-soft); border: 1px solid var(--warn-line); color: #6b4e00; font-size: 13px; line-height: 1.4;
}
.notice .ic { flex: none; width: 18px; height: 18px; margin-top: 1px; }
.notice a { color: var(--accent-dark); }
.notice:empty { display: none; }
details.notice { display: block; }
details.notice > summary { cursor: pointer; font-weight: 600; }
details.notice > p { margin: 8px 0 0; }
.error, [data-error]:not(:empty), p[role="alert"]:not(:empty), [data-errors]:not(:empty) { color: var(--danger); }
p.error:empty, [data-error]:empty, p[role="alert"]:empty { display: none; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #eef1f6; color: #4b5563; white-space: nowrap; line-height: 1.5; }
.badge.draft { background: #eef1f6; }
.badge.sent, .badge.pending, .badge.in_progress, .badge.scheduled { background: var(--accent-soft); color: var(--accent); }
.badge.sale, .badge.accepted, .badge.invoiced, .badge.done, .badge.paid, .badge.posted { background: var(--ok-soft); color: var(--ok); }
.badge.cancel, .badge.cancelled, .badge.rejected { background: var(--danger-soft); color: var(--danger); }
.badge.obsolete, .badge.classification_pending { background: var(--warn-soft); color: var(--warn); }
.chip { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); font-size: 12px; margin: 2px 4px 2px 0; }
.chip.worker { background: var(--panel-soft); color: var(--text); font-weight: 400; border: 1px solid var(--line); }
.chip.worker b { font-weight: 600; }
.quote-state { font-weight: 600; font-size: 12px; color: var(--accent); padding: 5px 10px; background: var(--accent-soft); border-radius: 999px; white-space: nowrap; }
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: #111827; color: #fff; padding: 10px 14px; border-radius: var(--radius-sm); box-shadow: 0 8px 24px rgba(0,0,0,0.2); max-width: 380px; font-size: 13px; }
.toast.error { background: var(--danger); }
.toast.ok { background: var(--ok); }

/* ---------- controles de formulario ---------- */
input[type=text], input[type=number], input[type=date], input[type=datetime-local], input[type=email], input[type=password], input[type=search], input[type=tel], input:not([type]), select, textarea, .visual-control {
  width: 100%; min-height: var(--control-h); padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: #fff; outline: none; max-width: 100%;
}
input[type=search] { -webkit-appearance: none; appearance: none; }
textarea { resize: vertical; min-height: 72px; line-height: 1.4; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(29, 111, 224, 0.15); }
input[readonly], textarea[readonly], .ro, .visual-control:read-only:not(select) { background: var(--panel-soft); color: #4b5563; }
input:disabled, select:disabled, textarea:disabled { background: var(--panel-soft); color: var(--muted); cursor: not-allowed; }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; min-height: 0; margin: 0; padding: 0; accent-color: var(--accent); flex: none; }
input[type=file] { border: 0; padding: 4px 0; min-height: 0; }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--danger); }
output { display: block; }
/* etiqueta + control: siempre etiqueta encima, en gris */
.fl { display: block; min-width: 0; }
.fl > span, .fl > .lbl, .fl > label.lbl { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 600; line-height: 1.3; }
.fl > span:last-child { margin-bottom: 0; }
.fl > small { display: block; margin-top: 4px; }
label.fl:not(:has(> .lbl)):not(:has(> span)) { font-size: 12px; color: var(--muted); font-weight: 600; line-height: 1.3; }
label.fl:not(:has(> .lbl)):not(:has(> span)) > input:not([type=checkbox]), label.fl:not(:has(> .lbl)):not(:has(> span)) > select, label.fl:not(:has(> .lbl)):not(:has(> span)) > textarea, label.fl:not(:has(> .lbl)):not(:has(> span)) > button, label.fl:not(:has(> .lbl)):not(:has(> span)) > output { margin-top: 4px; font-size: 14px; color: var(--text); font-weight: 400; }
.fl > input:not([type=checkbox]):not([type=radio]), .fl > select, .fl > textarea, .fl > output, .fl > .m2o, .fl > .ro-value { display: block; }
label.fl > button.btn { display: inline-flex; width: auto; max-width: 100%; }
label.fl > button.btn + button.btn { margin-left: 6px; }
.fl.check, label.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); font-weight: 400; min-height: var(--control-h); cursor: pointer; }
.fl.check > span, .fl.check > .lbl { margin: 0; font-size: 13px; color: var(--text); font-weight: 400; }
.form-grid .check { align-self: end; padding-top: 0; }
.req::after { content: " *"; color: var(--danger); }
.ro-value { min-height: var(--control-h); padding: 7px 10px; border-radius: var(--radius-sm); background: var(--panel-soft); color: #374151; overflow-wrap: anywhere; }
.ro-value.money { font-weight: 600; font-variant-numeric: tabular-nums; }
.visual-date-hint { display: block; font-size: 10px; line-height: 1.2; font-weight: 400; color: var(--muted); white-space: nowrap; }
.visual-date-readable { display: block; font-size: 11px; line-height: 1.25; font-weight: 400; color: var(--muted); margin-top: 3px; }
.visual-control[data-visual-size=date] { width: 160px; }
.visual-control[type=datetime-local][data-visual-size=date] { width: 220px; }
.visual-control[data-visual-size=short] { width: 170px; }
.visual-control[data-visual-size=contact] { width: 230px; }
.visual-control[data-visual-size=number] { width: 170px; }
.form-grid > .fl > .visual-control[data-visual-size], .obra-header-grid > .fl > .visual-control[data-visual-size], .customer-form .visual-control[data-visual-size] { width: 100%; }
.form-grid > .fl > input[type=date].visual-control, .form-grid > .fl > input[type=datetime-local].visual-control { max-width: 220px; }

/* rejilla de campos: 12 columnas, 4 por campo; .full ocupa toda la fila */
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 12px 16px; padding: var(--pad); }
.form-grid > * { grid-column: span 4; min-width: 0; }
.form-grid > .full { grid-column: 1 / -1; }
.form-grid > [data-visual-size=short], .form-grid > [data-visual-size=number], .form-grid > [data-visual-size=date] { grid-column: span 3; }
.form-grid > .fl > textarea { width: 100%; }
.form-grid > .fl.check { grid-column: span 4; }
.form-grid .check input { width: 16px; height: 16px; }
.form-grid + .form-grid { padding-top: 0; }
#form > .form-grid:first-child, form.card > .form-grid:first-child { padding-top: var(--pad); }
#form > .btn, #form > p.hint, #form > #new-customer-summary { margin: 0 var(--pad) 12px; }
#form > .btn { margin-top: 2px; }
/* secciones de la ficha */
.customer-address, .quote-work-location, .quote-conditions, .quote-extra, .lines-wrap { border-top: 1px solid var(--line); }
.customer-address > .hint, .quote-work-location > .hint { display: block; padding: 12px var(--pad) 0; font-weight: 600; color: var(--text); font-size: 13px; }
.customer-address > .form-grid, .quote-work-location > .form-grid { padding-top: 10px; }
.crm-contact { border-top: 1px solid var(--line); }
.crm-contact > .row, .crm-contact > .hint { margin: 12px var(--pad); }
.crm-contact > .row { flex-wrap: wrap; }
.crm-contact h3 { margin: 0; font-size: 14px; }
.crm-contact > .form-grid { padding-top: 0; padding-bottom: 0; }
details.quote-extra > summary { cursor: pointer; padding: 12px var(--pad); font-weight: 600; font-size: 13px; }
details.quote-extra > summary:hover { background: var(--panel-soft); }
details.quote-extra > .form-grid { padding-top: 4px; }
.lines-wrap { padding: 12px var(--pad) var(--pad); overflow-x: auto; }
.lines-wrap h3 { font-size: 14px; margin: 0 0 10px; }
.sticky-save {
  position: sticky; bottom: 0; z-index: 10; display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin: 0 -28px -40px; padding: 10px 28px; background: var(--panel); border-top: 1px solid var(--line);
  box-shadow: 0 -4px 14px rgba(16, 24, 40, 0.06);
}
.sticky-save .hint { margin-left: 8px; }
.sticky-save #dirty:not(:empty), .sticky-save [data-dirty]:not(:empty) { color: var(--warn); font-weight: 600; }
.card.rel { margin-top: 14px; padding: 0; }
.tabs { display: flex; gap: 2px; padding: 6px 10px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tabs button { border: 0; background: transparent; padding: 10px 12px; cursor: pointer; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; font-size: 13px; }
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.card.rel table.grid { margin: 0; }
.card.rel .empty { padding: 18px; }
#record-attachments > h3 { border-bottom: 1px solid var(--line); }
#record-attachments .empty { padding: 16px; text-align: left; }

/* selector de registro (many2one) */
.m2o { position: relative; min-width: 0; }
.m2o input { padding-right: 32px; }
.m2o .clear { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 4px 6px; font-size: 15px; line-height: 1; }
.m2o .clear:hover { color: var(--text); }
.m2o .menu {
  position: absolute; z-index: 20; left: 0; right: 0; top: 100%; margin-top: 4px; background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-pop); max-height: 260px; overflow: auto; display: none;
}
.m2o .menu.open { display: block; }
.m2o .menu div { padding: 8px 10px; cursor: pointer; }
.m2o .menu div:hover, .m2o .menu div.hi { background: var(--accent-soft); }
.m2o .menu .none { color: var(--muted); cursor: default; }
.m2o .menu div b { display: block; font-weight: 600; }
.m2o .menu div .meta { display: block; font-size: 12px; color: var(--muted); }

/* ---------- barra de filtros de un listado ---------- */
.toolbar { display: flex; gap: 10px 14px; align-items: flex-end; padding: 12px var(--pad); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.toolbar .search { position: relative; flex: 1 1 240px; max-width: 420px; }
.toolbar .search input { padding-left: 36px; }
.toolbar .search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.toolbar > label:not(.check):not(.inline) { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); min-width: 0; }
.toolbar > label:not(.check):not(.inline) > input, .toolbar > label:not(.check):not(.inline) > select { width: auto; min-width: 150px; font-weight: 400; color: var(--text); font-size: 14px; }
.toolbar > label:not(.check):not(.inline) > input[type=text], .toolbar > label:not(.check):not(.inline) > input:not([type]) { width: 180px; }
.toolbar > label:not(.check):not(.inline) > input[type=date] { width: 160px; }
.toolbar > label.check, .toolbar > label:has(> input[type=checkbox]) { flex-direction: row; align-items: center; gap: 8px; font-size: 13px; font-weight: 400; color: var(--text); min-height: var(--control-h); }
.toolbar label.inline { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.toolbar label.inline input[type=date] { width: 160px; font-weight: 400; color: var(--text); }
.toolbar .btn { align-self: flex-end; }
.toolbar .badge { align-self: center; }
.toolbar [role="alert"] { color: var(--danger); font-size: 13px; }
.summary { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px var(--pad) 6px; }
.summary .notice { flex-basis: 100%; }
.list-note { padding: 10px var(--pad) 0; color: var(--muted); font-size: 13px; margin: 0; }
[data-list] > p:first-child { padding: 10px var(--pad) 0; color: var(--muted); font-size: 13px; margin: 0; }
/* varios valores (etapas) */
.visual-multiselect { position: relative; min-width: 200px; max-width: 300px; font-weight: 400; }
.visual-multiselect > summary { cursor: pointer; min-height: var(--control-h); border: 1px solid var(--line-strong); padding: 7px 10px; border-radius: var(--radius-sm); background: #fff; white-space: nowrap; color: var(--text); font-size: 14px; list-style: none; display: flex; align-items: center; }
.visual-multiselect > summary::after { content: "▾"; margin-left: auto; color: var(--muted); padding-left: 8px; }
.visual-multi-panel { position: absolute; top: 100%; left: 0; z-index: 25; width: 280px; max-width: 80vw; padding: 8px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow-pop); }
.visual-multi-panel select { width: 100%; min-height: 110px; }
.visual-multi-panel small { display: block; padding-top: 4px; }
/* filtros con grupos (facturas) */
.main [data-filters] > fieldset, .main [data-filters] > details > fieldset { display: inline-flex; gap: 8px 12px; flex-wrap: wrap; align-items: flex-end; vertical-align: top; width: auto; max-width: 100%; margin: 10px var(--pad) 0 var(--pad); padding: 8px 12px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.main [data-filters] fieldset + fieldset { margin-left: 0; }
.main [data-filters] legend { font-size: 12px; font-weight: 600; padding: 0 4px; color: var(--muted); }
.main [data-filters] fieldset label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; font-weight: 600; color: var(--muted); }
.main [data-filters] fieldset label input { width: 160px; font-weight: 400; color: var(--text); }
.main [data-filters] > details { margin: 10px var(--pad) 0; font-size: 13px; }
.main [data-filters] > details > summary { cursor: pointer; font-weight: 600; }
.main [data-filters] > details > .row { margin: 8px 0; }
.main [data-filters] > .btn { margin: 12px 0 12px var(--pad); }
.main [data-filters] > .btn + .btn { margin-left: 0; }
.main [data-filters] > .toolbar { border-bottom: 0; }
.main[data-visual-entity^=facturas-] .page-head + p, .main[data-visual-entity^=facturas-] form + p { color: var(--muted); font-size: 13px; }

/* ---------- tablas ---------- */
table.grid { width: 100%; border-collapse: collapse; }
table.grid th, table.grid td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.grid th { font-size: 12px; line-height: 1.3; color: #475569; font-weight: 600; background: var(--panel-soft); user-select: none; position: sticky; top: 0; z-index: 1; white-space: nowrap; }
table.grid th.sortable { cursor: pointer; }
table.grid th.sortable:hover { color: var(--text); }
table.grid td { font-size: 13px; overflow-wrap: normal; word-break: normal; }
table.grid td a { overflow-wrap: anywhere; }
table.grid td small { display: block; font-size: 11.5px; color: var(--muted); line-height: 1.35; }
table.grid td .hint, table.grid td div.hint { display: block; }
table.grid tbody tr[data-id] { cursor: pointer; }
table.grid tbody tr:hover { background: #f6f9ff; }
table.grid tbody tr:last-child td { border-bottom: 0; }
table.grid td.num, table.grid th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.grid td.main { font-weight: 600; }
table.grid td .badge { white-space: nowrap; }
table.grid td.empty { padding: 32px 16px; text-align: center; }
table.grid tr.section td { background: var(--panel-soft); font-weight: 600; }
.main [data-list], .main #table, .obra-table-scroll, .procurement-scroll, .compact-policy-history, .modal .scroll { overflow-x: auto; }
.main [data-list] table.grid, .main #table table.grid { min-width: 720px; }
.pager { display: flex; align-items: center; gap: 10px; padding: 10px var(--pad); color: var(--muted); font-size: 13px; flex-wrap: wrap; border-top: 1px solid var(--line); }
.pager .spacer { flex: 1; }
/* las fechas y los importes nunca se parten en dos lineas */
table.grid td[data-nowrap], table.grid td.date { white-space: nowrap; }
.main #table table.grid td.main { white-space: nowrap; }
.main[data-visual-entity=presupuestos] #table table.grid td:nth-child(3), .main[data-visual-entity=presupuestos] #table table.grid td:nth-child(6), .main[data-visual-entity=presupuestos] #table table.grid td:nth-child(7),
.main[data-visual-entity=crm] #table table.grid td:nth-child(1), .main[data-visual-entity=crm] #table table.grid td:nth-child(5), .main[data-visual-entity=crm] #table table.grid td:nth-child(6), .main[data-visual-entity=crm] #table table.grid td:nth-child(7),
.main[data-visual-entity=partes] #table table.grid td:nth-child(2), .main[data-visual-entity=partes] #table table.grid td:nth-child(5),
.main[data-visual-entity=obras] #table table.grid td:nth-child(2), .main[data-visual-entity=obras] #table table.grid td:nth-child(5), .main[data-visual-entity=obras] #table table.grid td:nth-child(6),
.main[data-visual-entity=clientes] #table table.grid td:nth-child(2), .main[data-visual-entity=clientes] #table table.grid td:nth-child(3),
.main[data-visual-entity=proveedores] #table table.grid td:nth-child(2), .main[data-visual-entity=proveedores] #table table.grid td:nth-child(3),
.main[data-visual-entity=trabajadores] #table table.grid td:nth-child(3),
.main[data-visual-entity=albaranes-proveedores] #table table.grid td:nth-child(2), .main[data-visual-entity=asientos] #table table.grid td:nth-child(2), .main[data-visual-entity=asientos] #table table.grid td:nth-child(4),
.main[data-visual-entity^=facturas-] #table table.grid td:nth-child(2), .main[data-visual-entity^=facturas-] #table table.grid td:nth-child(4) { white-space: nowrap; }
.main #table table.grid td.main { max-width: 320px; white-space: normal; }
.main[data-visual-entity=presupuestos] #table table.grid td.main, .main[data-visual-entity=partes] #table table.grid td.main, .main[data-visual-entity=asientos] #table table.grid td.main, .main[data-visual-entity^=facturas-] #table table.grid td.main, .main[data-visual-entity=albaranes-proveedores] #table table.grid td.main { white-space: nowrap; }
.main[data-visual-entity^=facturas-] [data-list] > table.grid td:nth-child(3), .main[data-visual-entity^=facturas-] [data-list] > table.grid td:nth-child(4) { white-space: nowrap; }
.main[data-visual-entity^=facturas-] [data-list] > table.grid { min-width: 1180px; }
.main[data-visual-entity^=facturas-] [data-list] > table.grid td { vertical-align: top; }
.main[data-visual-entity^=facturas-] [data-list] > table.grid td:nth-child(1) { min-width: 180px; }

/* ---------- ventanas emergentes ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(17, 24, 39, 0.45); display: grid; place-items: center; z-index: 40; padding: 16px; }
.modal { background: #fff; border-radius: 12px; padding: 20px 22px; width: min(460px, 94vw); max-height: 92vh; overflow: auto; box-shadow: var(--shadow-pop); }
.modal.wide { width: min(960px, 96vw); }
.modal-bg .wide { max-width: 1100px; }
.modal h2, .modal h3 { margin: 0 0 8px; font-size: 17px; }
.modal > .row:first-child { margin: -4px 0 10px; }
.modal > .row:first-child h2 { margin: 0; }
.modal p { margin: 0 0 12px; }
.modal .row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.modal > .row:last-child, .modal form > .row:last-child { justify-content: flex-end; margin-top: 14px; }
.modal form .fl, .modal form > label { display: block; margin: 0 0 12px; }
.modal form > label:not(.fl):not(.check) { font-size: 12px; font-weight: 600; color: var(--muted); }
.modal form > label:not(.fl):not(.check) > input, .modal form > label:not(.fl):not(.check) > select, .modal form > label:not(.fl):not(.check) > textarea { margin-top: 4px; font-weight: 400; color: var(--text); font-size: 14px; }
.modal form > label.check, .modal form label:has(> input[type=checkbox]) { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; font-weight: 400; color: var(--text); margin: 0 0 12px; }
.modal form > label:has(> input[type=checkbox]) > input { margin-top: 2px; }
.modal form > .btn, .modal form > button { margin: 4px 8px 8px 0; }
.modal form > .btn:last-child { margin-right: 0; }
.modal .toolbar { padding: 0 0 12px; border: 0; }
.modal .toolbar input { flex: 1; min-width: 220px; }
.modal input[data-q], .modal input[data-search], .modal input[type=search]:not(.fl *) { width: 100%; margin-bottom: 10px; }
.modal input[type=text] { width: 100%; }
.modal .scroll { max-height: 60vh; overflow: auto; margin: 10px 0 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.modal table.grid tr[data-id] { cursor: pointer; }
.modal table.grid tr[data-id]:hover { background: var(--accent-soft); }
.modal table.grid th { position: static; }
.modal [data-results], .modal [data-picks], .modal [data-options], .modal [data-cities] { max-height: 50vh; overflow: auto; margin: 6px 0 10px; }
.modal [data-results] > .btn:not(.choice), .modal [data-options] > .btn, .modal [data-cities] > .btn, .modal [data-picks] > .btn { display: flex; width: 100%; justify-content: flex-start; text-align: left; margin: 4px 0; white-space: normal; }
.modal small { color: var(--muted); }
.modal .grid { width: 100%; }
.modal .grid input[data-quantity] { width: 100px; }
.modal .form-grid { padding: 0; gap: 10px 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.modal .form-grid > * { grid-column: auto; }
.modal .form-grid > .full { grid-column: 1 / -1; }
.modal .notice { margin: 0 0 12px; width: auto; }
.modal #po-note { margin-bottom: 12px; }
.modal pre { max-height: 240px; }
.modal [data-error]:not(:empty) { margin-top: 10px; }

/* ---------- partidas (tabla editable y arbol) ---------- */
table.lines { width: 100%; border-collapse: collapse; table-layout: fixed; min-width: 960px; }
table.lines th, table.lines td { padding: 7px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.lines th { font-size: 12px; color: #475569; font-weight: 600; text-align: left; background: var(--panel-soft); }
table.lines th.num, table.lines td.num { text-align: right; }
table.lines td.num input { text-align: right; }
table.lines input, table.lines select, table.lines textarea { min-height: 32px; padding: 5px 8px; }
table.lines textarea { min-height: 32px; resize: none; overflow: hidden; }
table.lines tr.section td { background: var(--panel-soft); }
table.lines tr.section textarea { font-weight: 700; }
table.lines td.subtotal { padding-top: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.lines td.tools { white-space: nowrap; padding-top: 8px; }
table.lines td.tools button { border: 0; background: transparent; cursor: pointer; color: var(--muted); padding: 2px 4px; }
table.lines td.tools button:hover { color: var(--text); }
table.lines td.tools button:disabled { opacity: 0.35; cursor: default; }
table.lines th.c-tipo { width: 100px; } table.lines th.c-cat { width: 230px; } table.lines th.c-qty { width: 80px; }
table.lines th.c-price { width: 100px; } table.lines th.c-dto { width: 70px; } table.lines th.c-sub { width: 100px; } table.lines th.c-tools { width: 84px; }
table.lines textarea[data-lf="name"], table.lines td select, table.lines td.num input { width: 100%; }
table.lines td small { display: block; color: var(--muted); font-size: 11px; }
.cat-info { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 4px; min-height: 14px; }
.line-extra-tools { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 5px; }
.lines-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; align-items: center; }
.lines-actions .spacer { flex: 1; }
.totals { display: flex; justify-content: flex-end; gap: 28px; margin-top: 14px; font-variant-numeric: tabular-nums; flex-wrap: wrap; align-items: flex-start; }
.totals div span { display: block; font-size: 12px; color: var(--muted); }
.totals div b { font-size: 16px; }
.totals p.hint { flex-basis: 100%; text-align: right; margin: 6px 0 0; }
/* arbol de capitulos */
.quote-lines-readonly .quote-copy-text { white-space: pre-wrap; min-width: 180px; }
.quote-lines-readonly td small { display: block; color: var(--muted); font-size: 11px; }
.quote-lines-readonly .tools { white-space: nowrap; }
.quote-lines-readonly .tools button { min-width: 28px; min-height: 28px; }
.quote-tree .quote-tree-table { table-layout: fixed; min-width: 900px; width: 100%; }
.quote-tree-col-type { width: 82px; } .quote-tree-col-qty { width: 102px; } .quote-tree-col-price { width: 108px; } .quote-tree-col-discount { width: 66px; } .quote-tree-col-amount { width: 116px; } .quote-tree-col-tools { width: 116px; }
.quote-tree .quote-tree-type { font-size: 11px; color: #465a70; white-space: nowrap; }
.quote-tree .quote-copy-text { min-width: 0; overflow-wrap: anywhere; }
.quote-tree-description { display: flex; align-items: flex-start; gap: 5px; padding-left: calc(var(--quote-tree-depth, 0) * 20px); min-width: 0; }
.quote-tree-copy { min-width: 0; flex: 1; }
.quote-tree-number { flex: none; min-width: 2.1em; font-weight: 700; font-variant-numeric: tabular-nums; color: #183e63; }
.quote-tree-original-code { overflow-wrap: anywhere; }
.quote-tree .quote-tree-toggle, .quote-tree-toggle-space { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 25px; width: 25px; min-height: 25px; padding: 0; border: 0; border-radius: 3px; background: transparent; color: #123b61; font-size: 17px; line-height: 1; }
.quote-tree .quote-tree-toggle { cursor: pointer; }
.quote-tree .quote-tree-toggle:hover { background: #d0e1f0; }
.quote-tree .quote-tree-row.quote-tree-section.quote-tree-level-0 td { background: #d8e8f6; border-top: 2px solid #739fc1; color: #133c60; font-weight: 700; }
.quote-tree .quote-tree-row.quote-tree-section.quote-tree-level-1 td { background: #e4eee2; border-top: 1px solid #9abb94; color: #28502d; font-weight: 600; }
.quote-tree .quote-tree-row.quote-tree-section.quote-tree-level-2 td, .quote-tree .quote-tree-row.quote-tree-section.quote-tree-level-3 td { background: #f7ecd7; border-top: 1px solid #d1b36e; color: #64480e; font-weight: 600; }
.quote-tree .quote-tree-row:not(.quote-tree-section).quote-tree-level-1 td:nth-child(2) { border-left: 3px solid #c1d8ea; }
.quote-tree .quote-tree-row:not(.quote-tree-section).quote-tree-level-2 td:nth-child(2), .quote-tree .quote-tree-row:not(.quote-tree-section).quote-tree-level-3 td:nth-child(2) { border-left: 3px solid #bfd3b8; }
.quote-tree .quote-tree-note td { color: #566879; font-style: italic; }
.quote-tree [data-quote-tree-row][hidden] { display: none !important; }
.quote-tree-toolbar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding: 0 0 10px; }
.quote-tree-toolbar .hint { font-size: 12px; flex: 1; min-width: 220px; }
.quote-tree .quote-tree-tools { white-space: normal; padding: 5px 1px; }
.quote-tree .quote-tree-tools button { min-width: 26px; min-height: 26px; padding: 2px; }

/* ---------- inicio ---------- */
.main[data-visual-entity=inicio] .page-head + p { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.stat { padding: 14px 16px; display: block; color: var(--text); margin: 0; }
.stat a { display: block; color: inherit; }
.stat a:hover { text-decoration: none; }
.stat:hover { border-color: #c9d6ee; }
.stat .n { font-size: 28px; font-weight: 700; line-height: 1.1; color: var(--accent); }
.stat .n.na { font-size: 15px; color: var(--muted); font-weight: 600; padding: 6px 0; }
.stat .l { color: var(--text); font-size: 13px; font-weight: 600; margin-top: 2px; }
.stat small { display: block; margin-top: 6px; }
.stat h3 { font-size: 13px; margin: 0 0 6px; }
.main[data-visual-entity=inicio] .stats + .row { margin: 0 0 14px; }
.home-range { display: flex; align-items: flex-end; gap: 8px 14px; flex-wrap: wrap; margin: 0 0 14px; padding: 12px var(--pad); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.home-range label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); position: relative; }
.home-range input[type=date] { width: 160px; font-weight: 400; color: var(--text); }
.home-range .home-presets { display: flex; gap: 4px; flex-wrap: wrap; }
.home-range [data-preset] { border: 1px solid var(--line-strong); background: var(--panel); border-radius: var(--radius-sm); padding: 0 12px; min-height: var(--control-h); cursor: pointer; font-weight: 500; }
.home-range [data-preset]:hover { background: var(--panel-soft); }
.home-range [data-preset][aria-pressed=true] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.home-range small { flex-basis: 100%; }
.home-range [data-range-error] { color: var(--danger); font-size: 12px; }
.home-range [data-range-error]:empty { display: none; }
.home-range .visual-date-hint, .home-range .visual-date-readable { display: none; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.two > .card { margin: 0; }
.two > .card > .hint, .two > .card > p.hint { display: block; padding: 8px var(--pad) 0; }
.two > .card > [data-rows] { padding: 8px 0 0; }
.two > .card > [data-rows]:not(:has(table)) { padding: 10px var(--pad); color: var(--muted); }
.two > .card > a.btn { margin: 10px var(--pad) 12px; }
.two table.grid th { position: static; }

/* ---------- cifras del negocio (Inicio) ---------- */
.kpis { margin: 0 0 16px; }
.k-head { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; margin: 2px 0 10px; }
.k-head h2 { font-size: 16px; margin: 0; }
.k-head .hint { margin-left: auto; }
.k-period { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 999px; overflow: hidden; background: var(--panel); margin-left: auto; }
.k-period button { border: 0; background: transparent; padding: 6px 14px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.k-period button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.k-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.k-tile { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px 12px 18px; display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto auto; gap: 2px 10px; min-height: 104px; overflow: hidden; }
.k-tile::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--k, var(--accent)); }
.k-tile-label { grid-column: 1; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }
.k-tile-value { grid-column: 1; font-size: 26px; font-weight: 750; line-height: 1.15; color: var(--text); font-variant-numeric: tabular-nums; letter-spacing: -0.4px; }
.k-tile small { grid-column: 1; font-size: 12px; color: var(--muted); line-height: 1.35; }
.k-tile .k-spark { grid-column: 2; grid-row: 2 / span 2; width: 120px; height: 34px; align-self: end; }
.k-tile-na { opacity: 0.75; }
.k-tile-na::before { background: var(--line-strong); }
.k-loading { grid-column: 1 / -1; }
.k-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.k-card { margin: 0; }
.k-card > h2 { font-size: 14px; }
.k-card-body { padding: 12px var(--pad) 6px; }
.k-card > p.hint { padding: 0 var(--pad) 12px; }
.k-chart { width: 100%; height: auto; display: block; }
line.k-grid { stroke: var(--line); stroke-width: 1; }
.k-axis { font-size: 11px; fill: var(--muted); }
.k-legends { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0 0 6px; font-size: 12px; color: var(--muted); }
.k-legends.col { flex-direction: column; gap: 6px; }
.k-legend { display: inline-flex; align-items: center; gap: 6px; }
.k-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.k-legend b { color: var(--text); margin-left: 4px; }
.k-hbars { display: flex; flex-direction: column; gap: 8px; }
.k-hbar { display: grid; grid-template-columns: minmax(120px, 2fr) minmax(0, 3fr) auto; gap: 10px; align-items: center; font-size: 13px; }
.k-hbar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.k-hbar-track { height: 10px; background: var(--panel-soft); border-radius: 999px; overflow: hidden; }
.k-hbar-fill { height: 100%; border-radius: 999px; }
.k-hbar b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.k-donut { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.k-donut svg { width: 150px; height: 150px; flex: none; }
.k-donut-total { font-size: 15px; font-weight: 700; fill: var(--text); }
@media (max-width: 1100px) { .k-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } .k-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 600px) { .k-tiles { grid-template-columns: minmax(0, 1fr); } .k-period { margin-left: 0; } }

/* ---------- selector de poblacion ---------- */
.geo-pick-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.3fr) minmax(0, 1fr); gap: 10px 12px; margin-bottom: 10px; }
.geo-pick-results { max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 6px; margin-bottom: 10px; background: var(--panel-soft); }
.geo-pick-results > p { padding: 8px 6px; margin: 0; }
.geo-pick-item { display: block; width: 100%; text-align: left; border: 1px solid transparent; background: var(--panel); border-radius: 6px; padding: 8px 10px; margin: 0 0 4px; cursor: pointer; font: inherit; color: var(--text); }
.geo-pick-item:hover { border-color: var(--line-strong); }
.geo-pick-item.active { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.geo-pick-item.is-manual { color: var(--muted); }
.geo-pick-item small { color: var(--muted); }
.geo-pick-manual { display: block; width: 100%; text-align: left; border: 1px dashed var(--line-strong); background: transparent; border-radius: 6px; padding: 8px 10px; margin: 4px 0 0; cursor: pointer; font: inherit; color: var(--accent); }
.geo-pick-manual:hover { background: var(--accent-soft); }
.geo-pick-hood { max-width: 360px; margin-bottom: 8px; }
.geo-pick-choice { min-height: 18px; font-size: 13px; color: var(--ok); font-weight: 600; margin: 0 0 6px; }
.geo-pick-choice:empty { display: none; }
.geo-pick-actions { margin-top: 6px; }
@media (max-width: 700px) { .geo-pick-row { grid-template-columns: minmax(0, 1fr); } }

/* ---------- ficha generica: acciones y herramientas ---------- */
.visual-more-actions { position: relative; }
.visual-more-actions > summary { display: inline-flex; align-items: center; cursor: pointer; padding: 0 14px; min-height: var(--control-h); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--panel); font-size: 14px; font-weight: 500; white-space: nowrap; list-style: none; }
.visual-more-actions > summary::after { content: "▾"; margin-left: 8px; color: var(--muted); }
.visual-more-actions[open] > summary { background: var(--panel-soft); }
.visual-actions-panel { position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; display: flex; flex-direction: column; gap: 6px; min-width: 260px; max-width: 90vw; padding: 10px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow-pop); }
.visual-actions-panel .actions-bar { display: flex; flex-direction: column; gap: 6px; }
.visual-actions-panel .btn { justify-content: flex-start; width: 100%; }
.visual-help { margin: 0 0 12px; padding: 8px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 12px; }
.visual-help > summary { font-weight: 600; cursor: pointer; color: #445268; }
.visual-help > p, .visual-help > .notice { margin: 8px 0 0; width: auto; }
.visual-help > .notice { padding: 8px 10px; }
/* herramientas del presupuesto: una fila de botones pequenos bajo la cabecera */
.quote-revisions, .quote-material-tools { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 6px 10px 0; padding: 0; vertical-align: middle; }
.office-tools { display: inline-flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 0 6px 10px 0; padding: 0; }
.quote-revisions .btn, .quote-material-tools .btn, .office-tools .btn { min-height: 30px; padding: 0 10px; font-size: 13px; }
.page-head ~ .quote-revisions:first-of-type { margin-left: 0; }
.main[data-visual-entity=presupuestos] .page-head + .hint, .main[data-visual-entity=presupuestos] .quote-revisions ~ p.hint { display: block; margin: 0 0 10px; }

/* ---------- presupuesto ---------- */
.quote-form .form-grid > .fl, .quote-form .m2o { min-width: 0; }
.quote-form { background: transparent; border: 0; box-shadow: none; }
.quote-form .quote-data, .quote-form .quote-costs, .quote-form .lines-wrap, .quote-form .quote-extra, .quote-form .quote-conditions, .quote-form .quote-invoicing { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; overflow: clip; }
.quote-data > h2, .quote-costs > h2, .quote-invoicing > h2, .quote-form .lines-wrap > h3 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px var(--pad); margin: 0; font-size: 16px; background: var(--panel-soft); border-bottom: 1px solid var(--line); }
.quote-data > h2 > .btn { margin-left: auto; }
.quote-costs > h2 > small { font-size: 12px; font-weight: 400; color: var(--muted); }
/* facturacion del presupuesto: facturas, TicketBAI y confirmaciones en la misma pantalla */
.quote-invoicing > h2 > small { font-size: 12px; font-weight: 400; color: var(--muted); }
.quote-invoicing .inv-body { display: flex; flex-direction: column; gap: 10px; padding: 12px var(--pad); }
.quote-invoicing .inv-body > .hint, .quote-invoicing .inv-body > .notice { margin: 0; }
.quote-invoicing .inv-table th { position: static; }
.quote-invoicing .inv-table td.nowrap, .quote-invoicing .inv-table td.num { white-space: nowrap; }
.quote-invoicing .inv-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.quote-invoicing .inv-id { display: block; font-size: 11px; color: var(--muted); overflow-wrap: anywhere; }
.quote-invoicing .inv-error { color: var(--danger); overflow-wrap: anywhere; }
.quote-invoicing .inv-body > h3 { margin: 6px 0 0; font-size: 14px; }
.quote-invoicing .inv-concepts tr.inv-section td { background: var(--panel-soft); font-weight: 700; }
.quote-invoicing .inv-concepts input[type=number] { width: 96px; min-width: 0; text-align: right; }
.quote-invoicing .inv-concepts tr.inv-extra input:not([type=number]) { width: 100%; min-width: 160px; }
.quote-invoicing .inv-concepts tfoot td { border-top: 2px solid var(--line-strong); }
.quote-invoicing .inv-total { font-weight: 700; white-space: nowrap; }
.inv-confirm { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border: 1px solid var(--warn-line); border-radius: var(--radius-sm); background: var(--warn-soft); }
.inv-confirm > p { margin: 0; }
.inv-confirm .fl { max-width: 560px; }
.quote-form .quote-header { grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 10px 14px; padding: 14px var(--pad) 12px; }
.quote-form .quote-header > .fl { grid-column: span 4; }
.quote-form .quote-header > [data-quote-field=date_order], .quote-form .quote-header > [data-quote-field=validity_date] { grid-column: span 2; }
.quote-form .quote-header > .quote-header-reference { grid-column: span 8; min-width: 0; }
.quote-form .quote-header > .quote-header-reference input { width: 100%; max-width: none; }
.quote-form .quote-header input[type=date] { max-width: 100%; }
.quote-header-terms { min-width: 0; }
.quote-header-terms .quote-terms-controls { display: flex; flex-direction: column; gap: 4px; }
.quote-header-terms .quote-terms-controls label { min-width: 0; margin: 0; font-size: 12px; color: var(--muted); }
.quote-header-terms .quote-terms-controls label > span { display: block; margin-bottom: 3px; font-weight: 600; }
.quote-header-terms select { width: 100%; max-width: 100%; height: 34px; min-height: 34px; font-size: 13px; }
.quote-header-terms [data-terms-discard] { align-self: start; }
.quote-header-terms .quote-terms-error:empty, .quote-header-terms [data-terms-proposal]:empty { display: none; }
.quote-header-terms [data-terms-proposal], .quote-header-terms [data-terms-error] { margin: 4px 0 0; font-size: 11px; }
.quote-extra > summary > small { font-weight: 400; color: var(--muted); margin-left: 10px; }
.quote-extra > section > h3, .quote-rate-details > summary { padding: 10px var(--pad); font-size: 13px; background: var(--panel-soft); }
.quote-rate-details > summary { cursor: pointer; border-top: 1px solid var(--line); }
.quote-rate-details .quote-terms-detail, .quote-rate-details .quote-policy-originals { padding: 10px var(--pad); font-size: 12px; }
.quote-rate-details .quote-terms-detail h3, .quote-rate-details .quote-policy-originals h3 { font-size: 13px; margin-bottom: 6px; }
.quote-rate-details .quote-terms-detail p, .quote-rate-details .quote-policy-originals p { margin: 4px 0; }
.quote-rate-details .quote-terms-detail details > summary { cursor: pointer; }
.quote-form .lines-wrap { padding: 0; }
.quote-form .lines-wrap #lines { padding: 12px var(--pad); }

.quote-cost-strip { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px 10px; padding: 10px var(--pad); background: var(--accent-soft); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.quote-cost-strip > div { min-width: 0; text-align: right; }
.quote-cost-strip span { display: block; font-size: 11px; line-height: 1.3; color: var(--muted); }
.quote-cost-strip b { display: block; font-size: 13px; line-height: 1.3; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.quote-cost-rule { padding: 6px var(--pad); color: var(--muted); font-size: 11px; border-bottom: 1px solid var(--line); }
.quote-editor-policy { display: grid; grid-template-columns: minmax(0, 1fr); align-items: start; gap: 8px; margin: 0; padding: 12px var(--pad); background: var(--panel); }
.quote-editor-policy .quote-policy-heading { display: flex; flex-direction: column; align-self: center; gap: 3px; min-width: 0; }
.quote-editor-policy .quote-policy-heading b { font-size: 13px; line-height: 18px; }
.quote-editor-policy .quote-policy-heading small { font-size: 11.5px; line-height: 16px; }
.quote-editor-policy .quote-policy-fields { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(0, 1.25fr); align-items: start; gap: 12px; min-width: 0; }
.quote-editor-policy .quote-policy-field { display: flex; flex-direction: column; gap: 3px; min-width: 0; font-size: 12px; line-height: 16px; }
.quote-editor-policy .quote-policy-field > span { display: flex; flex: 1; align-items: flex-end; min-height: 16px; color: var(--muted); font-weight: 600; }
.quote-editor-policy input[type=number], .quote-editor-policy output, .quote-editor-policy input.visual-control[type=number] { width: 100%; min-width: 0; height: 34px; min-height: 34px; padding: 6px 8px; font-size: 13px; line-height: 20px; }
.quote-editor-policy output { display: flex; align-items: center; background: var(--panel-soft); border: 1px solid var(--line); border-radius: var(--radius-sm); font-weight: 600; white-space: nowrap; }
.quote-editor-policy .quote-policy-field small { min-height: 16px; font-size: 11.5px; line-height: 16px; overflow-wrap: anywhere; }
.quote-editor-policy .quote-policy-profit input { background: var(--accent-soft); }
.quote-editor-policy .quote-policy-profit input { font-weight: 600; }
.quote-editor-policy .quote-policy-actions { display: flex; grid-column: 1 / -1; align-items: center; flex-wrap: wrap; gap: 6px; min-width: 0; }
.quote-editor-policy .quote-policy-actions input, .quote-editor-policy .quote-policy-actions input.visual-control { flex: 1 1 190px; width: auto; min-width: 0; max-width: 420px; height: 34px; min-height: 34px; padding: 6px 8px; font-size: 13px; }
.quote-editor-policy .quote-policy-actions .btn { min-height: 34px; padding: 0 10px; font-size: 12px; }
.quote-editor-policy .quote-policy-actions:empty { display: none; }
.quote-editor-policy .quote-policy-unavailable { font-size: 12px; line-height: 17px; }
.quote-editor-policy .quote-policy-status { grid-column: 1 / -1; min-width: 0; }
.quote-editor-policy .quote-policy-status p { margin: 0; font-size: 12px; line-height: 17px; overflow-wrap: anywhere; }
.quote-editor-policy .quote-policy-status [data-policy-error]:empty { display: none; }
.quote-form .quote-work-location .form-grid { grid-template-columns: repeat(12, minmax(0, 1fr)); }
.quote-form .quote-work-location .form-grid > .fl:nth-child(1) { grid-column: span 6; }
.quote-form .quote-work-location .form-grid > .fl:nth-child(2) { grid-column: span 2; }
.quote-form .quote-work-location .form-grid > .fl:nth-child(3), .quote-form .quote-work-location .form-grid > .fl:nth-child(4) { grid-column: span 2; }
.quote-form .quote-conditions { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 12px var(--pad); }
.quote-form .quote-conditions > .fl, .quote-form .quote-conditions > .fl.full { grid-column: auto; }
.quote-form .quote-conditions textarea { min-height: 80px; }
.quote-form .lines-wrap { padding: 12px var(--pad); }
.quote-form .lines th { font-size: 11px; padding: 7px 5px; }
.quote-form .lines td { padding: 7px 5px; }
.quote-form .line-extra-tools { gap: 4px 10px; margin-top: 4px; }
.quote-form .line-extra-tools .link { font-size: 11px; }
.quote-editor-columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.quote-editor-columns > section > h3 { font-size: 14px; margin-bottom: 6px; }
.quote-line-editor label { margin-bottom: 10px; }
.quote-line-editor input { min-height: 32px; }
.quote-line-editor .row > .fl { flex: 1; min-width: 85px; }
.quote-line-editor output { display: block; padding: 6px; background: #f5f7fa; border-radius: 5px; min-height: 32px; }
.quote-line-editor [data-editor-result] { margin: 10px 0; padding: 8px; background: #eef4ff; border-radius: 5px; font-size: 12px; }
.quote-line-editor [data-editor-resources] { overflow: auto; }
.quote-line-editor td small { display: block; font-size: 10px; color: var(--muted); }
.quote-line-editor [data-editor-reason] { margin-top: 10px; }
.quote-line-editor [data-price-mode] { font-size: 11px; color: var(--muted); }
.quote-line-editor .btn + .btn { margin-left: 6px; }

/* ---------- partidas del presupuesto: edicion en la misma pantalla ---------- */
.ql-toolbar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding: 0 0 10px; }
.ql-add { display: flex; gap: 6px; flex-wrap: wrap; }
.ql-hint { margin: 0 0 10px; }
.ql-list { display: flex; flex-direction: column; gap: 8px; }
.ql-line { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel); }
.ql-line.ql-section { background: var(--accent-soft); border-color: var(--line-strong); }
.ql-line.ql-section.ql-level-1 { background: var(--panel-soft); border-color: var(--line); }
.ql-line.ql-note { background: var(--panel-soft); }
.ql-line.ql-level-1 { margin-left: 16px; }
.ql-line.ql-level-2 { margin-left: 32px; }
.ql-line.ql-level-3 { margin-left: 48px; }
.ql-main { display: grid; grid-template-columns: 18px 20px 40px minmax(0, 1fr) 72px 84px 50px 96px 28px; gap: 6px; align-items: start; padding: 8px 10px; }
.ql-section .ql-main { grid-template-columns: 18px 20px 40px minmax(0, 1fr) 110px 28px; }
.ql-note .ql-main { grid-template-columns: 18px 20px 40px minmax(0, 1fr) 28px; }
.ql-field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ql-field > span { font-size: 11px; font-weight: 600; color: var(--muted); line-height: 1.2; white-space: nowrap; }
.ql-field > small { font-size: 11px; color: var(--muted); overflow-wrap: anywhere; }
.ql-tools .ql-type { flex: 0 0 110px; }
.ql-tools .ql-type > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.ql-field input, .ql-field select, .ql-field textarea, .ql-field .visual-control[data-visual-size] { width: 100%; min-width: 0; max-width: 100%; min-height: 32px; padding: 5px 8px; font-size: 13px; }
.ql-field textarea { resize: none; overflow: hidden; line-height: 1.35; }
.ql-section .ql-name textarea { font-weight: 700; }
.ql-qty input, .ql-price input, .ql-dto input { text-align: right; }
.ql-amount { align-items: flex-end; text-align: right; }
.ql-amount b { display: block; min-height: 32px; padding: 6px 0; font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 13px; }
.ql-section .ql-amount b { color: var(--accent-dark); }
.ql-code .ql-num { min-height: 32px; padding: 6px 0; font-weight: 700; color: var(--accent-dark); font-variant-numeric: tabular-nums; }
.ql-fold, .ql-fold-space { width: 22px; height: 32px; margin-top: 17px; display: inline-flex; align-items: center; justify-content: center; border: 0; background: transparent; color: #123b61; font-size: 16px; padding: 0; border-radius: 4px; }
.ql-fold { cursor: pointer; }
.ql-fold:hover { background: #d0e1f0; }
.ql-order { display: flex; flex-direction: column; gap: 2px; margin-top: 16px; }
.ql-order button { border: 1px solid var(--line); background: var(--panel); color: var(--muted); border-radius: 4px; width: 24px; height: 16px; font-size: 9px; line-height: 1; cursor: pointer; padding: 0; }
.ql-order button:hover:not(:disabled) { color: var(--text); border-color: var(--line-strong); }
.ql-order button:disabled { opacity: .3; cursor: default; }
.ql-remove { margin-top: 17px; width: 30px; height: 32px; border: 0; background: transparent; color: var(--muted); cursor: pointer; border-radius: 4px; display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.ql-remove:hover:not(:disabled) { color: var(--danger); background: var(--danger-soft); }
.ql-remove:disabled { opacity: .3; cursor: default; }
.ql-cat .m2o input { min-height: 32px; padding: 5px 30px 5px 8px; font-size: 13px; }
.ql-cat .cat-info { margin-top: 2px; }
.ql-cat .m2o .menu { right: auto; width: 420px; max-width: 72vw; }
.ql-tools { display: flex; gap: 6px 12px; align-items: center; flex-wrap: wrap; padding: 0 10px 8px 62px; }
.ql-child-actions { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 10px 8px 62px; }
.ql-summary { display: block; width: calc(100% - 20px); margin: 0 10px 8px; padding: 6px 10px; border: 1px dashed var(--line-strong); border-radius: 6px; background: transparent; color: var(--muted); font-size: 12px; text-align: left; cursor: pointer; }
.ql-resources { margin: 0 10px 10px 62px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #f8fafd; }
.ql-resource-editor { padding: 10px; margin: 8px 0; background: var(--panel-soft); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.ql-resource-editor .form-grid { padding: 8px 0; }
.ql-resource-editor .error:empty { display: none; }
.ql-res-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-bottom: 8px; }
.ql-res-head b { font-size: 13px; }
.ql-res-status { color: var(--muted); font-size: 13px; padding: 4px 0; }
.ql-res-table { margin-bottom: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.ql-res-table th { position: static; font-size: 11px; padding: 6px 10px; }
.ql-res-table td { padding: 6px 10px; font-size: 13px; }
.ql-res-table td.empty { padding: 12px; text-align: left; }
.ql-res-add { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; }
.ql-res-add .ql-res-kind { flex: 0 0 220px; }
.ql-res-add .ql-res-product { flex: 1 1 280px; }
.ql-res-add .ql-res-qty, .ql-res-add .ql-res-cost { flex: 0 0 150px; }
.ql-res-add .ql-res-origin { flex: 1 1 260px; }
.ql-res-add .ql-res-note { flex-basis: 100%; }
.ql-res-add .error { flex-basis: 100%; font-size: 12px; }
.ql-res-add .error:empty { display: none; }
.ql-mat .menu { max-height: 300px; }
@media (max-width: 1250px) {
  /* A 1024 px la partida va en dos filas: descripcion arriba y cifras debajo. Capitulos y textos no cambian. */
  .ql-item .ql-main { grid-template-columns: 18px 20px 40px repeat(4, minmax(0, 1fr)) 28px; }
  .ql-item .ql-name { grid-column: 4 / span 4; grid-row: 1; }
  .ql-item .ql-remove { grid-column: 8; grid-row: 1; }
  .ql-item .ql-qty { grid-column: 4; grid-row: 2; }
  .ql-item .ql-price { grid-column: 5; grid-row: 2; }
  .ql-item .ql-dto { grid-column: 6; grid-row: 2; }
  .ql-item .ql-amount { grid-column: 7; grid-row: 2; }
  .ql-tools, .ql-child-actions, .ql-resources { padding-left: 10px; margin-left: 10px; }
}

/* ---------- ficha de obra y de aviso: dos columnas, grupos y menos ruido ---------- */
.obra-layout, .notice-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.obra-main, .notice-main, .obra-side, .notice-side { min-width: 0; }
.obra-side, .notice-side { position: sticky; top: 12px; }
.obra-side > .card, .obra-side > .obra-lifecycle, .notice-side > .card { margin: 0 0 14px; }
.obra-side .obra-section-head { padding: 10px var(--pad); }
.obra-actions { display: flex; flex-direction: column; gap: 6px; padding: 12px var(--pad); }
.obra-actions .obra-operation-buttons { margin: 0; flex-direction: column; align-items: stretch; }
.obra-actions .obra-operation-buttons .btn { justify-content: flex-start; min-height: 34px; }
.obra-side .obra-missing { padding: 10px var(--pad) 12px; border-color: var(--warn-line); background: var(--warn-soft); }
.obra-side .obra-missing summary { font-weight: 600; color: var(--warn); cursor: pointer; }
.obra-side .obra-missing .link { display: block; margin: 6px 0 0; text-align: left; }
.obra-legacy { margin: 10px var(--pad) 0; padding: 8px 12px; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); background: var(--panel-soft); }
.obra-legacy summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.obra-legacy .fl.full { padding: 8px 0 0; }
.obra-group > h3 { margin: 14px var(--pad) 0; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.obra-group .obra-header-grid { padding-top: 8px; }
.obra-group .obra-address { padding: 8px var(--pad) 4px; }
.obra-group .obra-caption { padding-top: 0; }
.obra-views { margin: 0 0 14px; padding: 4px; gap: 2px; background: var(--panel-soft); border: 1px solid var(--line); border-radius: 999px; width: fit-content; max-width: 100%; }
.obra-views > .btn[role=tab], .obra-views > a.btn { border: 0; background: transparent; box-shadow: none; min-height: 32px; }
.obra-views > .btn[role=tab].primary { background: var(--panel); color: var(--accent-dark); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.obra-views > .btn[role=tab]:not(.primary):hover, .obra-views > a.btn:hover { background: var(--panel); }
.obra-side .obra-lifecycle .obra-date-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.obra-items .grid td:first-child { max-width: 560px; }
.obra-items .grid td:first-child .hint { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.notice-workspace .notice-layout { margin-top: 6px; }
.notice-workspace .notice-main > .card, .notice-workspace .notice-below > .card, .notice-workspace .notice-below > details.card { margin: 0 0 14px; }
.notice-workspace .notice-side > .card { padding: 12px var(--pad); }
.notice-workspace .notice-side > .card > h2 { margin: 0 0 8px; font-size: 14px; }
.notice-workspace .notice-side > details.card > summary { font-weight: 600; cursor: pointer; }
.notice-workspace .notice-state .row { display: flex; flex-direction: column; gap: 6px; }
.notice-workspace .notice-state .row .btn { width: 100%; justify-content: center; }
.notice-workspace .notice-state .hint { margin: 8px 0 0; }
.notice-workspace .notice-below { margin-top: 14px; }
.notice-workspace .notice-form > .row.notice-save { position: sticky; bottom: 0; z-index: 2; background: var(--panel); border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); }
.notice-workspace .notice-price > p { display: flex; gap: 6px 18px; flex-wrap: wrap; font-size: 14px; margin: 0 0 6px; }
.notice-workspace .notice-price-help { font-size: 12px; }
@media (max-width: 1250px) {
  .obra-layout, .notice-layout { grid-template-columns: 1fr; }
  .obra-side, .notice-side { position: static; }
}

/* ---------- QR de TicketBAI y resumen contable ---------- */
.inv-tbai-ok { display: flex; gap: 10px; align-items: flex-start; }
.inv-tbai-ok .inv-qr { display: block; width: 72px; height: 72px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.inv-tbai-ok > span > small { display: block; }
.acc-year { min-width: 120px; }
.acc-year > span { font-size: 11px; font-weight: 600; color: var(--muted); }
.acc-tiles { margin-bottom: 12px; }
.acc-months td, .acc-months th { white-space: nowrap; }
.acc-months tfoot td { font-weight: 700; border-top: 2px solid var(--line-strong); }
.acc-neg { color: var(--danger); }

/* ---------- partes de trabajo: revision compacta en el listado (los motivos se leen en la ficha) ---------- */
table.grid td[data-work-review] { min-width: 200px; vertical-align: top; }
table.grid td[data-work-review] [data-review-status] { font-weight: 600; white-space: nowrap; margin-bottom: 4px; }
table.grid td[data-work-review] .row { gap: 4px; margin: 0; flex-wrap: wrap; }
table.grid td[data-work-review] .btn.small { min-height: 26px; padding: 0 8px; font-size: 12px; }
table.grid td[data-work-review] .btn.small[disabled] { display: none; }
table.grid td[data-work-review] .hint { display: none; }
table.grid td[data-work-review] .hint[data-review-note]:not(:empty), table.grid td[data-work-review] .error:not(:empty) { display: block; margin: 4px 0 0; font-size: 11px; }

/* ---------- CRM: la descripcion del trabajo se lee entera de un vistazo ---------- */
form.card [data-field=description] textarea { min-height: 150px; }

/* ---------- cliente ---------- */
.customer-form .form-grid { grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 12px 16px; }
.customer-form .form-grid > .fl { grid-column: span 4; }
.customer-form [data-field=name] { grid-column: span 8; }
.customer-form [data-field=cestero_customer_kind] { grid-column: span 4; }
.customer-form [data-field=is_property_manager] { grid-column: span 4; align-self: end; }
.customer-form [data-field=vat], .customer-form [data-field=ref] { grid-column: span 4; }
.customer-form [data-field=comment] { grid-column: 1 / -1; }
.customer-form textarea { min-height: 72px; }
.customer-address .form-grid { grid-template-columns: repeat(12, minmax(0, 1fr)); }
.customer-address [data-field=street], .customer-address [data-field=street2] { grid-column: 1 / -1; }
.customer-address [data-field=zip] { grid-column: span 2; }
.customer-address [data-field=city] { grid-column: span 5; }
.customer-address [data-field=state_id], .customer-address [data-field=country_id] { grid-column: span 5; }
.customer-address [data-field=zip] input { max-width: 140px; }
/* alta de cliente en dos pasos */
[data-customer-wizard] { padding-top: 4px; }
[data-customer-wizard] .customer-wizard-progress { display: flex; gap: 22px; flex-wrap: wrap; padding: 12px var(--pad) 0; margin: 0 0 4px; list-style: none; color: var(--muted); font-weight: 600; font-size: 13px; }
[data-customer-wizard] .customer-wizard-progress [aria-current=step] { color: var(--accent); }
[data-customer-wizard] h2 { font-size: 16px; margin: 0; padding: 12px var(--pad) 4px; }
[data-customer-wizard] section > p { padding: 0 var(--pad); color: var(--muted); font-size: 13px; }
[data-customer-wizard] .customer-wizard-summary { margin: 0; padding: 6px var(--pad) 10px; overflow-wrap: anywhere; font-size: 13px; }
[data-customer-wizard] .customer-wizard-error { margin: 8px var(--pad); color: var(--danger); }
[data-customer-wizard] .customer-wizard-error:empty { display: none; }
[data-customer-wizard] .customer-address { margin: 0; border-top: 0; }
[data-customer-wizard] .customer-wizard-buttons { display: flex; gap: 10px; flex-wrap: wrap; padding: 8px var(--pad) var(--pad); }
[data-customer-wizard] [data-geo-operational] { margin: 8px var(--pad) 4px; }

/* ---------- direccion compartida ---------- */
.address-summary { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 6px 12px; align-items: center; padding: 10px var(--pad); min-width: 0; }
.address-summary-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.address-summary [data-address-summary] { min-width: 0; overflow-wrap: anywhere; font-size: 13px; }
.address-summary [data-address-load-error] { grid-column: 1 / -1; font-size: 12px; }
.address-summary [data-address-load-error]:empty { display: none; }
.record-address { border-top: 1px solid var(--line); }
#obra-form .obra-address, .notice-form .notice-location { grid-column: 1 / -1; min-width: 0; }
#obra-form .obra-address .address-summary, .notice-form .notice-location .address-summary { padding-left: 0; padding-right: 0; }
.address-editor { min-width: 0; }
.address-editor-head { display: flex; gap: 10px; align-items: baseline; justify-content: space-between; flex-wrap: wrap; }
.address-editor .form-grid { padding: 10px 0; gap: 10px 12px; }
.address-editor .form-grid .fl { margin: 0; }
.address-editor input, .address-editor select { width: 100%; min-width: 0; }
.address-editor .check input { width: 16px; }
.address-editor [data-address-complements] > summary { cursor: pointer; padding: 8px 0; font-weight: 600; }
.address-editor [data-address-review] { padding: 8px 10px; margin: 8px 0; }
.address-preview { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel-soft); margin-top: 10px; }
.address-preview > p { margin: 4px 0 0; overflow-wrap: anywhere; }
.address-editor-actions { position: sticky; bottom: 0; background: var(--panel); border-top: 1px solid var(--line); padding: 10px 0 0; margin-top: 10px; }
.address-editor [data-address-error]:empty { display: none; }

/* ---------- obra ---------- */
.obra-views { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 0 0 12px; }
.obra-views > .btn[role=tab] { border-radius: 999px; }
.obra-views > a.btn { border-radius: 999px; }
.obra-operation-buttons { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.obra-operation-buttons .btn { min-height: 32px; padding: 0 12px; font-size: 13px; }
#obra-missing { display: block; }
#obra-missing summary { cursor: pointer; }
#obra-missing .link { margin: 5px 0; }
#obra-missing p { margin: 8px 0 0; }
.obra-form, .obra-items { background: var(--panel); padding: 0; }
.obra-header-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); align-items: start; gap: 12px 16px; padding: 12px var(--pad) 4px; }
.obra-header-grid > * { min-width: 0; }
.obra-header-grid .full { grid-column: 1 / -1; }
.obra-header-grid .fl, .obra-header-grid .m2o { min-width: 0; }
.obra-header-grid input:not([type=checkbox]), .obra-header-grid select, .obra-header-grid textarea { max-width: 100%; width: 100%; }
#obra-form [data-work-field] { grid-column: span 3; display: flex; flex-direction: column; gap: 4px; }
#obra-form .obra-header-grid > .fl > .lbl { margin: 0; }
#obra-form [data-work-field=code] { grid-column: span 2; }
#obra-form [data-work-field=name] { grid-column: span 4; }
#obra-form [data-work-field=cestero_gmao_project_type] { grid-column: span 3; }
#obra-form [data-work-field=partner_id], #obra-form [data-work-field=contract] { grid-column: span 6; }
#obra-form [data-work-field=cestero_work_address] { grid-column: span 6; }
#obra-form [data-work-field=cestero_work_zip], #obra-form [data-work-field=cestero_work_city], #obra-form [data-work-field=cestero_work_state_id] { grid-column: span 2; }
#obra-form [data-work-field=cestero_work_zip] input, #obra-form [data-work-field=cestero_work_zip] .visual-control { max-width: 140px; width: 100%; }
#obra-form [data-work-field=cestero_requester_id], #obra-form [data-work-field=cestero_intermediary_id] { grid-column: span 4; }
#obra-form .obra-header-grid > [data-work-field].check { grid-column: span 2; flex-direction: row; align-items: center; align-self: end; gap: 8px; min-height: var(--control-h); padding: 0; margin: 0; font-size: 12px; line-height: 1.3; }
#obra-form [data-work-field=description] { grid-column: 1 / -1; }
#obra-form textarea { min-height: 64px; }
.obra-caption { margin: 0; padding: 8px var(--pad) 12px; }
p.obra-caption, .hint.obra-caption { color: var(--muted); font-size: 12px; }
h3.obra-caption { font-size: 14px; color: var(--text); padding-top: 14px; }
details.obra-caption > summary { cursor: pointer; }
.visual-work-header > summary { padding: 9px var(--pad); border-bottom: 1px solid var(--line); cursor: pointer; font-size: 12px; font-weight: 600; color: var(--muted); }
.visual-work-header > summary:hover { color: var(--text); }
#obra-contacts { padding: 0; }
.obra-contact { display: grid; grid-template-columns: minmax(160px, 1.2fr) minmax(130px, auto) minmax(160px, 1fr) auto; gap: 12px; align-items: end; padding: 12px var(--pad); border-bottom: 1px solid var(--line); }
.obra-contact > div:first-child { align-self: center; }
.obra-contact .link { font-size: 14px; text-decoration: none; font-weight: 600; text-align: left; }
.obra-contact .link:hover { text-decoration: underline; }
.obra-contact .hint { display: block; overflow-wrap: anywhere; }
.obra-contact-note { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.obra-contact-note input { width: 100%; min-width: 0; }
#obra-contacts > p.hint { padding: 10px var(--pad) 12px; margin: 0; }
.obra-errors { color: var(--danger); padding: 12px var(--pad); }
.obra-form [aria-invalid=true] { border-color: var(--danger); }
.obra-table-scroll { overflow-x: auto; }
.obra-chapter { background: var(--bg); font-weight: 600; }
.obra-extra-item { background: #f4f8ff; }
.obra-extra-item .badge { display: block; width: fit-content; margin-top: 5px; }
.obra-lifecycle { margin: 0 0 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.obra-lifecycle .obra-section-head { padding: 10px var(--pad); }
.obra-date-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 14px; padding: 12px var(--pad) 10px; }
.obra-date-grid span { display: block; font-size: 11px; color: var(--muted); }
.obra-date-grid b { display: block; font-size: 13px; }
.obra-lifecycle .obra-caption { margin: 0; padding: 0 var(--pad) 10px; }
.obra-cert-actions { display: flex; gap: 5px; flex-wrap: wrap; }
.obra-view-pager, .obra-material-tabs { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px var(--pad); color: var(--muted); font-size: 13px; }
.obra-material-tabs { gap: 6px; }
.obra-declared-text { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 6px; }
#obra-parts, #obra-materials { padding: 0; background: var(--panel); }
#obra-parts > .empty, #obra-materials > .empty { padding: 20px; }
/* parte de trabajo manual */
#manual-part > .row, #manual-part > .notice, #manual-part > [data-errors] { margin: 12px var(--pad); }
#manual-part > [data-errors]:empty { display: none; }
#manual-part > p.hint { padding: 8px var(--pad) 0; }
#manual-part .fl.full > button { margin-top: 4px; }
#manual-part .fl.full > .hint { display: block; margin-top: 6px; }
.manual-part-line { margin: 10px var(--pad); padding: 0 0 4px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel); }
.manual-part-line .form-grid { gap: 10px 14px; padding: 12px; }

/* ---------- avisos ---------- */
.notice-workspace .page-head .badge { align-self: center; }
.notice-workspace .notice-filters { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 10px 14px; padding: 12px var(--pad); margin-bottom: 12px; }
.notice-workspace .notice-filters > label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.notice-workspace .notice-filters > label > input, .notice-workspace .notice-filters > label > select { font-weight: 400; color: var(--text); font-size: 14px; }
.notice-workspace .notice-filters .notice-search { flex: 1 1 260px; max-width: 460px; }
.notice-workspace .notice-filters input[type=date] { width: 160px; }
.notice-workspace .notice-filters select { width: 230px; max-width: 100%; }
.notice-workspace .notice-filters .visual-date-hint, .notice-workspace .notice-filters .visual-date-readable { display: none; }
.notice-workspace .notice-form { max-width: 1320px; }
.notice-workspace .notice-section { padding: 12px var(--pad) 14px; border-bottom: 1px solid var(--line); }
.notice-workspace .notice-section > h2 { padding: 0 0 10px; border: 0; font-size: 14px; }
.notice-workspace .notice-work-grid { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 12px 16px; }
.notice-workspace .notice-work-text textarea { min-height: 90px; }
.notice-workspace .notice-contact-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 16px; }
.notice-workspace .notice-contact-grid .fl { min-width: 0; }
.notice-workspace .notice-fiscal { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 6px 8px; grid-column: span 2; }
.notice-workspace .notice-fiscal > .fl { flex: 0 0 auto; }
.notice-workspace .notice-fiscal > small { flex-basis: 100%; }
.notice-workspace .notice-location { grid-column: 1 / -1; }
.notice-workspace .notice-location input { width: 100%; }
.notice-workspace .notice-price-grid { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 12px 18px; }
.notice-workspace .notice-price-grid .fl { min-width: 170px; }
.notice-workspace .notice-price-grid select { width: 240px; }
.notice-workspace .notice-price-grid [data-total] { margin: 0; padding: 8px 12px; background: var(--accent-soft); border-radius: var(--radius-sm); font-weight: 600; }
.notice-workspace .notice-price-grid [data-minimum] { flex-basis: 100%; }
.notice-workspace .notice-price-help { margin: 10px 0 0; }
.notice-workspace .notice-form > .row { padding: 12px var(--pad); }
.notice-workspace .notice-price > details { padding: 0 var(--pad) 10px; }
.notice-workspace .notice-section > p { margin: 0 0 6px; }
.notice-customer-create .form-grid { padding: 8px 0; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.notice-customer-create > details { margin: 8px 0; }
.notice-customer-create > details > summary { cursor: pointer; }
.notice-customer-create [data-customer-status] { min-height: 18px; }
.notice-workspace [data-internal-costs] > details { padding: 0 var(--pad) 12px; }
.notice-workspace [data-internal-costs] > details > summary { cursor: pointer; padding: 4px 0; }
.notice-workspace details.card > summary { padding: 12px var(--pad); cursor: pointer; font-weight: 600; font-size: 14px; }
.notice-workspace details.card > summary:hover { background: var(--panel-soft); }
.notice-workspace details.card > p, .notice-workspace details.card > ul, .notice-workspace details.card > a { margin-left: var(--pad); margin-right: var(--pad); }
.notice-workspace details.card > .btn, .notice-workspace details.card > a.btn { margin: 8px var(--pad) 12px; }
.notice-workspace details.card > ul li + li { margin-top: 6px; }
.notice-workspace .card > section { padding-bottom: 10px; }
.notice-workspace .card > h3 { padding-top: 8px; border-bottom: 0; }
.notice-workspace [data-error] { margin-bottom: 10px; }
.notice-workspace [data-retry] { margin-bottom: 12px; }
.notice-workspace .card .row[data-states] { gap: 8px; }
.notice-workspace .card .row[data-states]:empty { display: none; }

/* ---------- compras ---------- */
.procurement-page .page-head { margin-bottom: 8px; }
.procurement-tabs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 0 0 12px; }
.procurement-tabs .btn { border-radius: 999px; }
.procurement-page section.card > .procurement-filters { padding: 12px var(--pad); border-bottom: 1px solid var(--line); }
.procurement-filters { display: flex; align-items: flex-end; gap: 10px 14px; flex-wrap: wrap; }
.procurement-filters label { display: flex; flex-direction: column; gap: 4px; flex: 0 1 180px; font-size: 12px; font-weight: 600; color: var(--muted); }
.procurement-filters label > input, .procurement-filters label > select { font-weight: 400; color: var(--text); font-size: 14px; }
.procurement-filters label:has(input[type=date]) { flex: 0 0 160px; }
.procurement-date { display: inline-flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); margin: 8px 0; }
.procurement-date input { width: 160px; font-weight: 400; color: var(--text); }
.procurement-page [data-procurement-error]:not(:empty) { padding: 10px var(--pad) 0; }
.procurement-page .procurement-pages { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px var(--pad); color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); }
.procurement-page .procurement-pages:empty { display: none; }
.procurement-page .grid td { vertical-align: top; }
.procurement-page .grid small { display: block; color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.procurement-heading { padding: 12px var(--pad); border-bottom: 1px solid var(--line); }
.procurement-heading h2 { margin: 0; flex: 1; font-size: 16px; }
.procurement-heading > span { color: var(--muted); font-size: 13px; }
.procurement-summary { display: grid; grid-template-columns: repeat(4, minmax(130px, 1fr)); gap: 12px; padding: 12px var(--pad); border-bottom: 1px solid var(--line); margin: 0; }
.procurement-summary b, .procurement-summary span { display: block; }
.procurement-summary b { font-size: 11px; color: var(--muted); font-weight: 600; }
.procurement-summary span { font-size: 13px; }
.procurement-page [data-offer-form], .procurement-page [data-receive-form], .procurement-page section.card > section, .procurement-page section.card > details { padding: 12px var(--pad); border-top: 1px solid var(--line); }
.procurement-page [data-offer-form] h3, .procurement-page [data-receive-form] h3, .procurement-page section.card > section h3 { font-size: 14px; margin: 0 0 8px; }
.procurement-page [data-offer-form] .grid { min-width: 1030px; }
.procurement-page [data-offer-form] .grid th:nth-child(2) { width: 24%; }
.procurement-page [data-offer-form] input[type=number] { width: 106px; min-height: 30px; padding: 5px 6px; }
.procurement-page [data-offer-form] input[data-offer-discount] { width: 65px; }
.procurement-page [data-offer-form] select, .procurement-page [data-offer-form] input[data-offer-reference] { display: block; max-width: 175px; width: 100%; min-height: 30px; padding: 5px 6px; }
.procurement-page [data-offer-form] select + input { margin-top: 4px; }
.procurement-page [data-receive-form] input[type=number] { width: 120px; min-height: 30px; padding: 5px 6px; }
.procurement-page [data-receive-form] .procurement-receive-head { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; margin: 0 0 8px; }
.procurement-page form > .btn.primary { margin-top: 10px; }
.procurement-confirm { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.procurement-page section.card > p.notice { margin: 12px var(--pad) 0; }
.procurement-page section.card > p.notice:empty { display: none; }
.procurement-page [data-procurement-retry] > p { padding: 0 var(--pad); }
.procurement-page section.card > details > summary { cursor: pointer; font-weight: 600; }
.procurement-page .num { text-align: right; }
.procurement-page button:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- facturas: control administrativo ---------- */
.main[data-visual-entity^=facturas-] > .card:first-child { padding: 10px var(--pad); font-size: 13px; color: var(--muted); }
.main[data-visual-entity^=facturas-] [data-summary] { padding: 10px var(--pad) 12px; }
.main[data-visual-entity^=facturas-] [data-summary] > p { padding: 0; margin: 0 0 10px; color: var(--muted); font-size: 13px; }
.main[data-visual-entity^=facturas-] [data-summary] { display: flex; flex-wrap: wrap; gap: 10px; align-items: stretch; }
.main[data-visual-entity^=facturas-] [data-summary] > p { flex-basis: 100%; }
.main[data-visual-entity^=facturas-] [data-summary] > .stat { flex: 1 1 260px; margin: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel-soft); }
.main[data-visual-entity^=facturas-] [data-summary] > .stat h3 { font-size: 13px; margin-bottom: 4px; }
.main[data-visual-entity^=facturas-] [data-summary] > .stat p { margin: 0 0 4px; font-size: 12.5px; color: var(--muted); }
.main[data-visual-entity^=facturas-] [data-list] > p { padding: 12px var(--pad); color: var(--muted); }
.main[data-visual-entity^=facturas-] .stats > .card { margin: 0; padding: 0 0 10px; }
.main[data-visual-entity^=facturas-] .stats > .card > h3 { border-bottom: 0; padding-bottom: 4px; }
.main[data-visual-entity^=facturas-] .stats > .card > p { font-size: 12px; color: var(--muted); }
.main[data-visual-entity^=facturas-] .row[role=tablist] { gap: 4px; margin: 14px 0 10px; }
.main[data-visual-entity^=facturas-] .row[role=tablist] .btn { border-radius: 999px; }
.main[data-visual-entity^=facturas-] .row[role=tablist] .btn[aria-selected=true] { background: var(--accent); border-color: var(--accent); color: #fff; }
.main[data-visual-entity^=facturas-] .row[data-admin] { margin: 0 0 10px; }
.main[data-visual-entity^=facturas-] .row[data-admin]:empty { display: none; }
.main[data-visual-entity^=facturas-] [data-content] > h2 { font-size: 15px; }
.main[data-visual-entity^=facturas-] [data-content] > h3 { font-size: 14px; padding-top: 10px; border-bottom: 0; }
.main[data-visual-entity^=facturas-] [data-content] > a.btn { margin: 8px var(--pad) 12px; }
.main[data-visual-entity^=facturas-] [data-content] article { padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.main[data-visual-entity^=facturas-] [data-content] article:last-child { border-bottom: 0; }
.main[data-visual-entity^=facturas-] [data-native-actions]:empty { display: none; }
.main[data-visual-entity=calendario-factura] [data-accounting-due] { padding: var(--pad); }

/* ---------- configuracion y maestros ---------- */
.visual-masters { margin: 0 0 14px; }
.visual-master-group { margin: 14px 0; }
.visual-master-group > h2 { font-size: 14px; margin: 0 0 8px; padding: 0; border: 0; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; font-size: 12px; }
.visual-master-links { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.visual-master-links > a { display: flex; align-items: center; min-height: 46px; padding: 9px 14px; font-size: 13px; margin: 0; }
.visual-master-links > a:hover { border-color: var(--accent); text-decoration: none; }
.compact-policy { padding: 0; }
.compact-policy > h2 { border-bottom: 0; padding-bottom: 2px; }
.compact-policy > p.hint { padding: 0 var(--pad) 4px; }
.compact-policy form { padding: 0 var(--pad) 14px; }
.compact-policy form .form-grid { padding: 10px 0 12px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.compact-policy form .form-grid > .fl { grid-column: auto; }
.compact-policy form .form-grid > .fl.full { grid-column: 1 / -1; max-width: 520px; }
.compact-policy .error { padding: 0 var(--pad); }
.compact-policy-history { border-top: 1px solid var(--line); }
.main[data-visual-entity=configuracion] .visual-masters + .card { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px var(--pad); }
.main[data-visual-entity=configuracion] .visual-masters + .card > .btn { margin: 0; }

/* ---------- condiciones de pago y contactos del proveedor (fichas) ---------- */
#form ~ .card:not(.rel) > h2, #form ~ .card:not(.rel) > h3 { border-bottom: 1px solid var(--line); }
#form ~ .card > p.notice { margin-top: 10px; }
#form ~ .card > .row > .fl { flex: 1 1 260px; max-width: 460px; }
#form ~ .card > .row > .btn { align-self: flex-end; }
#form ~ .card [data-message]:not(:empty) { color: var(--ok); font-weight: 600; }
#form ~ .card [data-fiscal-preview] > h3 { padding: 10px 0 6px; border: 0; }
#form ~ .card [data-fiscal-preview] form .row > .fl { flex: 1 1 160px; }
#form ~ .card [data-fiscal-preview] form .row > .btn { align-self: flex-end; }
#form ~ .card [data-fiscal-preview] table, [data-example-result] table, [data-result] table { border-collapse: collapse; margin-top: 8px; }
#form ~ .card [data-fiscal-preview] table th, #form ~ .card [data-fiscal-preview] table td, [data-example-result] table th, [data-example-result] table td, [data-result] table th, [data-result] table td { padding: 6px 12px; border-bottom: 1px solid var(--line); text-align: left; font-size: 13px; }
#form ~ .card article { padding-top: 8px; }
#form ~ .card article h3 { font-size: 13px; margin-bottom: 2px; }
/* editor de una condicion de pago */
section.card[aria-label="Editar condición nativa"] > h3 { border-bottom: 1px solid var(--line); }
section.card[aria-label="Editar condición nativa"] > form { padding: 12px var(--pad); }
section.card[aria-label="Editar condición nativa"] > form > .fl { margin-bottom: 12px; max-width: 640px; }
section.card[aria-label="Editar condición nativa"] > form > .row { align-items: flex-end; margin-bottom: 12px; }
section.card[aria-label="Editar condición nativa"] > form > .row > .fl { flex: 0 1 170px; }
section.card[aria-label="Editar condición nativa"] > form > .row > label.fl:has(> input[type=checkbox]) { display: flex; align-items: center; gap: 8px; flex-direction: row; font-size: 13px; font-weight: 400; color: var(--text); min-height: var(--control-h); flex: 0 0 auto; }
section.card[aria-label="Editar condición nativa"] [data-lines] > .row { align-items: flex-end; gap: 10px; padding: 10px 12px; margin-bottom: 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel-soft); }
section.card[aria-label="Editar condición nativa"] [data-lines] > .row > .fl { flex: 1 1 130px; }
section.card[aria-label="Editar condición nativa"] [data-lines] > .row > .btn { align-self: flex-end; }
section.card[aria-label="Editar condición nativa"] > section { padding: 12px var(--pad); border-top: 1px solid var(--line); }
section.card[aria-label="Editar condición nativa"] > section > h3 { font-size: 14px; margin-bottom: 8px; }
section.card[aria-label="Editar condición nativa"] > section form .row { align-items: flex-end; }
section.card[aria-label="Editar condición nativa"] > section form .row > .fl { flex: 1 1 160px; }
section.card[aria-label="Editar condición nativa"] > p[data-message] { padding: 0 var(--pad) 12px; }

/* ---------- registro horario ---------- */
.main[data-visual-entity=horario] .toolbar { align-items: flex-end; }

/* ---------- planificacion semanal ---------- */
.plan-wrap { overflow-x: auto; }
table.plan { width: 100%; border-collapse: collapse; min-width: 980px; table-layout: fixed; }
table.plan th, table.plan td { border: 1px solid var(--line); padding: 6px; vertical-align: top; }
table.plan th { font-size: 12px; color: var(--muted); background: var(--panel-soft); text-align: center; }
table.plan th:first-child { text-align: left; width: 190px; }
table.plan td.who { font-weight: 600; background: #fcfdff; }
table.plan td.cell { min-height: 46px; }
table.plan .we { background: #f8f8f8; }
table.plan .today { background: #eef6ff; }
table.plan th.today { color: var(--accent); }
table.plan .chip.obra { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin: 0 0 4px; padding: 4px 6px 4px 8px; background: var(--accent-soft); color: var(--accent); border-radius: 6px; font-size: 12px; font-weight: 600; white-space: normal; }
table.plan .chip.obra button { border: 0; background: transparent; color: var(--accent); cursor: pointer; font-size: 15px; line-height: 1; padding: 0 2px; }
table.plan .chip.obra button:hover { color: var(--danger); }
table.plan button.add { width: 100%; border: 1px dashed var(--line-strong); background: transparent; color: var(--muted); border-radius: 6px; cursor: pointer; padding: 3px; font-size: 15px; line-height: 1; }
table.plan button.add:hover { border-color: var(--accent); color: var(--accent); background: #fff; }

/* ---------- pantallas estrechas ---------- */
@media (max-width: 1100px) {
  .quote-form .quote-header > .fl, .quote-form .quote-header > .fl:nth-child(1), .quote-form .quote-header > .fl:nth-child(2), .quote-form .quote-header > .quote-header-reference { grid-column: span 6; }
  .quote-editor-policy { grid-template-columns: minmax(0, 1fr); }
  .quote-editor-policy .quote-policy-heading { flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
  .quote-cost-strip { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  #obra-form .obra-header-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  #obra-form [data-work-field=code] { grid-column: span 2; }
  #obra-form [data-work-field=name] { grid-column: span 4; }
  #obra-form [data-work-field=cestero_work_address], #obra-form [data-work-field=description] { grid-column: 1 / -1; }
  #obra-form [data-work-field=partner_id], #obra-form [data-work-field=contract] { grid-column: span 3; }
  .obra-contact { grid-template-columns: minmax(0, 1fr) auto; }
  .customer-form [data-field=name] { grid-column: 1 / -1; }
  .customer-form .form-grid > .fl, .customer-address .form-grid > .fl { grid-column: span 6; }
  .customer-address [data-field=street], .customer-address [data-field=street2], .customer-form [data-field=comment] { grid-column: 1 / -1; }
}
@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar { width: auto; height: auto; position: static; max-height: 60vh; max-height: 60dvh; overflow: hidden; }
  .brand { display: flex; align-items: center; gap: 8px; padding: 8px 14px; }
  .brand .logo { width: 44px; height: 32px; object-fit: contain; margin: 0; padding: 3px 4px; }
  .brand .name { font-size: 15px; }
  .brand .tag { display: none; }
  .nav { padding: 4px 8px; }
  .sidebar .user { margin: 0; padding: 6px 12px; }
  .sidebar .user .who b, .sidebar .user .who span { display: inline; font-size: 12px; }
  .sidebar .user .who span { margin-left: 6px; }
  .sidebar .user .who small { font-size: 10px; }
  .main { padding: 14px 16px 40px; }
  .sticky-save { margin: 0 -16px -40px; padding: 10px 16px; }
  .form-grid > *, .form-grid > .fl.check, .form-grid > [data-visual-size=short], .form-grid > [data-visual-size=number], .form-grid > [data-visual-size=date], .customer-form .form-grid > .fl, .customer-address .form-grid > .fl, .customer-address [data-field=zip], .customer-address [data-field=city], .customer-address [data-field=state_id], .customer-address [data-field=country_id] { grid-column: span 6; }
  .form-grid > .full { grid-column: 1 / -1; }
  .two { grid-template-columns: 1fr; }
  .quote-form .quote-work-location .form-grid > .fl, .quote-form .quote-work-location .form-grid > .fl:nth-child(1), .quote-form .quote-work-location .form-grid > .fl:nth-child(2), .quote-form .quote-work-location .form-grid > .fl:nth-child(3), .quote-form .quote-work-location .form-grid > .fl:nth-child(4) { grid-column: span 6; }
  .quote-form .quote-conditions { grid-template-columns: minmax(0, 1fr); }
  .notice-workspace .notice-contact-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .notice-workspace .notice-fiscal { grid-column: 1 / -1; }
  .notice-workspace .notice-work-grid { grid-template-columns: minmax(0, 1fr); }
  .notice-workspace .notice-work-grid input[type=date] { width: 160px; }
  .obra-date-grid, .procurement-summary, .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quote-editor-columns { grid-template-columns: minmax(0, 1fr); }
  .quote-lines-readonly { overflow: auto; }
  .visual-actions-panel { max-height: 65vh; overflow: auto; }
  .obra-operation-buttons { margin-left: 0; }
  .address-summary { grid-template-columns: minmax(0, 1fr) auto; }
  .address-summary-label { grid-column: 1 / -1; }
  .address-summary [data-address-summary] { grid-column: 1; }
  .address-summary [data-address-open] { grid-column: 2; }
}
@media (max-width: 600px) {
  .ql-line.ql-level-1, .ql-line.ql-level-2, .ql-line.ql-level-3 { margin-left: 0; }
  .form-grid, .customer-form .form-grid, .customer-address .form-grid, .quote-form .quote-header, .obra-header-grid, #obra-form .obra-header-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid > *, .customer-form .form-grid > *, .customer-address .form-grid > *, .quote-form .quote-header > *, #obra-form .obra-header-grid > [data-work-field] { grid-column: 1 / -1 !important; }
  .obra-contact { grid-template-columns: minmax(0, 1fr); }
  .obra-contact .btn { justify-self: start; }
  .obra-date-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quote-cost-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quote-editor-policy .quote-policy-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 10px; }
  .quote-editor-policy .quote-policy-payment { grid-column: 1 / -1; }
  .address-editor .form-grid { grid-template-columns: minmax(0, 1fr); }
  .address-editor .form-grid > .fl { grid-column: 1 / -1; }
  .quote-editor-policy .quote-policy-actions input { flex-basis: 100%; max-width: none; }
  .notice-workspace .notice-contact-grid { grid-template-columns: minmax(0, 1fr); }
  .notice-workspace .notice-filters .notice-search { flex-basis: 100%; }
  .notice-workspace .notice-price-grid .fl { flex: 1; }
  .notice-workspace .notice-price-grid select { width: 100%; }
  .home-range label { flex: 1; }
  .home-range input[type=date] { width: 100%; min-width: 110px; }
  .visual-master-links { grid-template-columns: minmax(0, 1fr); }
  .visual-control[data-visual-size=date] { width: 150px; }
  .visual-multiselect { min-width: 175px; }
  .main [data-filters] > fieldset { margin: 6px 8px; gap: 6px; }
  .stats { grid-template-columns: 1fr; }
}

/* ---------- zonas de proveedor y cliente (portal.html) y su revision en Oficina ---------- */
.portal-page { max-width: 1080px; margin: 0 auto; padding: 16px; }
.portal-head { display: flex; align-items: center; gap: 14px; margin: 8px 0 10px; }
.portal-head img { height: 44px; width: auto; }
.portal-head h1 { font-size: 22px; }
.portal-intro { margin-bottom: 12px; }
.portal-tabs { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; }
.portal-scroll { overflow-x: auto; }
.portal-actions { padding: 10px var(--pad) 12px; }
.portal-num { width: 110px; text-align: right; }
.portal-num.small { width: 72px; }
.portal-code { width: 120px; }
.portal-file { cursor: pointer; }
.portal-data { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 4px 12px; padding: 12px var(--pad); margin: 0; }
.portal-data dt { margin: 0; }
.portal-data dd { margin: 0; color: var(--text); }
.portal-days { columns: 2; padding: 10px var(--pad) 0 calc(var(--pad) + 18px); margin: 0; }
.portal-free { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 var(--pad) 10px; }
.card [data-change-box] > p, .card [data-change-box] > .fl, .card [data-change-box] > .notice { margin: 0 var(--pad) 10px; }
.portal-msg { padding: 10px var(--pad); border-bottom: 1px solid var(--line); }
.portal-msg:last-child { border-bottom: 0; }
.portal-msg .notice { margin-top: 8px; background: var(--accent-soft); border-color: var(--line); color: var(--text); }
.portal-pre { white-space: pre-wrap; }
.portal-foot { text-align: center; margin: 18px 0; }
.portal-notice { display: block; }
.portal-notice > div > div + div { margin-top: 4px; }
@media (max-width: 600px) {
  .portal-page { padding: 10px; }
  .portal-days { columns: 1; }
  .portal-data { grid-template-columns: minmax(0, 1fr); }
}
.portal-fill .portal-file { margin-left: 6px; }
