/* Kosmo · estilos (inspirados en la estética de x.com: negro, una columna, botones grandes tipo píldora) */

:root {
  --bg: #000000;
  --bg-elevated: #16181c;
  --bg-hover: rgba(231, 233, 234, 0.05);
  --bg-active: rgba(231, 233, 234, 0.1);
  --border: #2f3336;
  --text: #e7e9ea;
  --muted: #71767b;
  --accent: #1d9bf0;
  --accent-hover: #1a8cd8;
  --accent-soft: rgba(29, 155, 240, 0.14);
  --danger: #f4212e;
  --danger-soft: rgba(244, 33, 46, 0.14);
  --warning: #ffd400;
  --warning-soft: rgba(255, 212, 0, 0.14);
  --success: #00ba7c;
  --success-soft: rgba(0, 186, 124, 0.14);
  --purple: #7856ff;
  --purple-soft: rgba(120, 86, 255, 0.16);
  --pink: #f91880;
  --pink-soft: rgba(249, 24, 128, 0.14);
  --overlay: rgba(91, 112, 131, 0.4);
  --modal-glow: 0 0 18px rgba(255, 255, 255, 0.16);
  --radius: 16px;
  --pill: 9999px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #ffffff;
  --bg-elevated: #f7f9f9;
  --bg-hover: rgba(15, 20, 25, 0.03);
  --bg-active: rgba(15, 20, 25, 0.07);
  --border: #eff3f4;
  --text: #0f1419;
  --muted: #536471;
  --overlay: rgba(0, 0, 0, 0.4);
  --modal-glow: 0 8px 28px rgba(0, 0, 0, 0.18);
  --warning: #c99a00;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.38;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body.no-scroll { overflow: hidden; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
svg { display: block; flex-shrink: 0; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.accent { color: var(--accent); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.boot { min-height: 100vh; display: grid; place-items: center; }
.boot img { animation: pulse 1.4s ease-in-out infinite; }

/* ---------- Layout ---------- */
.layout { display: flex; justify-content: center; min-height: 100vh; }
.sidebar {
  width: 275px; flex-shrink: 0; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; padding: 4px 12px 12px; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 12px; font-weight: 800; font-size: 23px; letter-spacing: -0.5px; width: fit-content; border-radius: var(--pill); }
.brand:hover { background: var(--bg-active); }
.brand img { width: 34px; height: 34px; }
.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 2px; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 18px; padding: 12px 18px 12px 12px;
  border-radius: var(--pill); font-size: 20px; width: fit-content; transition: background 0.15s;
}
.nav-item:hover { background: var(--bg-active); }
.nav-item.active { font-weight: 800; }
.nav-item svg { width: 27px; height: 27px; }
.nav-item.active svg { stroke-width: 2.6; }
.badge {
  position: absolute; top: 5px; left: 26px; min-width: 19px; height: 19px; padding: 0 5px;
  border-radius: var(--pill); background: var(--accent); color: #fff; border: 2px solid var(--bg);
  font-size: 11px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center;
}
.btn-compose { margin: 16px 0 0; width: 90%; }
.sidebar-user { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: var(--pill); }
.sidebar-user .who { flex: 1; min-width: 0; }
.sidebar-user .who b, .sidebar-user .who span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .who span { color: var(--muted); font-size: 14px; }

.main {
  width: 600px; max-width: 100%; min-height: 100vh; padding-bottom: 96px;
  border-left: 1px solid var(--border); border-right: 1px solid var(--border);
}
.aside { width: 350px; flex-shrink: 0; padding: 12px 0 24px 28px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }

.topbar, .bottom-nav, .fab { display: none; }

@media (max-width: 1260px) {
  .sidebar { width: 88px; align-items: center; }
  .nav-item { padding: 12px; }
  .nav-item span:not(.badge), .brand span, .btn-compose span, .sidebar-user .who, .sidebar-user .user-tools { display: none; }
  .btn-compose { width: 52px; height: 52px; min-height: 52px; padding: 0; }
}
@media (max-width: 1000px) { .aside { display: none; } }
@media (max-width: 640px) {
  .layout { flex-direction: column; justify-content: flex-start; }
  .sidebar { display: none; }
  .main { border: 0; width: 100%; padding-bottom: 120px; }
  .topbar {
    display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 30;
    height: 53px; padding: 0 16px; background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  }
  .topbar img { width: 30px; height: 30px; }
  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; height: calc(56px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom); background: var(--bg); border-top: 1px solid var(--border);
  }
  .bottom-nav a { flex: 1; display: grid; place-items: center; position: relative; }
  .bottom-nav a svg { width: 26px; height: 26px; }
  .bottom-nav a.active svg { stroke-width: 2.6; }
  .bottom-nav .badge { left: calc(50% + 2px); top: 6px; }
  .fab {
    display: grid; place-items: center; position: fixed; right: 16px; bottom: calc(72px + env(safe-area-inset-bottom)); z-index: 31;
    width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: #fff;
    box-shadow: 0 4px 14px rgba(29, 155, 240, 0.45);
  }
  .fab svg { width: 26px; height: 26px; }
  .page-header { top: 53px; }
}

/* ---------- Encabezado de página y pestañas ---------- */
.page-header {
  position: sticky; top: 0; z-index: 20; border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.page-header-row { display: flex; align-items: center; gap: 20px; min-height: 53px; padding: 0 16px; }
.page-header-text { flex: 1; min-width: 0; }
.page-title { font-size: 20px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-subtitle { font-size: 13px; color: var(--muted); }
.page-header .tabs { border-bottom: 0; }

.tabs { display: flex; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--border); }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: 1 0 auto; min-width: 84px; padding: 0 14px; height: 53px; color: var(--muted); font-weight: 600; transition: background 0.15s; }
.tab span { display: inline-block; padding: 15px 0 12px; border-bottom: 4px solid transparent; border-radius: 2px; }
.tab:hover { background: var(--bg-hover); }
.tab.active { color: var(--text); font-weight: 800; }
.tab.active span { border-bottom-color: var(--accent); }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 36px; padding: 0 16px;
  border-radius: var(--pill); font-weight: 700; font-size: 15px; border: 1px solid transparent; white-space: nowrap;
  transition: background 0.15s, opacity 0.15s, border-color 0.15s;
}
.btn svg { width: 18px; height: 18px; }
.btn-sm { min-height: 32px; padding: 0 14px; font-size: 14px; }
.btn-lg { min-height: 52px; padding: 0 30px; font-size: 17px; }
.btn-lg svg { width: 22px; height: 22px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-light { background: var(--text); color: var(--bg); }
.btn-light:hover { opacity: 0.88; }
.btn-outline { border-color: #536471; }
.btn-outline:hover { background: var(--bg-active); }
.btn-ghost { color: var(--accent); padding: 0 10px; }
.btn-ghost:hover { background: var(--accent-soft); }
.btn-danger { color: var(--danger); border-color: rgba(244, 33, 46, 0.5); }
.btn-danger:hover { background: var(--danger-soft); }
.btn:disabled, .btn.is-loading { opacity: 0.5; pointer-events: none; }

.icon-btn {
  width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; color: var(--muted);
  transition: background 0.15s, color 0.15s; flex-shrink: 0;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { background: var(--accent-soft); color: var(--accent); }
.icon-btn.accent { color: var(--accent); }
.icon-btn.ok:hover { background: var(--success-soft); color: var(--success); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.icon-btn.on-text { color: var(--text); }
.icon-btn.on-text:hover { background: var(--bg-active); color: var(--text); }

/* Botón circular "Verificar todo" de cada cliente */
.btn-verify {
  width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--border); color: var(--accent);
  display: grid; place-items: center; flex-shrink: 0; transition: background 0.15s, border-color 0.15s;
}
.btn-verify svg { width: 22px; height: 22px; }
.btn-verify:hover { background: var(--accent-soft); border-color: var(--accent); }
.btn-verify.is-loading svg, .is-loading > svg:first-child { animation: spin 0.9s linear infinite; }

/* ---------- Formularios ---------- */
.stack { display: flex; flex-direction: column; gap: 16px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: block; }
.field > span, .field-label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 6px 2px; }
.input {
  width: 100%; background: transparent; color: var(--text); font: inherit; font-size: 17px;
  border: 1px solid var(--border); border-radius: 6px; padding: 13px 12px; outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.input-sm { font-size: 15px; padding: 9px 10px; }
textarea.input { resize: vertical; min-height: 90px; line-height: 1.4; }
select.input option { background: var(--bg); color: var(--text); }
.check { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.form-error { color: var(--danger); font-size: 14px; }
.hint { font-size: 13px; color: var(--muted); }

.search-wrap { padding: 4px 16px 12px; }
.search {
  width: 100%; height: 44px; border-radius: var(--pill); border: 1px solid transparent; outline: none;
  background: var(--bg-elevated); color: var(--text); font: inherit; padding: 0 20px;
}
.search:focus { border-color: var(--accent); background: var(--bg); }

/* ---------- Secciones, filas, avatares ---------- */
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 10px; font-size: 20px; font-weight: 800; }
.list { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); transition: background 0.15s; }
.row:hover { background: var(--bg-hover); }
.row-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; }
.row-body { flex: 1; min-width: 0; }
.row-title { font-weight: 700; display: flex; align-items: center; gap: 6px; }
.row-title .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub .warn { color: var(--danger); }

.avatar {
  width: 40px; height: 40px; border-radius: 50%; background: var(--av, var(--accent)); color: #fff; flex-shrink: 0;
  display: grid; place-items: center; font-weight: 800; font-size: 15px; user-select: none;
}
.avatar-sm { width: 32px; height: 32px; font-size: 13px; }
.avatar-lg { width: 84px; height: 84px; font-size: 30px; border: 4px solid var(--bg); }

.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--muted); flex-shrink: 0; }
.dot-ok { background: var(--success); }
.dot-warn { background: var(--warning); }
.dot-fail { background: var(--danger); }
.dot-none { background: var(--border); }

/* ---------- Chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: var(--pill);
  font-size: 12.5px; font-weight: 700; background: var(--bg-active); color: var(--text); white-space: nowrap;
}
.chip svg { width: 12px; height: 12px; }
.chip-request { background: var(--accent-soft); color: var(--accent); }
.chip-risk { background: var(--danger-soft); color: var(--danger); }
.chip-opportunity { background: var(--success-soft); color: var(--success); }
.chip-followup { background: var(--purple-soft); color: var(--purple); }
.chip-strategy { background: var(--pink-soft); color: var(--pink); }
.chip-warn { background: var(--warning-soft); color: var(--warning); }
.chip-ai { background: transparent; color: var(--accent); padding: 2px 4px; }
.chip-source { background: transparent; border: 1px solid var(--border); color: var(--muted); font-weight: 600; }
.chip-contact { background: var(--success-soft); color: var(--success); }

.chip-select { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-radio input { position: absolute; opacity: 0; pointer-events: none; }
.chip-radio span {
  display: inline-block; padding: 6px 14px; border-radius: var(--pill); border: 1px solid var(--border);
  font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.15s;
}
.chip-radio span:hover { background: var(--bg-hover); }
.chip-radio input:checked + span { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip-radio input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Paneles (Avisos) ---------- */
.panel { margin: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--bg-elevated); }
.panel-title { display: flex; align-items: center; gap: 10px; padding: 12px 16px; font-size: 20px; font-weight: 800; }
.panel-title svg { width: 22px; height: 22px; }
.panel-title .count { margin-left: auto; font-size: 14px; color: var(--muted); font-weight: 600; }
.panel-empty { padding: 4px 16px 16px; color: var(--muted); }
.panel-more { display: block; padding: 14px 16px; color: var(--accent); border-top: 1px solid var(--border); }
.panel-more:hover { background: var(--bg-hover); }

.alert-item { display: flex; align-items: flex-start; gap: 12px; padding: 12px 12px 12px 16px; border-top: 1px solid var(--border); transition: background 0.15s; }
.alert-item:hover { background: var(--bg-hover); }
.alert-icon { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; }
.alert-icon svg { width: 18px; height: 18px; }
.lvl-critical { background: var(--danger-soft); color: var(--danger); }
.lvl-warning { background: var(--warning-soft); color: var(--warning); }
.lvl-info { background: var(--accent-soft); color: var(--accent); }
.alert-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.alert-title { font-weight: 700; }
.alert-body { color: var(--muted); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.alert-meta { color: var(--muted); font-size: 13px; }
.alert-list .alert-item:first-child { border-top: 0; }
.alert-list .alert-item { border-top: 0; border-bottom: 1px solid var(--border); }

/* ---------- Perfil del cliente ---------- */
.profile { padding: 16px 16px 12px; border-bottom: 1px solid var(--border); }
.profile-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.profile-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.profile-name { font-size: 22px; font-weight: 800; margin-top: 10px; line-height: 1.2; }
.profile-bio { margin-top: 10px; white-space: pre-wrap; }
.profile-links { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; color: var(--muted); font-size: 15px; }
.profile-links a { display: inline-flex; align-items: center; gap: 4px; color: var(--accent); }
.profile-links a:hover { text-decoration: underline; }
.profile-contacts { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.profile-stats { display: flex; gap: 18px; margin-top: 10px; color: var(--muted); font-size: 14px; }
.profile-stats b { color: var(--text); }

/* ---------- Tarjetas (Acciones a realizar) ---------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: var(--pill); padding: 3px; }
.segmented button { padding: 5px 14px; border-radius: var(--pill); font-size: 14px; font-weight: 700; color: var(--muted); }
.segmented button.active { background: var(--text); color: var(--bg); }

.card-item { display: flex; gap: 12px; padding: 14px 12px 14px 16px; border-bottom: 1px solid var(--border); transition: background 0.15s; }
.card-item:hover { background: var(--bg-hover); }
.card-item.is-closed { opacity: 0.6; }
.card-main { flex: 1; min-width: 0; }
.card-title { font-weight: 700; font-size: 16px; margin-top: 6px; }
.card-detail { color: var(--text); opacity: 0.85; margin-top: 2px; font-size: 14.5px; }
.card-meta { color: var(--muted); font-size: 13.5px; margin-top: 6px; }
.card-meta .overdue { color: var(--danger); font-weight: 700; }
.card-actions { display: flex; flex-direction: column; gap: 2px; }

/* ---------- Bitácora ---------- */
.compose-prompt { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.compose-prompt .fake-input { flex: 1; color: var(--muted); font-size: 19px; }
.compose-prompt .icons { display: flex; color: var(--accent); }

.entry { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.entry-content { flex: 1; min-width: 0; }
.entry-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.entry-author { font-weight: 700; }
.entry-meta { color: var(--muted); }
.entry-head .entry-tools { margin-left: auto; }
.entry-body { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 4px; }
.entry-body.clamp { max-height: 11.5em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }
.show-more { color: var(--accent); font-size: 15px; margin-top: 2px; }
.show-more:hover { text-decoration: underline; }
.entry-media { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 3px; margin-top: 10px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.entry-media img { width: 100%; height: 200px; object-fit: cover; display: block; }
.entry audio { width: 100%; margin-top: 10px; height: 40px; }
.entry-file { display: inline-flex; align-items: center; gap: 6px; margin: 10px 8px 0 0; padding: 8px 12px; border: 1px solid var(--border); border-radius: 12px; font-size: 14px; }
.entry-file:hover { background: var(--bg-hover); }
.entry-transcript { margin-top: 8px; font-size: 14px; }
.entry-transcript summary { color: var(--accent); cursor: pointer; width: fit-content; }
.entry-transcript .entry-body { color: var(--muted); max-height: 320px; overflow: auto; }
.entry-ai { margin-top: 10px; border: 1px solid var(--border); border-radius: 14px; padding: 10px 12px; font-size: 14.5px; }
.entry-ai-head { display: flex; align-items: center; gap: 6px; color: var(--accent); font-weight: 800; font-size: 13px; margin-bottom: 4px; }
.entry-ai-head svg { width: 14px; height: 14px; }
.entry-ai-foot { color: var(--muted); font-size: 13px; margin-top: 6px; }
.entry-ai.is-pending { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.entry-ai.is-failed { color: var(--danger); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.load-more { display: block; width: 100%; padding: 16px; color: var(--accent); }
.load-more:hover { background: var(--bg-hover); }

/* ---------- Composer (nueva entrada) ---------- */
.composer { display: flex; flex-direction: column; gap: 14px; }
.composer-main { display: flex; gap: 12px; padding-top: 4px; }
.composer-text {
  flex: 1; border: 0; outline: none; resize: none; background: transparent; color: var(--text);
  font: inherit; font-size: 19px; line-height: 1.35; min-height: 120px; padding: 6px 0;
}
.composer-text::placeholder { color: var(--muted); }
.composer-files { display: flex; flex-wrap: wrap; gap: 8px; }
.composer-files:empty { display: none; }
.file-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 6px 6px 12px; border: 1px solid var(--border); border-radius: var(--pill); font-size: 14px; max-width: 100%; }
.file-chip .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.file-chip img { width: 28px; height: 28px; border-radius: 6px; object-fit: cover; }
.file-chip .icon-btn { width: 28px; height: 28px; }
.composer-bar { display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--border); padding-top: 10px; position: sticky; bottom: 0; background: var(--bg); }
.composer-tools { display: flex; gap: 2px; flex: 1; }
.composer-tools label { cursor: pointer; }
.upload-progress { flex: 1; height: 4px; background: var(--bg-active); border-radius: 2px; overflow: hidden; }
.upload-progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }
.drop-hint { outline: 2px dashed var(--accent); outline-offset: -8px; }

.recorder { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--danger); border-radius: var(--radius); background: var(--danger-soft); }
.recorder .rec-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--danger); animation: pulse 1.2s infinite; }
.recorder .rec-time { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 18px; }
.recorder .rec-label { flex: 1; color: var(--text); font-size: 14px; }
.recorder .level { width: 60px; height: 6px; background: var(--bg-active); border-radius: 3px; overflow: hidden; }
.recorder .level span { display: block; height: 100%; width: 0; background: var(--danger); transition: width 0.1s; }

/* ---------- Verificación ---------- */
.verify-loading { padding: 40px 12px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.verify-head { display: flex; align-items: center; gap: 16px; padding: 8px 0 16px; border-bottom: 1px solid var(--border); }
.verify-headline { font-size: 17px; font-weight: 700; }
.score {
  --p: 0; --score-color: var(--accent); width: 82px; height: 82px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center;
  background: conic-gradient(var(--score-color) calc(var(--p) * 1%), var(--bg-active) 0);
}
.score::before { content: ""; grid-area: 1 / 1; width: 66px; height: 66px; border-radius: 50%; background: var(--bg); }
.score b { grid-area: 1 / 1; font-size: 26px; font-weight: 800; z-index: 1; }
.block-title { font-size: 17px; font-weight: 800; margin: 18px 0 8px; }
.risk { display: flex; gap: 10px; padding: 10px 12px; border-radius: 12px; margin-bottom: 8px; }
.risk svg { width: 18px; height: 18px; margin-top: 2px; }
.risk p { color: var(--text); opacity: 0.85; font-size: 14px; margin-top: 2px; }
.risk-critical { background: var(--danger-soft); color: var(--danger); }
.risk-warning { background: var(--warning-soft); color: var(--warning); }
.risk b { color: var(--text); }
.strategy { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; }
.strategy-title { font-weight: 800; font-size: 16px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.strategy > p { margin: 4px 0 8px; font-size: 14.5px; }
.strategy .btn-ghost { margin-top: 8px; margin-left: -10px; }
.client-message { margin-top: 10px; padding: 10px 12px; background: var(--bg-elevated); border-radius: 12px; }
.client-message-label { font-size: 12px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }
.client-message p { margin: 4px 0 8px; white-space: pre-wrap; }
.mini-action { display: flex; gap: 8px; align-items: flex-start; padding: 6px 0; }
.mini-action svg { color: var(--success); margin-top: 2px; }

/* ---------- Salud ---------- */
.health-item { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.health-item.compact { padding: 8px 0; }
.health-icon { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; }
.health-icon svg { width: 16px; height: 16px; }
.st-ok { background: var(--success-soft); color: var(--success); }
.st-warn { background: var(--warning-soft); color: var(--warning); }
.st-fail, .st-error { background: var(--danger-soft); color: var(--danger); }
.st-skip { background: var(--bg-active); color: var(--muted); }
.health-label { font-weight: 700; }
.health-summary { font-size: 14.5px; }
.health-time { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.issue-list { margin: 6px 0 0; padding-left: 18px; color: var(--muted); font-size: 14px; }
.scores { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }

/* ---------- Directrices y vencimientos ---------- */
.directive { display: flex; gap: 12px; padding: 14px 12px 14px 16px; border-bottom: 1px solid var(--border); }
.directive-body { flex: 1; min-width: 0; }
.directive-text { white-space: pre-wrap; font-size: 15.5px; }
.directive-meta { color: var(--muted); font-size: 13px; margin-top: 4px; }
.directive.is-proposed { background: var(--accent-soft); }
.directive-actions { display: flex; gap: 6px; margin-top: 8px; }

.inline-form { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.inline-form .actions { display: flex; justify-content: flex-end; gap: 8px; }

.exp-item { display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 16px; border-bottom: 1px solid var(--border); }
.exp-days { min-width: 64px; text-align: center; padding: 6px 4px; border-radius: 12px; font-weight: 800; font-size: 13px; line-height: 1.1; }
.exp-days b { display: block; font-size: 20px; }
.exp-critical { background: var(--danger-soft); color: var(--danger); }
.exp-warning { background: var(--warning-soft); color: var(--warning); }
.exp-ok { background: var(--success-soft); color: var(--success); }
.exp-none { background: var(--bg-active); color: var(--muted); }

/* ---------- Columna derecha ---------- */
.widget { background: var(--bg-elevated); border-radius: var(--radius); margin-bottom: 16px; overflow: hidden; }
.widget-title { padding: 12px 16px; font-size: 20px; font-weight: 800; }
.widget-item { display: block; padding: 10px 16px; transition: background 0.15s; }
.widget-item:hover { background: var(--bg-hover); }
.widget-item small { display: block; color: var(--muted); font-size: 13px; }
.widget-empty { padding: 0 16px 14px; color: var(--muted); }
.aside-footer { color: var(--muted); font-size: 13px; padding: 0 16px; }

/* ---------- Estados ---------- */
.empty { padding: 40px 24px; text-align: center; color: var(--muted); }
.empty strong { display: block; font-size: 24px; font-weight: 800; color: var(--text); margin-bottom: 6px; line-height: 1.2; }
.empty .btn { margin-top: 18px; }
.loading-block { display: grid; place-items: center; padding: 40px; }
.skeleton { height: 64px; margin: 12px 16px; border-radius: 12px; background: linear-gradient(90deg, var(--bg-elevated), var(--bg-active), var(--bg-elevated)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }

.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid var(--accent-soft); border-top-color: var(--accent); animation: spin 0.8s linear infinite; flex-shrink: 0; }
.spinner-lg { width: 40px; height: 40px; border-width: 4px; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: var(--overlay); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; overflow-y: auto; }
.modal {
  width: 600px; max-width: 100%; max-height: 90vh; display: flex; flex-direction: column;
  background: var(--bg); border-radius: var(--radius); box-shadow: var(--modal-glow); animation: rise 0.18s ease-out;
}
.modal-wide { width: 680px; }
.modal-head { display: flex; align-items: center; gap: 12px; min-height: 53px; padding: 0 16px 0 8px; flex-shrink: 0; }
.modal-head .icon-btn { color: var(--text); }
.modal-head .icon-btn:hover { background: var(--bg-active); }
.modal-title { flex: 1; font-size: 20px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.modal-body { padding: 0 16px 16px; overflow-y: auto; }
@media (max-width: 640px) {
  .modal-backdrop { padding: 0; }
  .modal, .modal-wide { width: 100%; height: 100%; max-height: 100%; border-radius: 0; }
  .row-2 { grid-template-columns: 1fr; }
}

/* ---------- Avisos emergentes ---------- */
.toast-wrap { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { background: var(--accent); color: #fff; padding: 12px 16px; border-radius: 6px; font-size: 15px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3); animation: rise 0.2s ease-out; transition: opacity 0.3s; }
.toast-error { background: var(--danger); }
.toast.out { opacity: 0; }
@media (max-width: 640px) { .toast-wrap { bottom: calc(140px + env(safe-area-inset-bottom)); } }

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 24px; }
.auth-card img { width: 56px; height: 56px; }
.auth-card h1 { font-size: 31px; font-weight: 800; line-height: 1.15; letter-spacing: -0.5px; }
.auth-card p { color: var(--muted); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: 0.35; } }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- Documentos del Drive ---------- */
.doc-search { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.doc-item { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.doc-icon { width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0; background: var(--accent-soft); color: var(--accent); }
.doc-item a.name:hover { text-decoration: underline; }
.doc-summary { margin-top: 6px; font-size: 15px; line-height: 1.4; }
.doc-item .chips { margin-top: 8px; }

/* ---------- Equipo → Google Drive ---------- */
.drive-pad { padding: 0 16px 12px; }
.drive-pad .actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.drive-email { display: flex; align-items: center; gap: 8px; margin-top: 6px; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); }
.drive-email code { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 14px; }
.drive-status { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; border-radius: var(--radius); background: var(--bg-hover); }
.drive-folder { padding-left: calc(16px + var(--depth, 0) * 14px); }
.drive-select { width: auto; max-width: 46%; flex-shrink: 0; }
.hint.warn { color: var(--danger); }
@media (max-width: 640px) {
  .drive-folder { flex-wrap: wrap; }
  .drive-select { max-width: 100%; width: 100%; }
  .drive-status { flex-direction: column; align-items: stretch; }
}

/* ---------- Chat con Kosmo ---------- */
.chat-intro { padding: 28px 16px 8px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.chat-intro h2 { font-size: 24px; font-weight: 800; }
.chat-logo { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.chat-client { width: 100%; max-width: 360px; text-align: left; }
.chat-suggestions { justify-content: center; }
.chat-suggestions .chip { cursor: pointer; white-space: normal; text-align: left; }
.chat-suggestions .chip:hover { background: var(--bg-hover); }
.chat-thread-icon { background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.chat-log { display: flex; flex-direction: column; gap: 14px; padding: 16px; min-height: 40vh; }
.chat-empty { text-align: center; margin-top: 20vh; }
.msg { display: flex; gap: 10px; max-width: 100%; }
.msg-user { justify-content: flex-end; }
.msg-user .bubble { background: var(--accent); color: #fff; border-radius: 20px 20px 4px 20px; max-width: 85%; }
.msg-user .bubble a { color: #fff; text-decoration: underline; }
.msg-kosmo .msg-body { flex: 1; min-width: 0; }
.msg-kosmo .bubble { background: var(--bg-hover); border: 1px solid var(--border); border-radius: 20px 20px 20px 4px; }
.msg-avatar { width: 32px; height: 32px; flex-shrink: 0; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.bubble { padding: 10px 14px; font-size: 15px; line-height: 1.45; overflow-wrap: anywhere; }
.bubble p + p, .bubble p + ul, .bubble ul + p { margin-top: 8px; }
.bubble ul { margin: 6px 0 0; padding-left: 20px; }
.bubble a { color: var(--accent); }
.msg-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.msg-action { white-space: normal; }
.msg-action.is-undone { text-decoration: line-through; opacity: 0.6; }
.msg-undo { display: inline-grid; place-items: center; margin-left: 4px; padding: 2px; border-radius: 50%; color: inherit; }
.msg-undo:hover { background: var(--bg-active); }
.msg-sources { margin-top: 6px; font-size: 13px; color: var(--muted); }
.typing { display: flex; gap: 4px; align-items: center; height: 40px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }
.chat-composer {
  position: sticky; bottom: 0; z-index: 20; display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px;
  background: var(--bg); border-top: 1px solid var(--border);
}
.chat-input { flex: 1; resize: none; min-height: 44px; max-height: 220px; border-radius: 22px; padding: 11px 16px; line-height: 1.35; }
.chat-send { width: 44px; height: 44px; min-height: 44px; padding: 0; border-radius: 50%; flex-shrink: 0; }

/* ---------- Memoria y accesos ---------- */
.tab-toolbar { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 16px; }
.memory-text { font-size: 15px; line-height: 1.4; }
.vault-secret:not(:empty) { margin-top: 6px; display: flex; align-items: center; gap: 6px; font-size: 14px; }
.vault-secret code { padding: 2px 8px; border-radius: 6px; background: var(--bg-hover); border: 1px solid var(--border); }
@media (max-width: 640px) {
  .chat-composer { bottom: calc(56px + env(safe-area-inset-bottom)); }
  .msg-user .bubble { max-width: 92%; }
}
body.in-chat .fab { display: none; }
.usage-row { display: flex; flex-direction: column; gap: 4px; }
.usage-bar { height: 8px; border-radius: 4px; background: var(--bg-hover); border: 1px solid var(--border); overflow: hidden; }
.usage-bar span { display: block; height: 100%; background: var(--accent); }
.usage-bar span.warn { background: var(--warning); }
