/* Diseño compartido con AquaLab: azul eléctrico + acento violeta, tema claro/oscuro. */
:root {
  --primary-dark: #1e40af;
  --primary: #2563eb;
  --primary-soft: #eff6ff;
  --primary-hover: #dbeafe;
  --accent: #7c3aed;
  --card: #ffffff;
  --text: #1e2430;
  --muted: #667085;
  --border: #e4e7ec;
  --bg: #f7f8fa;
  --on-primary: #ffffff;
  --link: var(--primary-dark);
  --header-bg: rgba(255, 255, 255, 0.75);
  --grid: rgba(37, 99, 235, 0.07);
  --glow: rgba(37, 99, 235, 0.18);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 4px 12px rgba(16, 24, 40, 0.06);
  --radius: 10px;
  --error: #e11d48;
  --error-bg: #fff1f2;
  --ok: #065f46;
}

:root[data-tema="oscuro"] {
  --primary-soft: #1b2c4d;
  --primary-hover: #223a63;
  --card: #161a26;
  --text: #e4e7ec;
  --muted: #8a93a6;
  --border: #262b3a;
  --bg: #0d1017;
  --link: #93c5fd;
  --header-bg: rgba(13, 16, 23, 0.7);
  --grid: rgba(147, 197, 253, 0.08);
  --glow: rgba(96, 165, 250, 0.28);
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  --error: #fb7185;
  --error-bg: rgba(225, 29, 72, 0.18);
  --ok: #6ee7b7;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 16px;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

/* Cabecera: cristal esmerilado con cuadrícula y halo azul, como AquaLab */
.topbar {
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 16px;
  background: var(--header-bg);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  backdrop-filter: blur(14px) saturate(160%);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}
.topbar::before {
  content: "";
  position: absolute;
  top: -120%;
  left: 50%;
  transform: translateX(-50%);
  width: 620px;
  height: 220px;
  background: radial-gradient(closest-side, var(--glow), transparent 72%);
  pointer-events: none;
}
.topbar::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 26px 26px;
  -webkit-mask-image: radial-gradient(ellipse 60% 100% at 50% 0%, black 0%, transparent 75%);
  mask-image: radial-gradient(ellipse 60% 100% at 50% 0%, black 0%, transparent 75%);
  pointer-events: none;
}
.topbar > * { position: relative; z-index: 1; }

.brand { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -0.01em; }
.brand-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 4px 12px -4px rgba(37, 99, 235, 0.5);
  flex-shrink: 0;
}

.topbar nav { display: flex; gap: 4px; }
.topbar nav a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
  padding: 7px 12px;
  border-radius: 999px;
  transition: background .15s, color .15s;
}
.topbar nav a:hover { background: var(--primary-soft); color: var(--link); }
.topbar nav a.active { background: var(--primary-soft); color: var(--link); }

main {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 16px;
}

/* Chat */
.chat-layout { display: flex; flex-direction: column; min-height: 0; padding-bottom: 0; }
.messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding-bottom: 12px; }
.msg {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--primary), #4f46e5);
  color: var(--on-primary);
  border-bottom-right-radius: 4px;
}
.msg.assistant {
  align-self: flex-start;
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-bottom-left-radius: 4px;
}
.msg.error { border-color: var(--error); color: var(--error); background: var(--error-bg); }
.msg.pending { color: var(--muted); font-style: italic; }
.sources { margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); white-space: normal; }

.composer {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 8px;
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
  background: var(--bg);
}
.composer textarea {
  flex: 1;
  min-width: 0;
  resize: none;
  max-height: 140px;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.composer textarea::placeholder, .login-form input::placeholder { color: var(--muted); }
.composer textarea:focus-visible, .login-form input:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

button {
  padding: 10px 16px;
  font: inherit;
  font-weight: 600;
  color: var(--on-primary);
  background: linear-gradient(135deg, var(--primary), #4f46e5);
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  transition: filter .15s, background .15s;
}
button:hover { filter: brightness(1.08); }
button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
button.secondary { background: var(--card); color: var(--link); border: 1px solid var(--border); }
button.secondary:hover { background: var(--primary-soft); filter: none; }
.composer button.secondary { padding: 10px 12px; }
button:disabled { opacity: .5; cursor: default; }
button.link { background: none; color: var(--error); padding: 4px 8px; font-weight: 500; }
button.link:hover { filter: none; text-decoration: underline; }

/* Documentos */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}
.card h1, .card h2 { margin: 0 0 8px; font-size: 18px; }
.muted { color: var(--muted); font-size: 14px; }
#upload-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
#upload-form input[type=file] { flex: 1; min-width: 0; color: var(--muted); }
.status { margin-top: 10px; font-size: 14px; white-space: pre-line; }
.status.ok { color: var(--ok); }
.status.error { color: var(--error); }
.doc-list { list-style: none; margin: 0; padding: 0; }
.doc-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.doc-list li:last-child { border-bottom: 0; }
.doc-name { font-weight: 500; overflow-wrap: anywhere; }

/* Cuenta, tema y login */
.account { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.account form { margin: 0; }
.account select {
  font: inherit;
  padding: 5px 8px;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.username { color: var(--muted); }
button.ghost {
  background: var(--card);
  color: var(--link);
  border: 1px solid var(--border);
  padding: 6px 12px;
  font-weight: 600;
  font-size: 14px;
}
button.ghost:hover { background: var(--primary-soft); filter: none; }
.theme-toggle {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  font-size: 1rem;
  line-height: 1;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
}
.theme-toggle:hover { background: var(--primary-soft); filter: none; }
.login-card { max-width: 380px; margin: 40px auto; }
.login-form { display: flex; flex-direction: column; gap: 12px; }
.login-form label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); font-weight: 500; }
.login-form input {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
code { background: var(--primary-soft); color: var(--link); padding: 2px 6px; border-radius: 4px; font-size: 13px; }

/* Pantallas medias: la marca queda solo con el icono para que todo quepa en una línea */
@media (max-width: 920px) {
  .brand-text { display: none; }
}

/* Móvil y tablet vertical: la navegación pasa a una barra de pestañas inferior (como una app) */
@media (max-width: 820px) {
  :root { --tabbar-h: 58px; }
  body { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
  .username { display: none; }
  .topbar {
    flex-wrap: nowrap;
    padding: 8px 12px;
    overflow: visible;
    background: var(--card);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .topbar::before, .topbar::after { display: none; }
  .topbar nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 25;
    gap: 2px;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: var(--card);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 16px rgba(16, 24, 40, 0.06);
  }
  .topbar nav { overflow-x: auto; scrollbar-width: none; }
  .topbar nav::-webkit-scrollbar { display: none; }
  .topbar nav a {
    flex: 1 0 auto;            /* con 6 pestañas (administrador) la barra se desplaza en vez de cortar los nombres */
    text-align: center;
    padding: 9px 10px;
    font-size: 0.82rem;
    border-radius: 12px;
    white-space: nowrap;
  }
  .composer { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); flex-wrap: wrap; }
  .composer textarea { flex: 1 1 100%; }
  .composer #send { flex: 1; }
  .home-hero h1 { font-size: 1.3rem; }
  .orb-big { width: 128px; height: 128px; }
}

/* Espacio del asistente: orbe animado + voz */
.assistant-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 6px 4px 14px;
}
.hero-text h1 { margin: 0; font-size: 1.15rem; letter-spacing: -0.01em; }
.hero-text p { margin: 2px 0 0; }

.orb {
  position: relative;
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #93c5fd, var(--primary) 55%, var(--accent));
  box-shadow: 0 6px 22px -6px rgba(37, 99, 235, 0.65);
  transition: transform .3s, box-shadow .3s;
}
.orb span {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  opacity: 0;
}
.orb[data-state="idle"] { animation: orb-breathe 4s ease-in-out infinite; }
.orb[data-state="listening"] { transform: scale(1.08); box-shadow: 0 0 0 6px rgba(225, 29, 72, .18), 0 6px 26px -4px rgba(225, 29, 72, .6); background: radial-gradient(circle at 35% 30%, #fda4af, #e11d48 60%, var(--accent)); }
.orb[data-state="listening"] span { border-color: #e11d48; animation: orb-ring 1.4s ease-out infinite; }
.orb[data-state="thinking"] { animation: orb-think 1.1s ease-in-out infinite; }
.orb[data-state="speaking"] span { animation: orb-ring 1s ease-out infinite; }
.orb[data-state="speaking"] { animation: orb-breathe 1s ease-in-out infinite; }

@keyframes orb-breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@keyframes orb-think { 0%, 100% { transform: scale(.94); filter: saturate(.8); } 50% { transform: scale(1.04); filter: saturate(1.3); } }
@keyframes orb-ring { 0% { transform: scale(.9); opacity: .7; } 100% { transform: scale(1.5); opacity: 0; } }

.icon-btn { padding: 10px 12px; font-size: 1.05rem; line-height: 1; }
#mic.listening { background: var(--error-bg); border-color: var(--error); animation: orb-breathe 1s ease-in-out infinite; }

@media (prefers-reduced-motion: reduce) {
  .orb, .orb span, #mic.listening { animation: none !important; }
}

/* Pantalla principal */
button.orb { padding: 0; border: 0; cursor: pointer; }
button.orb:focus-visible { outline: 3px solid var(--primary); outline-offset: 4px; }
.home-hero { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 18px 0 10px; }
.home-hero h1 { margin: 22px 0 4px; font-size: 1.5rem; letter-spacing: -0.02em; }
.home-hero p { margin: 0; font-size: 1rem; }
.orb-big { width: 148px; height: 148px; box-shadow: 0 14px 44px -10px rgba(37, 99, 235, 0.7); }
.orb-big span { inset: -12px; }
/* La gota de AquaLab es la identidad del asistente */
.orb::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46%;
  height: 46%;
  transform: translate(-50%, -50%);
  background: no-repeat center / contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 2.5c3.5 4 6.5 8.2 6.5 11.8a6.5 6.5 0 0 1-13 0c0-3.6 3-7.8 6.5-11.8z'/%3E%3C/svg%3E");
}
.orb-big::before {
  content: "";
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #fff no-repeat center / 22px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232563eb' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='9' y='3' width='6' height='11' rx='3'/%3E%3Cpath d='M5 11a7 7 0 0 0 14 0M12 18v3'/%3E%3C/svg%3E");
  box-shadow: 0 4px 14px -4px rgba(0, 0, 0, 0.45);
}
.home-links { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin: 18px 0; }
.home-link {
  display: flex; flex-direction: column; gap: 2px;
  padding: 12px 14px; text-decoration: none; color: var(--text);
  background: var(--card); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
  transition: border-color .15s, transform .15s;
}
.home-link:hover { border-color: var(--primary); transform: translateY(-1px); }
.home-link span { font-size: 0.85rem; color: var(--muted); }
.home .messages:empty { display: none; }

/* Dentro del panel de AquaLab: solo el contenido, sin barra de navegación */
.embed .topbar { display: none; }
.embed { padding-bottom: 0; }
.embed .home-links { display: none; }
.embed .composer { bottom: 0; }

.badge {
  flex-shrink: 0;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--link);
  background: var(--primary-soft);
}

/* Pantalla de consumo */
:root {
  --s-claude: #2a78d6;
  --s-local: #eb6834;
  --s-none: #1baf7a;
  --meter-track: #cde2fb;
  --warn: #d97706;
}
:root[data-tema="oscuro"] {
  --s-claude: #3987e5;
  --s-local: #d95926;
  --s-none: #199e70;
  --meter-track: #1b2c4d;
  --warn: #f59e0b;
}
.usage { transition: opacity .15s; }
.usage.is-loading { opacity: .6; }
.usage-filters { display: flex; gap: 6px; margin-bottom: 14px; }
.usage-filters button { padding: 7px 14px; font-size: 14px; }
.usage-filters button[aria-pressed="true"] { background: var(--primary-soft); color: var(--link); border-color: var(--primary); }
button.small { padding: 6px 12px; font-size: 13px; }

.usage-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(116px, 1fr)); gap: 10px; margin-bottom: 16px; }
.usage-tile { background: var(--card); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 12px 14px; }
.usage-tile-label { font-size: 13px; color: var(--muted); }
.usage-tile-value { font-size: 1.7rem; font-weight: 700; letter-spacing: -0.02em; margin: 2px 0; }
.usage-tile-note { font-size: 12px; color: var(--muted); }
.meter { height: 8px; margin-top: 8px; border-radius: 999px; background: var(--meter-track); overflow: hidden; }
.meter-fill { height: 100%; border-radius: 999px; background: var(--primary); }
.meter-fill.is-warn { background: var(--warn); }
.meter-fill.is-full { background: var(--error); }

.usage-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.usage-head h2 { margin: 0; }
.usage-legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 10px 0 6px; font-size: 13px; color: var(--muted); }
.usage-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.usage-swatch { width: 12px; height: 12px; border-radius: 3px; }
.usage-chart { position: relative; }
.usage-svg { display: block; width: 100%; height: auto; overflow: visible; }
.usage-grid { stroke: var(--border); stroke-width: 1; }
.usage-baseline { stroke: var(--muted); stroke-width: 1; opacity: .5; }
.usage-axis { font-size: 11px; fill: var(--muted); }
.usage-peak { font-size: 12px; font-weight: 700; fill: var(--text); }
.usage-day { outline: none; }
.usage-day:hover .usage-seg, .usage-day:focus-visible .usage-seg { filter: brightness(1.15); }
.usage-day:focus-visible .usage-hit { stroke: var(--primary); stroke-width: 2; rx: 4; }
.usage-tip {
  position: absolute; top: 0; z-index: 5; pointer-events: none; min-width: 150px;
  padding: 8px 10px; border-radius: 10px; font-size: 13px;
  background: var(--card); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.usage-tip[hidden] { display: none; }
.usage-tip-date { color: var(--muted); font-size: 12px; }
.usage-tip-total { font-weight: 700; margin-bottom: 4px; }
.usage-tip-row { display: flex; align-items: center; gap: 8px; }
.usage-tip-key { width: 14px; height: 3px; border-radius: 2px; flex-shrink: 0; }
.usage-tip-name { color: var(--muted); }
.usage-empty { padding: 24px 0; text-align: center; }

.usage-table { overflow-x: auto; }
.usage-table table { width: 100%; border-collapse: collapse; font-size: 14px; }
.usage-table th, .usage-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.usage-table th { color: var(--muted); font-weight: 600; font-size: 13px; }
.usage-table td.num, .usage-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.usage-table tbody tr:last-child th, .usage-table tbody tr:last-child td { border-bottom: 0; }
@media (max-width: 520px) {
  .usage-tile:last-child:nth-child(odd) { grid-column: 1 / -1; }
}

/* Gestión de usuarios */
.user-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: end; }
.user-form label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); font-weight: 500; }
.user-form input {
  font: inherit; color: var(--text); background: var(--bg);
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radio, 10px);
}
.user-form input:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.user-form-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }
.user-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.user-pass-row { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 0 12px; border-bottom: 1px solid var(--border); }
.user-pass-row input {
  flex: 1; min-width: 160px; font: inherit; color: var(--text); background: var(--bg);
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px;
}
#user-status code { user-select: all; font-size: 14px; }
@media (max-width: 520px) { .user-form { grid-template-columns: 1fr; } }

/* Enlace a Mi cuenta */
.account-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; padding: 4px 6px; border-radius: 8px; }
.account-link:hover { background: var(--primary-soft); color: var(--link); }

/* Aviso de la IA y enlaces legales */
.ai-notice { margin: 4px 0 0; padding: 0 2px; font-size: 12px; line-height: 1.35; color: var(--muted); text-align: center; }
.legal { padding: 10px 16px; text-align: center; font-size: 12px; color: var(--muted); }
.legal a { color: inherit; text-decoration: underline; }
@media (max-width: 820px) { .legal { padding-bottom: calc(var(--tabbar-h, 58px) + 12px + env(safe-area-inset-bottom)); } }
.embed .ai-notice { padding-bottom: 2px; }

.audit-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }

/* ===== Comunidades ===== */
.com-search {
  width: 100%; font: inherit; color: var(--text); background: var(--bg);
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; margin: 6px 0 8px;
}
.com-search:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.com-grid { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.com-card-item { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 12px; background: var(--card); overflow: hidden; }
.com-card-item:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.com-card { display: flex; flex-direction: column; gap: 6px; padding: 14px; color: inherit; text-decoration: none; flex: 1; }
.com-card:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.com-name { font-size: 16px; line-height: 1.25; }
.com-addr { font-size: 13px; }
.com-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.badge.soft { background: transparent; border: 1px solid var(--border); color: var(--muted); font-weight: 500; }
.com-contact-line { font-size: 13px; }
.com-call {
  display: block; padding: 11px 14px; background: var(--primary-soft); color: var(--link); text-decoration: none;
  font-weight: 600; border-top: 1px solid var(--border);
}
.com-call:hover { background: var(--primary-hover); }
.com-empty { grid-column: 1 / -1; padding: 14px 4px; }

.com-head h1 { margin: 6px 0 4px; font-size: 22px; }
.com-back { display: inline-block; font-size: 14px; color: var(--link); text-decoration: none; margin-bottom: 4px; }
.com-back:hover { text-decoration: underline; }
.com-addr-link { display: inline-block; margin: 2px 0 8px; color: var(--link); text-decoration: none; overflow-wrap: anywhere; }
.com-addr-link:hover { text-decoration: underline; }
.com-incomplete { margin: 10px 0 0; padding: 8px 10px; border-radius: 8px; background: rgba(217, 119, 6, 0.12); color: var(--text); font-size: 14px; border: 1px solid rgba(217, 119, 6, 0.45); }
.com-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; align-items: center; }
.com-section h2 { font-size: 16px; margin: 0 0 8px; }
.com-arrive { border-left: 4px solid var(--primary); }
.com-todo { border-left: 4px solid var(--accent); }
.com-contacts { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 8px; }
.com-contacts li { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; padding: 8px 10px; background: var(--bg); border-radius: 10px; }
.com-role { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.com-contacts .com-call { display: inline-block; border: 0; border-radius: 8px; padding: 8px 12px; }
.com-dl { margin: 0; display: grid; grid-template-columns: minmax(130px, 34%) 1fr; gap: 0; }
.com-dl dt, .com-dl dd { margin: 0; padding: 9px 0; border-bottom: 1px solid var(--border); }
.com-dl dt { color: var(--muted); font-size: 14px; padding-right: 12px; }
.com-dl dd { overflow-wrap: anywhere; white-space: pre-line; }
.com-dl dt:last-of-type, .com-dl dd:last-of-type { border-bottom: 0; }
.com-missing { color: var(--muted); font-style: italic; }
.com-pre { white-space: pre-line; margin: 0; line-height: 1.5; }
.com-notes { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.com-note { padding: 10px 12px; background: var(--bg); border-radius: 10px; display: flex; flex-direction: column; gap: 2px; }
.com-note-text { margin: 0; white-space: pre-line; overflow-wrap: anywhere; }
.com-note-meta { font-size: 12px; }
.com-note button.link { align-self: flex-end; padding: 0 4px; font-size: 13px; }
.com-note-form { display: flex; flex-direction: column; gap: 8px; }
.com-note-form textarea, .com-form textarea, .com-form input, .com-form select, .com-contact-row input, .com-contact-row select {
  font: inherit; color: var(--text); background: var(--bg); padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; width: 100%;
}
.com-note-form textarea:focus-visible, .com-form textarea:focus-visible, .com-form input:focus-visible, .com-form select:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 1px;
}
.com-note-form button { align-self: flex-end; }
.com-meta { text-align: center; margin: 4px 0 16px; }

.com-form fieldset { border: 1px solid var(--border); border-radius: 12px; margin: 14px 0; padding: 12px 14px 14px; display: grid; gap: 12px; }
.com-form legend { padding: 0 6px; font-weight: 700; color: var(--link); }
.com-field { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); font-weight: 500; }
.com-contact-list { display: grid; gap: 10px; }
.com-contact-row { display: grid; grid-template-columns: 140px 1fr 150px 1fr auto; gap: 8px; align-items: center; }
.com-form-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; position: sticky; bottom: calc(var(--tabbar-h, 0px) + 8px); background: var(--card); padding: 10px 0 2px; }
@media (max-width: 820px) {
  .com-contact-row { grid-template-columns: 1fr 1fr; }
  .com-contact-row select, .com-contact-row input[name=notas] { grid-column: 1 / -1; }
  .com-contact-row button.link { grid-column: 1 / -1; justify-self: end; }
  .com-dl { grid-template-columns: 1fr; }
  .com-dl dt { padding: 8px 0 0; border-bottom: 0; font-size: 13px; }
  .com-dl dd { padding: 2px 0 8px; }
}

.com-tools { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; }
.com-tool, .com-tools button.secondary { padding: 8px 14px; font: inherit; font-weight: 600; font-size: 14px; border-radius: 10px; }
.com-tool { display: inline-block; text-decoration: none; background: var(--card); color: var(--link); border: 1px solid var(--border); }
.com-tool:hover { background: var(--primary-soft); }
.com-errors { margin: 8px 0 0; padding-left: 20px; display: grid; gap: 4px; font-size: 14px; color: var(--error); }
.com-names { font-size: 14px; color: var(--muted); line-height: 1.6; }

/* Comunidades: fotos */
.com-photo-filter { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.com-photo-filter .chip { padding: 4px 10px; border: 1px solid var(--border, #cfd6dd); border-radius: 999px; background: transparent; color: inherit; font-size: 13px; cursor: pointer; }
.com-photo-filter .chip[aria-pressed="true"] { background: var(--accent, #0b6fa4); border-color: var(--accent, #0b6fa4); color: #fff; }
.com-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 12px; }
.com-photo { margin: 0; background: var(--bg); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; }
.com-photo-open { padding: 0; border: 0; background: none; cursor: zoom-in; display: block; }
.com-photo-open img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.com-photo figcaption { padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.com-photo-pie { overflow-wrap: anywhere; }
.com-photo button.link { align-self: flex-end; padding: 0 4px; font-size: 13px; }
.com-photo-form { display: flex; flex-direction: column; gap: 8px; }
.com-photo-form select, .com-photo-form input { font: inherit; padding: 8px 10px; border: 1px solid var(--border, #cfd6dd); border-radius: 10px; background: var(--card, transparent); color: inherit; }
.com-photo-form button { align-self: flex-end; }
.com-lightbox { position: fixed; inset: 0; z-index: 1000; background: rgba(0, 0, 0, .88); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 16px; }
.com-lightbox img { max-width: 100%; max-height: 80vh; object-fit: contain; border-radius: 8px; }
.com-lightbox-caption { color: #fff; margin: 0; text-align: center; overflow-wrap: anywhere; }
.com-lightbox-close { padding: 8px 18px; }

/* ---- Partes de trabajo ---- */
.par-section { margin-top: 14px; }
.par-section h2 { margin-bottom: 4px; }
.par-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
.par-mini { padding: 4px 10px; font-size: 13px; }
.par-ficha { display: inline-flex; flex-wrap: wrap; gap: 4px; align-items: center; white-space: normal; }
.par-cards, .par-plan { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 10px; }
.par-plan { counter-reset: paso; }
.par-item { border: 1px solid var(--border); border-radius: 12px; background: var(--card); padding: 12px 14px; }
.par-item p { margin: 6px 0 0; }
.par-conf { font-size: 14px; }
.par-why, .par-list { margin: 6px 0 0; padding-left: 20px; display: grid; gap: 3px; font-size: 14px; }
.par-details { margin-top: 8px; }
.par-details summary { cursor: pointer; font-size: 14px; color: var(--link); }
.par-diag { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--primary-soft); border: 1px solid var(--primary); }
.par-text { white-space: pre-wrap; line-height: 1.5; margin-top: 6px; }
.par-map { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); margin-top: 10px; }
.par-map-row { display: flex; flex-direction: column; gap: 3px; font-size: 14px; }
.par-check { display: block; margin-top: 8px; font-size: 14px; }
.par-empty { padding: 18px 4px; }
.usage-table td:has(.par-ficha) { white-space: normal; min-width: 200px; }
.com-where { border-left: 4px solid var(--primary); }
.com-where-list { margin: 6px 0 0; padding-left: 20px; display: grid; gap: 3px; }
.com-missing-note { margin: 6px 0 0; font-size: 13px; color: var(--muted); }

/* Panel del operador */
.op-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.op-bar h1 { margin: 0; font-size: 22px; }
.op-who { display: flex; align-items: center; gap: 10px; margin: 0; }
.op-scroll { overflow-x: auto; }
.op-table { width: 100%; border-collapse: collapse; font-size: 14px; white-space: nowrap; }
.op-table th, .op-table td { text-align: left; padding: 9px 12px 9px 0; border-bottom: 1px solid var(--border); }
.op-table thead th { color: var(--muted); font-weight: 600; font-size: 13px; }
.op-table tbody th { font-weight: 600; }
.op-table tbody tr:last-child th, .op-table tbody tr:last-child td { border-bottom: 0; }
.op-suspended { opacity: .75; }
.op-badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid var(--border); }
.op-badge-on { color: var(--ok); }
.op-badge-off { color: var(--error); }
.op-warn { color: var(--error); font-size: 12px; font-weight: 600; }
.op-bars { display: block; width: 100%; height: 110px; margin: 10px 0 4px; overflow: visible; }
.op-bars-base { stroke: var(--muted); stroke-width: 1; vector-effect: non-scaling-stroke; opacity: .6; }
.op-bars-fill { fill: var(--primary); }
.op-bars-hit { fill: transparent; }
.op-bars g:hover .op-bars-fill { filter: brightness(1.2); }
.op-bars-axis { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.op-form { display: flex; flex-direction: column; gap: 12px; max-width: 460px; }
.op-form label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; font-weight: 500; }
.op-form input, .op-form select { font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); color: var(--text); }
.op-form .muted { font-weight: 400; font-size: 13px; }
button.danger { background: var(--error); color: #fff; }
.op h1 .op-badge { vertical-align: middle; margin-left: 6px; }
.op-notice { border-color: var(--primary); background: var(--primary-soft); }
.op-secret { display: block; font-size: 1.5rem; letter-spacing: .04em; padding: 14px 16px; margin: 12px 0; border: 1px dashed var(--primary); border-radius: 10px; background: var(--card); user-select: all; overflow-wrap: anywhere; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.op-health { margin: 0 0 14px; font-weight: 600; font-size: 14px; }
.op-health a { color: inherit; text-decoration: none; }
.op-health-ok { color: var(--ok); } .op-health-warn { color: #b45309; } .op-health-bad { color: var(--error); }
.op-checks { list-style: none; margin: 0; padding: 0; }
.op-check { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.op-check:last-child { border-bottom: 0; }
.op-check-mark { flex: none; width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; border: 1.5px solid currentColor; }
.op-check-ok .op-check-mark { color: var(--ok); } .op-check-info .op-check-mark { color: var(--muted); }
.op-check-warn .op-check-mark { color: #b45309; } .op-check-error .op-check-mark { color: var(--error); }

/* Revisiones */
.rev h1 { font-size: 22px; margin: 0 0 8px; }
.rev h3 { font-size: 15px; margin: 14px 0 6px; }
.rev-list, .rev-order { list-style: none; margin: 8px 0 0; padding: 0; }
.rev-order { counter-reset: paso; }
.rev-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.rev-row:last-child { border-bottom: 0; }
.rev-info { flex: 1; min-width: 0; font-size: 14px; overflow-wrap: anywhere; }
.rev-name { font-weight: 600; }
.rev-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 4px; font-size: 13px; }
.rev-chips { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.rev-chip { font-size: 12px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); }
.rev-chip-on { color: var(--ok); border-color: currentColor; }
.rev-status-pendiente { color: #b45309; } .rev-status-hecha { color: var(--ok); } .rev-status-parada, .rev-status-sin_configurar { color: var(--muted); }
.rev-progress { height: 8px; border-radius: 999px; background: var(--border); overflow: hidden; margin: 6px 0 10px; }
.rev-progress-fill { display: block; height: 100%; background: var(--primary); }
.rev-service { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin: 0; }
.rev-service legend { font-weight: 600; padding: 0 6px; }
.rev-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-top: 10px; }
.rev-fields label, .rev-form label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; font-weight: 500; }
.rev-form { max-width: 640px; }
.rev-form input, .rev-form select, .rev-form textarea, .rev-fields input, .rev-fields select { font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); color: var(--text); }
.rev-inline { flex-direction: row !important; align-items: center; gap: 8px !important; font-weight: 400 !important; }
.rev-pick .rev-row input[type=checkbox] { width: 20px; height: 20px; flex: none; }
.rev-reminders { border-color: #b45309; }
.rev-fields[hidden] { display: none; }

/* Hoja de ruta imprimible */
.hoja-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.hoja-head h1 { margin: 0; font-size: 22px; }
.hoja-head p { margin: 2px 0 12px; color: var(--muted); }
.hoja-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.hoja-table th, .hoja-table td { border: 1px solid var(--border); padding: 6px 8px; vertical-align: top; text-align: left; }
.hoja-table thead th { background: var(--primary-soft); font-size: 13px; }
.hoja-table .c-n, .hoja-table .c-ok { width: 44px; text-align: center; font-size: 18px; }
.hoja-small { font-size: 12.5px; }
.hoja-svc { margin-bottom: 6px; line-height: 1.7; }
.hoja-notes { margin-top: 6px; min-height: 22px; border-bottom: 1px dotted var(--muted); }
.hoja-hecha { opacity: .55; }
.hoja-foot { color: var(--muted); }
@media print {
  @page { size: A4 landscape; margin: 9mm; }
  body { background: #fff !important; color: #000 !important; }
  .topbar, .legal, .no-print, footer { display: none !important; }
  main { padding: 0 !important; max-width: none !important; }
  .hoja-table th, .hoja-table td { border-color: #000; }
  .hoja-table thead th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .hoja-table tr { break-inside: avoid; }
  .hoja-head p, .hoja-foot { color: #000; }
}
.rev-link { display: inline-block; margin: 0 0 8px; font-size: 14px; font-weight: 600; }
.op-msg { white-space: pre-line; background: var(--primary-soft); border-radius: 8px; padding: 10px 12px; font-size: 14px; }

/* Documentación de la API */
.apidoc h1 { margin: 0 0 6px; font-size: 24px; } .apidoc h2 { font-size: 17px; margin: 18px 0 6px; } .apidoc h3 { margin: 0 0 6px; font-size: 15px; overflow-wrap: anywhere; }
.apidoc code { background: var(--primary-soft); padding: 1px 6px; border-radius: 6px; font-size: .88em; }
.apidoc-code { background: var(--primary-soft); padding: 12px 14px; border-radius: 10px; overflow-x: auto; font-size: 13px; }
.apidoc-m { display: inline-block; min-width: 58px; text-align: center; padding: 2px 8px; border-radius: 6px; color: #fff; font-size: 12px; font-weight: 700; vertical-align: middle; }
.apidoc-get { background: #2563eb; } .apidoc-post { background: #059669; } .apidoc-put { background: #d97706; } .apidoc-delete { background: #dc2626; }
.int-scopes { display: grid; gap: 8px; border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; margin: 0; }
.int-scopes legend { font-weight: 600; padding: 0 6px; font-size: 14px; }
#int-secret { margin-top: 14px; }
