/* =====================================================================
   GESTIÓN DE TAREAS – ADMINISTRACIÓN DE EDIFICIOS
   Todos los colores corporativos se controlan con variables CSS
   (se actualizan desde Configuración mediante js/theme.js).
   ===================================================================== */
:root {
  --primary: #1E368D;
  --primary-dark: #16286A;
  --primary-light: #DFE3F0;
  --primary-soft: #EEF1F8;
  --secondary: #8BCA3A;
  --secondary-dark: #618D29;
  --secondary-light: #E8F4D8;
  --accent: #7EBE3E;
  --on-primary: #fff;
  --on-secondary: #1b1f2a;

  --bg: #F3F5F9;
  --surface: #FFFFFF;
  --border: #E1E5EE;
  --text: #1F2533;
  --muted: #6B7385;

  --sem-verde: #2E9E4F;
  --sem-amarillo: #E3A800;
  --sem-rojo: #D64545;
  --sem-gris: #A0A6B2;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --topbar-h: 64px;
  --sidebar-w: 248px;
  --bottom-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); font-size: 15px; color: var(--text); background: var(--bg); line-height: 1.45; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
body.modal-open { overflow: hidden; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.2; color: var(--text); }
h1 { font-size: 1.55rem; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.08rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0 0 .5rem; }
code { background: var(--primary-soft); padding: 1px 5px; border-radius: 4px; font-size: .88em; }
.muted { color: var(--muted); }
.sm { font-size: .85rem; }
.danger { color: var(--sem-rojo) !important; }
mark { background: #FFF2A8; padding: 0 1px; border-radius: 2px; }
[hidden] { display: none !important; }

/* ---------- Botones ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font: inherit; font-weight: 600; font-size: .92rem; padding: .55rem 1rem; border-radius: var(--radius-sm); border: 1px solid transparent; cursor: pointer; background: var(--surface); color: var(--text); text-decoration: none !important; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s; min-height: 40px; }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--secondary); color: var(--on-secondary); }
.btn-secondary:hover { background: var(--accent); }
.btn-success { background: var(--sem-verde); color: #fff; }
.btn-success:hover { filter: brightness(.92); }
.btn-danger { background: var(--sem-rojo); color: #fff; }
.btn-outline { border-color: var(--primary); color: var(--primary); background: var(--surface); }
.btn-outline:hover { background: var(--primary-soft); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--primary-soft); color: var(--text); }
.btn-lg { min-height: 48px; padding: .7rem 1.2rem; font-size: .95rem; }
.btn-sm { min-height: 30px; padding: .25rem .6rem; font-size: .82rem; }
.btn-block { width: 100%; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.btn-group .btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.btn-group .btn.on { background: var(--primary); color: var(--on-primary); }
.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }
.icon-btn { background: transparent; border: 0; font-size: 1.15rem; cursor: pointer; padding: .35rem .5rem; border-radius: var(--radius-sm); color: inherit; }
.icon-btn:hover { background: rgba(0, 0, 0, .06); }

/* ---------- Formularios ---------- */
.form .field, .field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .85rem; }
.field label { font-size: .82rem; font-weight: 600; color: #3B4357; }
.field.inline { flex-direction: row; align-items: center; gap: .6rem; margin-top: .5rem; }
input, select, textarea { font: inherit; color: var(--text); background: #fff; border: 1px solid #CDD3DF; border-radius: var(--radius-sm); padding: .55rem .7rem; min-height: 40px; width: 100%; }
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; }
input[type=color] { padding: 2px; width: 52px; height: 40px; cursor: pointer; }
input[type=range] { padding: 0; border: 0; accent-color: var(--primary); }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-light); border-color: var(--primary); }
input:disabled, select:disabled { background: #F2F4F7; }
.input-lg { min-height: 48px; font-size: 1rem; }
.hint { color: var(--muted); font-size: .78rem; }
.check { flex-direction: row !important; display: flex; align-items: center; gap: .5rem; font-weight: 500 !important; cursor: pointer; }
.grid2, .grid3, .grid4 { display: grid; gap: 0 1rem; }
.grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .5rem; }
.inline-form { display: flex; gap: .5rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .35rem; }
.chip { font: inherit; font-size: .82rem; font-weight: 600; padding: .35rem .75rem; border: 1px solid var(--border); background: #fff; border-radius: 999px; cursor: pointer; color: var(--primary); min-height: 34px; }
.chip:hover, .chip.on { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.seg { display: flex; gap: .4rem; flex-wrap: wrap; }
.seg-opt { flex: 1; min-width: 70px; position: relative; }
.seg-opt input { position: absolute; opacity: 0; inset: 0; }
.seg-opt span { display: flex; align-items: center; justify-content: center; min-height: 46px; border: 2px solid var(--border); border-radius: var(--radius-sm); font-weight: 650; cursor: pointer; background: #fff; }
.seg-opt input:checked + span { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.seg-opt input:focus-visible + span { outline: 2px solid var(--primary); }
.seg-prio .prio-urgente input:checked + span { border-color: var(--sem-rojo); background: #FDECEC; color: var(--sem-rojo); }
.seg-prio .prio-alta input:checked + span { border-color: #E07B18; background: #FEF2E6; color: #B85F0B; }
.seg-prio .prio-baja input:checked + span { border-color: var(--secondary-dark); background: var(--secondary-light); color: var(--secondary-dark); }
details.more { border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: .5rem .75rem; margin-bottom: .5rem; }
details.more summary { cursor: pointer; font-weight: 600; color: var(--primary); padding: .25rem 0; }
details.more[open] summary { margin-bottom: .6rem; }
.color-in { display: flex; align-items: center; gap: .5rem; }
.alert { background: var(--secondary-light); border: 1px solid var(--secondary); padding: .7rem .9rem; border-radius: var(--radius-sm); margin-bottom: 1rem; }

/* ---------- Topbar / Shell ---------- */
.topbar { position: sticky; top: 0; z-index: 40; height: var(--topbar-h); background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: .75rem; padding: 0 1rem; box-shadow: var(--shadow); }
.topbar::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: linear-gradient(90deg, var(--primary) 0 70%, var(--secondary) 70%); }
.menu-btn { display: none; }
.app-title { display: flex; flex-direction: column; line-height: 1.15; color: var(--primary); text-decoration: none !important; min-width: 0; }
.app-title .t-full { font-weight: 800; font-size: 1.02rem; letter-spacing: .01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-title .t-short { display: none; font-weight: 800; }
.app-title small { color: var(--muted); font-size: .76rem; font-weight: 500; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: .75rem; }
.top-logo { height: 52px; width: auto; max-width: 120px; object-fit: contain; }
.user-chip { display: flex; align-items: center; gap: .5rem; color: var(--text); text-decoration: none !important; padding: .25rem .5rem; border-radius: 999px; }
.user-chip:hover { background: var(--primary-soft); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; font-weight: 700; }
.u-txt { display: flex; flex-direction: column; line-height: 1.1; }
.u-txt b { font-size: .85rem; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.u-txt small { color: var(--muted); font-size: .74rem; }
.sync-pill { display: inline-flex; align-items: center; gap: .3rem; font-size: .76rem; font-weight: 700; padding: .3rem .65rem; border-radius: 999px; border: 1px solid var(--border); white-space: nowrap; background: #fff; }
.sync-pill.s-ok { color: var(--sem-verde); border-color: #BFE3C9; background: #F1FAF3; }
.sync-pill.s-syncing { color: #9A7200; border-color: #F3DC94; background: #FFF9E6; }
.sync-pill.s-offline { color: var(--sem-rojo); border-color: #F2C3C3; background: #FDF1F1; }
.cf-badge { background: #FFF4E5; color: #A35A00; border: 1px solid #F7D3A1; border-radius: 999px; padding: .2rem .6rem; font-size: .8rem; text-decoration: none !important; }

.shell { display: flex; min-height: calc(100vh - var(--topbar-h)); }
.sidebar { width: var(--sidebar-w); flex-shrink: 0; background: var(--primary); color: var(--on-primary); position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); overflow-y: auto; display: flex; flex-direction: column; padding: .75rem .6rem; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a { display: flex; align-items: center; gap: .7rem; padding: .7rem .8rem; border-radius: var(--radius-sm); color: var(--on-primary); opacity: .88; font-weight: 600; font-size: .86rem; letter-spacing: .03em; text-decoration: none !important; border-left: 3px solid transparent; }
.sidebar nav a:hover { background: rgba(255, 255, 255, .09); opacity: 1; }
.sidebar nav a.on { background: rgba(255, 255, 255, .14); opacity: 1; border-left-color: var(--secondary); }
.sidebar .ic { width: 22px; text-align: center; }
.sidebar .nb { margin-left: auto; font-style: normal; font-size: .72rem; background: rgba(255, 255, 255, .2); padding: 1px 7px; border-radius: 999px; }
.sidebar .nb:empty { display: none; }
.sidebar .nb.red { background: var(--sem-rojo); }
.side-new { margin-top: 1rem; }
.side-foot { margin-top: auto; padding: 1rem .5rem 0; opacity: .7; font-size: .78rem; }
main { flex: 1; min-width: 0; padding: 1.5rem 1.75rem 3rem; outline: none; }
.view { max-width: 1400px; margin: 0 auto; }
.scrim { display: none; }
.bottom-nav { display: none; }

/* ---------- Encabezados de página ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.page-head h1 { margin-bottom: .2rem; }
.head-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.back { display: inline-block; font-size: .85rem; margin-bottom: .3rem; font-weight: 600; }
.badges { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; margin-top: .35rem; }

/* ---------- Tarjetas ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; }
.empty { padding: 2rem 1rem; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }
.empty.sm { padding: 1rem; font-size: .9rem; border: 0; background: transparent; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .95rem 1rem; display: flex; flex-direction: column; gap: .2rem; box-shadow: var(--shadow); border-top: 4px solid var(--primary); color: var(--text); text-decoration: none !important; min-height: 92px; }
a.kpi[href]:hover { box-shadow: 0 4px 12px rgba(16, 24, 40, .12); }
.kpi-v { font-size: 1.9rem; font-weight: 750; line-height: 1; }
.kpi-l { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; }
.k-blue { border-top-color: var(--primary); } .k-blue .kpi-v { color: var(--primary); }
.k-blue2 { border-top-color: #3D6BD6; } .k-blue2 .kpi-v { color: #3D6BD6; }
.k-gray { border-top-color: #8A94A6; }
.k-red { border-top-color: var(--sem-rojo); } .k-red .kpi-v { color: var(--sem-rojo); }
.k-orange { border-top-color: #E07B18; } .k-orange .kpi-v { color: #C2650C; }
.k-green { border-top-color: var(--sem-verde); } .k-green .kpi-v { color: var(--sem-verde); }
.k-yellow { border-top-color: var(--sem-amarillo); } .k-yellow .kpi-v { color: #B48500; }
.k-ring { flex-direction: column; align-items: flex-start; gap: .35rem; border-top-color: var(--secondary); min-width: 0; }
.k-ring .kpi-l { font-size: .68rem; }

.ring { --p: 0; width: 86px; height: 86px; border-radius: 50%; background: conic-gradient(var(--secondary) calc(var(--p) * 1%), #E6EAF1 0); display: grid; place-items: center; flex-shrink: 0; }
.ring::before { content: ""; grid-area: 1/1; width: 70%; height: 70%; background: var(--surface); border-radius: 50%; }
.ring span { grid-area: 1/1; font-weight: 750; font-size: 1.05rem; color: var(--primary); z-index: 1; }
.ring.sm { width: 56px; height: 56px; } .ring.sm span { font-size: .8rem; }
.cumpl { display: flex; align-items: center; gap: 1rem; margin-bottom: .5rem; }

.global-search { display: flex; align-items: center; gap: .5rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .35rem .4rem .35rem .9rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.global-search input { border: 0; min-height: 44px; font-size: 1rem; padding: 0; }
.global-search input:focus { outline: none; }
.global-search.big input { min-height: 52px; font-size: 1.1rem; }

.quick-actions { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .7rem; margin-bottom: 1.1rem; }
.qa { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .35rem; padding: .9rem .5rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; font: inherit; font-weight: 700; font-size: .78rem; letter-spacing: .03em; color: var(--primary); box-shadow: var(--shadow); min-height: 84px; }
.qa b { font-size: 1.5rem; line-height: 1; }
.qa:hover { border-color: var(--primary); background: var(--primary-soft); }
.qa-main { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.qa-main:hover { background: var(--primary-dark); }

.grid-charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; }
.chart-box { position: relative; height: 260px; width: 100%; min-width: 0; }
.card { min-width: 0; }
.chart-box.sm { height: 150px; }
.grid3-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 1rem; }
.grid2-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; }
.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li { display: flex; align-items: center; gap: .65rem; padding: .55rem .25rem; border-bottom: 1px solid var(--border); cursor: pointer; }
.mini-list li:last-child { border-bottom: 0; }
.mini-list li:hover { background: var(--primary-soft); }
.mini-list li div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mini-list strong { font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-list small { color: var(--muted); font-size: .78rem; }

/* ---------- Semáforo / badges ---------- */
.sem { display: inline-flex; align-items: center; gap: .35rem; font-size: .78rem; font-weight: 650; white-space: nowrap; }
.sem i { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex-shrink: 0; box-shadow: 0 0 0 2px rgba(255, 255, 255, .9), 0 0 0 3px rgba(0, 0, 0, .06); }
.sem-verde i { background: var(--sem-verde); } .sem-verde span { color: var(--sem-verde); }
.sem-amarillo i { background: var(--sem-amarillo); } .sem-amarillo span { color: #A57A00; }
.sem-rojo i { background: var(--sem-rojo); } .sem-rojo span { color: var(--sem-rojo); }
.sem-gris i { background: var(--sem-gris); } .sem-gris span { color: var(--muted); }
.badge { display: inline-block; font-size: .74rem; font-weight: 700; padding: .18rem .55rem; border-radius: 999px; background: #EEF0F4; color: #4A5163; white-space: nowrap; letter-spacing: .01em; }
.est-pendiente { background: #EEF0F4; color: #4A5163; }
.est-en_proceso { background: #E3EBFB; color: #2A55B8; }
.est-pendiente_terceros { background: #EFEAFB; color: #5B44A8; }
.est-completada { background: #E3F4E8; color: #1F7A3C; }
.est-cancelada { background: #F1F2F4; color: #7A808C; }
.est-vencida { background: #FBE6E6; color: #B23434; }
.prio-baja { background: var(--secondary-light); color: var(--secondary-dark); }
.prio-media { background: #E6EEF9; color: #2E5AA8; }
.prio-alta { background: #FEEEDD; color: #B85F0B; }
.prio-urgente { background: var(--sem-rojo); color: #fff; }
.progress { position: relative; height: 18px; background: #E8EBF1; border-radius: 999px; overflow: hidden; min-width: 90px; }
.progress div { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, var(--secondary), var(--accent)); border-radius: 999px; }
.progress span { position: relative; display: block; text-align: center; font-size: .72rem; font-weight: 700; line-height: 18px; color: #1d2b0c; }
.pend { display: inline-block; margin-left: .35rem; color: #B48500; font-size: .85rem; animation: spin 2s linear infinite; }
.pend.err { color: var(--sem-rojo); animation: none; font-weight: 800; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .88rem; background: var(--surface); }
.table th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; padding: .65rem .7rem; border-bottom: 2px solid var(--border); background: #FAFBFD; white-space: nowrap; }
.table td { padding: .65rem .7rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr[data-open-task] { cursor: pointer; }
.table tbody tr:hover { background: var(--primary-soft); }
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--primary); }
.table th.asc::after { content: " ▲"; font-size: .65rem; }
.table th.desc::after { content: " ▼"; font-size: .65rem; }
.table .t-title strong { display: block; }
.table .t-title small { color: var(--muted); }
.table .w-prog { width: 130px; }
.table.compact td, .table.compact th { padding: .4rem .5rem; }
.tasks.table { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.row-warn { background: #FFF8EA; }
.list-count { font-size: .82rem; margin-bottom: .4rem; }

.filters { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: .9rem; }
.filters > * { flex: 1 1 170px; width: auto; }
.filters input[type=search] { flex: 2 1 220px; }
.filters-card .grid4 { gap: 0 1rem; }

/* Tarjetas de tareas (móvil) */
.cards { display: flex; flex-direction: column; gap: .7rem; }
.task-card { background: var(--surface); border: 1px solid var(--border); border-left: 5px solid var(--sem-gris); border-radius: var(--radius); padding: .85rem .95rem; box-shadow: var(--shadow); cursor: pointer; }
.task-card h3 { font-size: 1.02rem; margin: .45rem 0 .35rem; }
.sem-border-verde { border-left-color: var(--sem-verde); }
.sem-border-amarillo { border-left-color: var(--sem-amarillo); }
.sem-border-rojo { border-left-color: var(--sem-rojo); }
.tc-top, .tc-bottom { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.tc-bottom .progress { flex: 1; max-width: 55%; }
.tc-meta { display: flex; flex-wrap: wrap; gap: .3rem .9rem; font-size: .82rem; color: var(--muted); margin-bottom: .55rem; }
.only-mobile { display: none !important; }

/* Comunidades */
.com-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; }
.com-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); cursor: pointer; display: flex; flex-direction: column; gap: .8rem; border-top: 4px solid var(--primary); }
.com-card:hover { box-shadow: 0 6px 18px rgba(16, 24, 40, .12); }
.com-card.inactive { opacity: .65; border-top-color: var(--sem-gris); }
.com-card header { display: flex; justify-content: space-between; gap: .75rem; }
.com-card header small { color: var(--muted); font-weight: 600; font-size: .74rem; }
.com-card h3 { font-size: 1.15rem; margin: .1rem 0 .2rem; color: var(--primary); }
.com-card p { color: var(--muted); font-size: .85rem; margin: 0; }
.com-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .3rem; text-align: center; background: #F7F8FB; border-radius: var(--radius-sm); padding: .55rem .3rem; }
.com-stats span { display: flex; flex-direction: column; font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; font-weight: 600; }
.com-stats b { font-size: 1.25rem; color: var(--text); }
.com-stats .red b { color: var(--sem-rojo); }
.com-stats .green b { color: var(--sem-verde); }
.com-card footer { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; }
.dl { display: grid; grid-template-columns: minmax(130px, 200px) 1fr; gap: .45rem 1rem; margin: 0; }
.dl dt { color: var(--muted); font-size: .84rem; font-weight: 600; }
.dl dd { margin: 0; }
.dl.compact { grid-template-columns: 190px 1fr; }

/* Ficha */
.ficha-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); gap: 0 1rem; }
.action-grid { display: grid; gap: .55rem; }
.action-grid .btn { width: 100%; }
.next-steps { background: var(--secondary-light); border-color: var(--secondary); }
.ns-btns { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: .6rem; }
.tabs { display: flex; gap: .25rem; border-bottom: 2px solid var(--border); margin: .5rem 0 0; overflow-x: auto; }
.tab { font: inherit; font-weight: 650; font-size: .9rem; background: none; border: 0; padding: .7rem 1rem; cursor: pointer; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.tab.on { color: var(--primary); border-bottom-color: var(--secondary); }
.tab-body { border-top-left-radius: 0; border-top-right-radius: 0; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 1.2rem; border-left: 3px solid var(--primary-light); }
.timeline li { position: relative; padding: 0 0 1.2rem .9rem; }
.timeline li::before { content: ""; position: absolute; left: -1.2rem; top: .25rem; width: 13px; height: 13px; border-radius: 50%; background: var(--primary); transform: translateX(-5px); box-shadow: 0 0 0 3px #fff; }
.timeline li.tl-close::before { background: var(--sem-verde); }
.tl-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.tl-desc { margin: .3rem 0 .1rem; font-style: italic; }
.tl-com { margin: 0 0 .2rem; color: #3B4357; }
.thumbs { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .55rem; }
.thumb { width: 92px; height: 92px; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); padding: 0; cursor: zoom-in; background: #EEF0F4 center/24px no-repeat; position: relative; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb img:not([src]) { visibility: hidden; }
.thumb .pend { position: absolute; right: 4px; top: 2px; background: #fff; border-radius: 50%; margin: 0; }
.thumb-off::after { content: "Sin conexión"; position: absolute; inset: 0; display: grid; place-items: center; font-size: .7rem; color: var(--muted); }
.thumbs.big .thumb { width: 150px; height: 150px; }
.docs { list-style: none; padding: 0; margin: .5rem 0 0; display: flex; flex-direction: column; gap: .35rem; }
.doc-link { font: inherit; background: none; border: 0; color: var(--primary); cursor: pointer; padding: 0; text-align: left; font-weight: 600; }
.doc-link:hover { text-decoration: underline; }
details.manage { margin-top: 1rem; font-size: .88rem; }
details.manage summary { cursor: pointer; color: var(--muted); }

/* Selector de archivos */
.fp-buttons { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .5rem; }
.fp-btn { cursor: pointer; }
.fp-list { display: flex; flex-direction: column; gap: .4rem; margin-top: .55rem; }
.fp-item { display: flex; align-items: center; gap: .6rem; padding: .35rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #FAFBFD; }
.fp-item img { width: 48px; height: 48px; object-fit: cover; border-radius: 4px; }
.fp-ic { width: 48px; text-align: center; font-size: 1.6rem; }
.fp-name { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fp-name small { color: var(--muted); }

/* Calendario */
.cal-toolbar { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: .6rem; }
.cal-toolbar h2 { margin: 0; flex: 1; text-align: center; font-size: 1.2rem; min-width: 180px; }
.cal-toolbar select { width: auto; }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .8rem; margin-bottom: .75rem; color: var(--muted); }
.lgd { display: inline-flex; align-items: center; gap: .35rem; }
.lgd i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.lg-pendiente i, .ev-pendiente { background: #8A94A6; }
.lg-proceso i, .ev-proceso { background: #3D6BD6; }
.lg-proxima i, .ev-proxima { background: var(--sem-amarillo); }
.lg-vencida i, .ev-vencida { background: var(--sem-rojo); }
.lg-completada i, .ev-completada { background: var(--sem-verde); }
.ev-cancelada { background: #C3C8D2; }
.cal-month { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.cal-hdr, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-hdr span { padding: .5rem; text-align: center; font-size: .75rem; font-weight: 700; text-transform: uppercase; color: var(--muted); background: #FAFBFD; border-bottom: 1px solid var(--border); }
.cal-cell { min-height: 112px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: .3rem; cursor: pointer; display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.cal-cell:nth-child(7n) { border-right: 0; }
.cal-cell.out { background: #FAFBFC; }
.cal-cell.out .cal-d { color: #B5BBC6; }
.cal-cell.today .cal-d { background: var(--primary); color: var(--on-primary); }
.cal-cell.sel { outline: 2px solid var(--primary); outline-offset: -2px; }
.cal-d { font-size: .8rem; font-weight: 700; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; }
.cal-evs { display: flex; flex-direction: column; gap: 2px; }
.ev { font: inherit; font-size: .72rem; font-weight: 600; color: #fff; border: 0; border-radius: 4px; padding: 2px 5px; text-align: left; cursor: pointer; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; width: 100%; }
.ev.ev-proxima { color: #3a2c00; }
.ev span { overflow: hidden; text-overflow: ellipsis; }
.more { font-size: .7rem; color: var(--muted); padding-left: 4px; }
.cal-dots { display: none; gap: 3px; flex-wrap: wrap; justify-content: center; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.cal-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .5rem; }
.wk-col { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); min-height: 260px; padding: .4rem; display: flex; flex-direction: column; gap: 4px; }
.wk-col.today { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.wk-h { font: inherit; border: 0; background: #FAFBFD; border-radius: 4px; padding: .35rem; cursor: pointer; color: var(--muted); font-size: .8rem; }
.wk-h b { color: var(--text); font-size: 1rem; }
.wk-evs { display: flex; flex-direction: column; gap: 3px; }
.wk-evs .ev { white-space: normal; padding: 4px 6px; }
.cal-daylist { margin-top: 1rem; }

/* Informes */
.report { padding: 1.4rem; }
.rep-head small { color: var(--secondary-dark); font-weight: 750; letter-spacing: .06em; }
.rep-head h2 { font-size: 1.45rem; color: var(--primary); margin: .2rem 0; }
.rep-sum { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .5rem; margin: 1rem 0; }
.rep-sum span { background: #F7F8FB; border-radius: var(--radius-sm); padding: .6rem; text-align: center; display: flex; flex-direction: column; font-size: .72rem; color: var(--muted); text-transform: uppercase; font-weight: 650; }
.rep-sum b { font-size: 1.35rem; color: var(--primary); }
.rep-sum .red b { color: var(--sem-rojo); } .rep-sum .green b { color: var(--sem-verde); }
.report h3 { margin-top: 1.4rem; color: var(--primary); }
.rep-task { border-top: 1px solid var(--border); padding: .8rem 0; }
.rep-task h4 { display: flex; align-items: center; gap: .5rem; margin: 0 0 .3rem; }
.rep-task h4 small { color: var(--muted); font-weight: 500; }
.rep-av { margin: .3rem 0; padding-left: 1.2rem; font-size: .88rem; }

/* Búsqueda */
.sec-t { margin: 1.1rem 0 .6rem; font-size: .9rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.cards-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.com-chip { font: inherit; font-weight: 650; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: .5rem 1rem; cursor: pointer; color: var(--primary); }
.results { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: .8rem; }
.result { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; cursor: pointer; box-shadow: var(--shadow); }
.result:hover { border-color: var(--primary); }
.result h3 { margin: .45rem 0 .25rem; }
.r-top { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.r-meta { font-size: .82rem; color: var(--muted); }
.r-bottom { display: flex; flex-direction: column; gap: .35rem; }

/* Configuración */
.cfg-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; align-items: start; }
.logo-edit { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.logo-prev { width: 120px; height: 120px; border: 1px dashed var(--border); border-radius: var(--radius); display: grid; place-items: center; background: #fff; padding: .4rem; }
.logo-prev { overflow: hidden; }
.logo-prev img { max-width: 100%; max-height: 108px; width: auto; height: auto; object-fit: contain; display: block; }
.logo-btns { display: flex; flex-direction: column; gap: .4rem; align-items: flex-start; }
.small-list { font-size: .82rem; padding-left: 1.1rem; }
.conflict header { display: flex; justify-content: space-between; align-items: baseline; }
.cf-who { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; font-size: .86rem; margin: .5rem 0 .8rem; }
.cf-who > div { background: #F7F8FB; padding: .6rem .75rem; border-radius: var(--radius-sm); }

/* ---------- Modales ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 1rem; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border-radius: 12px; width: 100%; max-width: 560px; max-height: calc(100vh - 2rem); display: flex; flex-direction: column; box-shadow: var(--shadow-lg); }
.modal.lg { max-width: 760px; }
.modal.sm { max-width: 420px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: .9rem 1.2rem; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; color: var(--primary); font-size: 1.1rem; letter-spacing: .02em; }
.modal-body { padding: 1.1rem 1.2rem; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.modal-foot { display: flex; justify-content: flex-end; gap: .5rem; padding: .8rem 1.2rem; border-top: 1px solid var(--border); background: #FAFBFD; border-radius: 0 0 12px 12px; }

/* Visor */
.lightbox { position: fixed; inset: 0; background: rgba(8, 12, 22, .92); z-index: 200; display: flex; align-items: center; justify-content: center; }
.lightbox figure { margin: 0; max-width: 92vw; max-height: 88vh; display: flex; flex-direction: column; align-items: center; }
.lightbox img { max-width: 92vw; max-height: 80vh; object-fit: contain; border-radius: 4px; background: #222; }
.lightbox figcaption { color: #dfe3ea; font-size: .85rem; margin-top: .5rem; text-align: center; }
.lightbox button { position: absolute; background: rgba(255, 255, 255, .12); color: #fff; border: 0; font-size: 2rem; width: 52px; height: 52px; border-radius: 50%; cursor: pointer; }
.lb-x { top: 1rem; right: 1rem; font-size: 1.3rem !important; }
.lb-prev { left: 1rem; } .lb-next { right: 1rem; }
.lb-dl { position: absolute; bottom: 1rem; right: 1rem; background: #fff !important; }

/* Toasts */
#toasts { position: fixed; z-index: 300; left: 50%; transform: translateX(-50%); bottom: 1.2rem; display: flex; flex-direction: column; gap: .5rem; align-items: center; pointer-events: none; width: min(92vw, 520px); }
.toast { background: #1F2533; color: #fff; padding: .7rem 1rem; border-radius: 8px; box-shadow: var(--shadow-lg); font-size: .9rem; animation: up .2s; transition: opacity .3s, transform .3s; pointer-events: auto; border-left: 5px solid var(--primary); width: 100%; }
.toast-ok { border-left-color: var(--secondary); }
.toast-error { border-left-color: var(--sem-rojo); }
.toast-warn { border-left-color: var(--sem-amarillo); }
.toast.out { opacity: 0; transform: translateY(8px); }
@keyframes up { from { opacity: 0; transform: translateY(10px); } }
.update-bar { position: fixed; z-index: 250; top: calc(var(--topbar-h) + .5rem); left: 50%; transform: translateX(-50%); background: var(--primary); color: var(--on-primary); padding: .55rem .9rem; border-radius: 8px; box-shadow: var(--shadow-lg); display: flex; gap: .7rem; align-items: center; font-size: .9rem; }

/* ---------- Ingreso ---------- */
.auth-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1.5rem 1rem; background: linear-gradient(160deg, var(--primary-soft), #fff 55%, var(--secondary-light)); }
.auth-card { background: #fff; width: 100%; max-width: 460px; border-radius: 14px; box-shadow: var(--shadow-lg); padding: 1.8rem 1.8rem 1.5rem; border-top: 5px solid var(--primary); }
.auth-card h2 { color: var(--primary); margin: 1rem 0 .8rem; }
.auth-brand { display: flex; align-items: center; gap: 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border); }
.auth-brand img { height: 92px; width: auto; }
.auth-brand h1 { font-size: 1rem; color: var(--primary); font-weight: 800; margin: 0 0 .2rem; }
.auth-brand p { margin: 0; color: var(--muted); font-size: .85rem; }
.auth-links { display: flex; justify-content: space-between; margin-top: 1rem; font-size: .9rem; font-weight: 600; }
.auth-foot { color: var(--muted); font-size: .8rem; margin-top: 1rem; }
.steps { padding-left: 1.2rem; } .steps li { margin-bottom: .45rem; }
.splash { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; color: var(--muted); }
.splash img { height: 140px; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }

/* =====================================================================
   RESPONSIVE
   ===================================================================== */
@media (max-width: 1180px) {
  .grid3-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rep-sum { grid-template-columns: repeat(3, 1fr); }
  .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1000px) {
  .app-title .t-full { font-size: .9rem; }
  .u-txt { display: none; }
  .cfg-grid, .ficha-grid, .grid-charts { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  :root { --topbar-h: 58px; }
  .menu-btn { display: inline-block; }
  .app-title .t-full { display: none; }
  .app-title .t-short { display: block; font-size: .98rem; }
  .app-title small { font-size: .7rem; }
  .top-logo { height: 42px; max-width: 70px; }
  .user-chip { display: none; }
  .sidebar { position: fixed; z-index: 60; top: 0; left: 0; height: 100vh; transform: translateX(-105%); transition: transform .22s ease; box-shadow: var(--shadow-lg); padding-top: 1rem; }
  body.drawer-open .sidebar { transform: none; }
  body.drawer-open .scrim { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 55; }
  main { padding: 1rem .9rem calc(var(--bottom-h) + 1.5rem + var(--safe-b)); }
  .bottom-nav { display: flex; position: fixed; z-index: 50; left: 0; right: 0; bottom: 0; height: calc(var(--bottom-h) + var(--safe-b)); padding-bottom: var(--safe-b); background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -2px 10px rgba(16, 24, 40, .06); justify-content: space-around; align-items: center; }
  .bottom-nav a, .bottom-nav > button:not(.fab) { font: inherit; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .68rem; font-weight: 650; color: var(--muted); text-decoration: none !important; background: none; border: 0; padding: .3rem .4rem; min-width: 60px; cursor: pointer; }
  .bottom-nav a span, .bottom-nav button span { font-size: 1.25rem; line-height: 1; }
  .bottom-nav a.on { color: var(--primary); }
  .fab { width: 58px; height: 58px; border-radius: 50%; border: 4px solid var(--surface); background: var(--secondary); color: var(--on-secondary); font-size: 2rem; font-weight: 400; line-height: 1; margin-top: -26px; box-shadow: 0 4px 12px rgba(0, 0, 0, .2); cursor: pointer; }
  .only-desktop { display: none !important; }
  .only-mobile { display: flex !important; }
  .cards.only-mobile { display: flex !important; flex-direction: column; }
  .sync-pill span { display: none; }
  .sync-pill { padding: .3rem .45rem; }
  h1 { font-size: 1.3rem; }
  .page-head { align-items: flex-start; }
  .page-head .btn-lg { width: 100%; }
  .head-actions { width: 100%; }
  .head-actions .btn { flex: 1; }
  .quick-actions { grid-template-columns: repeat(3, 1fr); }
  .quick-actions .qa-main { grid-column: span 3; order: -1; flex-direction: row; min-height: 60px; font-size: .95rem; }
  .kpis { grid-template-columns: repeat(2, 1fr); gap: .6rem; }
  .kpi { min-height: 80px; padding: .75rem .8rem; }
  .kpi-v { font-size: 1.6rem; }
  .k-ring { grid-column: span 2; }
  .grid3-cards, .grid2-cards { grid-template-columns: minmax(0, 1fr); }
  .grid2, .grid3, .grid4 { grid-template-columns: minmax(0, 1fr); }
  .filters > * { flex: 1 1 100%; }
  .filters { gap: .5rem; }
  .dl, .dl.compact { grid-template-columns: minmax(0, 1fr); gap: .1rem; }
  .dl dd { margin-bottom: .5rem; }
  .cf-who { grid-template-columns: minmax(0, 1fr); }
  .rep-sum { grid-template-columns: repeat(3, 1fr); }
  .report { padding: 1rem; }
  /* Calendario compacto */
  .cal-cell { min-height: 54px; align-items: center; padding: .2rem; }
  .cal-evs { display: none; }
  .cal-dots { display: flex; }
  .cal-week { grid-template-columns: minmax(0, 1fr); }
  .wk-col { min-height: 0; flex-direction: row; align-items: flex-start; }
  .wk-h { width: 64px; flex-shrink: 0; }
  .wk-evs { flex: 1; }
  .cal-toolbar h2 { order: -1; flex-basis: 100%; }
  .seg-views { margin-left: auto; }
  .cal-toolbar select { flex-basis: 100%; }
  /* Modales como hoja inferior en celular */
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal, .modal.lg { max-width: 100%; max-height: 94vh; border-radius: 16px 16px 0 0; }
  .modal.sheet { height: 94vh; }
  .modal-body { flex: 1; }
  .modal-foot { border-radius: 0; padding-bottom: calc(.8rem + var(--safe-b)); }
  .modal-foot .btn { flex: 1; }
  #toasts { bottom: calc(var(--bottom-h) + var(--safe-b) + .8rem); }
  .fp-buttons { grid-template-columns: minmax(0, 1fr); }
  .thumb { width: 80px; height: 80px; }
  .thumbs.big .thumb { width: calc(50% - .25rem); height: 150px; }
  .action-grid .btn { min-height: 52px; }
  .tabs .tab { padding: .65rem .7rem; font-size: .85rem; }
  .table.hist { font-size: .8rem; }
  .auth-card { padding: 1.3rem 1.1rem; }
  .auth-brand img { height: 70px; }
}
@media (max-width: 420px) {
  .quick-actions { grid-template-columns: repeat(2, 1fr); }
  .quick-actions .qa-main { grid-column: span 2; }
  .rep-sum { grid-template-columns: repeat(2, 1fr); }
}
@media print {
  .topbar, .sidebar, .bottom-nav, .head-actions, .filters-card, .global-search { display: none !important; }
  main { padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
