/* AG Avalúos — portal interno.
   Layout: barra lateral fija (canales, herramientas) + panel de trabajo; en celular la barra se abre como cajón. */
/* Plantilla negra: un solo tema oscuro, igual en todas las computadoras y celulares. */
:root {
  --bg: #0B0B0B;
  --panel: #000000;
  --rail: #111111;
  --ink: #EDEDED;
  --muted: #8E8E8E;
  --line: #262626;
  --accent: #4CC497;
  --accent-ink: #04140D;
  --accent-soft: #14281F;
  --danger: #F07A6E;
  --bubble-me: #12241C;
  --overlay: rgba(0, 0, 0, .75);
  --k-visita: #6FD7AE;  --k-visita-bg: #13281F;
  --k-entrega: #F2C760; --k-entrega-bg: #2E2611;
  --k-reunion: #8EB4F2; --k-reunion-bg: #172238;
  --k-tramite: #CFA3EA; --k-tramite-bg: #2A1C34;
  --k-otro: #B5B5B5;    --k-otro-bg: #1E1E1E;
  --f-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --f-body: "Instrument Sans", "Segoe UI", system-ui, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --r: 10px;
  color-scheme: dark;
}
/* Modo claro: cada persona lo elige en «Mi cuenta» o con el botón del menú. */
:root[data-theme="light"] {
  --bg: #F3F5F4;
  --panel: #FFFFFF;
  --rail: #E7ECEA;
  --ink: #17211E;
  --muted: #5D6B66;
  --line: #D3DCD8;
  --accent: #1F7A5C;
  --accent-ink: #FFFFFF;
  --accent-soft: #DCEFE7;
  --danger: #B3362B;
  --bubble-me: #E3F2EB;
  --overlay: rgba(10, 16, 14, .55);
  --k-visita: #1F7A5C;  --k-visita-bg: #DCEFE7;
  --k-entrega: #9A6A00; --k-entrega-bg: #FBEFCB;
  --k-reunion: #2D5DA8; --k-reunion-bg: #DFE8F7;
  --k-tramite: #7A3E9D; --k-tramite-bg: #EEE2F5;
  --k-otro: #55625D;    --k-otro-bg: #E6EBE9;
  color-scheme: light;
}
.theme-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.theme-option { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 12px; border-radius: var(--r); border: 2px solid var(--line); background: var(--bg); text-align: left; }
.theme-option[aria-pressed="true"] { border-color: var(--accent); }
.theme-option small { color: var(--muted); font-size: 12px; }
.theme-option .swatch { display: flex; width: 100%; height: 44px; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); margin-bottom: 4px; }
.theme-option .swatch span { flex: 1; }
.dark-sample .swatch span:nth-child(1) { background: #000; flex: 0 0 30%; }
.dark-sample .swatch span:nth-child(2) { background: #111; }
.dark-sample .swatch span:nth-child(3) { background: #4CC497; flex: 0 0 14%; }
.light-sample .swatch span:nth-child(1) { background: #E7ECEA; flex: 0 0 30%; }
.light-sample .swatch span:nth-child(2) { background: #FFF; }
.light-sample .swatch span:nth-child(3) { background: #1F7A5C; flex: 0 0 14%; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.me .notify-btn { border-color: var(--k-entrega); color: var(--k-entrega); justify-content: center; }
.nav-item .badge { min-width: 20px; text-align: center; }
.levels { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.role-select { border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; background: var(--bg); font-size: 13px; }
.pill.role-admin { background: var(--accent-soft); color: var(--accent); }
.help-btn { border-color: #F7701D; color: #F7701D; }
.help-tips { list-style: none; padding: 0; margin: 0 0 14px; display: grid; gap: 8px; }
.help-tips li { display: grid; gap: 2px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }
.help-tips li span { color: var(--muted); }
.help-item { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; padding: 10px 0; border-top: 1px solid var(--line); }
.help-item p { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.help-item.done { opacity: .6; }
.pill.role-owner { background: #F7701D; color: #fff; font-weight: 600; }
.pill.role-supervisor { background: var(--k-reunion-bg); color: var(--k-reunion); }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 15px; line-height: 1.5; }
#root { height: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
h1, h2, h3 { font-family: var(--f-display); letter-spacing: -0.01em; text-wrap: balance; margin: 0; }

/* ---------- Botones y campos ---------- */
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 9px 14px; font-weight: 500; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: var(--ink); }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: none; }
.btn:disabled { opacity: .5; cursor: default; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 500; }
.field input:not([type=checkbox]):not([type=radio]), .field textarea, .field select, .input { border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; background: var(--bg); font-weight: 400; font-size: 15px; width: 100%; min-width: 0; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 18px; height: 18px; flex-shrink: 0; margin: 2px 0 0; cursor: pointer; }
.field .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; font-weight: 400; text-align: left; cursor: pointer; line-height: 1.4; }
.field .check { padding: 4px 0; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1 1 140px; }
.error { color: var(--danger); font-size: 14px; }

/* ---------- Pantallas de entrada ---------- */
.center-screen { min-height: 100%; display: grid; place-items: center; padding-block: 24px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.auth { width: min(400px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.auth .brand { margin-bottom: 4px; }
.auth h2 { font-size: 22px; }
.auth p { margin: 0; }

.brand { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.logo-full { display: flex; height: 40px; filter: drop-shadow(0 2px 6px rgba(0,0,0,.18)); }
.lf-ag { background: #F7701D; width: 60px; display: grid; place-items: center; padding: 0 6px 0 10px; border-radius: 5px 0 0 5px; clip-path: polygon(10px 0, 100% 0, calc(100% - 10px) 100%, 0 100%); }
.lf-ag svg { width: 100%; height: 26px; display: block; }
.lf-name { background: #23278A; color: #fff; margin-left: -10px; padding: 0 18px 0 18px; display: flex; align-items: center; font-family: var(--f-display); font-weight: 700; font-size: 19px; letter-spacing: .07em; border-radius: 0 5px 5px 0; clip-path: polygon(10px 0, 100% 0, calc(100% - 10px) 100%, 0 100%); }
.lf-check { width: .78em; height: .95em; margin: 0 .07em; display: block; }
.lf-sub { color: var(--muted); font-size: 9.5px; letter-spacing: .32em; padding-left: 4px; }
.auth .logo-full { height: 52px; }
.auth .lf-ag { width: 78px; }
.auth .lf-ag svg { height: 34px; }
.auth .lf-name { font-size: 25px; }
.brand-mark { width: 36px; height: 36px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-family: var(--f-display); font-weight: 700; font-size: 14px; letter-spacing: -0.02em; flex-shrink: 0; }
.brand h1 { font-size: 18px; }
.brand small { display: block; color: var(--muted); font-size: 12px; }

/* ---------- Estructura ---------- */
.app { display: grid; grid-template-columns: 260px 1fr; height: 100%; }
.rail { background: var(--rail); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 16px; padding-block: 18px; padding-left: max(14px, env(safe-area-inset-left, 0px)); padding-right: 14px; overflow-y: auto; min-height: 0; }
.rail-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; display: flex; justify-content: space-between; align-items: center; padding: 0 6px 4px; }
.rail-label button { border: 0; background: none; color: var(--accent); font-size: 18px; line-height: 1; padding: 0 4px; }
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-item { display: flex; align-items: center; gap: 8px; border: 0; background: none; text-align: left; padding: 7px 10px; border-radius: 7px; width: 100%; min-width: 0; }
.nav-item:hover { background: var(--accent-soft); }
.nav-item[aria-current="true"] { background: var(--accent); color: var(--accent-ink); }
.nav-item .sym { font-family: var(--f-mono); opacity: .6; width: 14px; text-align: center; flex-shrink: 0; }
.nav-item .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.nav-item.unread .label { font-weight: 600; }
.badge { background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 600; border-radius: 999px; padding: 0 7px; line-height: 18px; font-variant-numeric: tabular-nums; }
.nav-item[aria-current="true"] .badge { background: var(--accent-ink); color: var(--accent); }
.tag { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; opacity: .7; }
.me { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding: 10px 6px 0; border-top: 1px solid var(--line); }
.me .who { font-weight: 600; font-size: 14px; }
.me .install { border-color: var(--accent); color: var(--accent); justify-content: center; }
.me .username { font-family: var(--f-mono); font-size: 12px; color: var(--ink); opacity: .8; }
.me .role { color: var(--muted); font-size: 12px; }
.me .row { gap: 6px; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--panel); }
/* Fondo personal: el estilo elegido, suavizado con el color del tema para que se lea bien. */
:root[data-bg] .main { background: linear-gradient(color-mix(in srgb, var(--panel) 72%, transparent), color-mix(in srgb, var(--panel) 72%, transparent)), var(--user-bg) center / cover no-repeat; }
:root[data-bg="noche"], [data-swatch="noche"] { --user-bg: linear-gradient(135deg, #0f2027, #203a43 50%, #2c5364); }
:root[data-bg="grafito"], [data-swatch="grafito"] { --user-bg: linear-gradient(160deg, #232526, #414345); }
:root[data-bg="oceano"], [data-swatch="oceano"] { --user-bg: linear-gradient(135deg, #1a2980, #26d0ce); }
:root[data-bg="atardecer"], [data-swatch="atardecer"] { --user-bg: linear-gradient(135deg, #ee0979, #ff6a00); }
:root[data-bg="bosque"], [data-swatch="bosque"] { --user-bg: linear-gradient(135deg, #134e5e, #71b280); }
:root[data-bg="marca"], [data-swatch="marca"] { --user-bg: linear-gradient(120deg, #23278A 55%, #F7701D 55.2%); }
:root[data-bg="arena"], [data-swatch="arena"] { --user-bg: linear-gradient(135deg, #e6dada, #c9b79c); }
:root[data-bg="imagen"] { --user-bg: var(--user-bg-image); }
.bg-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; margin: 10px 0 14px; }
.bg-option { display: grid; gap: 6px; justify-items: center; padding: 6px; border: 2px solid transparent; border-radius: 12px; background: none; color: var(--ink); cursor: pointer; font: inherit; }
.bg-option[aria-pressed="true"] { border-color: var(--accent); }
.bg-swatch { width: 100%; aspect-ratio: 16 / 10; border-radius: 8px; border: 1px solid var(--line); background: var(--user-bg, var(--panel)) center / cover no-repeat; }
[data-swatch="ninguno"] { background: var(--panel); }
.avatar.has-photo { padding: 0; overflow: hidden; background: none !important; }
.avatar.has-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.avatar-xl { width: 88px; height: 88px; font-size: 30px; flex-shrink: 0; }
.profile-row { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.head { display: flex; align-items: center; gap: 10px; padding-block: 14px; padding-left: 24px; padding-right: max(24px, env(safe-area-inset-right, 0px)); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.head h2 { font-size: 22px; min-width: 0; overflow-wrap: anywhere; }
.head .sub { margin: 0; color: var(--muted); font-size: 13px; flex-basis: 100%; }
.head .spacer { flex: 1; }
.menu-btn { display: none; }
.body { flex: 1; overflow-y: auto; min-height: 0; padding: 20px 24px; }

.empty { margin: 40px auto; text-align: center; color: var(--muted); max-width: 400px; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.empty strong { color: var(--ink); font-family: var(--f-display); font-size: 18px; }

/* ---------- Chat ---------- */
.stream { flex: 1; overflow-y: auto; padding: 20px 24px; display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.day-sep { align-self: center; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 2px 10px; border: 1px solid var(--line); border-radius: 999px; }
.msg { display: grid; grid-template-columns: 36px 1fr; gap: 10px; max-width: 780px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 13px; color: #fff; flex-shrink: 0; }
.msg .meta { display: flex; gap: 8px; align-items: baseline; font-size: 13px; }
.msg .meta .name { font-weight: 600; }
.msg .meta .position { color: var(--muted); font-size: 12px; }
.msg .meta .time { color: var(--muted); font-family: var(--f-mono); font-size: 11px; }
.msg .meta .del { margin-left: auto; border: 0; background: none; color: var(--muted); font-size: 12px; opacity: 0; }
.msg:hover .del, .msg .del:focus-visible { opacity: 1; }
/* En el celular los campos van a 16px: con letra más chica el iPhone hace zoom al tocarlos y queda así */
@media (pointer: coarse) {
  input, textarea, select { font-size: 16px !important; }
}
/* Dictado por voz */
.mic-btn { white-space: nowrap; }
.mic-btn.rec { background: #C62828; border-color: #C62828; color: #fff; }
.dictation-status { font-size: 13px; color: var(--muted); padding: 2px 4px 6px; }
/* Teléfonos en los mensajes: se tocan para llamar */
.msg .text a.tel-link { white-space: nowrap; font-weight: 600; }
/* Flechas de leído: gris = le llegó, azul = lo vieron */
.msg .meta .ticks { border: 0; background: none; padding: 0 2px; font-size: 13px; font-weight: 700; letter-spacing: -4px; padding-right: 6px; color: #9AA0A6; cursor: pointer; line-height: 1; }
.msg .meta .ticks.seen { color: #34B7F1; }
.seen-group { margin-top: 12px; }
.seen-list { list-style: none; padding: 0; margin: 6px 0 0; display: grid; gap: 6px; }
.seen-list li { display: flex; align-items: center; gap: 8px; }
.seen-list li.seen-yes span::after { content: " ✓✓"; color: #34B7F1; font-weight: 700; letter-spacing: -3px; }
.msg .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg .bubble { min-width: 0; }
.msg.mine .bubble { background: var(--bubble-me); border-radius: var(--r); padding: 8px 12px; }
.thumb { margin-top: 6px; max-width: min(320px, 100%); max-height: 240px; border-radius: 8px; border: 1px solid var(--line); cursor: zoom-in; display: block; }
.file-chip { display: flex; align-items: center; gap: 10px; margin-top: 6px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); max-width: 440px; }
.ext { font-family: var(--f-mono); font-size: 10px; font-weight: 500; background: var(--ink); color: var(--panel); padding: 3px 6px; border-radius: 4px; text-transform: uppercase; flex-shrink: 0; max-width: 52px; overflow: hidden; }
.file-chip .fname { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.size { font-family: var(--f-mono); font-size: 11px; color: var(--muted); flex-shrink: 0; font-variant-numeric: tabular-nums; }
.composer { border-top: 1px solid var(--line); padding-block: 12px; padding-left: 24px; padding-right: max(24px, env(safe-area-inset-right, 0px)); display: flex; flex-direction: column; gap: 8px; }
.composer .line { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { flex: 1; min-width: 0; resize: none; border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; background: var(--bg); min-height: 44px; max-height: 160px; }
.pending-list { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pending-item { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 8px; padding: 4px 4px 4px 6px; max-width: 220px; font-size: 13px; }
.pending-item .fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.pending-thumb { width: 36px; height: 36px; object-fit: cover; border-radius: 5px; flex-shrink: 0; }
.pending { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.note-line { color: var(--muted); font-size: 13px; }
.more { align-self: center; }

/* ---------- Documentos ---------- */
.docs { display: grid; grid-template-columns: 240px 1fr; flex: 1; min-height: 0; }
.folders { border-right: 1px solid var(--line); padding: 16px 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.folder { display: flex; gap: 8px; align-items: center; border: 0; background: none; padding: 8px 10px; border-radius: 7px; text-align: left; width: 100%; }
.folder:hover { background: var(--accent-soft); }
.folder[aria-current="true"] { background: var(--accent-soft); font-weight: 600; }
.folder .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder .count { font-family: var(--f-mono); font-size: 11px; color: var(--muted); }
.folder-icon { width: 16px; height: 12px; border: 1.5px solid currentColor; border-radius: 2px 3px 3px 3px; position: relative; flex-shrink: 0; opacity: .7; }
.folder-icon::before { content: ""; position: absolute; left: -1.5px; top: -4px; width: 7px; height: 3px; border: 1.5px solid currentColor; border-bottom: 0; border-radius: 2px 2px 0 0; }
.files-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.files-tools { display: flex; gap: 8px; flex-wrap: wrap; padding: 16px 24px 0; align-items: center; }
.files-tools .input { flex: 1 1 220px; width: auto; }
.perm { font-size: 12px; color: var(--muted); padding: 8px 24px 0; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--bg); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.num { font-family: var(--f-mono); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.doc-name { display: flex; gap: 10px; align-items: center; min-width: 220px; }
.doc-name .sub { color: var(--muted); font-size: 12px; }
td.actions { white-space: nowrap; text-align: right; }
td.actions > * + * { margin-left: 4px; }
.dropzone { border: 2px dashed var(--line); border-radius: var(--r); padding: 18px; text-align: center; color: var(--muted); margin-bottom: 14px; }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }

/* ---------- Calendario ---------- */
.cal { display: grid; grid-template-columns: 1fr 300px; flex: 1; min-height: 0; }
.cal-main { display: flex; flex-direction: column; min-width: 0; padding: 16px 24px 24px; overflow-y: auto; }
.cal-nav { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.cal-nav h3 { font-size: 20px; min-width: 180px; }
.legend { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-left: auto; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.dow { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; padding: 6px 8px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--bg); }
.cell { min-height: 104px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 4px; display: flex; flex-direction: column; gap: 3px; background: var(--panel); cursor: pointer; min-width: 0; text-align: left; border-top: 0; border-left: 0; }
.cell:hover { background: var(--bg); }
.cell.out { background: var(--bg); color: var(--muted); }
.cell.sel { box-shadow: inset 0 0 0 2px var(--accent); }
.cell .n { font-family: var(--f-mono); font-size: 12px; padding: 2px 5px; align-self: flex-start; border-radius: 6px; font-variant-numeric: tabular-nums; }
.cell.today .n { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.ev { font-size: 12px; border-radius: 5px; padding: 2px 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: 0; text-align: left; width: 100%; display: block; }
.ev .t { font-family: var(--f-mono); font-size: 10px; margin-right: 4px; }
.ev-more { font-size: 11px; color: var(--muted); padding: 0 6px; }
.k-visita { background: var(--k-visita-bg); color: var(--k-visita); }
.k-entrega { background: var(--k-entrega-bg); color: var(--k-entrega); }
.k-reunion { background: var(--k-reunion-bg); color: var(--k-reunion); }
.k-tramite { background: var(--k-tramite-bg); color: var(--k-tramite); }
.k-otro { background: var(--k-otro-bg); color: var(--k-otro); }
.d-visita { background: var(--k-visita); } .d-entrega { background: var(--k-entrega); } .d-reunion { background: var(--k-reunion); } .d-tramite { background: var(--k-tramite); } .d-otro { background: var(--k-otro); }
.ev.done, .agenda-item.done .title { text-decoration: line-through; opacity: .65; }
.ev.late { box-shadow: inset 3px 0 0 var(--danger); }
.agenda-item .title .pill { margin-left: 6px; vertical-align: 1px; text-decoration: none; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; padding: 3px; gap: 2px; margin-bottom: 14px; align-self: flex-start; background: var(--bg); flex-wrap: wrap; }
.seg-btn { border: 0; background: none; padding: 6px 14px; border-radius: 6px; font-weight: 500; font-size: 14px; color: var(--muted); }
.seg-btn[aria-pressed="true"] { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.agenda { border-left: 1px solid var(--line); padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.agenda h3 { font-size: 16px; }
.agenda-item { display: grid; grid-template-columns: 4px 1fr; gap: 10px; padding: 8px 10px 8px 0; border: 0; background: none; text-align: left; border-radius: 8px; width: 100%; }
.agenda-item:hover { background: var(--bg); }
.agenda-item .bar { border-radius: 4px; }
.agenda-item .title { font-weight: 600; overflow-wrap: anywhere; }
.agenda-item .info { font-size: 12px; color: var(--muted); }
.agenda .group { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; margin-top: 8px; }

/* ---------- Avalúos ---------- */
.case-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.case-card { text-align: left; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.case-card:hover { border-color: var(--accent); }
.case-top { display: flex; justify-content: space-between; align-items: center; }
.case-title { font-family: var(--f-display); font-size: 17px; font-weight: 600; overflow-wrap: anywhere; }
.case-sub { color: var(--muted); font-size: 13px; }
.case-due { font-size: 13px; font-variant-numeric: tabular-nums; }
.case-due.late { color: var(--danger); font-weight: 600; }
.case-due.soon { color: var(--k-entrega); font-weight: 600; }
.case-people { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--muted); }
.case-foot { font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 6px; margin-top: 2px; }
.pill.st-visita_pendiente { background: var(--k-otro-bg); color: var(--k-otro); }
.pill.st-en_visita { background: var(--k-reunion-bg); color: var(--k-reunion); }
.pill.st-en_redaccion { background: var(--k-entrega-bg); color: var(--k-entrega); }
.pill.st-en_revision { background: var(--k-tramite-bg); color: var(--k-tramite); }
.pill.st-entregado { background: var(--accent-soft); color: var(--accent); }
.status-select { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; background: var(--bg); font-weight: 600; font-size: 13px; }
.case-tabbar { padding: 12px 24px 0; }
.case-tabs { margin-bottom: 0; }
.case-body { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow-y: auto; }
.case-body > .stream { flex: 1; }
.capture { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 8px; }
.btn.big { padding: 14px 20px; font-size: 16px; }
.btn.ai { border-color: var(--k-tramite); color: var(--k-tramite); }
.cat-field { min-width: 180px; }
.upload-status { margin: 0 0 8px; }
.photo-group { margin-top: 18px; }
.photo-group h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-family: var(--f-body); margin-bottom: 8px; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.photo { margin: 0; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; display: flex; flex-direction: column; }
.photo img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; cursor: zoom-in; display: block; }
.photo figcaption { padding: 8px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.photo select { border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; background: var(--panel); }
.ai-text { margin: 0; color: var(--ink); font-size: 12.5px; line-height: 1.45; }
.photo-meta { color: var(--muted); font-size: 11px; }
.fields-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; max-width: 900px; margin-bottom: 12px; }
.fields-grid .wide { grid-column: 1 / -1; }
.report-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.report-tools .spacer { flex: 1; }
textarea.report { width: 100%; min-height: 50vh; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg); padding: 14px; font-family: var(--f-body); font-size: 15px; line-height: 1.6; resize: vertical; }
@media (max-width: 760px) {
  .case-tabbar { padding: 10px 16px 0; }
  .capture .btn.big { flex: 1 1 100%; justify-content: center; }
  .photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
}

/* ---------- Equipo ---------- */
.pill { display: inline-block; white-space: nowrap; font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--k-otro-bg); color: var(--k-otro); }
.pill.admin { background: var(--accent-soft); color: var(--accent); }
.pill.off { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }
.panel-card { border: 1px solid var(--line); border-radius: var(--r); padding: 18px; display: flex; flex-direction: column; gap: 12px; max-width: 640px; margin-bottom: 20px; }
.panel-card h3 { font-size: 17px; }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.row > .bottom { display: flex; align-items: flex-end; flex: 0 0 auto; }
.secret { font-family: var(--f-mono); font-size: 18px; background: var(--bg); border: 1px solid var(--line); padding: 10px 14px; border-radius: 8px; user-select: all; overflow-wrap: anywhere; }

/* ---------- Diálogos ---------- */
.overlay { position: fixed; inset: 0; background: var(--overlay); display: grid; place-items: center; z-index: 50; padding: 16px; overflow-y: auto; }
.dialog { background: var(--panel); border-radius: 14px; padding: 22px; width: min(480px, 100%); display: flex; flex-direction: column; gap: 12px; border: 1px solid var(--line); max-height: calc(100vh - 32px); overflow-y: auto; }
.dialog h3 { font-size: 19px; }
.dialog .btns { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.dialog .btns .left { margin-right: auto; }
.people { display: flex; flex-direction: column; gap: 2px; max-height: 240px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: 6px; }
.person-row { align-items: center; padding: 6px 8px; border-radius: 6px; }
.person-row:hover { background: var(--bg); }
.person-row .who { display: flex; flex-direction: column; min-width: 0; }
.person-row .who strong { font-weight: 600; font-size: 14px; }
.person-row .who small { color: var(--muted); font-size: 12px; }
.person-row .avatar { width: 28px; height: 28px; font-size: 11px; }
.viewer img { max-width: 92vw; max-height: 86vh; border-radius: 8px; display: block; }
.toast { position: fixed; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--panel); padding: 10px 16px; border-radius: 8px; font-size: 14px; z-index: 60; max-width: calc(100% - 32px); }
.connection { background: color-mix(in srgb, var(--danger) 14%, transparent); font-size: 13px; padding: 6px 24px; }

/* ---------- Celular ---------- */
@media (max-width: 900px) {
  .cal { display: block; overflow-y: auto; }
  .cal-main, .agenda { overflow: visible; }
  .agenda { border-left: 0; border-top: 1px solid var(--line); }
  .docs { grid-template-columns: 1fr; }
  .folders { border-right: 0; border-bottom: 1px solid var(--line); flex-direction: row; overflow-x: auto; padding: 10px 16px; }
  .folder { width: auto; white-space: nowrap; flex-shrink: 0; border: 1px solid var(--line); }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .rail { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 40; transform: translateX(-100%); transition: transform .2s ease; padding-top: max(18px, env(safe-area-inset-top, 0px)); }
  .app.nav-open .rail { transform: none; }
  .app.nav-open::after { content: ""; position: fixed; inset: 0; background: var(--overlay); z-index: 30; }
  .menu-btn { display: inline-flex; }
  .head, .composer { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .stream, .body, .cal-main { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .files-tools, .perm { padding-left: 16px; padding-right: 16px; }
  .msg .meta .del { opacity: 1; }
  .cell { min-height: 58px; }
  .cell .ev { display: none; }
  .cell .ev-more { display: none; }
  .cell .dots { display: flex; }
  .legend { margin-left: 0; }
}
.cell .dots { display: none; gap: 3px; flex-wrap: wrap; padding: 0 4px; }
@media (prefers-reduced-motion: reduce) { .rail { transition: none; } }
.link-btn { background: none; border: none; color: var(--accent); text-decoration: underline; padding: 6px 0; font-size: 13px; justify-self: center; }
