/* =====================================================================
   InmoERP · Sistema de diseño
   Tokens en :root, modo oscuro con [data-theme="dark"], responsive.
   ===================================================================== */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f8;
  --border: #e3e8f0;
  --border-strong: #cfd7e4;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --primary: #4338ca;
  --primary-600: #3730a3;
  --primary-50: #eef2ff;
  --primary-100: #e0e7ff;
  --accent: #0d9488;
  --success: #059669; --success-bg: #ecfdf5; --success-bd: #a7f3d0;
  --warning: #b45309; --warning-bg: #fffbeb; --warning-bd: #fde68a;
  --orange: #c2410c;  --orange-bg: #fff7ed;  --orange-bd: #fed7aa;
  --danger: #dc2626;  --danger-bg: #fef2f2;  --danger-bd: #fecaca;
  --info: #0369a1;    --info-bg: #f0f9ff;    --info-bd: #bae6fd;
  --muted-bg: #f1f5f9; --muted-bd: #e2e8f0;
  --sidebar: #0c1426;
  --sidebar-2: #131e36;
  --sidebar-text: #aab6cc;
  --sidebar-active: #ffffff;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 6px 16px -6px rgba(15, 23, 42, .08);
  --shadow-lg: 0 24px 60px -12px rgba(15, 23, 42, .28);
  --radius: 14px;
  --radius-sm: 10px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --sidebar-w: 264px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --_auto-dark: 1; }
}
:root[data-theme="dark"], :root.auto-dark {
  --bg: #0a0f1c;
  --surface: #111827;
  --surface-2: #0f172a;
  --surface-3: #1a2336;
  --border: #1f2a3d;
  --border-strong: #2c3a52;
  --text: #e6ebf3;
  --text-2: #c3cddd;
  --muted: #8b98ad;
  --primary: #818cf8;
  --primary-600: #6366f1;
  --primary-50: #1c2140;
  --primary-100: #252c55;
  --success: #34d399; --success-bg: #0b2a22; --success-bd: #14532d;
  --warning: #fbbf24; --warning-bg: #2a2110; --warning-bd: #713f12;
  --orange: #fb923c;  --orange-bg: #2b1a0e;  --orange-bd: #7c2d12;
  --danger: #f87171;  --danger-bg: #2c1215;  --danger-bd: #7f1d1d;
  --info: #38bdf8;    --info-bg: #0c2233;    --info-bd: #0c4a6e;
  --muted-bg: #1a2336; --muted-bd: #2c3a52;
  --sidebar: #070b15;
  --sidebar-2: #0d1426;
  --shadow: 0 1px 3px rgba(0,0,0,.4), 0 8px 20px -8px rgba(0,0,0,.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.45rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
small, .small { font-size: .82em; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: .92em; }
.text-right, .num { text-align: right; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.opacity-25 { opacity: .35; }
.hidden { display: none !important; }
.mt-0{margin-top:0}.mt-1{margin-top:.5rem}.mt-2{margin-top:1rem}.mt-3{margin-top:1.5rem}.mb-0{margin-bottom:0}.mb-1{margin-bottom:.5rem}.mb-2{margin-bottom:1rem}.mb-3{margin-bottom:1.5rem}
.flex { display: flex; gap: .5rem; align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.gap-2 { gap: 1rem; }
.w-100 { width: 100%; }
.text-success { color: var(--success) } .text-danger { color: var(--danger) } .text-warning { color: var(--warning) } .text-primary { color: var(--primary) }

/* ------------------------------ Layout ------------------------------ */
.app { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 40;
  background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
  color: var(--sidebar-text); display: flex; flex-direction: column; transition: transform .25s ease, width .25s ease;
}
.brand { display: flex; gap: .75rem; align-items: center; padding: 1.1rem 1.2rem; border-bottom: 1px solid rgba(255,255,255,.06); }
.brand .logo { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; font-weight: 800; color: #fff; letter-spacing: -.02em;
  background: linear-gradient(135deg, #6366f1, #0d9488); box-shadow: 0 6px 18px -6px rgba(99,102,241,.7); flex: none; }
.brand b { color: #fff; font-size: 1.05rem; display: block; }
.brand small { color: var(--sidebar-text); font-size: .75rem; }
.menu { flex: 1; overflow-y: auto; padding: .6rem .6rem 1rem; scrollbar-width: thin; scrollbar-color: #26324c transparent; }
.menu-group { margin-top: .8rem; }
.menu-group > span { display: block; padding: .3rem .8rem; font-size: .68rem; text-transform: uppercase; letter-spacing: .09em; color: #5f6d86; font-weight: 600; }
.menu a { display: flex; align-items: center; gap: .7rem; padding: .52rem .8rem; border-radius: 9px; color: var(--sidebar-text); font-weight: 500; font-size: .9rem; text-decoration: none; transition: background .15s, color .15s; }
.menu a i { font-size: 1.05rem; width: 20px; text-align: center; opacity: .9; }
.menu a:hover { background: rgba(255,255,255,.06); color: #fff; }
.menu a.active { background: linear-gradient(90deg, rgba(99,102,241,.28), rgba(99,102,241,.08)); color: var(--sidebar-active); box-shadow: inset 3px 0 0 #818cf8; }
.sidebar-foot { padding: .8rem 1rem; border-top: 1px solid rgba(255,255,255,.06); font-size: .78rem; color: #5f6d86; }
.main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); transition: margin .25s ease; display: flex; flex-direction: column; }
body.sidebar-collapsed .sidebar { transform: translateX(-100%); }
body.sidebar-collapsed .main { margin-left: 0; }
.sidebar-backdrop { display: none; }

.topbar { position: sticky; top: 0; z-index: 30; height: 62px; display: flex; align-items: center; gap: .8rem; padding: 0 1.4rem;
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: saturate(160%) blur(10px); border-bottom: 1px solid var(--border); }
.icon-btn { width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--text-2); cursor: pointer; font-size: 1.15rem; position: relative; }
.icon-btn:hover { background: var(--surface-3); }
.icon-btn .dot { position: absolute; top: 4px; right: 4px; min-width: 17px; height: 17px; border-radius: 9px; background: var(--danger); color: #fff; font-size: .66rem; font-weight: 700; display: grid; place-items: center; padding: 0 4px; border: 2px solid var(--surface); }
.global-search { position: relative; flex: 1; max-width: 520px; }
.global-search input { width: 100%; height: 40px; padding: 0 1rem 0 2.4rem; border-radius: 11px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit; }
.global-search input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-100); background: var(--surface); }
.global-search > i { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-results { position: absolute; top: 46px; left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); max-height: 70vh; overflow: auto; display: none; padding: .4rem; }
.search-results.open { display: block; }
.search-results .grp { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: .5rem .6rem .2rem; font-weight: 600; }
.search-results a { display: flex; gap: .6rem; align-items: center; padding: .5rem .6rem; border-radius: 8px; color: var(--text); }
.search-results a:hover, .search-results a.focus { background: var(--primary-50); text-decoration: none; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: .3rem; }
.user-chip { display: flex; align-items: center; gap: .55rem; padding: .25rem .5rem .25rem .25rem; border-radius: 12px; cursor: pointer; border: 1px solid transparent; background: none; color: var(--text); font: inherit; }
.user-chip:hover { background: var(--surface-3); }
.avatar { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-weight: 700; font-size: .8rem; color: #fff; background: linear-gradient(135deg, #6366f1, #8b5cf6); flex: none; }
.avatar.lg { width: 56px; height: 56px; border-radius: 16px; font-size: 1.2rem; }
.avatar.teal { background: linear-gradient(135deg, #0d9488, #22c55e); }
.user-chip .who { text-align: left; line-height: 1.15; }
.user-chip .who b { font-size: .85rem; display: block; }
.user-chip .who small { color: var(--muted); font-size: .72rem; }

.content { padding: 1.4rem 1.6rem 3rem; max-width: 1600px; width: 100%; }
.crumbs { display: flex; gap: .35rem; align-items: center; font-size: .8rem; color: var(--muted); margin-bottom: .35rem; flex-wrap: wrap; }
.crumbs a { color: var(--muted); }
.crumbs i { font-size: .65rem; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.2rem; flex-wrap: wrap; }
.page-head h1 { margin: 0; display: flex; align-items: center; gap: .6rem; }
.page-head h1 .h-icon { width: 38px; height: 38px; border-radius: 11px; display: inline-grid; place-items: center; background: var(--primary-50); color: var(--primary); font-size: 1.1rem; }
.page-head p { margin: .25rem 0 0; color: var(--muted); }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ------------------------------ Dropdown ----------------------------- */
.dropdown { position: relative; }
.dropdown > summary { list-style: none; }
.dropdown > summary::-webkit-details-marker { display: none; }
.dropdown .dd-menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: .35rem; z-index: 50; }
.dropdown .dd-menu.left { right: auto; left: 0; }
.dd-menu a, .dd-menu button { display: flex; width: 100%; align-items: center; gap: .6rem; padding: .5rem .7rem; border-radius: 8px; color: var(--text); font: inherit; background: none; border: 0; text-align: left; cursor: pointer; font-size: .88rem; }
.dd-menu a:hover, .dd-menu button:hover { background: var(--surface-3); text-decoration: none; }
.dd-menu hr { border: 0; border-top: 1px solid var(--border); margin: .3rem 0; }
.dd-menu .danger { color: var(--danger); }
.notif-panel { width: 360px; max-height: 480px; overflow: auto; padding: 0; }
.notif-panel .nh { display: flex; justify-content: space-between; align-items: center; padding: .8rem 1rem; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
.notif-item { display: flex; gap: .7rem; padding: .75rem 1rem; border-bottom: 1px solid var(--border); color: var(--text); }
.notif-item:hover { background: var(--surface-2); text-decoration: none; }
.notif-item.unread { background: var(--primary-50); }
.notif-item .ni { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-3); color: var(--primary); flex: none; }

/* ------------------------------ Cards -------------------------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card + .card { margin-top: 1.1rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .8rem; padding: .95rem 1.2rem; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; font-size: 1rem; display: flex; align-items: center; gap: .5rem; }
.card-head h2 i, .card-head h3 i { color: var(--primary); }
.card-body { padding: 1.2rem; }
.card-body.p-0 { padding: 0; }
.card-foot { padding: .8rem 1.2rem; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.grid { display: grid; gap: 1.1rem; }
.grid > *, .kpis > *, .plano-wrap > * { min-width: 0; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid-side { grid-template-columns: 340px minmax(0, 1fr); }
.grid-aside { grid-template-columns: minmax(0, 1fr) 300px; }
.span-2 { grid-column: span 2; }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(225px, 1fr)); gap: 1rem; margin-bottom: 1.2rem; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; display: flex; gap: .9rem; align-items: center; box-shadow: var(--shadow-sm); position: relative; overflow: hidden; color: var(--text); }
a.kpi:hover { text-decoration: none; border-color: var(--primary); transform: translateY(-1px); transition: .15s; }
.kpi .ki { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 1.25rem; flex: none; background: var(--primary-50); color: var(--primary); }
.kpi .kv { font-size: clamp(1.05rem, 1.5vw, 1.35rem); font-weight: 750; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi > div:last-child { min-width: 0; }
.kpi .kl { color: var(--muted); font-size: .8rem; font-weight: 500; }
.kpi .kd { font-size: .75rem; font-weight: 600; margin-top: .15rem; }
.ki.green { background: var(--success-bg); color: var(--success); }
.ki.amber { background: var(--warning-bg); color: var(--warning); }
.ki.red { background: var(--danger-bg); color: var(--danger); }
.ki.orange { background: var(--orange-bg); color: var(--orange); }
.ki.teal { background: #e6fffa; color: #0d9488; }
:root[data-theme="dark"] .ki.teal { background: #0b2a28; color: #2dd4bf; }
.ki.blue { background: var(--info-bg); color: var(--info); }

/* ------------------------------ Buttons ------------------------------ */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; height: 38px; padding: 0 1rem; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; font-size: .87rem; cursor: pointer; white-space: nowrap; text-decoration: none !important; transition: background .15s, border-color .15s, box-shadow .15s, transform .05s; }
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .input:focus-visible { outline: 3px solid var(--primary-100); outline-offset: 1px; }
.btn[disabled], .btn.disabled { opacity: .55; pointer-events: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 4px 12px -4px color-mix(in srgb, var(--primary) 60%, transparent); }
.btn-primary:hover { background: var(--primary-600); border-color: var(--primary-600); }
:root[data-theme="dark"] .btn-primary { color: #0b1020; }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(.95); background: var(--success); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.95); background: var(--danger); }
.btn-outline-danger { color: var(--danger); border-color: var(--danger-bd); }
.btn-outline-danger:hover { background: var(--danger-bg); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-soft { background: var(--primary-50); border-color: transparent; color: var(--primary); }
.btn-soft:hover { background: var(--primary-100); }
.btn-wa { background: #25d366; border-color: #25d366; color: #fff; }
.btn-sm { height: 31px; padding: 0 .7rem; font-size: .8rem; border-radius: 8px; }
.btn-xs { height: 26px; padding: 0 .5rem; font-size: .75rem; border-radius: 7px; }
.btn-icon { width: 32px; padding: 0; height: 32px; border-radius: 8px; }
.btn-group { display: inline-flex; gap: .3rem; }

/* ------------------------------ Forms -------------------------------- */
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: .9rem 1rem; }
.field { grid-column: span 6; display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field.third { grid-column: span 4; }
.field.quarter { grid-column: span 3; }
.field.two-third { grid-column: span 8; }
.field.three-quarter { grid-column: span 9; }
.form-grid > .form-grid { gap: .9rem 1rem; }
.field > label, .lbl { font-size: .8rem; font-weight: 600; color: var(--text-2); }
.field > label .req { color: var(--danger); }
.input, select.input, textarea.input { width: 100%; height: 39px; padding: 0 .8rem; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit; font-size: .9rem; transition: border-color .15s, box-shadow .15s; }
textarea.input { height: auto; min-height: 84px; padding: .6rem .8rem; resize: vertical; line-height: 1.45; }
select.input { padding-right: 2rem; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16'%3E%3Cpath fill='%2364748b' d='M8 11 3 6h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .7rem center; }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-100); }
.input[readonly] { background: var(--surface-2); }
.input.is-invalid { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-bg); }
.input-sm { height: 33px; font-size: .84rem; }
input[type="color"].input { padding: 3px; width: 64px; }
.hint { font-size: .76rem; color: var(--muted); }
.error { font-size: .76rem; color: var(--danger); font-weight: 500; }
.input-group { display: flex; }
.input-group .addon { display: grid; place-items: center; padding: 0 .75rem; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--muted); font-size: .85rem; border-radius: var(--radius-sm) 0 0 var(--radius-sm); border-right: 0; }
.input-group .input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.check { display: inline-flex; align-items: center; gap: .5rem; cursor: pointer; font-size: .88rem; user-select: none; }
.check input { width: 17px; height: 17px; accent-color: var(--primary); }
.switch { position: relative; display: inline-flex; align-items: center; gap: .6rem; cursor: pointer; font-size: .88rem; }
.switch input { appearance: none; width: 38px; height: 22px; border-radius: 22px; background: var(--border-strong); position: relative; cursor: pointer; transition: .2s; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch input:checked { background: var(--primary); }
.switch input:checked::after { left: 19px; }
.form-section { grid-column: 1 / -1; font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--primary); border-bottom: 1px dashed var(--border-strong); padding: .6rem 0 .35rem; margin-top: .2rem; display: flex; align-items: center; gap: .4rem; }
.form-actions { display: flex; justify-content: flex-end; gap: .5rem; padding-top: 1rem; margin-top: 1rem; border-top: 1px solid var(--border); }

/* ------------------------------ Toolbar ------------------------------ */
.toolbar { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; padding: .85rem 1.2rem; border-bottom: 1px solid var(--border); }
.toolbar .search { position: relative; flex: 1; min-width: 200px; max-width: 360px; }
.toolbar .search i { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.toolbar .search .input { padding-left: 2.2rem; height: 36px; }
.toolbar select.input, .toolbar input.input { height: 36px; width: auto; min-width: 140px; font-size: .85rem; }
.toolbar .spacer { flex: 1; }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: .35rem; padding: .3rem .7rem; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: .8rem; font-weight: 600; cursor: pointer; text-decoration: none !important; }
.chip.active, .chip:hover { background: var(--primary-50); border-color: var(--primary-100); color: var(--primary); }
.chip .n { background: var(--surface-3); border-radius: 99px; padding: 0 .45rem; font-size: .72rem; }

/* ------------------------------ Tables ------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .87rem; }
.table th { text-align: left; font-weight: 600; font-size: .74rem; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding: .7rem 1rem; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: .72rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .th-sort { color: inherit; display: inline-flex; align-items: center; gap: .3rem; text-decoration: none; }
.table .actions { text-align: right; white-space: nowrap; }
.table tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--border); }
.table.compact td, .table.compact th { padding: .5rem .75rem; }
.table tr.row-muted td { color: var(--muted); }
.table tr.row-danger td { background: color-mix(in srgb, var(--danger-bg) 60%, transparent); }
.cell-title { font-weight: 600; color: var(--text); }
.cell-sub { font-size: .78rem; color: var(--muted); }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .8rem 1.2rem; border-top: 1px solid var(--border); flex-wrap: wrap; font-size: .82rem; color: var(--muted); }
.pager .pages { display: flex; gap: .25rem; }
.pager .pages a, .pager .pages span { min-width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; border: 1px solid var(--border); color: var(--text-2); font-weight: 600; padding: 0 .5rem; text-decoration: none; }
.pager .pages a:hover { background: var(--surface-3); }
.pager .pages .cur { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ------------------------------ Badges ------------------------------- */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .18rem .6rem; border-radius: 99px; font-size: .72rem; font-weight: 650; border: 1px solid; white-space: nowrap; line-height: 1.5; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { color: var(--success); background: var(--success-bg); border-color: var(--success-bd); }
.badge-warning { color: var(--warning); background: var(--warning-bg); border-color: var(--warning-bd); }
.badge-orange { color: var(--orange); background: var(--orange-bg); border-color: var(--orange-bd); }
.badge-danger { color: var(--danger); background: var(--danger-bg); border-color: var(--danger-bd); }
.badge-info { color: var(--info); background: var(--info-bg); border-color: var(--info-bd); }
.badge-muted { color: var(--muted); background: var(--muted-bg); border-color: var(--muted-bd); }
.tag { display: inline-flex; align-items: center; gap: .3rem; padding: .12rem .5rem; border-radius: 6px; font-size: .74rem; font-weight: 600; background: var(--surface-3); color: var(--text-2); }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: middle; border: 1px solid rgba(0,0,0,.1); }

/* ------------------------------ Alerts ------------------------------- */
.alert { display: flex; gap: .7rem; align-items: flex-start; padding: .8rem 1rem; border-radius: 12px; border: 1px solid; margin-bottom: 1rem; font-size: .88rem; }
.alert i { font-size: 1.1rem; margin-top: .05rem; }
.alert-info { color: var(--info); background: var(--info-bg); border-color: var(--info-bd); }
.alert-warning { color: var(--warning); background: var(--warning-bg); border-color: var(--warning-bd); }
.alert-danger { color: var(--danger); background: var(--danger-bg); border-color: var(--danger-bd); }
.alert-success { color: var(--success); background: var(--success-bg); border-color: var(--success-bd); }
.alert .grow { color: var(--text-2); }
.alert b { color: inherit; }

/* Empty state */
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty .ei { width: 64px; height: 64px; margin: 0 auto .8rem; border-radius: 18px; display: grid; place-items: center; font-size: 1.8rem; background: var(--primary-50); color: var(--primary); }
.empty h3 { color: var(--text); margin-bottom: .2rem; }

/* ------------------------------ Tabs --------------------------------- */
.tabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--border); padding: 0 1rem; overflow-x: auto; scrollbar-width: none; }
.tabs a, .tabs button { padding: .8rem .9rem; border: 0; background: none; color: var(--muted); font: inherit; font-weight: 600; font-size: .87rem; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none !important; display: inline-flex; gap: .4rem; align-items: center; }
.tabs a:hover, .tabs button:hover { color: var(--text); }
.tabs .active { color: var(--primary); border-bottom-color: var(--primary); }
.tabs .cnt { background: var(--surface-3); color: var(--text-2); border-radius: 99px; font-size: .7rem; padding: 0 .45rem; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ------------------------------ Detail lists ------------------------- */
.dl { display: grid; grid-template-columns: minmax(120px, 40%) 1fr; gap: .55rem 1rem; font-size: .88rem; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; font-weight: 550; word-break: break-word; }
.profile-head { display: flex; gap: 1rem; align-items: center; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .8rem; }
.stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: .75rem .9rem; }
.stat .sl { font-size: .74rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat .sv { font-size: 1.12rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.progress { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--primary), #8b5cf6); }
.progress.green > span { background: linear-gradient(90deg, #059669, #34d399); }
.progress.amber > span { background: linear-gradient(90deg, #d97706, #fbbf24); }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 15px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.timeline li { position: relative; padding: 0 0 1.1rem 44px; }
.timeline .tl-i { position: absolute; left: 0; top: 0; width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--border); color: var(--primary); font-size: .9rem; }
.timeline .tl-h { display: flex; gap: .5rem; align-items: baseline; flex-wrap: wrap; }
.timeline .tl-h b { font-size: .88rem; }
.timeline .tl-h small { color: var(--muted); }
.timeline .tl-b { font-size: .87rem; color: var(--text-2); margin-top: .15rem; white-space: pre-line; }

/* ------------------------------ Modal -------------------------------- */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 4vh 1rem; background: rgba(8, 12, 24, .55); backdrop-filter: blur(3px); overflow-y: auto; animation: fade .15s ease; }
.modal[hidden] { display: none; }
.modal-dialog { width: 100%; max-width: 640px; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); border: 1px solid var(--border); animation: pop .18s ease; }
.modal-dialog.lg { max-width: 920px; }
.modal-dialog.xl { max-width: 1180px; }
.modal-dialog.sm { max-width: 460px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.3rem; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 1.05rem; }
.modal-body { padding: 1.3rem; }
.modal-foot { display: flex; justify-content: flex-end; gap: .5rem; padding: .9rem 1.3rem; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 18px 18px; }
.modal .form-actions { margin: 1.3rem -1.3rem -1.3rem; padding: .9rem 1.3rem; background: var(--surface-2); border-radius: 0 0 18px 18px; }
@keyframes fade { from { opacity: 0 } }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.98) } }
.loading { display: grid; place-items: center; padding: 3rem; color: var(--muted); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg) } }

/* ------------------------------ Toasts ------------------------------- */
#toasts { position: fixed; right: 1rem; bottom: 1rem; z-index: 200; display: flex; flex-direction: column; gap: .5rem; max-width: min(420px, calc(100vw - 2rem)); }
.toast { display: flex; gap: .7rem; align-items: flex-start; padding: .85rem 1rem; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); font-size: .88rem; animation: pop .2s ease; border-left: 4px solid var(--info); }
.toast.success { border-left-color: var(--success); } .toast.success i { color: var(--success); }
.toast.error { border-left-color: var(--danger); } .toast.error i { color: var(--danger); }
.toast.warning { border-left-color: var(--warning); } .toast.warning i { color: var(--warning); }
.toast i { font-size: 1.1rem; color: var(--info); }

/* ------------------------------ Kanban ------------------------------- */
.kanban { display: flex; gap: .9rem; overflow-x: auto; padding-bottom: 1rem; align-items: flex-start; min-height: 60vh; }
.kcol { flex: 0 0 290px; background: var(--surface-3); border-radius: 14px; display: flex; flex-direction: column; max-height: calc(100vh - 230px); border: 1px solid var(--border); }
.kcol-h { padding: .75rem .9rem; display: flex; justify-content: space-between; align-items: center; font-weight: 650; font-size: .86rem; border-bottom: 1px solid var(--border); }
.kcol-h .kdot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: .45rem; }
.kcol-b { padding: .6rem; overflow-y: auto; flex: 1; min-height: 80px; display: flex; flex-direction: column; gap: .55rem; }
.kcol-b.over { background: var(--primary-50); outline: 2px dashed var(--primary); outline-offset: -6px; border-radius: 12px; }
.kcard { background: var(--surface); border: 1px solid var(--border); border-radius: 11px; padding: .7rem .8rem; cursor: grab; box-shadow: var(--shadow-sm); font-size: .84rem; }
.kcard:hover { border-color: var(--primary-100); box-shadow: var(--shadow); }
.kcard.dragging { opacity: .5; }
.kcard .kt { font-weight: 650; color: var(--text); display: block; margin-bottom: .2rem; }
.kcard .km { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: .76rem; }
.heat-caliente { color: #dc2626 } .heat-tibio { color: #d97706 } .heat-frio { color: #0284c7 }

/* ------------------------------ Calendar ----------------------------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--border); border-left: 1px solid var(--border); }
.cal .dow { padding: .5rem; font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; background: var(--surface-2); border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); text-align: center; }
.cal .day { min-height: 118px; padding: .35rem; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); font-size: .76rem; overflow: hidden; }
.cal .day.out { background: var(--surface-2); color: var(--muted); }
.cal .day.today { background: var(--primary-50); }
.cal .day .dn { font-weight: 700; font-size: .8rem; margin-bottom: .2rem; display: flex; justify-content: space-between; }
.cal-titulo { min-width: 190px; text-align: center; }
.cal .day { position: relative; }
.cal .day-link { display: none; }
.cal .ev { display: block; padding: .15rem .4rem; border-radius: 5px; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #fff; font-size: .72rem; font-weight: 600; text-decoration: none !important; cursor: pointer; }

/* ------------------------------ Plano -------------------------------- */
.plano-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1rem; }
.plano-stage { position: relative; background: repeating-conic-gradient(var(--surface-3) 0% 25%, var(--surface) 0% 50%) 50% / 22px 22px; border-radius: 14px; border: 1px solid var(--border); overflow: hidden; height: calc(100vh - 250px); min-height: 460px; }
.plano-canvas { position: absolute; inset: 0; }
.plano-tools { position: absolute; top: .7rem; left: .7rem; display: flex; gap: .3rem; z-index: 5; background: var(--surface); padding: .3rem; border-radius: 12px; box-shadow: var(--shadow); border: 1px solid var(--border); flex-wrap: wrap; }
.plano-tools .btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.legend { display: flex; gap: .8rem; flex-wrap: wrap; font-size: .8rem; }
.legend span { display: inline-flex; align-items: center; gap: .35rem; }
.plano-tip { position: absolute; pointer-events: none; z-index: 10; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: .6rem .8rem; font-size: .8rem; min-width: 180px; display: none; }

/* ------------------------------ Auth --------------------------------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-art { position: relative; overflow: hidden; color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between;
  background: radial-gradient(1200px 600px at -10% -10%, var(--primary) 0%, transparent 60%), radial-gradient(900px 600px at 110% 110%, var(--accent) 0%, transparent 55%), linear-gradient(135deg, #0b1224, #111b33); }
.auth-art .bg-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .34; z-index: 0; }
.brand-logo { height: 40px; width: auto; max-width: 96px; object-fit: contain; border-radius: 10px; flex: none; }
.brand-lg .brand-logo { height: 56px; max-width: 150px; }
.brand-txt { min-width: 0; }
.brand-txt b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-lg .brand-txt b { font-size: 1.2rem; }
.brand-lg .brand-txt small { color: #c7d2fe; }
.auth-art::after { content: ""; position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px); background-size: 42px 42px; mask-image: linear-gradient(180deg, transparent, #000 30%, #000 70%, transparent); }
.auth-art > * { position: relative; z-index: 1; }
.auth-art h1 { font-size: 2.3rem; line-height: 1.15; max-width: 520px; font-weight: 800; }
.auth-art p { color: #c7d2fe; max-width: 460px; font-size: 1.02rem; }
.auth-feats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; max-width: 520px; }
.auth-feats div { display: flex; gap: .6rem; align-items: center; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1); padding: .7rem .8rem; border-radius: 12px; font-size: .86rem; }
.auth-form { display: grid; place-items: center; padding: 2rem; background: var(--surface); }
.auth-box { width: 100%; max-width: 400px; }
.auth-box h2 { font-size: 1.6rem; font-weight: 750; }
.auth-box .field { grid-column: 1 / -1; margin-bottom: 1rem; }
.auth-box .input { height: 46px; }
.auth-box .btn { height: 46px; width: 100%; font-size: .95rem; }

/* ------------------------------ Documento ---------------------------- */
.doc { background: #fff; color: #111; font-family: "Georgia", "Times New Roman", serif; font-size: 12.5pt; line-height: 1.6; padding: 2.2cm 2cm; max-width: 21cm; margin: 0 auto; box-shadow: var(--shadow); }
.doc-head { display: flex; gap: 1rem; align-items: center; border-bottom: 2px solid #1e293b; padding-bottom: .6rem; margin-bottom: 1rem; font-family: var(--font); font-size: 10pt; }
.doc-logo { max-height: 56px; max-width: 160px; }
.doc-title { text-align: center; font-size: 14pt; margin: 1.2rem 0; letter-spacing: .02em; }
.doc-clause { margin-bottom: .8rem; text-align: justify; }
.doc-clause h4 { font-size: 11pt; margin: .6rem 0 .2rem; text-transform: uppercase; }
.doc-table { width: 100%; border-collapse: collapse; font-size: 9.5pt; font-family: var(--font); margin: .5rem 0; }
.doc-table th, .doc-table td { border: 1px solid #94a3b8; padding: 3px 6px; }
.doc-table th { background: #e2e8f0; }
.doc-firmas { display: flex; justify-content: space-around; gap: 2rem; margin-top: 3.2rem; flex-wrap: wrap; text-align: center; font-family: var(--font); font-size: 10pt; }
.doc-firma { min-width: 190px; }
.doc-firma .line { border-top: 1px solid #111; margin-bottom: .3rem; }
.doc-pie { margin-top: 2rem; border-top: 1px solid #cbd5e1; padding-top: .4rem; font-size: 8.5pt; color: #475569; font-family: var(--font); }
.doc-stage { background: var(--surface-3); padding: 1.5rem; border-radius: 14px; overflow-x: auto; }

/* Comprobante */
.voucher { background: #fff; color: #111; max-width: 820px; margin: 0 auto; padding: 1.6rem 1.8rem; font-size: 10pt; border: 1px solid #cbd5e1; border-radius: 6px; font-family: var(--font); }
.voucher .vh { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 2px solid #1e293b; padding-bottom: .8rem; }
.voucher .vbox { border: 2px solid #1e293b; border-radius: 8px; padding: .6rem 1rem; text-align: center; min-width: 220px; }
.voucher .vbox b { font-size: 11pt; display: block; }
.voucher table { width: 100%; border-collapse: collapse; margin: .8rem 0; }
.voucher th, .voucher td { border: 1px solid #cbd5e1; padding: 4px 8px; font-size: 9.5pt; }
.voucher th { background: #f1f5f9; text-align: left; }
.voucher .legal { font-size: 8.5pt; color: #475569; border: 1px dashed #94a3b8; padding: .5rem .7rem; border-radius: 6px; margin-top: .8rem; }
.voucher .anulado { color: #dc2626; font-weight: 800; font-size: 18pt; text-align: center; border: 3px solid #dc2626; padding: .3rem; transform: rotate(-3deg); margin: .5rem 0; }

/* ------------------------------ Portal ------------------------------- */
.portal-top { background: linear-gradient(135deg, #1e1b4b, #0f766e); color: #fff; }
.portal-top .inner { max-width: 1180px; margin: 0 auto; padding: 1rem 1.4rem; display: flex; align-items: center; gap: 1rem; }
.portal-nav { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.portal-nav .inner { max-width: 1180px; margin: 0 auto; display: flex; gap: .2rem; overflow-x: auto; padding: 0 1rem; scrollbar-width: none; }
.portal-nav .inner::-webkit-scrollbar, .tabs::-webkit-scrollbar { display: none; }
.portal-nav a { padding: .9rem .9rem; color: var(--muted); font-weight: 600; font-size: .88rem; border-bottom: 2px solid transparent; white-space: nowrap; text-decoration: none; display: inline-flex; gap: .4rem; align-items: center; }
.portal-nav a.active, .portal-nav a:hover { color: var(--primary); border-bottom-color: var(--primary); }
.portal-main { max-width: 1180px; margin: 0 auto; padding: 1.4rem; }

/* ------------------------------ Misc ------------------------------- */
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { padding: .6rem 0; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; gap: .6rem; align-items: center; }
.list-plain li:last-child { border-bottom: 0; }
.contact-row { display: grid; grid-template-columns: 130px 70px minmax(0, 1fr) 110px auto; gap: .5rem; align-items: center; padding: .5rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); margin-bottom: .5rem; }
.contact-row .opts { grid-column: 1 / -1; display: flex; gap: 1rem; flex-wrap: wrap; font-size: .8rem; }
.perm-table td, .perm-table th { text-align: center; }
.perm-table td:first-child, .perm-table th:first-child { text-align: left; }
.chart-box { position: relative; height: 290px; }
.chart-box.sm { height: 220px; }
.dup-box { border: 1px solid var(--warning-bd); background: var(--warning-bg); border-radius: 12px; padding: .8rem 1rem; margin-bottom: 1rem; }
.sticky-summary { position: sticky; top: 80px; }
kbd { background: var(--surface-3); border: 1px solid var(--border); border-radius: 5px; padding: 0 .35rem; font-size: .75rem; }
hr.sep { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }
.clause-edit { border: 1px solid var(--border); border-radius: 12px; padding: .8rem; margin-bottom: .7rem; background: var(--surface-2); }
.clause-edit.locked { opacity: .85; }
.clause-edit .ch { display: flex; justify-content: space-between; align-items: center; margin-bottom: .4rem; font-weight: 650; font-size: .85rem; }

/* ------------------------------ Responsive --------------------------- */
@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .plano-wrap { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 35; }
  .main { margin-left: 0 !important; }
  .grid-main, .grid-side, .grid-aside, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .user-chip .who { display: none; }
  .modal .field.quarter { grid-column: span 6; }
  .modal .field.three-quarter { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  .content { padding: 1rem .9rem 3rem; }
  .topbar { padding: 0 .8rem; }
  .grid-2, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .field, .field.third, .field.quarter, .field.two-third, .field.three-quarter { grid-column: 1 / -1 !important; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
  .kpi { padding: .8rem; gap: .6rem; }
  .kpi .ki { display: none; }
  .kpi .kv { font-size: 1rem; }
  .toolbar .search { max-width: none; }
  .global-search { display: none; }
  .contact-row { grid-template-columns: 1fr 1fr; }
  .notif-panel { width: calc(100vw - 2rem); }
  .doc { padding: 1.2cm .8cm; font-size: 11pt; }
  .dl { grid-template-columns: 1fr; gap: .1rem; }
  .dl dd { margin-bottom: .5rem; }
  .page-head h1 { font-size: 1.2rem; }
}

/* ------------------------------ Print -------------------------------- */
@media print {
  .sidebar, .topbar, .no-print, .page-actions, .toolbar, .pager, #toasts, .btn { display: none !important; }
  .main { margin: 0 !important; }
  .content { padding: 0 !important; max-width: none; }
  body { background: #fff !important; color: #000; }
  .card { border: 0; box-shadow: none; }
  .doc, .voucher { box-shadow: none; border: 0; padding: 0; max-width: none; }
  .doc-stage { background: none; padding: 0; }
  a { color: #000; text-decoration: none; }
}

/* ===================== Correcciones: modales, carga, combos ===================== */
.modal.modal-top { z-index: 150; background: rgba(8, 12, 24, .45); }
.modal-dialog.nudge { animation: nudge .32s ease; }
@keyframes nudge { 0%, 100% { transform: none } 25% { transform: scale(1.012) } 60% { transform: scale(.996) } }
.modal.busy .modal-dialog { cursor: progress; }
.modal.busy [data-close] { opacity: .45; pointer-events: none; }
#ajaxBar { position: fixed; top: 0; left: 0; height: 3px; width: 0; z-index: 300; background: linear-gradient(90deg, var(--primary), #22c55e); opacity: 0; transition: opacity .2s; pointer-events: none; }
#ajaxBar.on { opacity: 1; width: 100%; animation: ajaxbar 1.4s ease-in-out infinite; transform-origin: left; }
@keyframes ajaxbar { 0% { transform: scaleX(0) } 60% { transform: scaleX(.75) } 100% { transform: scaleX(1); opacity: .4 } }
.spinner.spinner-sm { width: 15px; height: 15px; border-width: 2px; display: inline-block; vertical-align: -3px; }
.is-busy { position: relative; pointer-events: none; opacity: .7; }
.field.is-loading > label::after { content: ""; display: inline-block; width: 11px; height: 11px; margin-left: .4rem; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -1px; }
select.input:disabled, .input:disabled { background-color: var(--surface-2); color: var(--muted); cursor: not-allowed; }
.field .error::before { content: "\F333"; font-family: "bootstrap-icons"; margin-right: .3rem; }

/* Combo con búsqueda */
select.combo-native { position: absolute !important; width: 1px !important; height: 1px !important; opacity: 0; pointer-events: none; overflow: hidden; clip: rect(0 0 0 0); }
.combo { position: relative; width: 100%; }
.combo-btn { display: flex; align-items: center; justify-content: space-between; gap: .5rem; text-align: left; cursor: pointer; }
.combo-btn .combo-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-btn.placeholder .combo-text { color: var(--muted); }
.combo-btn i { font-size: .75rem; color: var(--muted); flex: none; }
.combo.sm .combo-btn { height: 33px; font-size: .84rem; }
.combo.disabled .combo-btn { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
select.is-invalid + .combo .combo-btn { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-bg); }
.combo-pop { display: none; position: absolute; z-index: 60; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: .35rem; min-width: 220px; }
.combo.open .combo-pop { display: block; }
.combo-sbox { display: flex; align-items: center; gap: .45rem; border: 1px solid var(--border-strong); border-radius: 8px; padding: 0 .6rem; margin-bottom: .3rem; }
.combo-sbox i { color: var(--muted); font-size: .8rem; }
.combo-search { border: 0; outline: 0; background: transparent; color: var(--text); height: 34px; width: 100%; font: inherit; font-size: .88rem; }
.combo-list { max-height: 260px; overflow-y: auto; }
.combo-opt { padding: .45rem .6rem; border-radius: 7px; cursor: pointer; font-size: .88rem; }
.combo-opt.ph { color: var(--muted); }
.combo-opt.act { background: var(--primary-50); }
.combo-opt.sel { font-weight: 600; color: var(--primary); }
.combo-empty { padding: .7rem; color: var(--muted); font-size: .85rem; }
.form-section { grid-column: 1 / -1; }

/* ============================ Hoja A4 de documentos ============================ */
.a4 { position: relative; width: 210mm; min-height: 297mm; margin: 0 auto; background: #fff; color: #111; padding: 11mm 13mm 13mm; box-shadow: 0 10px 30px rgba(15, 23, 42, .18); font-family: var(--font); font-size: 10pt; line-height: 1.45; }
.a4.landscape { width: 297mm; min-height: 210mm; }
.a4-frame { width: 100%; border-collapse: collapse; }
.a4-frame > thead > tr > td, .a4-frame > tfoot > tr > td, .a4-frame > tbody > tr > td { padding: 0; border: 0; background: none; }
.a4-head { display: flex; justify-content: space-between; gap: 5mm; align-items: center; border-bottom: 1.5px solid #cbd5e1; padding-bottom: 3mm; margin-bottom: 5mm; }
.a4-brand { display: flex; gap: 3.5mm; align-items: center; min-width: 0; }
.a4-logo { max-height: 15mm; max-width: 34mm; object-fit: contain; }
.a4-emp { display: flex; flex-direction: column; font-size: 7.8pt; color: #475569; line-height: 1.35; min-width: 0; }
.a4-emp b { font-size: 10.5pt; color: #0f172a; }
.a4-box { border: 1.3px solid #1e293b; border-radius: 2mm; padding: 2mm 3mm; text-align: center; min-width: 52mm; max-width: 62mm; display: flex; flex-direction: column; gap: .6mm; font-size: 7.2pt; color: #475569; }
.a4-box b { font-size: 8pt; color: #0f172a; text-transform: uppercase; letter-spacing: .02em; }
.a4-num { font-size: 10pt; font-weight: 800; color: #0f172a; }
.a4-foot { display: flex; justify-content: space-between; gap: 2mm 6mm; flex-wrap: wrap; border-top: 1px solid #cbd5e1; margin-top: 6mm; padding-top: 2mm; font-size: 7pt; color: #64748b; }
.a4-body { vertical-align: top; }
.a4-watermark { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; font-size: 70pt; font-weight: 800; color: rgba(220, 38, 38, .13); transform: rotate(-35deg); z-index: 1; letter-spacing: .08em; }
.a4-pdf { font-family: var(--font); color: #111; font-size: 10pt; line-height: 1.45; }
/* Contenido heredado dentro de la hoja: el encabezado lo pone la hoja */
.a4 .doc, .a4-pdf .doc { padding: 0; box-shadow: none; max-width: none; margin: 0; }
.a4 .doc-head, .a4-pdf .doc-head, .a4 .voucher .vh, .a4-pdf .voucher .vh { display: none; }
.a4 .voucher, .a4-pdf .voucher { border: 0; padding: 0; max-width: none; border-radius: 0; }
.a4 .doc-title, .a4-pdf .doc-title { margin-top: .2rem; }
/* Evitar cortes de tablas, firmas, cláusulas y bloques entre páginas */
.a4 tr, .a4-pdf tr, .doc-clause, .doc-firmas, .doc-firma, .no-break, .avoid-break, .qr-block { break-inside: avoid; page-break-inside: avoid; }
.a4 h2, .a4 h3, .a4 h4, .a4-pdf h2, .a4-pdf h3, .a4-pdf h4 { break-after: avoid; page-break-after: avoid; }
.a4 table thead, .a4-pdf table thead { display: table-header-group; }
.a4 .a4-frame > tfoot { display: table-footer-group; }
.doc-stage .a4 { box-shadow: 0 6px 20px rgba(15, 23, 42, .15); }
.doc-history { font-size: .85rem; }
/* Diseño de membrete aplicado: tipografía, tamaño y colores elegidos en Documentos → Diseños de membrete */
.a4[style*="--doc-font"], .a4[style*="--doc-font"] .doc, .a4[style*="--doc-font"] .doc-head, .a4[style*="--doc-font"] .doc-table, .a4[style*="--doc-font"] .doc-firmas, .a4[style*="--doc-font"] .doc-pie { font-family: var(--doc-font), Arial, sans-serif; }
.a4-pdf[style*="--doc-font"], .a4-pdf[style*="--doc-font"] .doc { font-family: var(--doc-font), Arial, sans-serif; }
.a4 .doc, .a4-pdf .doc { font-size: 1.1em; }
.a4 .a4-head { border-bottom-color: var(--doc-linea, #cbd5e1); }
.a4 .a4-foot { border-top-color: var(--doc-linea, #cbd5e1); }
.a4 .a4-box { border-color: var(--doc-linea, #1e293b); }
.a4 .a4-box b, .a4 .doc-title, .a4 .doc h2, .a4 .doc h3, .a4 .doc-clause h4, .a4-pdf .doc-title, .a4-pdf .doc h2, .a4-pdf .doc h3 { color: var(--doc-titulo, inherit); }
.a4 .doc-table th, .a4-pdf .doc-table th, .a4 .doc table th, .a4-pdf .doc table th { background: var(--doc-tabla, #e2e8f0); }
/* Hoja membretada: fondo A4 en pantalla; al imprimir se repite en cada página (ver layouts/print.php) */
.a4.con-membrete { background-image: var(--doc-fondo); background-size: 210mm 297mm; background-repeat: no-repeat; background-position: 0 0; }
.a4.landscape.con-membrete { background-size: 297mm 210mm; }
.a4-fondo-print, .a4-esp { display: none; }
.a4.con-membrete .a4-frame { position: relative; z-index: 1; }
.a4.con-membrete .a4-foot { margin-top: 8mm; }
@media print {
  .a4 { width: auto; min-height: 0; padding: 0 !important; box-shadow: none; margin: 0; }
  .a4-watermark { position: fixed; inset: 0; }
  .a4 .a4-foot { margin-top: 4mm; }
}
@media (max-width: 720px) {
  .doc-stage { padding: .5rem; }
}

/* ======================= Apariencia y personalización ======================= */
.pb-0 { padding-bottom: 0 !important; }
.section-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin: 1.1rem 0 .6rem; }
.section-title:first-child { margin-top: 0; }
.grid-apariencia { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: start; }

.color-pick { display: flex; align-items: center; gap: .45rem; }
.color-pick input[type="color"] { width: 42px; height: 40px; padding: 2px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer; flex: none; }
.color-pick input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 7px; }
.color-pick input[type="color"]::-moz-color-swatch { border: 0; border-radius: 7px; }
.color-pick .input { flex: 1; min-width: 0; font-family: ui-monospace, "Cascadia Code", Consolas, monospace; text-transform: lowercase; }
.color-pick input[type="range"] { accent-color: var(--primary); }

.check-list { list-style: none; margin: 0 0 .6rem; padding: 0; display: grid; gap: .35rem; }
.check-list li { display: flex; align-items: center; gap: .5rem; font-size: .85rem; padding: .5rem .7rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.check-list li > .grow { flex: 1; min-width: 0; }
.check-list li.ok > i { color: var(--success); }
.check-list li.bad { border-color: var(--warning-bd); background: var(--warning-bg); }
.check-list li.bad > i { color: var(--warning); }

/* Maqueta de vista previa (no usa las variables globales: sólo las suyas) */
.brand-preview { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; min-height: 260px; box-shadow: var(--shadow-sm); }
.brand-preview .bp-side { width: 40%; max-width: 190px; background: var(--sidebar); padding: .7rem .5rem; display: flex; flex-direction: column; gap: .2rem; }
.brand-preview .bp-brand { display: flex; align-items: center; gap: .5rem; color: #fff; font-size: .8rem; padding: .2rem .4rem .7rem; }
.brand-preview .bp-logo { width: 26px; height: 26px; border-radius: 8px; background: var(--primary); color: var(--btn-text); display: grid; place-items: center; font-size: .85rem; flex: none; }
.brand-preview .bp-side a { color: var(--sidebar-text); font-size: .78rem; padding: .42rem .5rem; border-radius: 9px; display: flex; align-items: center; gap: .5rem; text-decoration: none; }
.brand-preview .bp-side a.active { background: var(--primary); color: var(--btn-text); font-weight: 600; }
.brand-preview .bp-main { flex: 1; min-width: 0; background: var(--bg); display: flex; flex-direction: column; }
.brand-preview .bp-top { height: 40px; background: var(--topbar); border-bottom: 1px solid rgba(0, 0, 0, .08); display: flex; align-items: center; gap: .6rem; padding: 0 .7rem; color: var(--text); font-size: .85rem; }
.brand-preview .bp-search { flex: 1; font-size: .72rem; color: var(--text); opacity: .5; border: 1px solid rgba(0, 0, 0, .12); border-radius: 8px; padding: .2rem .5rem; }
.brand-preview .bp-body { padding: .7rem; display: grid; gap: .6rem; }
.brand-preview .bp-card { background: #fff; border: 1px solid rgba(0, 0, 0, .09); border-radius: var(--radius-sm); padding: .65rem .7rem; color: var(--text); }
.brand-preview .bp-card > b { font-size: .8rem; }
.brand-preview .bp-card p { margin: .25rem 0 .5rem; font-size: .73rem; opacity: .85; }
.brand-preview .bp-card a { color: var(--link); }
.brand-preview .bp-btns { display: flex; gap: .4rem; margin-bottom: .5rem; }
.brand-preview .bp-btn { font-size: .72rem; padding: .3rem .7rem; border-radius: var(--radius-sm); font-weight: 600; }
.brand-preview .bp-btn.primary { background: var(--primary); color: var(--btn-text); }
.brand-preview .bp-btn.ghost { border: 1px solid rgba(0, 0, 0, .15); color: var(--text); }
.brand-preview .bp-chips { display: flex; flex-wrap: wrap; gap: .3rem; }
.brand-preview .bp-chip { font-size: .66rem; font-weight: 650; padding: .13rem .5rem; border-radius: 99px; border: 1px solid; }
.brand-preview .bp-chip.ok { color: var(--success); background: var(--success-bg); border-color: var(--success-bd); }
.brand-preview .bp-chip.warn { color: var(--warning); background: var(--warning-bg); border-color: var(--warning-bd); }
.brand-preview .bp-chip.err { color: var(--danger); background: var(--danger-bg); border-color: var(--danger-bd); }
.brand-preview .bp-chip.info { color: var(--info); background: var(--info-bg); border-color: var(--info-bd); }
.brand-preview .bp-chart { height: 56px; display: flex; align-items: flex-end; gap: .35rem; margin-top: .4rem; }
.brand-preview .bp-chart i { flex: 1; border-radius: 3px 3px 0 0; }
.brand-preview .bp-chart i:nth-child(1) { background: var(--chart-1); }
.brand-preview .bp-chart i:nth-child(2) { background: var(--chart-2); }
.brand-preview .bp-chart i:nth-child(3) { background: var(--chart-3); }
.brand-preview .bp-chart i:nth-child(4) { background: var(--chart-4); }
.brand-preview .bp-chart i:nth-child(5) { background: var(--chart-5); }
.brand-preview .bp-chart i:nth-child(6) { background: var(--chart-6); }

/* Galería de imágenes del sistema */
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(235px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.img-card { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); display: flex; flex-direction: column; }
.img-card.is-default { border-style: dashed; }
.img-thumb { height: 120px; display: flex; align-items: center; justify-content: center; overflow: hidden; background: var(--surface-3); padding: .6rem; position: relative;
  background-image: linear-gradient(45deg, rgba(0,0,0,.05) 25%, transparent 25%), linear-gradient(-45deg, rgba(0,0,0,.05) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(0,0,0,.05) 75%), linear-gradient(-45deg, transparent 75%, rgba(0,0,0,.05) 75%);
  background-size: 14px 14px; background-position: 0 0, 0 7px, 7px -7px, -7px 0; }
.img-thumb.dark { background-color: #1e293b; }
.img-thumb.lg { height: 170px; }
.img-thumb.xs { height: 34px; width: 60px; padding: 2px; border-radius: 6px; display: inline-flex; background-size: 8px 8px; }
.img-thumb img { display: block; max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; }
.img-card .img-thumb { flex: none; }
.img-none { font-size: .74rem; color: var(--muted); display: flex; align-items: center; gap: .35rem; }
.img-meta { padding: .6rem .75rem; display: grid; gap: .15rem; flex: 1; }
.img-meta b { font-size: .85rem; }
.img-acts { display: flex; gap: .35rem; padding: .5rem .75rem .7rem; }
.img-acts .btn { flex: 1; justify-content: center; }
.img-acts .btn:only-child { flex: none; }

@media (max-width: 900px) {
  .grid-apariencia { grid-template-columns: minmax(0, 1fr); }
  .brand-preview { min-height: 220px; }
}

/* =============== Ubicación geográfica en un solo campo =============== */
.ubi { position: relative; display: flex; align-items: center; }
.ubi > .bi-geo-alt { position: absolute; left: .75rem; color: var(--muted); pointer-events: none; font-size: .95rem; }
.ubi .input { padding-left: 2.3rem; padding-right: 2.3rem; width: 100%; }
.ubi-clear { position: absolute; right: .35rem; width: 28px; height: 28px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; display: grid; place-items: center; font-size: .8rem; }
.ubi-clear:hover { background: var(--surface-3); color: var(--danger); }
.ubi-list { top: calc(100% + 4px); max-height: 320px; z-index: 40; }
.ubi-list a { display: flex; align-items: center; gap: .6rem; padding: .5rem .7rem; }
.ubi-list a > i { color: var(--primary); font-size: .9rem; flex: none; }
.ubi-list a > .grow { display: grid; min-width: 0; }
.ubi-list a b { font-weight: 600; font-size: .88rem; }
.ubi-list a small { color: var(--muted); font-size: .76rem; }
.ubi-list a.active, .ubi-list a:hover { background: var(--primary-50); }
:root[data-theme="dark"] .ubi-list a.active, :root[data-theme="dark"] .ubi-list a:hover { background: var(--surface-3); }
.ubi-filtro { position: relative; min-width: 230px; flex: 1 1 230px; max-width: 340px; }
.ubi-filtro .ubi-list { min-width: 300px; }

/* ============================ Mapa del Perú ============================ */
.mapa-peru { display: flex; flex-direction: column; gap: .6rem; }
.mapa-barra { display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap; }
.mapa-ruta { font-size: .85rem; color: var(--text-2); }
.mapa-ruta i { color: var(--primary); }
.mapa-caja { position: relative; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem; }
.mapa-svg { width: 100%; height: auto; max-height: 70vh; display: block; }
.mapa-cargando { padding: 3rem; text-align: center; color: var(--muted); }
.mapa-fondo .pt { fill: var(--border-strong); opacity: .5; }
.mapa-fondo .pt.dentro { fill: var(--primary); opacity: .35; }
.mapa-burbujas .zona { cursor: pointer; }
.mapa-burbujas .zona:hover circle, .mapa-burbujas .zona:focus circle { stroke-width: 2.4; }
.mapa-burbujas .zona:focus { outline: none; }
.mapa-burbujas .zona.vacia { cursor: default; }
.mapa-num { font: 700 11px var(--font); fill: #fff; pointer-events: none; }
.mapa-burbujas .marcador .mk { fill: var(--primary); fill-opacity: .25; stroke: var(--primary); stroke-width: 1.4; cursor: pointer; }
.mapa-burbujas .marcador .mk-centro { fill: var(--primary); pointer-events: none; }
.mapa-burbujas .marcador.alerta .mk { fill: var(--danger); stroke: var(--danger); }
.mapa-burbujas .marcador.alerta .mk-centro { fill: var(--danger); }
.mapa-burbujas .marcador.aviso .mk { fill: var(--warning); stroke: var(--warning); }
.mapa-burbujas .marcador.aviso .mk-centro { fill: var(--warning); }
.mapa-burbujas .marcador.inactivo .mk { fill: var(--muted); stroke: var(--muted); }
.mapa-burbujas .marcador.inactivo .mk-centro { fill: var(--muted); }
.mapa-tip { position: absolute; z-index: 5; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg);
  padding: .45rem .6rem; font-size: .8rem; pointer-events: none; max-width: 210px; line-height: 1.35; }
.mapa-leyenda { display: flex; align-items: center; gap: .5rem; font-size: .76rem; color: var(--muted); }
.mapa-leyenda .escala { width: 90px; height: 9px; border-radius: 5px; background: linear-gradient(90deg, color-mix(in srgb, var(--primary) 25%, transparent), var(--primary)); }
@media (max-width: 720px) { .mapa-svg { max-height: 58vh; } }

/* ---------- Mapa interactivo (Leaflet) ---------- */
.mapa-caja.mp-leaflet { padding: 0; overflow: hidden; position: relative; }
.mp-lienzo { height: clamp(360px, 62vh, 560px); width: 100%; background: var(--surface-3); z-index: 0; }
.mapa-ayuda { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; margin-left: auto; }
.mapa-ayuda i { color: var(--primary); }
.mp-leaflet .leaflet-container { font: 400 .8rem var(--font); background: var(--surface-3); }
.mp-leaflet .leaflet-bar { border: 1px solid var(--border); box-shadow: 0 1px 3px rgba(16, 24, 40, .12); border-radius: 8px; overflow: hidden; }
.mp-leaflet .leaflet-bar a { width: 34px; height: 34px; line-height: 34px; color: var(--text); background: var(--surface); border-bottom-color: var(--border); display: grid; place-items: center; font-size: 1rem; }
.mp-leaflet .leaflet-bar a:hover { background: var(--surface-2); color: var(--primary); }
.mp-leaflet .leaflet-control-layers { border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 1px 3px rgba(16, 24, 40, .12); background: var(--surface); color: var(--text); }
.mp-leaflet .leaflet-control-layers-toggle { width: 36px; height: 36px; background-size: 20px; }
.mp-leaflet .leaflet-control-layers-expanded { padding: .5rem .75rem; }
.mp-leaflet .leaflet-control-layers label { display: flex; align-items: center; gap: .35rem; margin: .15rem 0; cursor: pointer; }
.mp-leaflet .leaflet-control-attribution { font-size: .66rem; background: color-mix(in srgb, var(--surface) 82%, transparent); color: var(--muted); }
.mp-leaflet .leaflet-control-attribution a { color: var(--text-2); }
.mp-leaflet .leaflet-control-scale-line { border-color: var(--text-2); background: color-mix(in srgb, var(--surface) 75%, transparent); color: var(--text-2); }
.mp-zona-ico, .mp-pin-ico { background: none; border: 0; }
.mp-burbuja { display: grid; place-items: center; width: 100%; height: 100%; border-radius: 50%; color: #fff; font: 700 .72rem var(--font); letter-spacing: -.01em;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--primary) 70%, #fff), var(--primary) 70%);
  opacity: var(--a, .8); border: 2px solid #fff; box-shadow: 0 2px 8px rgba(30, 27, 75, .35); transition: transform .15s ease, opacity .15s ease; cursor: pointer; }
.mp-zona-ico:hover .mp-burbuja, .mp-zona-ico:focus .mp-burbuja { transform: scale(1.1); opacity: 1; }
.mp-vacia { display: block; width: 100%; height: 100%; border-radius: 50%; background: var(--surface); border: 2px solid var(--border-strong); opacity: .9; }
.mp-pin { position: relative; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  background: var(--primary); border: 2px solid #fff; box-shadow: 0 3px 8px rgba(16, 24, 40, .35); transition: transform .15s ease; }
.mp-pin i { transform: rotate(45deg); color: #fff; font-size: .85rem; }
.mp-pin-ico:hover .mp-pin { transform: rotate(-45deg) scale(1.12); }
.mp-pin.aviso { background: var(--warning); }
.mp-pin.alerta { background: var(--danger); }
.mp-pin.inactivo { background: var(--muted); }
.mp-leaflet .leaflet-tooltip.mp-tip { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-lg); padding: .4rem .6rem; font-size: .78rem; line-height: 1.35; }
.mp-leaflet .leaflet-tooltip-top.mp-tip::before { border-top-color: var(--surface); }
.mp-leaflet .leaflet-popup-content-wrapper { background: var(--surface); color: var(--text); border-radius: 10px; box-shadow: var(--shadow-lg); }
.mp-leaflet .leaflet-popup-tip { background: var(--surface); }
.mp-leaflet .leaflet-popup-content { margin: .7rem .85rem; font-size: .82rem; line-height: 1.4; }
.mp-pop .btn { color: #fff; }
.mp-leyenda { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .45rem .6rem; box-shadow: 0 1px 3px rgba(16, 24, 40, .12); font-size: .72rem; color: var(--text-2); }
.mp-ley-t { font-weight: 600; margin-bottom: .25rem; color: var(--text); }
.mp-ley-e { display: flex; align-items: center; gap: .35rem; }
.mp-ley-min, .mp-ley-max { display: inline-block; border-radius: 50%; background: var(--primary); border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); }
.mp-ley-min { width: 10px; height: 10px; opacity: .5; }
.mp-ley-max { width: 20px; height: 20px; }
.mp-aviso { position: absolute; inset: auto 0 44px; margin: 0 auto; width: max-content; max-width: 90%; z-index: 500; pointer-events: none;
  background: rgba(17, 24, 39, .82); color: #fff; font-size: .78rem; padding: .4rem .75rem; border-radius: 999px; opacity: 0; transition: opacity .2s ease; }
.mp-aviso.visible { opacity: 1; }
.mapa-peru.mp-completo { position: fixed; inset: 0; z-index: 1200; background: var(--surface); padding: .75rem; gap: .5rem; }
.mapa-peru.mp-completo .mapa-caja { flex: 1; }
.mapa-peru.mp-completo .mp-lienzo { height: 100%; }
html.mp-bloqueo, html.mp-bloqueo body { overflow: hidden; }
/* Ubicación exacta: selector del formulario y mapa de la ficha */
.mp-punto-acc { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.mp-punto-estado i { margin-right: .15rem; }
.mp-punto-mapa, .mp-ver { position: relative; z-index: 0; height: 280px; border: 1px solid var(--border); border-radius: var(--radius-ctl, 8px); overflow: hidden; background: var(--surface-3); }
.mp-ver { height: 230px; }
.mp-punto-mapa.leaflet-container, .mp-ver.leaflet-container { font: 400 .8rem var(--font); cursor: crosshair; }
.mp-ver.leaflet-container { cursor: grab; }
.mp-sin-mapa { display: grid; place-items: center; padding: 1rem; text-align: center; height: auto; min-height: 90px; }
.mp-pin, .mp-burbuja, .mp-vacia { box-sizing: border-box; }
@media (max-width: 720px) {
  .mp-lienzo { height: 58vh; min-height: 320px; }
  .mapa-ayuda { display: none; }
  .mp-leaflet .leaflet-bar a { width: 38px; height: 38px; line-height: 38px; }
  .mp-leyenda { font-size: .68rem; }
}

/* Publicidad física */
.qr-box { display: inline-block; padding: .7rem; background: #fff; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.qr-box img, .qr-box canvas { display: block; }
tr.row-sub td { border-top: 0; padding-top: 0; }
.pub-foto { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--border); }

/* ===================== Agenda: vistas de día, semana y lista ===================== */
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.segmented a { padding: .4rem .7rem; font-size: .8rem; font-weight: 600; color: var(--text-2); text-decoration: none !important; border-right: 1px solid var(--border); display: inline-flex; gap: .35rem; align-items: center; }
.segmented a:last-child { border-right: 0; }
.segmented a:hover { background: var(--surface-3); }
.segmented a.active { background: var(--primary); color: var(--btn-text, #fff); }

.ag-lista { display: grid; gap: .35rem; }
.ag-item { display: flex; align-items: center; gap: .7rem; padding: .5rem .7rem; border: 1px solid var(--border); border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--text); text-decoration: none !important; }
.ag-item:hover { background: var(--surface-2); }
.ag-item.hecho { opacity: .6; }
.ag-item.hecho b { text-decoration: line-through; }
.ag-item .ag-hora { font-weight: 700; font-size: .82rem; min-width: 46px; display: grid; }
.ag-item .ag-hora small { font-weight: 500; color: var(--muted); font-size: .7rem; }
.ag-item .grow { display: grid; min-width: 0; }
.ag-item b { font-size: .88rem; }
.ag-item small { color: var(--muted); font-size: .76rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-dia + .ag-dia { margin-top: 1rem; }

.cal-semana { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--border); border-left: 1px solid var(--border); }
.cal-semana .col { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); min-height: 260px; display: flex; flex-direction: column; }
.cal-semana .col.today { background: var(--primary-50); }
.cal-semana .ch { display: flex; justify-content: space-between; align-items: center; padding: .45rem .5rem; border-bottom: 1px solid var(--border); font-size: .78rem; background: var(--surface-2); }
.cal-semana .ch a { color: var(--text-2); text-decoration: none !important; }
.cal-semana .cb { padding: .4rem; display: grid; gap: .3rem; align-content: start; }
.cal-semana .ag-item { padding: .35rem .45rem; gap: .4rem; }
.cal-semana .ag-item .ag-hora { min-width: 34px; font-size: .74rem; }
.cal-semana .ag-item b { font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-semana .ag-item small { font-size: .7rem; }
.cal-semana .ag-item .badge { display: none; }

@media (max-width: 900px) {
  .cal-semana { grid-template-columns: minmax(0, 1fr); }
  .cal-semana .col { min-height: 0; }
  .segmented a span { display: none; }
}

/* ===================== Firmas de documentos ===================== */
.firma-mini { max-height: 38px; max-width: 110px; object-fit: contain; background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 2px; }
.firma-pad { border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); background: #fff; padding: .4rem; }
.firma-pad canvas { width: 100%; height: auto; touch-action: none; cursor: crosshair; display: block; border-radius: 6px; }
.firma-acc { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding-top: .4rem; }
.firma-acc .muted { color: #64748b; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .4rem .8rem; }

/* Membrete configurable y firmas impresas */
.a4 .a4-banda { display: block; width: 100%; height: auto; margin-bottom: 3mm; }
.a4 .a4-foot .a4-legal { display: block; font-size: 7pt; color: #64748b; margin-top: 1mm; }
.doc-firmas-reg { display: flex; flex-wrap: wrap; gap: 8mm; justify-content: space-around; margin-top: 10mm; }
.doc-firma { text-align: center; min-width: 55mm; display: grid; gap: 1px; break-inside: avoid; page-break-inside: avoid; }
.doc-firma img { max-height: 18mm; max-width: 55mm; object-fit: contain; margin: 0 auto 1mm; }
.doc-firma .linea { display: block; border-top: 1px solid #334155; margin: 12mm auto 1mm; width: 55mm; }
.doc-firma b { font-size: 9pt; }
.doc-firma span { font-size: 8pt; color: #475569; }
.doc-firma small { font-size: 6.5pt; color: #94a3b8; }

/* ===================== Móvil: las tablas se leen como fichas ===================== */
@media (max-width: 720px) {
  .table-wrap { overflow: visible; max-height: none !important; }
  table.table.como-fichas { display: block; }
  table.table.como-fichas thead { display: none; }
  table.table.como-fichas tbody, table.table.como-fichas tfoot { display: block; }
  table.table.como-fichas tr { display: block; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
    margin-bottom: .6rem; padding: .3rem .1rem; box-shadow: var(--shadow-sm); }
  table.table.como-fichas tr.row-sub { border-top: 0; margin-top: -.6rem; border-top-left-radius: 0; border-top-right-radius: 0; }
  table.table.como-fichas td { display: flex; justify-content: space-between; gap: .8rem; align-items: baseline;
    border: 0; padding: .32rem .75rem; text-align: right !important; }
  table.table.como-fichas td::before { content: attr(data-label); font-size: .72rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .04em; color: var(--muted); text-align: left; flex: none; max-width: 45%; }
  table.table.como-fichas td:empty { display: none; }
  table.table.como-fichas td[data-label=""]::before { display: none; }
  table.table.como-fichas td.actions { justify-content: flex-end; border-top: 1px dashed var(--border); margin-top: .25rem; padding-top: .5rem; }
  table.table.como-fichas .cell-title { font-weight: 700; }
  table.table.como-fichas .cell-sub { text-align: right; }
  .segmented { width: 100%; }
  .segmented a { flex: 1; justify-content: center; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; justify-content: center; }
  .modal-dialog { max-width: none; }
  .check-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ===================== Reportes: gráficos configurables ===================== */
.rg-barra { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin: .4rem 0 .8rem; }
.rg-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.rg-grid > .rg-card { grid-column: span 2; margin: 0; }
.rg-grid > .rg-card.rg-mitad { grid-column: span 1; }
.rg-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .7rem 1rem .4rem; flex-wrap: wrap; }
.rg-titulo { margin: 0; font-size: .98rem; display: flex; align-items: center; gap: .45rem; min-width: 0; }
.rg-titulo span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rg-titulo i { color: var(--primary); }
.rg-acc { display: flex; gap: .15rem; flex-wrap: wrap; }
.rg-acc .btn.active { background: var(--primary-50, var(--surface-3)); color: var(--primary); }
.rg-panel { margin: 0 1rem .6rem; padding: .8rem; border: 1px solid var(--border); border-radius: var(--radius-sm, 10px); background: var(--surface-2); display: grid; gap: .6rem; }
.rg-panel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .6rem; }
.rg-panel .field { margin: 0; }
.rg-panel label { font-size: .78rem; }
.rg-vars { display: flex; flex-wrap: wrap; gap: .35rem 1rem; }
.rg-switches { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; }
.rg-lienzo { position: relative; padding: 0 1rem .6rem; }
.rg-lienzo canvas { max-width: 100%; }
.rg-nota { margin: 0 1rem .8rem; }
.rg-img-modal { position: fixed; inset: 0; z-index: 1300; background: rgba(15, 23, 42, .55); display: grid; place-items: center; padding: 1rem; }
.rg-img-box { background: var(--surface); border-radius: 12px; padding: 1rem; max-width: min(920px, 100%); max-height: 92vh; overflow: auto; box-shadow: var(--shadow-lg); }
.rg-img-box img { max-width: 100%; border: 1px solid var(--border); border-radius: 8px; display: block; }
.rep-comp { align-items: center; gap: .5rem; }
.rep-comp select { max-width: 420px; }
.rep-comp-nota { margin: 0 0 .6rem; color: var(--text-2); font-size: .9rem; }
.rep-comp-nota i { color: var(--primary); }
@media (max-width: 900px) {
  .rg-grid { grid-template-columns: minmax(0, 1fr); }
  .rg-grid > .rg-card, .rg-grid > .rg-card.rg-mitad { grid-column: span 1; }
}

/* ===================== Plantillas de reporte ===================== */
.rp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.rp-grid > .card.rp-card { margin: 0; display: flex; flex-direction: column; }
.rp-card .card-body { flex: 1; }
.rp-mini { position: relative; overflow: hidden; background: #e2e8f0; border-bottom: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0; height: 250px; flex: none; }
.rp-mini-lienzo .hoja { box-shadow: 0 2px 10px rgba(15, 23, 42, .18); }
.rp-mini-lienzo { transform-origin: 0 0; position: absolute; left: 0; top: 0; pointer-events: none; }
.rp-mini-lienzo .hojas, .rp-mini-lienzo { padding: 0; gap: 0; display: block; }
.rp-meta { display: flex; flex-wrap: wrap; gap: .3rem .9rem; color: var(--text-2); }
.rp-meta i { color: var(--primary); }

/* ===================== Diseñador de plantillas de reporte ===================== */
.dz-cab { margin-bottom: .75rem; }
.dz { display: grid; grid-template-columns: 230px minmax(0, 1fr) 300px; gap: .85rem; align-items: start; }
.dz > .card { margin: 0; }
.dz-paleta, .dz-props { padding: .8rem; position: sticky; top: calc(var(--topbar-h, 60px) + .75rem); max-height: calc(100vh - var(--topbar-h, 60px) - 1.5rem); overflow: auto; }
.dz-sec { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: .9rem 0 .45rem; padding-bottom: .3rem; border-bottom: 1px solid var(--border); }
.dz-paleta > .dz-sec:first-child, .dz-props-cab + .dz-sec { margin-top: .2rem; }
.dz-tipos { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem; }
.dz-tipo { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .2rem; min-height: 3.4rem; padding: .4rem .3rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit; font-size: .72rem; cursor: grab; text-align: center; line-height: 1.15; transition: border-color .15s, background .15s; }
.dz-tipo i { color: var(--primary); font-size: 1.05rem; flex: none; }
.dz-tipo span { min-width: 0; max-width: 100%; }
.dz-tipo:hover { border-color: var(--primary); background: var(--primary-50); }
.dz-tipo:active { cursor: grabbing; }
.dz-fondo { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.dz-campos { display: flex; flex-wrap: wrap; gap: .25rem; }
.dz-campo { border: 1px dashed var(--border-strong); background: var(--surface-2); color: var(--text-2); border-radius: 4px; padding: .12rem .35rem; font: 500 .7rem/1.3 ui-monospace, Consolas, monospace; cursor: pointer; }
.dz-campo:hover { border-color: var(--primary); color: var(--primary); }

.dz-centro { min-width: 0; display: flex; flex-direction: column; gap: .5rem; }
.dz-barra { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .9rem; padding: .45rem .6rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.dz-grupo { display: flex; align-items: center; gap: .3rem; }
.dz-grupo .input-sm { width: auto; }
.dz-zoom { min-width: 3.2rem; text-align: center; font-size: .8rem; font-variant-numeric: tabular-nums; color: var(--text-2); }
#dzEstado { margin-left: auto; }
.dz-lienzo { background: var(--surface-3); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; overflow: auto; max-height: calc(100vh - var(--topbar-h, 60px) - 8rem); min-height: 420px; }
.dz-hoja { position: relative; margin: 0 auto; outline: none; }
.dz-hoja:focus-visible { box-shadow: 0 0 0 3px var(--primary-100); }
.dz-hoja.soltar .dz-capa { outline: 2px dashed var(--primary); outline-offset: 3px; }
.dz-capa { position: absolute; left: 0; top: 0; overflow: visible; transform-origin: 0 0; user-select: none; touch-action: none; --asa: 9px; }
.dz-capa.con-rejilla { background-image: linear-gradient(to right, rgba(99, 102, 241, .07) 1px, transparent 1px), linear-gradient(to bottom, rgba(99, 102, 241, .07) 1px, transparent 1px); }
.dz-capa .hoja-fondo { z-index: 0; }
.dz-el { position: absolute; z-index: 2; cursor: move; outline: 1px dashed rgba(100, 116, 139, .45); }
.dz-el:hover { outline-color: var(--primary); }
.dz-el.sel { outline: 1.5px solid var(--primary); z-index: 3; }
.dz-el > .he { pointer-events: none; }
.dz-el.pag-ultima { outline-color: rgba(217, 119, 6, .6); }
.dz-el.pag-primera { outline-color: rgba(100, 116, 139, .45); }
.dz-etq { position: absolute; left: -1px; bottom: 100%; white-space: nowrap; font: 600 9px/1.6 var(--font, system-ui); color: #fff; background: var(--primary); padding: 0 5px; border-radius: 3px 3px 0 0; display: none; pointer-events: none; }
.dz-el.sel .dz-etq, .dz-el:hover .dz-etq { display: block; }
.dz-el[style*="top:0mm"] .dz-etq, .dz-el[style*="top: 0mm"] .dz-etq { bottom: auto; top: 100%; border-radius: 0 0 3px 3px; }
.dz-asa { position: absolute; width: var(--asa); height: var(--asa); background: #fff; border: 1.5px solid var(--primary); border-radius: 2px; z-index: 4; }
.dz-asa.n, .dz-asa.s { left: calc(50% - var(--asa) / 2); cursor: ns-resize; }
.dz-asa.e, .dz-asa.w { top: calc(50% - var(--asa) / 2); cursor: ew-resize; }
.dz-asa.n, .dz-asa.ne, .dz-asa.nw { top: calc(var(--asa) / -2); }
.dz-asa.s, .dz-asa.se, .dz-asa.sw { bottom: calc(var(--asa) / -2); }
.dz-asa.e, .dz-asa.ne, .dz-asa.se { right: calc(var(--asa) / -2); }
.dz-asa.w, .dz-asa.nw, .dz-asa.sw { left: calc(var(--asa) / -2); }
.dz-asa.ne, .dz-asa.sw { cursor: nesw-resize; }
.dz-asa.nw, .dz-asa.se { cursor: nwse-resize; }
.dz-guia { position: absolute; left: 0; right: 0; height: 0; border-top: 1px dashed #d97706; z-index: 1; pointer-events: none; }
.dz-guia span { position: absolute; right: 2mm; top: 0; font: 600 7px/1.5 var(--font, system-ui); color: #b45309; background: rgba(255, 251, 235, .92); padding: 0 4px; border-radius: 0 0 3px 3px; }

.dz-props-cab { display: flex; align-items: center; justify-content: space-between; gap: .4rem; padding-bottom: .45rem; border-bottom: 1px solid var(--border); }
.dz-props-cab b { font-size: .92rem; display: flex; align-items: center; gap: .4rem; }
.dz-props-cab b i { color: var(--primary); }
.dz-props .field { margin-bottom: .55rem; }
.dz-props .field > label { font-size: .74rem; }
.dz-props .hint { display: block; font-size: .72rem; color: var(--muted); margin-top: .2rem; line-height: 1.35; }
.dz-props p.hint { margin: .2rem 0 .5rem; }
.dz-medidas { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .5rem; }
.dz-medidas > .field { grid-column: auto; min-width: 0; }
.dz-checks { display: flex; flex-wrap: wrap; gap: .3rem .8rem; margin: .1rem 0 .6rem; font-size: .8rem; }
.dz-color { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.dz-color input[type=color] { width: 2.2rem; height: 1.9rem; padding: 2px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; }
.dz-color .check { font-size: .74rem; }
.dz-lista { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .2rem; }
.dz-lista button { width: 100%; display: flex; align-items: center; gap: .45rem; padding: .32rem .45rem; border: 1px solid transparent; border-radius: var(--radius-sm); background: none; color: var(--text); font: inherit; font-size: .8rem; text-align: left; cursor: pointer; }
.dz-lista button:hover { background: var(--surface-2); border-color: var(--border); }
.dz-lista button i { color: var(--primary); }
.dz-lista small { margin-left: auto; color: var(--muted); font-size: .7rem; }

.dz-previa { position: fixed; inset: 0; z-index: 1200; background: rgba(15, 23, 42, .82); overflow: auto; }
.dz-previa[hidden] { display: none; }
.dz-previa-barra { position: sticky; top: 0; z-index: 2; display: flex; flex-wrap: wrap; align-items: center; gap: .4rem 1rem; padding: .6rem 1rem; background: #0f172a; color: #e2e8f0; }
.dz-previa-barra .small { color: #94a3b8; }
.dz-previa-barra .btn { margin-left: auto; }

@media (max-width: 1280px) {
  .dz { grid-template-columns: 210px minmax(0, 1fr) 270px; }
}
@media (max-width: 1080px) {
  .dz { grid-template-columns: 1fr; }
  .dz-paleta, .dz-props { position: static; max-height: none; }
  .dz-tipos { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .dz-centro { order: -1; }
  .dz-lienzo { max-height: 75vh; }
}
