/* =====================================================================
   Dana CRM · sistema de diseño inspirado en monday.com
   ===================================================================== */
:root {
  --primary: #0073ea; --primary-hover: #0060b9; --primary-soft: #cce5ff; --primary-softer: #e6f1fd;
  --bg: #f6f7fb; --surface: #ffffff; --surface-hover: #f5f6f8; --surface-head: #f9fafc;
  --text: #1f2330; --text-2: #5f6373; --text-3: #8b8fa0;
  --border: #d5d9e6; --border-light: #e7eaf2;
  --success: #00c875; --warning: #fdab3d; --danger: #e2445c; --purple: #a25ddc; --info: #579bfc;
  --radius: 8px; --radius-sm: 4px;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.06); --shadow: 0 4px 12px rgba(16,24,40,.08); --shadow-lg: 0 12px 40px rgba(16,24,40,.18);
  --sidebar-w: 240px; --topbar-h: 52px;
  --font: "Figtree", "Roboto", -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: var(--font); font-size: 14px; color: var(--text); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4, h5 { font-weight: 600; color: var(--text); letter-spacing: -.01em; }
h3 { font-size: 1.25rem; }
.muted { color: var(--text-2); }
.small { font-size: .8rem; }
.focus-visible, :focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

/* Botones */
.btn-primary, .btn-secondary, .btn-ghost, .btn-danger { border-radius: var(--radius-sm); padding: 6px 14px; font: inherit; font-weight: 500; cursor: pointer; border: 1px solid transparent; line-height: 1.4; white-space: nowrap; transition: background-color .12s, border-color .12s, box-shadow .12s, color .12s; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:focus-visible, .btn-secondary:focus-visible { box-shadow: 0 0 0 3px var(--primary-softer); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: .5; cursor: default; }
.btn-secondary { background: var(--surface); border-color: var(--border); color: var(--text); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { background: var(--surface-hover); }
.btn-ghost { background: transparent; color: var(--text); }
.btn-ghost:hover { background: var(--surface-hover); }
.btn-danger { background: var(--surface); border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 3px 10px; font-size: .8rem; }
.icon-btn { background: transparent; border: 0; border-radius: var(--radius-sm); width: 30px; height: 30px; cursor: pointer; color: var(--text-2); font-size: 1rem; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.icon-btn.tiny { width: 22px; height: 22px; font-size: .75rem; }

/* Formularios */
.form-label { font-size: .8rem; color: var(--text-2); font-weight: 500; margin-bottom: 4px; }
.form-control, .form-select { border: 1px solid var(--border); border-radius: var(--radius-sm); font: inherit; font-size: .9rem; padding: 6px 10px; }
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-softer); }
.validation-message { color: var(--danger); font-size: .78rem; }

/* ---------- Shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border-light); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; height: 100dvh; flex-shrink: 0; overflow: hidden; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content { padding: 20px 24px 40px; flex: 1; min-width: 0; }

.brand { padding: 14px 10px 8px 16px; display: flex; align-items: center; justify-content: space-between; }
.sidebar-toggle { color: var(--text-3); font-size: 1rem; }
.brand-link { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 1.15rem; }
.brand-link:hover { text-decoration: none; }
.brand-logo { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, var(--primary), var(--purple)); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; }
.workspace { margin: 6px 12px 10px; padding: 8px 10px; border: 1px solid var(--border-light); border-radius: var(--radius); display: flex; align-items: center; gap: 10px; background: var(--bg); }
.ws-ico { width: 28px; height: 28px; border-radius: 6px; background: var(--purple); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }
.ws-name { font-weight: 600; font-size: .9rem; }
.ws-sub { font-size: .72rem; color: var(--text-3); }
.nav-list { display: flex; flex-direction: column; padding: 0 8px 8px; gap: 2px; flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; }
.nav-list::-webkit-scrollbar { width: 6px; }
.nav-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.nav-section { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); padding: 12px 10px 4px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius-sm); color: var(--text); font-weight: 500; position: relative; }
/* Sidebar contraído: solo iconos, texto como tooltip */
.sidebar { transition: width .18s ease; }
.sidebar.collapsed { width: 64px; }
.sidebar.collapsed .brand { padding: 14px 0 8px; flex-direction: column; gap: 6px; }
.sidebar.collapsed .brand-name, .sidebar.collapsed .ws-text, .sidebar.collapsed .nav-section, .sidebar.collapsed .nav-item > span:not(.nav-dot) { display: none; }
.sidebar.collapsed .workspace { margin: 6px 8px 10px; padding: 6px; justify-content: center; }
.sidebar.collapsed .nav-list { padding: 0 8px; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 9px 0; }
.sidebar.collapsed .nav-item .nav-dot { margin: 0; width: 14px; height: 14px; }
.nav-item:hover { background: var(--surface-hover); text-decoration: none; }
.nav-item.active { background: var(--primary-softer); color: var(--primary); font-weight: 600; }
.nav-item.active::before { content: ""; position: absolute; left: -8px; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0; background: var(--primary); }
.nav-svg { width: 18px; height: 18px; }
.nav-dot { width: 10px; height: 10px; border-radius: 3px; margin: 0 4px; }

.topbar { height: var(--topbar-h); background: var(--surface); border-bottom: 1px solid var(--border-light); display: flex; align-items: center; gap: 12px; padding: 0 20px; position: sticky; top: 0; z-index: 30; }
.topbar-search { display: flex; align-items: center; gap: 6px; background: var(--bg); border: 1px solid var(--border-light); border-radius: var(--radius-sm); padding: 4px 10px; width: 320px; max-width: 50vw; }
.topbar-search input { border: 0; background: transparent; outline: 0; font: inherit; width: 100%; }
.topbar-search:focus-within { background: var(--surface); border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-softer); }
.search-ico { color: var(--text-3); }
.topbar-spacer { flex: 1; }
.nav-toggle { display: none; }
.user-menu { position: relative; }
.user-btn { display: flex; align-items: center; gap: 8px; background: transparent; border: 0; cursor: pointer; font: inherit; padding: 4px 6px; border-radius: var(--radius-sm); }
.user-btn:hover { background: var(--surface-hover); }
.user-name { font-weight: 500; }
.menu-backdrop { position: fixed; inset: 0; z-index: 40; }
.dropdown-panel { position: absolute; right: 0; top: 40px; background: var(--surface); border: 1px solid var(--border-light); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 180px; z-index: 41; padding: 6px; display: flex; flex-direction: column; }
.dropdown-panel a, .dropdown-panel button { display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; background: transparent; color: var(--text); border-radius: var(--radius-sm); font: inherit; cursor: pointer; }
.dropdown-panel a:hover, .dropdown-panel button:hover { background: var(--surface-hover); text-decoration: none; }

.avatar { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.avatar-letter { display: inline-flex; align-items: center; justify-content: center; color: #fff; font-weight: 600; font-size: .78rem; background: var(--text-3); }
.avatar-sm { width: 24px; height: 24px; font-size: .68rem; }
.person-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; }
.person-chip.empty .avatar { background: transparent; border: 1px dashed var(--border); color: var(--text-3); }

/* ---------- Encabezado de página / tablero ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.page-head h3 { margin: 0; font-size: 1.55rem; font-weight: 700; letter-spacing: -.02em; }
.page-head .sub { color: var(--text-2); font-size: .85rem; margin-top: 2px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.view-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border-light); margin-bottom: 12px; }
.view-tab { padding: 8px 12px; border: 0; background: transparent; color: var(--text-2); font: inherit; font-weight: 500; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.view-tab:hover { color: var(--text); background: var(--surface-hover); border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.view-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.toolbar .search { display: flex; align-items: center; gap: 6px; border: 1px solid var(--border-light); border-radius: var(--radius-sm); padding: 4px 8px; background: var(--surface); }
.toolbar .search input { border: 0; outline: 0; font: inherit; width: 180px; }
.toolbar select { border: 1px solid var(--border-light); border-radius: var(--radius-sm); padding: 5px 8px; font: inherit; background: var(--surface); color: var(--text); }
.toolbar .tool { display: inline-flex; align-items: center; gap: 6px; border: 1px solid transparent; border-radius: var(--radius-sm); padding: 5px 10px; background: transparent; color: var(--text); font: inherit; cursor: pointer; }
.toolbar .tool:hover { background: var(--surface-hover); }
.toolbar .tool.on { background: var(--primary-soft); color: var(--primary-hover); }

/* ---------- Tablero (tabla) ---------- */
.board-scroll { overflow-x: auto; overflow-y: hidden; padding-bottom: 10px; margin: 0 -24px; padding-left: 24px; padding-right: 24px; }
.board { display: flex; flex-direction: column; gap: 22px; min-width: 0; }
.board.has-popover { padding-bottom: 320px; }
.board-group { --group-color: var(--primary); }
.group-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; color: var(--group-color); position: sticky; left: 24px; width: fit-content; }
.group-toggle { border: 0; background: transparent; color: inherit; cursor: pointer; font-size: .9rem; width: 22px; }
.group-title { font-weight: 600; font-size: 1rem; }
.group-count { color: var(--text-3); font-size: .8rem; font-weight: 400; }
.board-table-wrap { overflow: visible; background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border-light); box-sizing: content-box; }
.board-table { border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.board-table th, .board-table td { border-right: 1px solid var(--border-light); border-bottom: 1px solid var(--border-light); height: 36px; padding: 0; font-size: .85rem; vertical-align: middle; }
.board-table th { font-weight: 600; font-size: .8rem; color: var(--text-2); text-align: center; background: var(--surface-head); user-select: none; cursor: pointer; }
.board-table th:hover { background: var(--surface-hover); }
.board-table th.sorted { color: var(--primary); }
.board-table .col-sel { width: 36px; text-align: center; border-left: 6px solid var(--group-color); }
.board-table th.col-sel { border-left-color: var(--group-color); border-top-left-radius: var(--radius); }
.board-table .col-name { width: 300px; text-align: left; padding: 0 8px; }
.board-table .col-fill { border-right: 0; width: auto; min-width: 20px; }
.board-table tbody tr:hover td { background: var(--surface-hover); }
.board-table tbody tr.selected td { background: var(--primary-softer); }
.name-cell { display: flex; align-items: center; gap: 6px; }
.item-name { flex: 1; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-name:hover { text-decoration: underline; }
.open-btn, .cell-edit-btn { opacity: 0; border: 1px solid var(--border-light); background: var(--surface); border-radius: var(--radius-sm); font-size: .72rem; padding: 1px 6px; cursor: pointer; color: var(--text-2); }
.board-table tr:hover .open-btn, .board-table tr:hover .cell-edit-btn { opacity: 1; }
.open-btn:hover, .cell-edit-btn:hover { color: var(--primary); border-color: var(--primary); }
.cell { position: relative; text-align: center; cursor: pointer; }
.cell .cell-text { display: block; padding: 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 36px; }
.cell.cell-number .cell-text, .cell.cell-money .cell-text { text-align: right; font-variant-numeric: tabular-nums; }
.cell.readonly { cursor: default; color: var(--text-2); }
.cell.cell-status { padding: 0; }
.status-pill { display: flex; align-items: center; justify-content: center; height: 36px; color: #fff; font-weight: 500; font-size: .82rem; cursor: pointer; }
.status-pill.empty { background: #c4c4c4; }
.cell-editor { width: 100%; height: 36px; border: 2px solid var(--primary); border-radius: 0; padding: 0 8px; font: inherit; font-size: .85rem; outline: 0; background: var(--surface); }
textarea.cell-editor { height: auto; min-height: 72px; resize: vertical; position: absolute; left: 0; top: 0; z-index: 5; box-shadow: var(--shadow); }
.cell-link { color: var(--primary); }
.cell-empty { color: var(--text-3); }

.popover-backdrop { position: fixed; inset: 0; z-index: 50; cursor: default; }
.popover { position: absolute; left: 0; top: 36px; min-width: 240px; z-index: 51; background: var(--surface); border: 1px solid var(--border-light); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 8px; min-width: 100%; text-align: left; cursor: default; }
.popover.popover-right { left: auto; right: 0; }
.status-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; min-width: 240px; }
.status-opt { height: 32px; border: 0; border-radius: var(--radius-sm); color: #fff; font: inherit; font-size: .8rem; font-weight: 500; cursor: pointer; padding: 0 8px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.status-opt:hover { filter: brightness(1.08); outline: 2px solid var(--text); outline-offset: -2px; }
.status-opt.selected { outline: 2px solid var(--text); outline-offset: -2px; }
.status-opt.clear { background: #c4c4c4; }
.list-popover { min-width: 240px; max-height: 300px; overflow-y: auto; }
.list-popover input { width: 100%; margin-bottom: 6px; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 5px 8px; font: inherit; }
.list-opt { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: transparent; padding: 6px 8px; border-radius: var(--radius-sm); font: inherit; text-align: left; cursor: pointer; }
.list-opt:hover { background: var(--surface-hover); }
.list-opt.selected { background: var(--primary-softer); color: var(--primary-hover); }

.add-row td { height: 34px; }
.add-input { width: 100%; height: 34px; border: 0; padding: 0 8px; font: inherit; font-size: .85rem; outline: 0; background: transparent; }
.add-input:focus { background: var(--surface-hover); }
.summary-row td { height: 32px; background: var(--bg); border-bottom: 0; }
.summary-row .sum { display: block; padding: 0 8px; text-align: right; font-size: .78rem; color: var(--text-2); font-variant-numeric: tabular-nums; line-height: 32px; white-space: nowrap; overflow: hidden; }
.summary-row .sum small { margin-left: 4px; color: var(--text-3); }
.summary-row .sum b { color: var(--text); }
.status-bar { display: flex; height: 22px; margin: 5px 8px; border-radius: 3px; overflow: hidden; background: var(--border-light); }
.status-bar span { display: block; height: 100%; }
.date-range { font-size: .78rem; color: var(--text-2); }

.board-empty { padding: 32px; text-align: center; color: var(--text-2); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }

/* Menú de columna, agregar columna, hojas modales */
.board-table th { position: relative; }
.th-menu-btn { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); opacity: 0; border: 0; background: var(--surface); border-radius: 3px; width: 20px; height: 20px; cursor: pointer; color: var(--text-2); font-size: .75rem; }
.board-table th:hover .th-menu-btn, .board-table th.menu-open .th-menu-btn { opacity: 1; }
.column-menu { min-width: 220px; display: flex; flex-direction: column; font-weight: 400; color: var(--text); text-align: left; }
.column-menu .list-opt:disabled { opacity: .4; cursor: default; }
.column-menu .list-opt.danger { color: var(--danger); }
.add-col-btn { border: 1px dashed var(--border); background: transparent; border-radius: 4px; width: 26px; height: 26px; cursor: pointer; color: var(--text-2); font-size: 1rem; line-height: 1; margin-left: 6px; }
.add-col-btn:hover { color: var(--primary); border-color: var(--primary); }
.cell-check { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; vertical-align: middle; }
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 80; }
.sheet { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(520px, 94vw); max-height: 90vh; display: flex; flex-direction: column; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-lg); z-index: 81; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border-light); }
.sheet-body { padding: 16px; overflow-y: auto; }
.sheet-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border-light); }
.type-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.type-opt { border: 1px solid var(--border-light); background: var(--surface); border-radius: var(--radius-sm); padding: 8px; font: inherit; font-size: .85rem; cursor: pointer; text-align: left; }
.type-opt:hover { background: var(--surface-hover); }
.type-opt.selected { border-color: var(--primary); background: var(--primary-softer); color: var(--primary-hover); }
.label-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.label-row .form-control-color { width: 42px; padding: 2px; flex-shrink: 0; }
.tool-wrap { position: relative; }
.filter-panel { min-width: 560px; max-width: 90vw; left: 0; right: auto; }
.filter-row { display: grid; grid-template-columns: 1.2fr 1fr 1.2fr 28px; gap: 6px; align-items: center; margin-bottom: 6px; }
.filter-row select, .filter-row input { border: 1px solid var(--border-light); border-radius: var(--radius-sm); padding: 5px 8px; font: inherit; font-size: .85rem; min-width: 0; }
.view-tab.saved { color: var(--text); }
.view-tab.add { color: var(--text-3); font-weight: 400; }
.view-del { margin-left: 6px; color: var(--text-3); font-size: .75rem; }
.view-del:hover { color: var(--danger); }
@media (max-width: 700px) { .filter-panel { min-width: 90vw; } .filter-row { grid-template-columns: 1fr 1fr; } }

/* Barra de selección masiva */
.bulk-bar { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 0; z-index: 45; overflow: hidden; border: 1px solid var(--border-light); }
.bulk-count { background: var(--primary); color: #fff; font-weight: 700; font-size: 1.2rem; width: 54px; align-self: stretch; display: flex; align-items: center; justify-content: center; margin: -10px 0; }
.bulk-bar select { border: 1px solid var(--border-light); border-radius: var(--radius-sm); padding: 5px 8px; font: inherit; }

/* ---------- Kanban ---------- */
.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.kanban-col { flex: 0 0 280px; background: var(--bg); border-radius: var(--radius); min-height: 60vh; display: flex; flex-direction: column; border: 1px solid var(--border-light); }
.kanban-col.drag-over { background: var(--primary-softer); outline: 2px dashed var(--primary); }
.kanban-head { padding: 8px 12px; border-radius: var(--radius) var(--radius) 0 0; color: #fff; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.kanban-head .meta { font-weight: 400; font-size: .78rem; opacity: .9; }
.kanban-body { padding: 8px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.kanban-card { background: var(--surface); border: 1px solid var(--border-light); border-radius: var(--radius); padding: 10px 12px; cursor: grab; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.kanban-card:hover { box-shadow: var(--shadow); }
.kanban-card:active { cursor: grabbing; }
.kanban-card.dragging { opacity: .5; }
.kanban-card .title { font-weight: 600; font-size: .9rem; cursor: pointer; margin-bottom: 6px; }
.kanban-card .title:hover { text-decoration: underline; color: var(--primary); }
.kanban-card .kv { display: flex; justify-content: space-between; gap: 8px; font-size: .78rem; color: var(--text-2); padding: 2px 0; }
.kanban-card .kv b { color: var(--text); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kanban-card .pill { color: #fff; border-radius: 3px; padding: 1px 8px; font-size: .74rem; font-weight: 500; }
.kanban-add { border: 1px dashed var(--border); background: transparent; border-radius: var(--radius); padding: 8px; color: var(--text-2); font: inherit; cursor: pointer; }
.kanban-add:hover { background: var(--surface); color: var(--primary); }

/* ---------- Drawer ---------- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.25); z-index: 60; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(880px, 94vw); background: var(--bg); z-index: 61; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slide-in .18s ease-out; }
@keyframes slide-in { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border-light); }
.drawer-title { font-weight: 600; color: var(--text-2); font-size: .85rem; }
.drawer-body { overflow-y: auto; padding: 16px 20px 32px; flex: 1; }

/* ---------- Vista de elemento ---------- */
.item-view { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.item-view.single { grid-template-columns: 1fr; }
@media (max-width: 1100px) { .item-view { grid-template-columns: 1fr; } }
.card { background: var(--surface); border: 1px solid var(--border-light); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-header { padding: 10px 16px; border-bottom: 1px solid var(--border-light); font-weight: 600; display: flex; align-items: center; justify-content: space-between; background: var(--surface); border-radius: var(--radius) var(--radius) 0 0; }
.card-body { padding: 16px; }
.card-footer { padding: 10px 16px; border-top: 1px solid var(--border-light); background: var(--bg); border-radius: 0 0 var(--radius) var(--radius); }
.item-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border-light); margin-bottom: 12px; }
.stage-bar { display: flex; flex-wrap: wrap; gap: 6px; }
.stage-step { border: 2px solid #ccc; background: var(--surface); border-radius: 999px; padding: 3px 12px; font-size: .78rem; font: inherit; cursor: pointer; }
.stage-step.active { font-weight: 600; color: #fff; }

.updates { display: flex; flex-direction: column; gap: 10px; }
.composer { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; }
.composer textarea { width: 100%; border: 0; outline: 0; resize: vertical; font: inherit; font-size: .9rem; }
.composer-actions { display: flex; justify-content: flex-end; }
.update { display: flex; gap: 10px; background: var(--surface); border: 1px solid var(--border-light); border-radius: var(--radius); padding: 12px; }
.update.system { background: transparent; border-color: transparent; padding: 4px 12px; }
.update.system .avatar { width: 24px; height: 24px; font-size: .65rem; }
.update.system .update-text { color: var(--text-2); font-size: .85rem; }
.update-body { flex: 1; min-width: 0; }
.update-meta { display: flex; gap: 8px; align-items: center; font-size: .8rem; margin-bottom: 4px; }
.update-text { white-space: pre-wrap; word-break: break-word; }
.updates-empty { text-align: center; padding: 24px; color: var(--text-2); }
.updates-empty-ico { font-size: 2rem; }
.badge-soft { background: var(--bg); border: 1px solid var(--border-light); border-radius: 999px; padding: 0 8px; font-size: .7rem; color: var(--text-2); }
.timeline { list-style: none; padding-left: 0; margin: 0; }
.timeline li { position: relative; padding-left: 1.25rem; padding-bottom: .6rem; border-left: 2px solid var(--border-light); margin-left: .35rem; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: .3rem; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }
.timeline .when { font-size: .75rem; color: var(--text-2); }

/* ---------- Dashboard ---------- */
.widgets { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px; }
.widget { background: var(--surface); border: 1px solid var(--border-light); border-radius: var(--radius); padding: 16px 18px; min-width: 0; box-shadow: var(--shadow-sm); }
.widget-title { font-weight: 600; font-size: .9rem; color: var(--text-2); margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; }
.w-3 { grid-column: span 3; } .w-4 { grid-column: span 4; } .w-6 { grid-column: span 6; } .w-8 { grid-column: span 8; } .w-12 { grid-column: span 12; }
@media (max-width: 1100px) { .w-3 { grid-column: span 6; } .w-4, .w-8 { grid-column: span 12; } }
@media (max-width: 640px) { .w-3, .w-6 { grid-column: span 12; } }
.number-widget { color: #fff; border: 0; display: block; }
.number-widget:hover { text-decoration: none; filter: brightness(1.05); }
.number-widget .label { font-size: .8rem; opacity: .9; }
.number-widget .value { font-size: 2.1rem; font-weight: 700; line-height: 1.1; }
.number-widget .foot { font-size: .78rem; opacity: .85; margin-top: 2px; }
.funnel-row { display: grid; grid-template-columns: 150px 1fr 110px; gap: 10px; align-items: center; margin-bottom: 6px; font-size: .85rem; }
.funnel-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.funnel-bar { background: var(--bg); border-radius: 4px; height: 16px; overflow: hidden; }
.funnel-bar > div { height: 100%; border-radius: 4px; }
.funnel-count { text-align: right; color: var(--text-2); }
.battery { display: flex; height: 26px; border-radius: 4px; overflow: hidden; background: var(--bg); margin-bottom: 8px; }
.battery span { display: flex; align-items: center; justify-content: center; color: #fff; font-size: .75rem; font-weight: 600; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: .78rem; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
.feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.feed li { display: flex; gap: 8px; align-items: flex-start; font-size: .85rem; }
.feed .when { color: var(--text-3); font-size: .75rem; }
.list-rows { list-style: none; margin: 0; padding: 0; }
.list-rows li { display: flex; justify-content: space-between; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--border-light); font-size: .85rem; }
.list-rows li:last-child { border-bottom: 0; }
.empty-state { text-align: center; padding: 40px 16px; color: var(--text-2); }

/* ---------- Páginas de cuenta ---------- */
.auth-page { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.5rem; background: linear-gradient(160deg, #0f172a, #1e293b); color: #fff; padding: 1rem; }
.auth-brand { font-size: 2.2rem; font-weight: 700; }
.auth-brand small { font-weight: 400; opacity: .7; }
.auth-box { background: #fff; color: #111; border-radius: 1rem; padding: 2rem; max-width: 420px; width: 100%; text-align: center; box-shadow: var(--shadow-lg); }
.auth-sep { display: flex; align-items: center; gap: .75rem; color: #9ca3af; font-size: .8rem; margin: 1rem 0; }
.auth-sep::before, .auth-sep::after { content: ""; flex: 1; border-top: 1px solid #e5e7eb; }
.auth-box .btn-primary { width: 100%; padding: 9px; }

/* ---------- Utilidades ---------- */
.badge-pill { display: inline-block; border-radius: 999px; padding: 2px 10px; color: #fff; font-size: .75rem; font-weight: 500; }
.stage-dot { display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; vertical-align: middle; margin-right: .3rem; }
.text-nowrap { white-space: nowrap; }
table.crm-table td, table.crm-table th { vertical-align: middle; }

/* Blazor */
#blazor-error-ui { color-scheme: light only; background: lightyellow; bottom: 0; box-shadow: 0 -1px 2px rgba(0,0,0,.2); box-sizing: border-box; display: none; left: 0; padding: .6rem 1.25rem .7rem 1.25rem; position: fixed; width: 100%; z-index: 1000; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }
.blazor-error-boundary { background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121; padding: 1rem 1rem 1rem 3.7rem; color: white; }
.blazor-error-boundary::after { content: "Ocurrió un error."; }

/* Responsive */
@media (max-width: 900px) {
  .board-scroll { margin: 0 -12px; padding-left: 12px; padding-right: 12px; }
  .group-header { left: 12px; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 70; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .nav-toggle { display: inline-flex; }
  .content { padding: 14px 12px 32px; }
  .board-table .col-name { width: 200px; }
}

/* ---------- Etapa 3: actividades, menciones, adjuntos, notificaciones ---------- */
.mention-wrap { position: relative; }
.mention-list { position: absolute; left: 8px; bottom: 100%; background: var(--surface); border: 1px solid var(--border-light); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; min-width: 240px; z-index: 20; }
.mention { color: var(--primary); font-weight: 600; background: var(--primary-softer); border-radius: 3px; padding: 0 3px; }
.file-btn { position: relative; overflow: hidden; cursor: pointer; display: inline-block; }
.file-btn input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.composer-actions { display: flex; justify-content: flex-end; gap: 8px; align-items: center; }
.pending-files { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 0; }
.chip { background: var(--bg); border: 1px solid var(--border-light); border-radius: 999px; padding: 2px 10px; font-size: .78rem; }
.files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.file-chip { display: flex; align-items: center; gap: 6px; border: 1px solid var(--border-light); border-radius: var(--radius); padding: 6px 10px; background: var(--surface); color: var(--text); font-size: .8rem; max-width: 220px; }
.file-chip:hover { text-decoration: none; border-color: var(--primary); }
.file-chip img { width: 36px; height: 36px; object-fit: cover; border-radius: 4px; }
.file-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.task-form { display: flex; flex-direction: column; gap: 8px; background: var(--bg); border-radius: var(--radius); padding: 12px; margin-bottom: 12px; }
.task-form-row { display: grid; grid-template-columns: 1.4fr 1fr 1.2fr; gap: 8px; }
.kind-picker { display: flex; gap: 6px; flex-wrap: wrap; }
.kind-opt { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 4px 12px; font: inherit; font-size: .82rem; cursor: pointer; }
.task-list { list-style: none; margin: 0; padding: 0; }
.task-list li { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border-light); }
.task-list li:last-child { border-bottom: 0; }
.task-list li.done .task-title { text-decoration: line-through; color: var(--text-3); }
.task-list li.overdue .task-meta { color: var(--danger); }
.task-kind { width: 26px; height: 26px; border-radius: 6px; color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: .85rem; flex-shrink: 0; }
.task-main { flex: 1; min-width: 0; }
.task-title { font-weight: 500; }
.task-meta { font-size: .78rem; color: var(--text-2); display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.task-notes { font-size: .82rem; color: var(--text-2); white-space: pre-wrap; margin-top: 2px; }
.task-entity { font-size: .78rem; }

.mywork-section { margin-bottom: 20px; }
.mywork-section h5 { font-size: .95rem; margin: 0 0 6px; display: flex; align-items: center; gap: 8px; }
.mywork-section h5 .count { background: var(--bg); border-radius: 999px; padding: 0 8px; font-size: .75rem; color: var(--text-2); }
.mywork-section.overdue h5 { color: var(--danger); }
.mywork-section.today h5 { color: var(--primary); }

.bell { position: relative; }
.bell-badge { position: absolute; top: 2px; right: 2px; background: var(--danger); color: #fff; border-radius: 999px; font-size: .65rem; min-width: 16px; height: 16px; display: flex; align-items: center; justify-content: center; padding: 0 4px; font-weight: 700; }
.notif-panel { min-width: 340px; max-width: 90vw; max-height: 70vh; overflow-y: auto; }
.notif { display: flex; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer; align-items: flex-start; }
.notif:hover { background: var(--surface-hover); }
.notif.unread { background: var(--primary-softer); }
.notif .when { font-size: .72rem; color: var(--text-3); }
.notif-head { display: flex; justify-content: space-between; align-items: center; padding: 4px 10px 8px; border-bottom: 1px solid var(--border-light); margin-bottom: 4px; }

/* ---------- Etapa 4: API, automatizaciones, formularios, tutorial ---------- */
pre.code { background: #1e293b; color: #e2e8f0; border-radius: var(--radius); padding: 12px 14px; font-size: .8rem; overflow-x: auto; white-space: pre; margin-bottom: 12px; }
pre.code.small { font-size: .72rem; max-height: 160px; }
.recipe { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .95rem; }
.recipe .when { background: #fff4e5; border: 1px solid #fdab3d; color: #8a5400; border-radius: 999px; padding: 3px 12px; }
.recipe .then { background: #e6f1fd; border: 1px solid var(--primary); color: var(--primary-hover); border-radius: 999px; padding: 3px 12px; }
.recipe .arrow { color: var(--text-3); }
.recipe-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 10px; }
.recipe-card { border: 1px solid var(--border-light); border-radius: var(--radius); padding: 12px; background: var(--surface); cursor: pointer; }
.recipe-card:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.action-row { display: grid; grid-template-columns: 200px 1fr 28px; gap: 8px; align-items: start; padding: 8px; border: 1px solid var(--border-light); border-radius: var(--radius); margin-bottom: 8px; background: var(--bg); }
.action-params { display: flex; flex-wrap: wrap; gap: 6px; }
.action-params input, .action-params select { border: 1px solid var(--border-light); border-radius: var(--radius-sm); padding: 5px 8px; font: inherit; font-size: .85rem; }
.action-params input.wide { min-width: 280px; flex: 1; }
.tut-flow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; margin: 12px 0 20px; }
.tut-node { border-radius: 12px; padding: 12px 18px; color: #fff; text-align: center; min-width: 150px; box-shadow: var(--shadow); }
.tut-node small { display: block; opacity: .9; font-size: .75rem; }
.tut-arrow { font-size: 1.6rem; color: var(--text-3); }
.tut-steps { counter-reset: step; }
.tut-step { display: flex; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--border-light); }
.tut-step:last-child { border-bottom: 0; }
.tut-step .num { width: 30px; height: 30px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }
.tut-step.done .num { background: var(--success); }
.tut-step .num::before { content: counter(step); counter-increment: step; }
.tut-step.done .num::before { content: "✓"; }
.tut-tip { background: #fff8e6; border-left: 4px solid var(--warning); padding: 10px 12px; border-radius: 0 var(--radius) var(--radius) 0; font-size: .9rem; }
.tut-nav { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tut-nav a { border: 1px solid var(--border-light); border-radius: 999px; padding: 4px 12px; color: var(--text); font-size: .85rem; background: var(--surface); }
.tut-nav a:hover { text-decoration: none; border-color: var(--primary); color: var(--primary); }
.onboarding { background: linear-gradient(120deg, #e6f1fd, #f3e8ff); border: 1px solid var(--border-light); border-radius: var(--radius); padding: 14px 18px; display: flex; gap: 14px; align-items: center; margin-bottom: 16px; }
.onboarding .big { font-size: 1.8rem; }
.pub-form { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 20px; }
.pub-card { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); width: min(520px, 100%); padding: 28px; border-top: 6px solid var(--accent, var(--primary)); }
.pub-card h2 { margin: 0 0 4px; }
.pub-card .btn-primary { width: 100%; padding: 10px; background: var(--accent, var(--primary)); margin-top: 6px; }
.hp { position: absolute; left: -9999px; }

/* ---------- Etapa 5: informes, gráficos, calendario, cronograma ---------- */
.chart { position: relative; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--border-light); stroke-width: 1; }
.chart .tick { font-size: 10px; fill: var(--text-2); }
.chart .crosshair { stroke: var(--text-3); stroke-dasharray: 3 3; }
.chart-empty { color: var(--text-3); padding: 24px; text-align: center; }
.chart-tip { position: absolute; top: 8px; right: 8px; background: var(--surface); border: 1px solid var(--border-light); border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 6px 10px; font-size: .78rem; pointer-events: none; }
.chart-tip i, .legend-list i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.donut-wrap { display: grid; grid-template-columns: 160px 1fr; gap: 12px; align-items: center; }
.donut { width: 160px; height: 160px; }
.donut-seg { transition: stroke-width .1s; }
.donut-total { font-size: 15px; font-weight: 700; fill: var(--text); }
.donut-label { font-size: 9px; fill: var(--text-2); }
.legend-list { list-style: none; margin: 0; padding: 0; font-size: .8rem; }
.legend-list li { display: grid; grid-template-columns: 16px 1fr auto auto; gap: 6px; padding: 3px 4px; border-radius: 4px; align-items: center; }
.legend-list li.on { background: var(--surface-hover); }
.legend-list small { color: var(--text-3); }
.lg-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.funnel-chart .fc-row { display: grid; grid-template-columns: 140px 1fr 80px; gap: 10px; align-items: center; padding: 3px 4px; border-radius: 4px; font-size: .85rem; }
.funnel-chart .fc-row.on { background: var(--surface-hover); }
.fc-bar { background: var(--bg); height: 18px; border-radius: 4px; overflow: hidden; }
.fc-bar > div { height: 100%; border-radius: 4px; }
.fc-val { text-align: right; font-variant-numeric: tabular-nums; }
.hero-number { font-size: 2.2rem; font-weight: 700; line-height: 1.1; }
.hero-number.small-hero { font-size: 1.4rem; margin-bottom: 6px; }
.report-table { width: 100%; border-collapse: collapse; font-size: .82rem; margin-top: 8px; }
.report-table th, .report-table td { padding: 5px 8px; border-bottom: 1px solid var(--border-light); text-align: left; }
.report-table th { color: var(--text-2); font-weight: 500; }
.report-table td:not(:first-child), .report-table th:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
.report-widget .widget-title small { font-size: .75rem; }

.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { text-align: center; font-size: .75rem; color: var(--text-2); padding: 4px 0; }
.cal-day { background: var(--surface); border: 1px solid var(--border-light); border-radius: var(--radius-sm); min-height: 96px; padding: 4px; display: flex; flex-direction: column; gap: 3px; }
.cal-day.other { opacity: .5; }
.cal-day.today { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.cal-num { font-size: .78rem; color: var(--text-2); text-align: right; }
.cal-day.today .cal-num { color: var(--primary); font-weight: 700; }
.cal-ev { display: block; width: 100%; text-align: left; border: 0; border-left: 3px solid; background: var(--bg); border-radius: 3px; padding: 2px 5px; font: inherit; font-size: .72rem; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.cal-ev:hover { background: var(--primary-softer); text-decoration: none; }
.cal-ev.done { text-decoration: line-through; opacity: .6; }
@media (max-width: 700px) { .cal-day { min-height: 60px; } .cal-ev { font-size: .62rem; } }

.gantt { background: var(--surface); border: 1px solid var(--border-light); border-radius: var(--radius); overflow: hidden; }
.gantt-head, .gantt-row { display: grid; grid-template-columns: 260px 1fr; border-bottom: 1px solid var(--border-light); }
.gantt-label { padding: 6px 10px; display: flex; flex-direction: column; min-width: 0; }
.gantt-label .link-btn { background: none; border: 0; padding: 0; text-align: left; font: inherit; color: var(--text); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gantt-label .link-btn:hover { color: var(--primary); text-decoration: underline; }
.gantt-scale, .gantt-track { position: relative; min-height: 34px; background-image: linear-gradient(to right, var(--border-light) 1px, transparent 1px); background-size: calc(100% / 12) 100%; }
.gantt-week { position: absolute; top: 8px; font-size: .7rem; color: var(--text-2); padding-left: 4px; white-space: nowrap; overflow: hidden; }
.gantt-group { background: var(--bg); padding: 6px 10px; font-weight: 600; border-bottom: 1px solid var(--border-light); }
.gantt-bar { position: absolute; top: 7px; height: 20px; border-radius: 4px; color: #fff; font-size: .7rem; line-height: 20px; padding: 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; box-shadow: 0 1px 2px rgba(0,0,0,.15); }
.gantt-bar.late { outline: 2px solid var(--danger); outline-offset: 1px; }
.gantt-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--danger); opacity: .6; pointer-events: none; }
@media (max-width: 700px) { .gantt-head, .gantt-row { grid-template-columns: 140px 1fr; } }
.iframe-preview { background: repeating-linear-gradient(45deg, #f3f4f6, #f3f4f6 10px, #fafafa 10px, #fafafa 20px); border: 1px dashed var(--border); border-radius: var(--radius); padding: 16px; }

/* ---------- Modo oscuro ---------- */
:root[data-theme="dark"] {
  --primary: #3987e5; --primary-hover: #5598e7; --primary-soft: #1c3a5e; --primary-softer: #17273a;
  --bg: #121417; --surface: #1b1e23; --surface-hover: #242830; --surface-head: #20242b;
  --text: #e8e9ee; --text-2: #a9adb8; --text-3: #7d828f;
  --border: #3a3f4a; --border-light: #2a2e36;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3); --shadow: 0 4px 12px rgba(0,0,0,.4); --shadow-lg: 0 12px 40px rgba(0,0,0,.6);
}
:root[data-theme="dark"] body { color-scheme: dark; }
:root[data-theme="dark"] .form-control, :root[data-theme="dark"] .form-select, :root[data-theme="dark"] .toolbar select, :root[data-theme="dark"] .cell-editor, :root[data-theme="dark"] .composer, :root[data-theme="dark"] .composer textarea, :root[data-theme="dark"] .add-input, :root[data-theme="dark"] .topbar-search input, :root[data-theme="dark"] .list-popover input, :root[data-theme="dark"] .filter-row select, :root[data-theme="dark"] .filter-row input, :root[data-theme="dark"] .action-params input, :root[data-theme="dark"] .action-params select { background: var(--surface); color: var(--text); border-color: var(--border); }
:root[data-theme="dark"] .th-menu-btn, :root[data-theme="dark"] .open-btn, :root[data-theme="dark"] .cell-edit-btn, :root[data-theme="dark"] .status-opt.clear { background: var(--surface-hover); color: var(--text); }
:root[data-theme="dark"] .kanban-col { background: var(--surface-hover); }
:root[data-theme="dark"] .kanban-card, :root[data-theme="dark"] .task-form, :root[data-theme="dark"] .update, :root[data-theme="dark"] .recipe-card, :root[data-theme="dark"] .action-row, :root[data-theme="dark"] .cal-day, :root[data-theme="dark"] .gantt, :root[data-theme="dark"] .pub-card, :root[data-theme="dark"] .auth-box { background: var(--surface); color: var(--text); border-color: var(--border-light); }
:root[data-theme="dark"] .stat-card, :root[data-theme="dark"] .widget, :root[data-theme="dark"] .card, :root[data-theme="dark"] .card-header, :root[data-theme="dark"] .board-table th, :root[data-theme="dark"] .sheet, :root[data-theme="dark"] .popover, :root[data-theme="dark"] .dropdown-panel, :root[data-theme="dark"] .drawer-head, :root[data-theme="dark"] .mention-list, :root[data-theme="dark"] .file-chip, :root[data-theme="dark"] .chart-tip { background: var(--surface); color: var(--text); border-color: var(--border-light); }
:root[data-theme="dark"] .card-footer, :root[data-theme="dark"] .summary-row td, :root[data-theme="dark"] .funnel-bar, :root[data-theme="dark"] .fc-bar, :root[data-theme="dark"] .battery, :root[data-theme="dark"] .status-bar, :root[data-theme="dark"] .workspace, :root[data-theme="dark"] .chip, :root[data-theme="dark"] .badge-soft, :root[data-theme="dark"] .gantt-group, :root[data-theme="dark"] .iframe-preview { background: var(--surface-hover); color: var(--text); border-color: var(--border-light); }
:root[data-theme="dark"] .drawer { background: var(--bg); }
:root[data-theme="dark"] .recipe .when { background: #3b2d12; color: #fdab3d; }
:root[data-theme="dark"] .recipe .then { background: var(--primary-softer); color: var(--primary); }
:root[data-theme="dark"] .onboarding { background: linear-gradient(120deg, #17273a, #2a1f3d); }
:root[data-theme="dark"] .tut-tip { background: #3b2d12; }
:root[data-theme="dark"] pre.code { background: #0b0e14; }
:root[data-theme="dark"] .alert { background: var(--surface-hover); color: var(--text); border-color: var(--border); }
:root[data-theme="dark"] .table, :root[data-theme="dark"] .table > :not(caption) > * > * { color: var(--text); background: transparent; border-color: var(--border-light); }
:root[data-theme="dark"] .table-hover > tbody > tr:hover > * { background: var(--surface-hover); color: var(--text); }
:root[data-theme="dark"] .status-opt { outline-color: #fff; }
:root[data-theme="dark"] #components-reconnect-modal { background: var(--surface); color: var(--text); }

/* ---------- Etapa 6: permisos, cotizaciones, impresión ---------- */
.perm-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 8px; min-width: 260px; }
.perm-grid label { display: flex; flex-direction: column; gap: 2px; color: var(--text-2); }
.quote-lines input { min-width: 60px; }
.print-page { max-width: 820px; margin: 0 auto; background: #fff; color: #111; padding: 40px; font-size: 13px; min-height: 100vh; }
.print-bar { display: flex; gap: 8px; margin-bottom: 20px; }
.print-head { display: flex; justify-content: space-between; border-bottom: 3px solid #0073ea; padding-bottom: 14px; margin-bottom: 18px; }
.print-company { font-size: 20px; font-weight: 700; }
.print-muted { color: #555; font-size: 12px; }
.print-title { text-align: right; }
.print-title h1 { font-size: 22px; letter-spacing: .08em; margin: 0 0 4px; color: #0073ea; }
.print-client { margin-bottom: 14px; }
.print-subject { font-size: 15px; margin: 0 0 10px; }
.print-table { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
.print-table th, .print-table td { border-bottom: 1px solid #ddd; padding: 6px 8px; text-align: left; vertical-align: top; }
.print-table th { background: #f3f4f6; font-size: 12px; }
.print-table .num { text-align: right; white-space: nowrap; }
.print-table tfoot td { border-bottom: 0; }
.print-table tr.total td { font-weight: 700; font-size: 14px; border-top: 2px solid #111; }
.print-terms { font-size: 11px; color: #444; }
.print-foot { margin-top: 30px; border-top: 1px solid #ddd; padding-top: 8px; font-size: 11px; color: #777; }
@media print { .no-print { display: none !important; } .print-page { padding: 0; } body { background: #fff; } .auth-page { background: #fff; color: #111; padding: 0; min-height: auto; display: block; } }

/* ---------- Menú personalizable ---------- */
.nav-foot { flex-shrink: 0; padding: 8px; border-top: 1px solid var(--border-light); background: var(--surface); }
.nav-customize { width: 100%; background: transparent; border: 0; font: inherit; cursor: pointer; color: var(--text-3); }
.nav-customize:hover { color: var(--text); }
.nav-emoji { width: 18px; text-align: center; display: inline-block; }
.menu-sec { border: 1px solid var(--border-light); border-radius: var(--radius); margin-bottom: 10px; padding: 8px; background: var(--bg); }
.menu-sec-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.menu-row { display: grid; grid-template-columns: 22px 24px 1fr 150px 24px 24px 24px; gap: 6px; align-items: center; padding: 3px 0; }
.menu-row.hidden input.form-control { opacity: .5; text-decoration: line-through; }
.menu-row.add { grid-template-columns: 60px 1fr 1.4fr 140px auto; }
.menu-ico { display: inline-flex; justify-content: center; color: var(--text-2); }
.sidebar.collapsed .nav-customize span { display: none; }
.sidebar.collapsed .nav-foot { padding: 8px 4px; }
@media (max-width: 600px) { .menu-row { grid-template-columns: 22px 24px 1fr 24px 24px 24px; } .menu-row select { grid-column: 1 / -1; } .menu-row.add { grid-template-columns: 1fr 1fr; } }

/* ---------- Diálogos y error boundary ---------- */
.sheet.dialog { width: min(440px, 94vw); }
.error-box { text-align: center; padding: 32px 16px; max-width: 720px; margin: 0 auto; }
.error-ico { font-size: 2.4rem; color: var(--warning); }
.error-box pre { text-align: left; max-height: 240px; overflow: auto; }

/* ---------- Productos: mosaico, etiquetas, imágenes ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.tile { background: var(--surface); border: 1px solid var(--border-light); border-radius: var(--radius); overflow: hidden; cursor: pointer; display: flex; flex-direction: column; transition: box-shadow .15s; }
.tile:hover { box-shadow: var(--shadow); }
.tile.inactive { opacity: .6; }
.tile-img { position: relative; aspect-ratio: 4 / 3; background: var(--bg); display: flex; align-items: center; justify-content: center; }
.tile-img img { width: 100%; height: 100%; object-fit: cover; }
.tile-noimg { font-size: 2.4rem; opacity: .5; }
.tile-badge { position: absolute; top: 8px; left: 8px; background: rgba(0,0,0,.6); color: #fff; font-size: .7rem; padding: 2px 8px; border-radius: 999px; }
.tile-badge.off { left: auto; right: 8px; background: var(--danger); }
.tile-body { padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.tile-name { font-weight: 600; }
.tile-price { font-size: 1rem; }
.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; background: var(--bg); display: inline-flex; align-items: center; justify-content: center; }
.thumb.noimg { opacity: .5; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.tags.big .tag { font-size: .85rem; }
.tag { display: inline-flex; align-items: center; gap: 2px; background: var(--primary-softer); color: var(--primary-hover); border-radius: 999px; padding: 1px 8px; font-size: .75rem; border: 0; font: inherit; }
.tag.ghost { background: transparent; border: 1px dashed var(--border); color: var(--text-2); cursor: pointer; margin-right: 4px; }
.tag.ghost:hover { border-color: var(--primary); color: var(--primary); }
.tag-x { border: 0; background: transparent; color: inherit; cursor: pointer; padding: 0 2px; line-height: 1; font-size: .9rem; opacity: .7; }
.tag-x:hover { opacity: 1; }
.tag-input { border: 0; background: transparent; font: inherit; font-size: .75rem; width: 80px; outline: 0; color: var(--text-2); }
.tag-input:focus { border-bottom: 1px solid var(--primary); }
.img-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.img-item { position: relative; aspect-ratio: 1; border-radius: 6px; overflow: hidden; border: 2px solid transparent; }
.img-item.main { border-color: var(--primary); }
.img-item img { width: 100%; height: 100%; object-fit: cover; }
.img-actions { position: absolute; top: 2px; right: 2px; display: flex; gap: 2px; background: rgba(255,255,255,.85); border-radius: 4px; }
.img-add { aspect-ratio: 1; border: 1px dashed var(--border); border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: .8rem; color: var(--text-2); cursor: pointer; position: relative; overflow: hidden; }
.img-add input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ---- Centro de configuración ---- */
.settings-hub { display: flex; flex-direction: column; gap: 10px; }
.settings-group { font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); margin: 14px 0 0; font-weight: 600; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.settings-card { display: flex; align-items: flex-start; gap: 12px; padding: 14px; background: var(--surface); border: 1px solid var(--border-light); border-radius: var(--radius); color: var(--text); text-align: left; font: inherit; cursor: pointer; transition: box-shadow .12s, border-color .12s; }
.settings-card:hover { text-decoration: none; border-color: var(--primary); box-shadow: var(--shadow); }
.settings-ico { width: 38px; height: 38px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--primary); background: var(--primary-softer); border: 1px solid var(--border-light); transition: background-color .12s; }
.settings-svg { width: 20px; height: 20px; }
.settings-card:hover .settings-ico { background: var(--primary-soft); }
.settings-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.settings-text strong { font-size: .92rem; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.settings-text .muted { font-size: .8rem; line-height: 1.35; }
.settings-status { grid-column: 1 / -1; }
.status-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 900px) { .status-grid { grid-template-columns: 1fr; } }
.status-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--border-light); border-radius: var(--radius-sm); background: var(--bg); min-width: 0; }
.st-dot { width: 10px; height: 10px; border-radius: 50%; background: #c4c4c4; flex-shrink: 0; margin-top: 5px; }
.st-dot.ok { background: #00c875; } .st-dot.warn { background: #fdab3d; } .st-dot.bad { background: #e2445c; }
.st-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.st-label { font-size: .88rem; font-weight: 600; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.st-state { font-size: .7rem; font-weight: 600; border-radius: 999px; padding: 0 7px; border: 1px solid var(--border-light); background: var(--surface); color: var(--text-2); white-space: nowrap; }
.st-state.ok { color: #00a65a; } .st-state.warn { color: #c4780b; } .st-state.bad { color: #e2445c; }
.st-detail { font-size: .8rem; color: var(--text-2); line-height: 1.35; overflow-wrap: anywhere; }
.st-action { font-size: .8rem; white-space: nowrap; align-self: center; }
.status-summary { font-size: .8rem; font-weight: 600; color: var(--text-2); }
.status-summary.ok { color: #00a65a; } .status-summary.warn { color: #c4780b; }
.settings-toolbar { display: flex; }
.settings-search { width: 100%; padding: 9px 14px; box-shadow: var(--shadow-sm); border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit; }
.settings-search:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.settings-counters { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.settings-counters .counter { display: flex; flex-direction: column; align-items: center; min-width: 96px; padding: 10px 12px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border-light); box-shadow: var(--shadow-sm); color: var(--text); transition: border-color .12s, box-shadow .12s; }
.settings-counters .counter:hover { box-shadow: var(--shadow); }
.settings-counters .counter:hover { text-decoration: none; border-color: var(--primary); }
.settings-counters .counter strong { font-size: 1.2rem; line-height: 1.1; }
.settings-counters .counter span { font-size: .72rem; color: var(--text-3); }

/* ---- Agentes de IA ---- */
.agent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.agent-card { background: var(--surface); border: 1px solid var(--border-light); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.agent-card.inactive { opacity: .6; }
.agent-card-top { display: flex; gap: 12px; align-items: flex-start; }
.agent-card-name { font-weight: 700; font-size: 1.02rem; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.agent-card-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.agent-card-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.agent-sprite { image-rendering: pixelated; flex-shrink: 0; }
.agent-avatar { width: 34px; height: 34px; border-radius: 50%; color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }
.agent-avatar.sm { width: 24px; height: 24px; font-size: .75rem; }
.agent-avatar.big { width: 56px; height: 56px; font-size: 1.4rem; }
.tool-list { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
@media (max-width: 760px) { .tool-list { grid-template-columns: 1fr; } }
.tool-opt { display: flex; gap: 8px; align-items: flex-start; padding: 8px; border: 1px solid var(--border-light); border-radius: var(--radius-sm); font-size: .85rem; cursor: pointer; }
.tool-opt.write { border-style: dashed; }
.tool-opt input { margin-top: 3px; }
.avatar-picker { display: flex; flex-wrap: wrap; gap: 4px; }
.avatar-picker button { border: 2px solid transparent; background: var(--bg); border-radius: 8px; padding: 2px; cursor: pointer; }
.avatar-picker button.sel { border-color: var(--primary); }
.agent-chat-panel { position: fixed; right: 16px; bottom: 16px; width: min(420px, calc(100vw - 32px)); height: min(640px, calc(100vh - 90px)); z-index: 60; box-shadow: var(--shadow-lg); border-radius: var(--radius); overflow: hidden; background: var(--surface); border: 1px solid var(--border-light); }

/* chat */
.agent-chat { display: flex; flex-direction: column; height: 100%; min-height: 0; background: var(--surface); }
.agent-chat-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border-light); }
.agent-chat-name { font-weight: 700; }
.agent-conv-list { max-height: 180px; overflow-y: auto; border-bottom: 1px solid var(--border-light); background: var(--bg); }
.agent-conv-item { display: flex; justify-content: space-between; gap: 8px; width: 100%; border: 0; background: transparent; padding: 6px 12px; font: inherit; font-size: .82rem; color: var(--text); cursor: pointer; text-align: left; }
.agent-conv-item:hover, .agent-conv-item.active { background: var(--surface-hover); }
.agent-chat-body { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; scroll-behavior: smooth; }
.agent-hello { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; margin: auto 0; padding: 12px; }
.agent-suggestions { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 8px; }
.agent-suggestions .chip { cursor: pointer; border: 1px solid var(--border); background: var(--bg); font: inherit; font-size: .8rem; }
.msg { display: flex; gap: 8px; align-items: flex-end; max-width: 100%; }
.msg.me { justify-content: flex-end; }
.msg .bubble { padding: 8px 12px; border-radius: 14px; font-size: .9rem; line-height: 1.4; max-width: 86%; word-wrap: break-word; }
.msg.me .bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.msg.bot .bubble { background: var(--bg); border: 1px solid var(--border-light); border-bottom-left-radius: 4px; }
.msg.err .bubble { background: #fde8ea; color: #b02a37; border: 1px solid #f5c2c7; }
[data-theme="dark"] .msg.err .bubble { background: #3a1d22; color: #ff8a95; border-color: #6b2a33; }
.msg.tool { justify-content: flex-start; padding-left: 32px; }
.tool-pill { font-size: .72rem; background: var(--bg); border: 1px dashed var(--border); border-radius: 999px; padding: 2px 10px; color: var(--text-2); }
.bubble.md p { margin: 0 0 6px; } .bubble.md p:last-child { margin: 0; }
.bubble.md ul, .bubble.md ol { margin: 4px 0 6px; padding-left: 20px; }
.bubble.md h3, .bubble.md h4, .bubble.md h5, .bubble.md h6 { font-size: .95rem; margin: 6px 0 4px; }
.bubble.md pre { background: #1e293b; color: #e2e8f0; padding: 8px 10px; border-radius: 8px; font-size: .8rem; overflow-x: auto; }
.bubble.md code { font-size: .85em; }
.bubble.typing span { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); margin-right: 3px; animation: typing 1s infinite; }
.bubble.typing span:nth-child(2) { animation-delay: .2s; } .bubble.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes typing { 0%, 60%, 100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-4px); opacity: 1; } }
.agent-chat-foot { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border-light); align-items: flex-end; }
.agent-chat-foot textarea { resize: none; }

/* oficina */
.office-page { display: flex; flex-direction: column; height: calc(100vh - var(--topbar-h) - 62px); min-height: 480px; }
.office-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.office-top h3 { font-size: 1.3rem; font-weight: 700; }
.office-top .sub { color: var(--text-3); font-size: .85rem; }
.office-people { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.office-person { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; background: var(--surface); border: 1px solid var(--border-light); border-radius: 999px; padding: 2px 10px 2px 3px; }
.office-wrap { flex: 1; min-height: 0; display: flex; gap: 12px; }
.office-stage { flex: 1; min-width: 0; position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border-light); background: #dfe6ee; }
[data-theme="dark"] .office-stage { background: #111318; }
.office-stage canvas { display: block; outline: none; cursor: pointer; }
.office-hint { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); background: rgba(30,41,59,.9); color: #fff; padding: 6px 14px; border-radius: 999px; font-size: .85rem; pointer-events: none; white-space: nowrap; }
.office-warn { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); background: #fff4d6; color: #7a4d00; border: 1px solid #fdd77a; padding: 4px 12px; border-radius: 999px; font-size: .8rem; }
.office-chat { width: min(400px, 40vw); min-width: 300px; border: 1px solid var(--border-light); border-radius: var(--radius); overflow: hidden; display: flex; }
.office-chat .agent-chat { flex: 1; }
kbd { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; font-size: .8em; font-family: inherit; font-weight: 600; }
@media (max-width: 800px) { .office-wrap { flex-direction: column; } .office-chat { width: 100%; min-width: 0; height: 50%; } .office-page { height: auto; min-height: 0; } .office-stage { height: 52vh; } }
.routine { border: 1px solid var(--border-light); border-radius: var(--radius-sm); padding: 8px 10px; margin-bottom: 8px; background: var(--surface); }
.routine.off { opacity: .65; }
.routine-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.routine-out { background: var(--bg); border-radius: var(--radius-sm); padding: 8px 10px; max-height: 220px; overflow-y: auto; }
.msg-source { font-size: .7rem; color: var(--text-3); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 4px; }
.agent-last { background: var(--bg); border-radius: var(--radius-sm); padding: 6px 8px; }
.sheet-head .btn-ghost.active { background: var(--primary-soft); color: var(--primary-hover); }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.tpl-card { display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 12px; border: 1px solid var(--border-light); border-top: 4px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.tpl-card:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.tpl-emoji { font-size: 1.5rem; }
.tpl-meta { font-size: .72rem; color: var(--text-3); margin-top: auto; }
.agent-mood { display: flex; align-items: center; gap: 8px; }
.agent-mood-emoji { font-size: 1.05rem; }
.agent-mood-bar { flex: 1; height: 6px; background: var(--border-light); border-radius: 3px; overflow: hidden; }
.agent-mood-bar span { display: block; height: 100%; border-radius: 3px; transition: width .3s; }
.collab { border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: 8px 10px; }
.msg-feedback { display: flex; gap: 2px; justify-content: flex-end; margin-top: 4px; }
.msg-feedback button { border: 0; background: transparent; cursor: pointer; opacity: .35; font-size: .85rem; padding: 0 3px; }
.msg-feedback button:hover, .msg-feedback button.on { opacity: 1; }
/* burbuja flotante de agentes */
.agent-bubble { position: fixed; right: 18px; bottom: 18px; z-index: 65; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.agent-bubble-btn { width: 54px; height: 54px; border-radius: 50%; border: 0; background: var(--surface); box-shadow: var(--shadow-lg); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; position: relative; font-size: 1.3rem; color: var(--text); transition: transform .12s; }
.agent-bubble-btn:hover { transform: scale(1.06); }
.agent-bubble-btn .agent-avatar { width: 42px; height: 42px; font-size: 1.1rem; }
.agent-bubble-dot { position: absolute; top: 4px; right: 4px; width: 12px; height: 12px; border-radius: 50%; background: #fdab3d; border: 2px solid var(--surface); animation: pulse 1s infinite; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.35); } }
.agent-bubble-panel { width: min(420px, calc(100vw - 36px)); height: min(640px, calc(100vh - 110px)); background: var(--surface); border: 1px solid var(--border-light); border-radius: var(--radius); box-shadow: var(--shadow-lg); overflow: hidden; display: flex; flex-direction: column; }
.agent-bubble-panel .agent-chat { flex: 1; min-height: 0; }
.agent-bubble-pick { display: flex; gap: 4px; padding: 8px 10px; border-bottom: 1px solid var(--border-light); background: var(--bg); overflow-x: auto; }
.agent-pick { border: 2px solid transparent; background: transparent; border-radius: 999px; padding: 2px; cursor: pointer; position: relative; flex-shrink: 0; }
.agent-pick.sel { border-color: var(--primary); }
.agent-pick .crown { position: absolute; top: -8px; right: -4px; font-size: .7rem; }
@media (max-width: 640px) { .agent-bubble { right: 10px; bottom: 10px; } }
.msg.action { justify-content: flex-start; }
.action-card { border: 1px solid var(--border); border-left: 4px solid #fdab3d; border-radius: var(--radius-sm); background: var(--bg); padding: 8px 10px; max-width: 92%; font-size: .85rem; }
.action-card.done { border-left-color: #00c875; } .action-card.cancelled { border-left-color: #c4c4c4; opacity: .7; } .action-card.failed { border-left-color: #e2445c; }
.action-title { font-weight: 600; margin-bottom: 4px; }
.action-body { white-space: pre-wrap; font: inherit; margin: 0 0 8px; max-height: 220px; overflow-y: auto; }
.bubble.streaming .caret { display: inline-block; width: 6px; height: 14px; background: var(--text-3); margin-left: 2px; vertical-align: text-bottom; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.memory-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--border-light); font-size: .85rem; }
/* documentos */
.doc-layout { display: grid; grid-template-columns: 1fr 300px; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .doc-layout { grid-template-columns: 1fr; } }
.doc-panes { display: grid; gap: 10px; min-height: 520px; }
.doc-panes.split { grid-template-columns: 1fr 1fr; } .doc-panes.edit .doc-preview { display: none; } .doc-panes.preview .doc-text { display: none; }
.doc-text { min-height: 520px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .86rem; line-height: 1.5; resize: vertical; }
.doc-preview { background: #fff; color: #111; border: 1px solid var(--border-light); border-radius: var(--radius); padding: 28px 32px; overflow-y: auto; max-height: 75vh; font-size: 14px; line-height: 1.55; }
.doc-preview h1 { font-size: 1.4rem; text-align: center; margin: 0 0 14px; } .doc-preview h2 { font-size: 1.05rem; margin: 16px 0 6px; } .doc-preview h3, .doc-preview h4 { font-size: .95rem; margin: 12px 0 4px; }
.doc-preview p { margin: 0 0 8px; } .doc-preview ul, .doc-preview ol { margin: 4px 0 8px; padding-left: 22px; }
.doc-table { width: 100%; border-collapse: collapse; margin: 8px 0 12px; font-size: .92em; } .doc-table th, .doc-table td { border: 1px solid #cbd5e1; padding: 6px 8px; text-align: left; vertical-align: top; } .doc-table th { background: #f1f5f9; }
.doc-print .doc-preview { border: 0; padding: 0; max-height: none; }
.file-btn { position: relative; overflow: hidden; cursor: pointer; } .file-btn input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
/* firma electrónica */
.sig-block { margin-top: 28px; border-top: 1px solid #cbd5e1; padding-top: 12px; }
.sig-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.sig-box { border-bottom: 1px solid #1e293b; padding-bottom: 4px; min-height: 90px; display: flex; flex-direction: column; justify-content: flex-end; }
.sig-img { max-height: 70px; max-width: 100%; object-fit: contain; align-self: flex-start; }
.sig-typed { font-family: "Segoe Script", "Brush Script MT", cursive; font-size: 1.5rem; }
.sig-pending { color: #94a3b8; font-style: italic; font-size: .85rem; }
.sig-name { font-weight: 600; margin-top: 4px; } .sig-meta { font-size: .75rem; color: #64748b; }
.signer-row { display: flex; align-items: center; gap: 6px; padding: 6px 0; border-bottom: 1px dashed var(--border-light); font-size: .85rem; }
.sign-page { min-height: 100vh; background: #e9eef4; padding: 24px 12px; }
.sign-card { max-width: 860px; margin: 0 auto; background: #fff; color: #111; border-radius: 12px; padding: 28px 32px; box-shadow: 0 6px 30px rgba(0,0,0,.08); }
.sign-head { display: flex; justify-content: space-between; gap: 12px; border-bottom: 3px solid #0073ea; padding-bottom: 12px; margin-bottom: 16px; }
.sign-doc { max-height: 55vh; border: 1px solid #e2e8f0; }
.sign-form { margin-top: 20px; border-top: 1px solid #e2e8f0; padding-top: 16px; }
.sig-pad-wrap { position: relative; border: 2px dashed #94a3b8; border-radius: 8px; background: #fafafa; }
.sig-pad-wrap canvas { width: 100%; height: 160px; display: block; touch-action: none; cursor: crosshair; }
.sig-pad-wrap button { position: absolute; right: 6px; top: 6px; }
.sign-ok { background: #e6f9ef; color: #0f6b3a; border: 1px solid #9ae6b4; padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; }
.sign-err { background: #fde8ea; color: #b02a37; border: 1px solid #f5c2c7; padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; }
@media print { .sign-page { background: #fff; padding: 0; } .sign-card { box-shadow: none; } .sign-doc { max-height: none; border: 0; } .sign-form { display: none; } }
.home-alert { background: #fff4d6; border: 1px solid #fdd77a; color: #7a4d00; border-radius: var(--radius-sm); padding: 6px 10px; font-size: .85rem; margin-bottom: 6px; }
[data-theme="dark"] .home-alert { background: #3a2f12; border-color: #6b5520; color: #ffd98a; }
.tool-details summary { list-style: none; cursor: pointer; display: inline-block; }
.tool-details summary::-webkit-details-marker { display: none; }
.tool-io { font-size: .72rem; margin: 4px 0 0 4px; max-width: 420px; }
.tool-io pre { background: var(--bg); border: 1px solid var(--border-light); border-radius: 6px; padding: 6px; white-space: pre-wrap; word-break: break-word; max-height: 160px; overflow: auto; margin: 2px 0 6px; }
