/* ============================================
 * PANEL PRIVADO · IG Tech Advisory
 * Hereda paleta y filosofía de la web pública,
 * adaptada para app interna (mayor densidad).
 * ============================================ */

:root {
  --navy-50:  #EAEDF2;
  --navy-100: #C8D0DC;
  --navy-300: #7187A0;
  --navy-500: #2E4763;
  --navy-600: #0F2A44;
  --navy-700: #0B2138;
  --navy-800: #07182A;
  --green:    #22C55E;
  --green-dark: #16A34A;
  --green-bg: #E8FAEE;
  --red:      #DC2626;
  --red-bg:   #FEF2F2;
  --amber:    #D97706;
  --amber-bg: #FEF3C7;

  --bg:           #FAFAFA;
  --bg-elevated:  #FFFFFF;
  --surface:      #FFFFFF; /* data-table-pro y sticky headers · en dark lo redefine panel-dark.css */
  --bg-soft:      #F9FAFB; /* hover de filas dt-pro · en dark lo redefine panel-dark.css */
  --border:       #E4E4E7;
  --border-strong: #D4D4D8;
  --text:         #18181B;
  --text-muted:   #5C6B7A;
  --text-soft:    #71717A;
  --brand:        var(--navy-600);
  --accent:       var(--green);

  --font-display: 'Inter', system-ui, -apple-system, sans-serif;
  --font-body:    'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, 'SF Mono', monospace;

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  --shadow-sm: 0 1px 3px 0 rgb(15 42 68 / 0.06);
  --shadow:    0 4px 8px -2px rgb(15 42 68 / 0.08), 0 2px 4px -2px rgb(15 42 68 / 0.04);
  --shadow-lg: 0 12px 24px -6px rgb(15 42 68 / 0.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--navy-500); }

img, svg { display: block; max-width: 100%; }

h1, h2, h3, h4 { font-family: var(--font-display); letter-spacing: -0.01em; color: var(--text); }
h1 { font-size: 2rem; font-weight: 800; line-height: 1.15; }
h2 { font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
h3 { font-size: 1.15rem; font-weight: 700; }
h4 { font-size: 1rem; font-weight: 600; }

code, pre {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
}
pre {
  padding: 14px 16px;
  overflow-x: auto;
  line-height: 1.5;
  white-space: pre;
}

.container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 24px;
}

.kicker {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.lead {
  font-size: 1.05rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ============================================
 * LOGIN · pantalla completa, centrado
 * ============================================ */
.login-bg {
  background:
    radial-gradient(circle at 20% 0%, rgb(15 42 68 / 0.04) 0, transparent 50%),
    radial-gradient(circle at 80% 100%, rgb(34 197 94 / 0.04) 0, transparent 50%),
    var(--bg);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-wrap {
  width: 100%;
  max-width: 460px;
}

.login-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: var(--shadow-lg);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}
.login-brand-name {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}
.login-brand-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2em;
  color: var(--accent);
  margin-top: 2px;
}

.login-title {
  font-size: 1.5rem;
  margin-bottom: 4px;
}
.login-sub {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 24px;
}

.login-footer {
  text-align: center;
  margin-top: 24px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-soft);
  letter-spacing: 0.05em;
}

/* ============================================
 * FORMS
 * ============================================ */
.field {
  margin-bottom: 16px;
}
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}
.field input[type="text"],
.field input[type="password"],
.field input[type="email"],
.field textarea {
  width: 100%;
  padding: 12px 14px;
  font-size: 15px;
  font-family: var(--font-body);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text);
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.field input:focus,
.field textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgb(15 42 68 / 0.08);
}

/* iOS: prevenir zoom */
@media (max-width: 768px) {
  .field input,
  .field textarea {
    font-size: 16px !important;
  }
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font-body);
  background: var(--brand);
  color: white;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 150ms ease, transform 150ms ease, box-shadow 150ms ease;
  min-height: 44px;
}
.btn-primary:hover:not(:disabled) {
  background: var(--navy-700);
  transform: translateY(-1px);
  box-shadow: 0 8px 16px -4px rgb(15 42 68 / 0.25);
}
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-block {
  width: 100%;
}

.btn-ghost {
  background: transparent;
  color: var(--brand);
  border: 1px solid var(--border-strong);
}
.btn-ghost:hover {
  background: var(--bg);
  border-color: var(--brand);
}

.back-link {
  display: inline-block;
  margin-top: 20px;
  font-size: 14px;
  color: var(--text-muted);
}
.back-link:hover {
  color: var(--brand);
}

/* ============================================
 * ALERTS
 * ============================================ */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 20px;
  border: 1px solid;
}
.alert p { margin: 0 0 8px; }
.alert p:last-child { margin: 0; }
.alert-error {
  background: var(--red-bg);
  border-color: rgb(220 38 38 / 0.3);
  color: var(--red);
}
.alert-success {
  background: var(--green-bg);
  border-color: rgb(34 197 94 / 0.3);
  color: var(--green-dark);
}
.alert-warning {
  background: var(--amber-bg);
  border-color: rgb(217 119 6 / 0.3);
  color: var(--amber);
}

/* ============================================
 * HEADER del panel (cuando logueado)
 * ============================================ */
.panel-header {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(8px);
  background: color-mix(in srgb, var(--bg-elevated) 92%, transparent);
}

.panel-header-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.panel-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
}
.panel-brand:hover { color: var(--text); }
.panel-brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.1;
}
.panel-brand-sub {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.2em;
  color: var(--accent);
  margin-top: 2px;
}

.panel-user {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 14px;
}
.user-greeting {
  color: var(--text-muted);
}
.user-greeting strong {
  color: var(--text);
  font-weight: 600;
}
.logout-btn {
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: all 150ms ease;
}
.logout-btn:hover {
  background: var(--red-bg);
  border-color: rgb(220 38 38 / 0.3);
  color: var(--red);
}

@media (max-width: 600px) {
  .panel-header-inner { height: 56px; padding: 0 16px; }
  .panel-brand-name { font-size: 0.85rem; }
  .panel-brand img { width: 28px; height: 28px; }
  .user-greeting { display: none; }
}

/* ============================================
 * MAIN
 * ============================================ */
.panel-main {
  padding: 32px 0 64px;
}

.dashboard-head {
  margin-bottom: 32px;
}
.dashboard-head h1 {
  margin-bottom: 8px;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin: 0 4px 0 12px;
  vertical-align: middle;
}
.status-dot.status-active { background: var(--green); }
.status-dot.status-coming { background: var(--text-soft); }

.breadcrumb {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.breadcrumb a {
  color: var(--text-muted);
}
.breadcrumb a:hover {
  color: var(--brand);
}
.breadcrumb .sep {
  margin: 0 8px;
  color: var(--text-soft);
}

/* ============================================
 * CARDS GRID · dashboard
 * ============================================ */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 40px;
}

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: all 200ms ease;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: var(--text);
}
.card-active:hover {
  transform: translateY(-2px);
  border-color: var(--brand);
  box-shadow: var(--shadow-lg);
}
.card-coming {
  opacity: 0.6;
  cursor: not-allowed;
}
.card-coming:hover {
  border-color: var(--border);
}

.card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  background: var(--navy-50);
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}
.card-active .card-icon {
  background: var(--green-bg);
  color: var(--green-dark);
}

.card h2 {
  font-size: 1.1rem;
  margin-bottom: 6px;
}
.card p {
  font-size: 14px;
  color: var(--text-muted);
  flex-grow: 1;
  line-height: 1.5;
  margin-bottom: 16px;
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
}
.card-status.active {
  color: var(--green-dark);
}
.card-status.coming {
  color: var(--text-soft);
}
.card-count {
  color: var(--text-muted);
}

/* ============================================
 * INFO PANEL (session info)
 * ============================================ */
.info-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-top: 32px;
}
.info-panel h3 {
  margin-bottom: 16px;
}
.info-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.info-table th,
.info-table td {
  text-align: left;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.info-table th {
  font-weight: 500;
  color: var(--text-muted);
  width: 30%;
}
.info-table td {
  font-family: var(--font-mono);
  font-size: 13px;
}

/* ============================================
 * FILTERS · portfolio
 * ============================================ */
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
  font-size: 14px;
}
.filters strong {
  margin-right: 4px;
}
.filter-pill {
  padding: 6px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 100px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 150ms ease;
}
.filter-pill:hover {
  border-color: var(--brand);
  color: var(--brand);
}
.filter-pill.active {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}

/* ============================================
 * PORTFOLIO GRID
 * ============================================ */
.portfolio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.proyecto-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  transition: all 200ms ease;
}
.proyecto-card:hover {
  transform: translateY(-2px);
  border-color: var(--brand);
  box-shadow: var(--shadow-lg);
}
.proyecto-card.destacado {
  border-left: 3px solid var(--green);
}

.proyecto-img {
  width: 100%;
  aspect-ratio: 16/9;
  background-color: var(--navy-600);
  background-size: cover;
  background-position: center;
  border-bottom: 1px solid var(--border);
}
.proyecto-img-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--navy-600), var(--navy-800));
  color: rgb(255 255 255 / 0.4);
}

.proyecto-body {
  padding: 20px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

.proyecto-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.proyecto-sector {
  color: var(--brand);
}
.proyecto-year {
  color: var(--text-soft);
}

.proyecto-body h3 {
  margin-bottom: 8px;
  font-size: 1.05rem;
}
.proyecto-body p {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 16px;
  flex-grow: 1;
}

.proyecto-metrica {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 12px 0;
  border-top: 1px dashed var(--border);
  margin-bottom: 12px;
}
.metrica-valor {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--green-dark);
  letter-spacing: -0.02em;
}
.metrica-label {
  font-size: 12px;
  color: var(--text-muted);
}

.proyecto-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tag {
  display: inline-block;
  padding: 3px 10px;
  background: var(--navy-50);
  color: var(--brand);
  border-radius: 100px;
  font-size: 11px;
  font-weight: 500;
  font-family: var(--font-mono);
}
.tag-large {
  display: inline-block;
  padding: 6px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
}

.tags-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ============================================
 * PROYECTO DETAIL
 * ============================================ */
.proyecto-detail {
  max-width: 800px;
}

.proyecto-detail-head {
  margin-bottom: 32px;
}
.proyecto-detail-head h1 {
  margin: 8px 0;
}

.proyecto-metrica-hero {
  background: linear-gradient(135deg, var(--navy-600), var(--navy-800));
  color: white;
  border-radius: var(--radius-lg);
  padding: 40px;
  text-align: center;
  margin-bottom: 32px;
}
.metrica-valor-xl {
  font-family: var(--font-display);
  font-size: 4rem;
  font-weight: 800;
  color: var(--green);
  line-height: 1;
  letter-spacing: -0.04em;
}
.metrica-label-xl {
  margin-top: 8px;
  font-size: 1rem;
  color: rgb(255 255 255 / 0.7);
}

.proyecto-detail-img {
  width: 100%;
  border-radius: var(--radius-lg);
  margin-bottom: 32px;
}

.proyecto-section {
  margin-bottom: 32px;
}
.proyecto-section h2 {
  font-size: 1.25rem;
  margin-bottom: 12px;
}
.proyecto-section p {
  color: var(--text);
  line-height: 1.65;
}

.testimonio {
  background: var(--bg-elevated);
  border-left: 3px solid var(--green);
  padding: 20px 24px;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-style: italic;
  color: var(--text);
}
.testimonio footer {
  margin-top: 12px;
  font-style: normal;
  font-size: 14px;
  color: var(--text-muted);
}

/* ============================================
 * EMPTY STATE / CALLOUT
 * ============================================ */
.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--text-muted);
}
.empty-state h2 {
  margin-bottom: 12px;
}
.empty-state p {
  margin-bottom: 20px;
}

.callout {
  background: var(--bg-elevated);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-top: 32px;
}
.callout h3 {
  margin-bottom: 8px;
}
.callout p {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0;
}

/* ============================================
 * MOBILE
 * ============================================ */
@media (max-width: 768px) {
  .container { padding: 0 16px; }
  .panel-main { padding: 24px 0 48px; }
  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.25rem; }
  .login-card { padding: 28px 24px; }
  .cards-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .card { padding: 20px; }
  .portfolio-grid { grid-template-columns: 1fr; gap: 16px; }
  .metrica-valor-xl { font-size: 3rem; }
  .proyecto-metrica-hero { padding: 28px; }
  .info-table th { width: 40%; }
}

/* ============================================
 * DEMO INTERACTIVA · web, agente IA, auditoría
 * ============================================ */
.demo-section {
  margin: 32px 0;
}
.demo-header {
  margin-bottom: 20px;
}
.demo-badge-live {
  display: inline-block;
  padding: 4px 10px;
  background: var(--green-bg);
  color: var(--green-dark);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  border-radius: 100px;
  margin-bottom: 8px;
}
.demo-description {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.5;
  margin-top: 4px;
}

.demo-frame {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-elevated);
  box-shadow: var(--shadow-lg);
}

.demo-frame-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}
.demo-frame-toolbar .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.dot-red    { background: #FF5F57; }
.dot-yellow { background: #FFBD2E; }
.dot-green  { background: #28C840; }
.demo-url {
  flex: 1;
  text-align: center;
  color: var(--text-soft);
}
.audit-label {
  flex: 1;
  font-weight: 600;
  color: var(--brand);
  letter-spacing: 0.05em;
}
.demo-newtab {
  text-decoration: none;
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: 4px;
  transition: all 150ms ease;
}
.demo-newtab:hover {
  background: var(--bg);
  color: var(--brand);
}

.demo-iframe {
  width: 100%;
  height: 700px;
  border: 0;
  display: block;
  background: white;
}
.demo-iframe-audit {
  height: 900px;
}

/* === CHAT demo agente IA === */
.demo-frame-chat {
  background: var(--navy-800);
  color: var(--bg-elevated);
  display: flex;
  flex-direction: column;
  height: 540px;
}
.demo-chat-head {
  background: linear-gradient(135deg, var(--navy-600), var(--navy-700));
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.demo-chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--green);
  color: var(--navy-800);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-family: var(--font-mono);
}
.demo-chat-name {
  font-weight: 600;
  font-size: 0.95rem;
}
.demo-chat-status {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--green);
  margin-top: 2px;
}
.demo-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background:
    radial-gradient(circle at 30% 30%, rgb(34 197 94 / 0.04) 0, transparent 50%),
    var(--navy-800);
}
.demo-bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
  animation: bubbleSlideIn 0.25s ease-out;
}
@keyframes bubbleSlideIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.demo-bubble--bot {
  align-self: flex-start;
  background: rgb(255 255 255 / 0.08);
  color: var(--bg-elevated);
  border-bottom-left-radius: 4px;
}
.demo-bubble--user {
  align-self: flex-end;
  background: var(--green-dark);
  color: white;
  border-bottom-right-radius: 4px;
}
.demo-typing {
  display: inline-flex;
  gap: 4px;
  padding: 14px;
  width: auto;
}
.demo-typing span {
  width: 6px;
  height: 6px;
  background: rgb(255 255 255 / 0.5);
  border-radius: 50%;
  animation: typingDot 1.2s infinite;
}
.demo-typing span:nth-child(2) { animation-delay: 0.2s; }
.demo-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingDot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}
.demo-chat-input-wrap {
  display: flex;
  gap: 8px;
  padding: 12px;
  background: var(--navy-700);
  border-top: 1px solid rgb(255 255 255 / 0.08);
}
.demo-chat-input {
  flex: 1;
  background: rgb(255 255 255 / 0.08);
  border: 1px solid rgb(255 255 255 / 0.15);
  border-radius: 100px;
  padding: 10px 16px;
  color: var(--bg-elevated);
  font-size: 14px;
  outline: none;
}
.demo-chat-input::placeholder { color: rgb(255 255 255 / 0.4); }
.demo-chat-input:focus {
  border-color: var(--green);
  background: rgb(255 255 255 / 0.12);
}
.demo-chat-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--green);
  color: var(--navy-800);
  border: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease;
}
.demo-chat-send:hover {
  background: var(--green-dark);
  transform: scale(1.05);
}
.demo-chat-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}
.demo-chat-quick button {
  padding: 8px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 100px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: all 150ms ease;
}
.demo-chat-quick button:hover {
  border-color: var(--green);
  background: var(--green-bg);
  color: var(--green-dark);
}

@media (max-width: 768px) {
  .demo-iframe { height: 500px; }
  .demo-iframe-audit { height: 700px; }
  .demo-frame-chat { height: 480px; }
}

/* ============================================
 * TOPBAR (StelOrder navy navigation)
 * ============================================ */
.topbar {
  background: var(--navy-600);
  color: white;
  position: sticky;
  top: 0;
  z-index: 60;
  box-shadow: 0 1px 0 rgb(0 0 0 / 0.12);
}
.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 28px;
}
/* Segunda línea de la topbar · barra de búsqueda global, en un tono
   diferenciado del navy principal para marcar visualmente que es otra fila. */
.topbar-searchbar {
  background: var(--navy-700);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.topbar-searchbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 6px 20px;
  display: flex;
}
.topbar-searchbar .topbar-cmdk { width: 100%; max-width: 360px; }

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: white;
  text-decoration: none;
  flex-shrink: 0;
}
.topbar-brand:hover { color: white; }
/* El logo del panel ya es legible sobre fondo navy (fondo navy redondeado, brackets blancos, dot verde).
   No aplicamos filtro brightness/invert para no perder el color del dot.
   Si en el futuro se sube un logo monocromo oscuro vía settings, basta con devolver el filtro aquí. */
.topbar-brand img { display: block; border-radius: 6px; }
.topbar-brand-name {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
}
.topnav {
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}
.topnav::-webkit-scrollbar { display: none; }

/* Drawer móvil · ocultos en escritorio, se activan en el media query de abajo */
.topbar-burger { display: none; }
.topbar-burger .ico-close { display: none; }
.topnav-backdrop { display: none; }

/* Grupo plegable · en escritorio el wrapper es transparente al layout
   (display:contents) para no alterar el dropdown-on-hover de siempre;
   el botón de flecha es exclusivo del drawer móvil. */
.topnav-group-row { display: contents; }
.topnav-group-panel { display: contents; }
.topnav-group-toggle { display: none; }
body.nav-locked { overflow: hidden; }

/* ============================================
 * FICHAJE · botón global de la topbar (siempre visible)
 * ============================================ */
.topbar-fichaje {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 14px 0 11px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 100px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  letter-spacing: 0.01em;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.16s ease, border-color 0.16s ease, opacity 0.16s ease, transform 0.12s ease;
}
.topbar-fichaje:hover { background: rgba(255, 255, 255, 0.26); }
.topbar-fichaje:active { transform: scale(0.97); }
.topbar-fichaje .tf-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.8);
  flex-shrink: 0;
}
/* Icono de reloj · sustituye al punto de estado solo en pantallas muy
   estrechas (≤400px, ver panel-polish.css), donde el punto solo no se
   reconocía como "fichar". Mismo color de estado que el punto. */
.topbar-fichaje .tf-clock { display: none; flex-shrink: 0; color: rgba(255, 255, 255, 0.85); }
.topbar-fichaje.is-on { background: rgba(34, 197, 94, 0.22); border-color: rgba(34, 197, 94, 0.45); }
.topbar-fichaje.is-on:hover { background: rgba(34, 197, 94, 0.32); }
.topbar-fichaje.is-on .tf-dot {
  background: #22C55E;
  animation: tf-pulse 2s ease-in-out infinite;
}
.topbar-fichaje.is-on .tf-clock { color: #22C55E; }
@keyframes tf-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
.topbar-fichaje.is-loading { opacity: 0.55; pointer-events: none; }

/* Toast de feedback (fichaje y otras acciones AJAX) */
.ig-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(14px);
  background: #0F2A44;
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 12px 32px rgba(15, 42, 68, 0.30);
  z-index: 300;
  opacity: 0;
  max-width: 90vw;
  transition: opacity 0.28s ease, transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}
.ig-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.ig-toast--ok  { background: #15803D; }
.ig-toast--err { background: #B91C1C; }

/* Widget de fichaje en el dashboard */
.dash-fichaje {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.dash-fichaje.is-on {
  border-color: color-mix(in srgb, var(--green, #22C55E) 45%, var(--border));
  background: color-mix(in srgb, var(--green, #22C55E) 6%, var(--bg-elevated));
}
.df-main { display: flex; align-items: center; gap: 18px; min-width: 0; }
.df-clock {
  font-family: var(--font-mono, monospace);
  font-size: 32px;
  font-weight: 800;
  color: var(--brand);
  letter-spacing: 0.02em;
  line-height: 1;
  flex-shrink: 0;
}
.df-info { min-width: 0; }
.df-state { font-size: 15px; font-weight: 600; color: var(--text); }
.df-sub { font-size: 13px; color: var(--text-muted); margin-top: 3px; }
.df-aus { color: var(--amber, #D97706); font-weight: 600; }
.df-actions { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
.df-btn {
  border: 0;
  border-radius: var(--radius);
  padding: 12px 22px;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  font-family: inherit;
  transition: filter 0.15s ease, transform 0.12s ease;
}
.df-btn--in  { background: var(--green, #22C55E); }
.df-btn--out { background: var(--red, #DC2626); }
.df-btn:hover { filter: brightness(1.06); }
.df-btn:active { transform: scale(0.97); }
.df-btn.is-loading { opacity: 0.6; pointer-events: none; }
.df-link { font-size: 13px; color: var(--brand); font-weight: 600; white-space: nowrap; }

@media (max-width: 600px) {
  .dash-fichaje { padding: 14px 16px; gap: 14px; }
  .df-clock { font-size: 26px; }
  .df-actions { width: 100%; justify-content: space-between; }
  .df-btn { flex: 1; }
}
.topnav-inner {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 56px;
}
.topnav-link {
  display: inline-flex;
  align-items: center;
  height: 56px;
  padding: 0 14px;
  color: rgb(255 255 255 / 0.78);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  position: relative;
  transition: color 120ms ease, background 120ms ease;
  white-space: nowrap;
}
.topnav-link:hover {
  color: white;
  background: rgb(255 255 255 / 0.06);
}
.topnav-link.is-active {
  color: white;
  font-weight: 600;
  background: rgb(255 255 255 / 0.08);
}
.topnav-link.is-active::after {
  content: '';
  position: absolute;
  left: 14px; right: 14px; bottom: 0;
  height: 3px;
  background: var(--green);
  border-radius: 2px 2px 0 0;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.topbar-user {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 4px 12px 4px 4px;
  border-radius: 100px;
  background: rgb(255 255 255 / 0.08);
}
.topbar-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--green);
  color: var(--navy-800);
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
}
.topbar-user-name {
  font-size: 13px;
  color: rgb(255 255 255 / 0.92);
  font-weight: 500;
}
.topbar-logout {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: rgb(255 255 255 / 0.7);
  transition: all 120ms ease;
}
.topbar-logout:hover {
  background: rgb(220 38 38 / 0.18);
  color: white;
}

/* Botón icono genérico de la topbar (gestión usuarios, etc.) */
.topbar-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: rgb(255 255 255 / 0.7);
  transition: all 120ms ease;
}
.topbar-icon-btn:hover {
  background: rgb(34 197 94 / 0.18);
  color: #22C55E;
}
.topbar-icon-btn.is-active {
  background: rgb(34 197 94 / 0.22);
  color: #22C55E;
}

/* ============================================
 * ERP SHELL · main full-width content
 * ============================================ */
.erp-shell {
  max-width: 1480px;
  margin: 0 auto;
  padding: 20px 20px 100px;
}

.erp-content {
  min-width: 0;
}

/* Compatibilidad antigua: si hay sidebar vacío */
.sidebar { display: none; }

/* ============================================
 * SUB-TOOLBAR contextual (debajo del nav)
 * ============================================ */
.subtoolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding-bottom: 16px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.subtoolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.subtoolbar-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
}
.subtoolbar-count {
  background: var(--navy-50);
  color: var(--brand);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 100px;
}
.subtoolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.subtoolbar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 7px 12px;
  min-width: 240px;
  transition: border-color 120ms ease;
}
.subtoolbar-search:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgb(15 42 68 / 0.08);
}
.subtoolbar-search input {
  border: 0;
  outline: 0;
  background: transparent;
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text);
  width: 100%;
}
.subtoolbar-search svg { color: var(--text-soft); flex-shrink: 0; }

.btn-fab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--green);
  color: white;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: all 120ms ease;
  box-shadow: 0 2px 6px -1px rgb(34 197 94 / 0.4);
}
.btn-fab:hover {
  background: var(--green-dark);
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px -1px rgb(34 197 94 / 0.5);
}
.btn-fab span {
  font-size: 18px;
  line-height: 1;
  font-weight: 400;
}

.erp-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.erp-toolbar h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
}
.erp-toolbar-left { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.erp-toolbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.erp-count {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg);
  padding: 4px 10px;
  border-radius: 100px;
  border: 1px solid var(--border);
}

.erp-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 6px 10px;
  min-width: 220px;
}
.erp-search input {
  border: 0;
  outline: 0;
  background: transparent;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text);
  width: 100%;
  padding: 2px 0;
}
.erp-search svg { color: var(--text-soft); flex-shrink: 0; }

.erp-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.erp-stat {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: block;
}
a.erp-stat { transition: border-color .12s, box-shadow .12s, transform .12s; }
a.erp-stat:hover {
  border-color: var(--brand);
  box-shadow: 0 4px 14px rgba(15,42,68,.08);
  transform: translateY(-1px);
}
.erp-stat-label {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.erp-stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  font-family: var(--font-display);
  letter-spacing: -0.02em;
}
.erp-stat-sub {
  font-size: 12px;
  color: var(--text-soft);
  margin-top: 2px;
}
.erp-stat--green .erp-stat-value { color: var(--green-dark); }
.erp-stat--red   .erp-stat-value { color: var(--red); }
.erp-stat--amber .erp-stat-value { color: var(--amber); }
.erp-stat--blue  .erp-stat-value { color: #2563eb; }

/* Banner de origen comercial (cliente ex-prospecto) */
.origen-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  margin-bottom: 16px;
  background: color-mix(in srgb, var(--green, #22C55E) 9%, var(--bg-elevated));
  border: 1px solid color-mix(in srgb, var(--green, #22C55E) 30%, var(--border));
  border-left: 3px solid var(--green, #22C55E);
  border-radius: var(--radius);
}
.origen-banner .origen-icon { font-size: 18px; line-height: 1; flex-shrink: 0; }
.origen-banner .origen-text { flex: 1; font-size: 13.5px; color: var(--text); }
.origen-banner .origen-meta { display: block; font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.origen-banner .origen-meta code { font-size: 11.5px; background: var(--bg); padding: 1px 5px; border-radius: 4px; }
.origen-banner .origen-link {
  flex-shrink: 0; font-size: 13px; font-weight: 600; text-decoration: none;
  color: var(--brand); white-space: nowrap;
}
.origen-banner .origen-link:hover { text-decoration: underline; }

/* ============================================
 * DATA TABLE (estilo StelOrder · compacta)
 * ============================================ */
.data-table-wrap {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.data-table thead th {
  background: #F7F8FA;
  text-align: left;
  padding: 9px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  /* sticky eliminado: data-table-wrap tiene overflow-x:auto que convierte
     el wrapper en scroll-container; top:56px empujaba el thead hacia abajo
     mostrando la primera fila de datos por encima de las cabeceras */
}
.data-table tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr {
  transition: background 100ms ease;
  position: relative;
}
.data-table tbody tr:hover {
  background: #F7F8FA;
  cursor: pointer;
}
.data-table tbody tr:nth-child(even) { background: #FCFCFD; }
.data-table tbody tr:nth-child(even):hover { background: #F7F8FA; }

/* Franja de color por estado en la primera columna */
.data-table tbody td:first-child {
  position: relative;
  padding-left: 16px;
}
.data-table tbody td:first-child::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: transparent;
}
.data-table tbody tr.row-state-green   td:first-child::before { background: var(--green); }
.data-table tbody tr.row-state-red     td:first-child::before { background: var(--red); }
.data-table tbody tr.row-state-amber   td:first-child::before { background: var(--amber); }
.data-table tbody tr.row-state-blue    td:first-child::before { background: #3B82F6; }
.data-table tbody tr.row-state-gray    td:first-child::before { background: var(--text-soft); }
.data-table .td-id {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--brand);
  white-space: nowrap;
}
.data-table .td-money {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}
.data-table .td-money-positive { color: var(--green-dark); }
.data-table .td-money-negative { color: var(--red); }
.data-table .td-date {
  white-space: nowrap;
  color: var(--text-muted);
  font-size: 13px;
}
.data-table .td-actions {
  text-align: right;
  white-space: nowrap;
}
.data-table .row-link {
  color: inherit;
  text-decoration: none;
  display: block;
}
.data-table th.th-num,
.data-table td.td-num { text-align: right; }

.data-table .empty-row td {
  padding: 48px 16px;
  text-align: center;
  color: var(--text-muted);
}

/* ============================================
 * BADGES de estado
 * ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 100px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-gray  { background: #F1F1F4; color: #52525B; border-color: #E4E4E7; }
.badge-blue  { background: #E0EAF7; color: #1E40AF; border-color: #BFD3F5; }
.badge-green { background: var(--green-bg); color: var(--green-dark); border-color: #BBF7D0; }
.badge-red   { background: var(--red-bg); color: var(--red); border-color: #FECACA; }
.badge-amber { background: var(--amber-bg); color: var(--amber); border-color: #FDE68A; }

/* ============================================
 * TABS · ficha detalle
 * ============================================ */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin: 24px 0 0;
}
.tab {
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  cursor: pointer;
  margin-bottom: -1px;
  transition: all 120ms ease;
}
.tab:hover { color: var(--text); }
.tab.is-active {
  color: var(--brand);
  border-bottom-color: var(--brand);
  font-weight: 600;
}
.tab-count {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  background: var(--bg);
  border-radius: 100px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.tab.is-active .tab-count {
  background: var(--navy-50);
  color: var(--brand);
  border-color: var(--navy-100);
}
.tab-panel { display: none; padding: 24px 0; }
.tab-panel.is-active { display: block; }

/* ============================================
 * FICHA · detalle compartido
 * ============================================ */
.ficha-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.ficha-titulo h1 {
  font-size: 1.7rem;
  margin: 4px 0 4px;
}
.ficha-titulo .ficha-id {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}
.ficha-meta-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 6px;
  flex-wrap: wrap;
  color: var(--text-muted);
  font-size: 13px;
}
.ficha-meta-row strong { color: var(--text); }

.ficha-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-body);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text);
  transition: all 120ms ease;
  text-decoration: none;
}
.btn:hover {
  border-color: var(--brand);
  color: var(--brand);
}
.btn-solid {
  background: var(--brand);
  color: white;
  border-color: var(--brand);
}
.btn-solid:hover {
  background: var(--navy-700);
  color: white;
  border-color: var(--navy-700);
}
.btn-green {
  background: var(--green);
  color: white;
  border-color: var(--green);
}
.btn-green:hover {
  background: var(--green-dark);
  color: white;
  border-color: var(--green-dark);
}
.btn-red {
  background: var(--bg-elevated);
  color: var(--red);
  border-color: var(--red-bg);
}
.btn-red:hover {
  background: var(--red-bg);
  border-color: var(--red);
}
.btn-sm { padding: 5px 10px; font-size: 12px; }

.kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px 32px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
}
.kv-grid .kv {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.kv .kv-label {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.kv .kv-value {
  font-size: 14px;
  color: var(--text);
  word-break: break-word;
}
.kv .kv-value-mono {
  font-family: var(--font-mono);
  font-size: 13px;
}

.totales-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-top: 16px;
  max-width: 380px;
  margin-left: auto;
}
.totales-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 14px;
}
.totales-row.totales-total {
  border-top: 2px solid var(--border-strong);
  margin-top: 8px;
  padding-top: 12px;
  font-size: 1.05rem;
  font-weight: 700;
}
.totales-row .label { color: var(--text-muted); }
.totales-row .value { font-family: var(--font-mono); }

/* ============================================
 * TIMELINE / COMENTARIOS
 * ============================================ */
.timeline {
  position: relative;
  padding-left: 24px;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--border);
}
.timeline-item {
  position: relative;
  padding: 0 0 18px;
}
.timeline-item::before {
  content: '';
  position: absolute;
  left: -24px;
  top: 4px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 2px solid var(--brand);
}
.timeline-item.is-system::before { border-color: var(--text-soft); }
.timeline-item.is-cliente::before { border-color: var(--green); }
.timeline-time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-soft);
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}
.timeline-author {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}
.timeline-text {
  font-size: 14px;
  color: var(--text);
  margin-top: 4px;
  line-height: 1.5;
  white-space: pre-wrap;
}
.timeline-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--bg);
  border-radius: 100px;
  color: var(--text-muted);
}

/* ============================================
 * SECTION HEADERS dentro de tabs
 * ============================================ */
.section-h {
  font-size: 1rem;
  font-weight: 700;
  margin: 24px 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.section-h:first-child { margin-top: 0; }

/* ============================================
 * FICHA · documento estilo factura (StelOrder)
 * Layout: [DOCUMENTO grande izquierda] [PANEL acciones derecha]
 * ============================================ */
.doc-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  align-items: start;
}
.doc-paper {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 36px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.doc-paper-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  padding-bottom: 20px;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--navy-600);
}
.doc-paper-head h1 {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--text);
}
.doc-paper-head .doc-id {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}
.doc-paper-head .doc-meta {
  text-align: right;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.7;
}
.doc-paper-head .doc-meta strong { color: var(--text); }

.doc-cliente-block {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  margin-bottom: 28px;
}
.doc-cliente-block h4 {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 600;
}
.doc-cliente-block .doc-cliente-name {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 4px;
  color: var(--text);
}
.doc-cliente-block p {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
}
.doc-cliente-block .doc-cliente-meta {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}

/* Tabla de líneas dentro del documento */
.doc-lines {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  margin-bottom: 16px;
}
.doc-lines thead th {
  text-align: left;
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-strong);
  background: transparent;
}
.doc-lines thead th.num { text-align: right; }
.doc-lines tbody td {
  padding: 10px 10px;
  border-bottom: 1px dashed var(--border);
  vertical-align: top;
}
.doc-lines tbody td.num {
  text-align: right;
  font-family: var(--font-mono);
  white-space: nowrap;
}

.doc-totales {
  margin-left: auto;
  width: 340px;
  margin-top: 10px;
}
.doc-totales .tot-row {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  font-size: 13.5px;
}
.doc-totales .tot-row .label { color: var(--text-muted); }
.doc-totales .tot-row .value { font-family: var(--font-mono); }
.doc-totales .tot-final {
  margin-top: 6px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--navy-600);
  color: white;
  font-weight: 700;
  font-size: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.doc-totales .tot-final .value { color: var(--green); font-family: var(--font-mono); }

.doc-footer-notes {
  margin-top: 32px;
  padding-top: 18px;
  border-top: 1px dashed var(--border-strong);
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  white-space: pre-wrap;
}

/* Panel derecho de acciones */
.doc-aside {
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: calc(var(--topbar-h, 117px) + 17px);
}
.doc-aside-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.doc-aside-card h4 {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 12px;
  font-weight: 600;
}
.doc-aside-card .doc-aside-state {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.doc-aside-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.doc-aside-actions .btn,
.doc-aside-actions button.btn {
  width: 100%;
  justify-content: center;
}
.doc-aside-actions form { display: contents; }

.doc-aside-info dt {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-top: 10px;
}
.doc-aside-info dt:first-child { margin-top: 0; }
.doc-aside-info dd {
  font-size: 13px;
  color: var(--text);
  margin: 2px 0 0;
}
.doc-aside-info dd a { color: var(--brand); }

/* ============================================
 * BARRA STICKY ABAJO (acciones documento)
 * ============================================ */
.doc-sticky-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  z-index: 40;
  box-shadow: 0 -4px 12px -4px rgb(15 42 68 / 0.08);
}
.doc-sticky-bar .sticky-info {
  font-size: 13px;
  color: var(--text-muted);
}
.doc-sticky-bar .sticky-info strong {
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 15px;
}
.doc-sticky-bar .sticky-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ============================================
 * BREADCRUMB compacto integrado
 * ============================================ */
.subtoolbar + .breadcrumb,
.breadcrumb {
  margin-bottom: 14px;
}

/* ============================================
 * MOBILE · ERP
 * ============================================ */
@media (max-width: 980px) {
  .doc-layout {
    grid-template-columns: 1fr;
  }
  .doc-aside { position: static; }
  .doc-paper { padding: 24px 22px; }
  .doc-cliente-block { grid-template-columns: 1fr; gap: 18px; }
  .doc-totales { width: 100%; }
}

@media (max-width: 900px) {
  .erp-shell {
    padding: 16px 12px 100px;
  }
  .topbar-inner { padding: 0 12px; gap: 12px; min-height: 56px; }
  .topbar-user-name { display: none; }

  /* CLAVE: la topbar usa backdrop-filter, lo que la convierte en bloque
     contenedor de sus hijos position:fixed. Eso hacía que el drawer se midiera
     contra la topbar (57px) en vez de la pantalla → quedaba aplastado a una
     cajita. Lo anulamos en móvil (doble .topbar para ganar a panel-modern.css,
     que carga después). Así el drawer se mide contra el viewport completo. */
  .topbar.topbar {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  /* ── Botón hamburguesa ── */
  .topbar-burger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: var(--r-md, 8px);
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
    order: -1; /* a la izquierda del todo */
  }
  .topbar-burger:active { background: rgba(255, 255, 255, 0.16); }
  .topbar.nav-open .topbar-burger .ico-burger { display: none; }
  .topbar.nav-open .topbar-burger .ico-close { display: block; }

  /* ── El nav se convierte en drawer lateral deslizante, bajo la topbar ──
     Prefijo .topbar en cada selector para ganar especificidad a
     panel-modern.css, que define .topnav-* y carga DESPUÉS de este archivo. */
  .topbar .topnav {
    position: fixed;
    top: var(--topbar-h, 117px); /* arranca justo debajo de la topbar (medida por JS, ver renderHeader) */
    bottom: 0;
    left: 0;
    right: auto;
    width: 320px;
    max-width: 86vw;
    flex: none;
    box-sizing: border-box;
    overflow-x: hidden;
    overflow-y: auto;
    background: var(--brand, #0F2A44);
    padding: 8px 0 24px;
    transform: translateX(-100%);
    transition: transform 0.24s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 200;
    -webkit-mask-image: none;
    mask-image: none;
    box-shadow: none;
  }
  .topbar.nav-open .topnav {
    transform: translateX(0);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.35);
  }
  .topbar .topnav-inner {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    height: auto;
    gap: 0;
  }

  /* Links del drawer: sin líneas divisorias (look "cuadriculado" descartado a
     propósito) — la separación es solo ritmo de espaciado, y el activo es una
     píldora redondeada insertada, no una barra a sangre viva de borde a borde. */
  .topbar .topnav-inner { gap: 2px; padding: 4px 8px; }
  .topbar .topnav-link {
    display: flex;
    align-items: center;
    width: 100%;
    height: auto;
    padding: 13px 14px;
    font-size: 15px;
    border-radius: 12px;
    transition: background-color 150ms ease;
  }
  .topbar .topnav-link.is-active::after { display: none; }
  .topbar .topnav-link.is-active { background: rgba(255, 255, 255, 0.12); font-weight: 600; }
  .topbar .topnav-link:active { background: rgba(255, 255, 255, 0.08); }
  .topbar .topnav-caret { display: none; }

  /* Grupo plegable: fila (enlace + botón de flecha) + panel animado.
     display:contents en escritorio deja el wrapper "invisible" al layout,
     así el hover-dropdown de siempre sigue funcionando sin cambios. */
  .topbar .topnav-dropdown { display: block; }
  .topbar .topnav-group-row { display: flex; align-items: stretch; gap: 2px; }
  .topbar .topnav-group-row .topnav-link { flex: 1; min-width: 0; }
  .topbar .topnav-group-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 44px;
    border: 0;
    background: transparent;
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.55);
    cursor: pointer;
  }
  .topbar .topnav-group-toggle:active { background: rgba(255, 255, 255, 0.08); }
  .topbar .topnav-group-chevron { transition: transform 220ms var(--ease-out-strong, cubic-bezier(0.23, 1, 0.32, 1)); }
  .topbar .topnav-dropdown.is-open .topnav-group-chevron { transform: rotate(180deg); }
  .topbar .topnav-dropdown.is-open .topnav-group-toggle { color: rgba(255, 255, 255, 0.9); }

  /* Panel plegable: grid-template-rows 0fr↔1fr es la técnica que anima una
     altura "auto" sin conocerla de antemano, cross-browser, sin JS de más. */
  .topbar .topnav-group-panel {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 220ms var(--ease-out-strong, cubic-bezier(0.23, 1, 0.32, 1));
  }
  .topbar .topnav-dropdown.is-open .topnav-group-panel { grid-template-rows: 1fr; }
  .topbar .topnav-dropdown-menu {
    position: static;
    overflow: hidden;
    min-height: 0;
    opacity: 1;
    visibility: visible;
    transform: none;
    transition: none;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
  }
  .topbar .topnav-dropdown-item {
    display: block;
    padding: 12px 14px 12px 34px;
    font-size: 14px;
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.72);
    transition: background-color 150ms ease;
  }
  .topbar .topnav-dropdown-item.is-active {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-weight: 600;
  }
  .topbar .topnav-dropdown-item:active { background: rgba(255, 255, 255, 0.08); }

  @media (prefers-reduced-motion: reduce) {
    .topbar .topnav-group-chevron,
    .topbar .topnav-group-panel { transition: none; }
  }

  /* Backdrop para cerrar tocando fuera (bajo la topbar, que sigue visible).
     top: var(--topbar-h) igual que .topbar .topnav — la topbar móvil tiene
     2 filas (marca+burger + buscador), ~100-120px, no los 57px de una sola
     fila; con el valor fijo el buscador quedaba tapado por el overlay. */
  .topnav-backdrop {
    display: block;
    position: fixed;
    top: var(--topbar-h, 117px);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(7, 24, 42, 0);
    z-index: 190;
    pointer-events: none;
    transition: background 0.24s ease;
  }
  .topbar.nav-open .topnav-backdrop {
    background: rgba(7, 24, 42, 0.5);
    pointer-events: auto;
  }
  /* Cabeceras MANTENIDAS en móvil: los <td> no llevan data-label, así que
     ocultar el thead dejaba los valores sin etiqueta. La tabla scrollea en
     horizontal dentro de .data-table-wrap (overflow-x:auto) con su cabecera. */
  .data-table { font-size: 13px; }
  .data-table thead th { padding: 8px 10px; }
  .data-table tbody td { padding: 9px 10px; }
  .data-table tbody td.td-money { font-size: 14px; }
  .data-table-wrap { -webkit-overflow-scrolling: touch; }
  /* Primera columna como ancla al hacer scroll horizontal */
  .data-table thead th:first-child,
  .data-table tbody td:first-child {
    position: sticky;
    left: 0;
    background: var(--bg-elevated);
    z-index: 1;
  }
  .data-table thead th:first-child { background: #F7F8FA; }
  .subtoolbar-search { min-width: 0; flex: 1; }
}

/* ============================================
 * PRINT · solo el documento, sin chrome de la app
 * ============================================ */
@media print {
  body { background: white; }
  .topbar,
  .subtoolbar,
  .breadcrumb,
  .doc-aside,
  .doc-sticky-bar,
  .erp-stats,
  .filters,
  .alert,
  .empty-state { display: none !important; }
  .erp-shell { padding: 0; max-width: 100%; }
  .doc-layout { grid-template-columns: 1fr; display: block; }
  .doc-paper {
    border: 0;
    box-shadow: none;
    padding: 0;
    margin: 0;
  }
  .doc-paper-head h1 { font-size: 1.5rem; }
  .doc-totales .tot-final { background: #f3f4f6 !important; color: black; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .doc-totales .tot-final .value { color: black; }
  .doc-lines thead th { color: #555; }
  a { color: inherit; text-decoration: none; }
  @page { margin: 1.5cm; }
}

/* ============================================
 * STELORDER · sub-sidebar lateral con menú del módulo
 * ============================================ */
.erp-shell--with-side {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  gap: 14px;
  align-items: start;     /* el sidebar NO se estira a la altura del contenido */
}
/* Cuando el sub-menú se renderiza como pills horizontales (≤5 items),
   colapsamos el grid a una sola columna para que las pills ocupen todo
   el ancho arriba y el contenido aproveche el espacio sin huecos. */
.erp-shell--with-side:has(.submenu-pills) {
  display: block;        /* desactiva el grid */
}
.erp-shell--with-side:has(.submenu-pills) .submenu-pills {
  margin-bottom: 14px;
}
.submenu-side {
  position: sticky;
  top: calc(var(--topbar-h, 117px) + 17px);
  height: fit-content;
}

/* ─── SUB-MENÚ PILLS (horizontal, compacto) ─── */
.submenu-pills {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  padding: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  align-items: center;
}
.submenu-pills-title {
  padding: 4px 12px 4px 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  border-right: 1px solid var(--border);
  margin-right: 4px;
}
.submenu-pills .submenu-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: calc(var(--radius) - 4px);
  border: 0;
  transition: background 0.12s, color 0.12s;
}
.submenu-pills .submenu-link:hover:not(.is-active) {
  background: var(--bg);
  color: var(--text);
}
.submenu-pills .submenu-link.is-active {
  background: var(--brand);
  color: #fff;
  border-left: 0;
  padding-left: 14px;
}
.submenu-pills .submenu-icon { font-size: 14px; line-height: 1; }
.submenu-pills .submenu-badge {
  min-width: 18px;
  padding: 0 6px;
  border-radius: 9px;
  background: rgba(0,0,0,0.08);
  color: inherit;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  line-height: 16px;
}
.submenu-pills .submenu-link.is-active .submenu-badge {
  background: rgba(255,255,255,0.25);
}
.submenu-nav {
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.submenu-title {
  padding: 8px 12px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-muted);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.submenu-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.submenu-icon { font-size: 14px; line-height: 1; flex-shrink: 0; }
.submenu-label { flex: 1; }
.submenu-badge {
  flex-shrink: 0;
  min-width: 20px;
  padding: 1px 7px;
  border-radius: 10px;
  background: var(--border);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-align: center;
}
.submenu-link:last-child { border-bottom: 0; }
.submenu-link:hover { background: var(--bg); }
.submenu-link.is-active {
  background: var(--navy-50);
  color: var(--brand);
  font-weight: 600;
  border-left: 3px solid var(--brand);
  padding-left: 9px;
}
.submenu-link.is-active .submenu-badge { background: var(--brand); color: #fff; }
@media (max-width: 980px) {
  .erp-shell--with-side { grid-template-columns: 1fr; }
  .submenu-side { position: static; }
  .submenu-title { display: none; }
  .submenu-nav { flex-direction: row; flex-wrap: wrap; }
  .submenu-link { flex: 1 1 auto; justify-content: center; padding: 8px 12px; border-bottom: 0; border-right: 1px solid var(--border); text-align: center; }
  .submenu-label { flex: 0 0 auto; }
  .submenu-link.is-active { border-left: 0; border-bottom: 3px solid var(--brand); padding-left: 12px; }
}

/* ============================================
 * STELORDER · barra de acciones de form arriba
 * ============================================ */
.stelorder-actions {
  display: flex;
  gap: 8px;
  padding: 12px 0;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.btn-stel {
  padding: 7px 16px;
  border-radius: 3px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--border-strong);
  background: white;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.1s;
}
.btn-stel:hover { background: var(--bg); }
.btn-stel-save { background: #FFF7E0; border-color: #F0D9A0; color: #8B6914; }
.btn-stel-save:hover { background: #FFE9A6; color: #8B6914; }
.btn-stel-cancel { background: white; color: var(--text); }
.stelorder-h1 {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0 0 20px;
  color: var(--text);
}

/* ============================================
 * STELORDER · form con filas label:input
 * ============================================ */
.stel-form {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 28px;
  margin-bottom: 16px;
}
.stel-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 14px;
  align-items: center;
  margin-bottom: 12px;
}
.stel-row > label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-align: right;
}
.stel-row > input,
.stel-row > select,
.stel-row > textarea {
  padding: 6px 10px;
  font-size: 13px;
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  background: white;
  font-family: var(--font-body);
  outline: none;
  width: 100%;
}
.stel-row > input:focus,
.stel-row > select:focus,
.stel-row > textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgb(15 42 68 / 0.1);
}
.stel-row > input[disabled] { background: #f5f5f5; color: #888; cursor: not-allowed; }
.stel-inline {
  display: flex;
  gap: 6px;
  align-items: center;
}
.stel-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 28px;
}
.stel-grid-2 .stel-row { margin-bottom: 12px; }

/* ============================================
 * STELORDER · tabs centrales
 * ============================================ */
.stel-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-top: 16px;
}
.stel-tab {
  padding: 10px 18px;
  background: transparent;
  border: 0;
  border-bottom: 3px solid transparent;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  margin-bottom: -1px;
  font-family: var(--font-body);
}
.stel-tab:hover:not(.disabled) { color: var(--text); }
.stel-tab.is-active {
  color: var(--brand);
  border-bottom-color: var(--brand);
  font-weight: 600;
}
.stel-tab.disabled {
  color: var(--text-soft);
  cursor: not-allowed;
  opacity: 0.5;
}
.stel-tab-content {
  display: none;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-top: 0;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 24px 28px;
}
.stel-tab-content.is-active { display: block; }

@media (max-width: 768px) {
  .stel-grid-2 { grid-template-columns: 1fr; }
  .stel-row { grid-template-columns: 1fr; }
  .stel-row > label { text-align: left; }
  .stel-tabs { overflow-x: auto; flex-wrap: nowrap; }
  .stel-tab { white-space: nowrap; }
}

/* ============================================
 * Demo tipo "producto" en portfolio
 * ============================================ */
.producto-pitch {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 32px;
}
.producto-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.producto-stat {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-align: center;
}
.producto-stat--green {
  background: var(--green-bg);
  border-color: var(--green);
}
.producto-stat-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.producto-stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--brand);
  font-family: var(--font-display);
}
.producto-stat--green .producto-stat-value {
  color: var(--green-dark);
}
.producto-h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 24px 0 12px;
  color: var(--text);
}
.producto-modules {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}
.producto-mod {
  font-size: 13px;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent);
}
.producto-list {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
}
.producto-list li {
  padding: 8px 0 8px 28px;
  position: relative;
  font-size: 14px;
  line-height: 1.6;
  border-bottom: 1px dashed var(--border);
}
.producto-list li::before {
  content: '✓';
  position: absolute;
  left: 0;
  top: 8px;
  color: var(--green-dark);
  font-weight: 700;
  font-size: 16px;
}
.producto-list li:last-child { border-bottom: 0; }

/* ============================================
 * Aging chip · días vencido en facturas
 * ============================================ */
.aging-chip {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  border-radius: 100px;
  border: 1px solid;
}
.aging-warning {
  background: var(--amber-bg);
  color: var(--amber);
  border-color: #FDE68A;
}
.aging-danger {
  background: var(--red-bg);
  color: var(--red);
  border-color: #FECACA;
}



/* ============================================================
 * EMPTY STATES PREMIUM (lib/empty-states.php)
 * ============================================================ */
.empty-state-premium {
  padding: 56px 24px;
  text-align: center;
  background: var(--bg-elevated, #fff);
  border: 1px dashed var(--border, #e4e4e7);
  border-radius: 14px;
  max-width: 520px;
  margin: 24px auto;
}
.empty-state-icon {
  font-size: 56px; line-height: 1;
  margin-bottom: 16px;
  opacity: 0.85;
}
.empty-state-title {
  font-size: 20px; font-weight: 700;
  color: var(--text, #18181B);
  margin: 0 0 8px;
}
.empty-state-desc {
  font-size: 14px; line-height: 1.5;
  color: var(--text-muted, #5C6B7A);
  margin: 0 0 24px;
  max-width: 380px;
  margin-left: auto; margin-right: auto;
}
.empty-state-ctas {
  display: flex; gap: 8px; justify-content: center; flex-wrap: wrap;
}
.empty-state-ctas .btn { min-height: 44px; padding: 10px 18px; }

@media (max-width: 600px) {
  .empty-state-premium { padding: 36px 16px; }
  .empty-state-ctas { flex-direction: column; }
  .empty-state-ctas .btn { width: 100%; justify-content: center; }
}

/* ============================================================
 * TOOLTIPS (lib/tooltips.php)
 * ============================================================ */
.has-tip {
  position: relative;
  cursor: help;
  border-bottom: 1px dotted var(--text-muted, #5C6B7A);
}
.has-tip .tip-icon {
  font-size: 11px;
  opacity: 0.6;
  vertical-align: super;
  margin-left: 2px;
}
.has-tip:hover::after,
.has-tip:focus::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #18181b;
  color: #fff;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 400;
  white-space: normal;
  line-height: 1.4;
  width: max-content;
  max-width: 280px;
  z-index: 100;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
  pointer-events: none;
}
.has-tip:hover::before,
.has-tip:focus::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #18181b;
  z-index: 100;
  pointer-events: none;
}
@media (max-width: 600px) {
  .has-tip:hover::after { max-width: calc(100vw - 32px); }
}

/* ============================================
   Page-header pegajoso · botones Guardar/Cancelar siempre visibles
   Aplicar añadiendo clase .is-sticky-top al .page-header
   Funciona con HTML5 form="ID" attribute (button submit fuera del form)
   ============================================ */
.page-header.is-sticky-top {
  position: sticky;
  top: var(--topbar-h, 117px);
  z-index: 50;
  padding: 14px 16px;
  margin: -14px -16px 16px;
  border-bottom: 1px solid var(--border, #E4E4E7);
  background-color: rgba(250, 250, 250, 0.92);
  backdrop-filter: saturate(180%) blur(6px);
  -webkit-backdrop-filter: saturate(180%) blur(6px);
  transition: box-shadow 150ms ease;
}
.page-header.is-sticky-top:hover {
  box-shadow: 0 1px 8px -2px rgba(0, 0, 0, 0.06);
}
.page-header.is-sticky-top .page-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
@media (max-width: 700px) {
  .page-header.is-sticky-top {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .page-header.is-sticky-top .page-header-actions {
    display: flex;
    gap: 6px;
  }
  .page-header.is-sticky-top .page-header-actions .btn {
    flex: 1;
    text-align: center;
    min-height: 44px;
  }
}

/* ============================================================
   Command Palette (Ctrl/Cmd+K) · buscador global de módulos y acciones
   ============================================================ */
.topbar-cmdk {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text-muted);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.topbar-cmdk:hover { border-color: var(--border-strong); color: var(--text); }
.topbar-cmdk kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-elevated);
  color: var(--text-muted);
}
@media (max-width: 900px) {
  .topbar-cmdk-label, .topbar-cmdk kbd { display: none; }
  .topbar-cmdk { padding: 0 8px; min-height: 44px; }
}

.cmdk-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(10, 18, 30, .55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 16px 16px;
}
/* CRÍTICO: el display:flex de arriba ganaría al atributo hidden del UA
   stylesheet y el palette quedaría abierto para siempre. */
.cmdk-overlay[hidden] { display: none !important; }
.cmdk-box {
  width: 100%;
  max-width: 580px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 8px 16px rgba(10, 18, 30, .12), 0 28px 80px rgba(10, 18, 30, .4);
  overflow: hidden;
}
.cmdk-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}
.cmdk-input-wrap input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 16px; /* >=16px evita zoom iOS */
}
.cmdk-input-wrap kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
}
.cmdk-results {
  max-height: min(48vh, 420px);
  overflow-y: auto;
  padding: 6px 8px 8px;
}
.cmdk-group {
  padding: 10px 10px 4px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.cmdk-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  border-left: 2px solid transparent;
  cursor: pointer;
  min-height: 40px;
}
.cmdk-item.is-sel {
  background: var(--bg);
  border-left-color: var(--green);
}
.cmdk-item-icon {
  flex: 0 0 22px;
  text-align: center;
  color: var(--green-dark);
  font-weight: 700;
}
.cmdk-item-label { flex: 1; color: var(--text); font-size: 13.5px; }
.cmdk-item-enter {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  opacity: 0;
}
.cmdk-item.is-sel .cmdk-item-enter { opacity: 1; }
.cmdk-empty { padding: 22px; text-align: center; color: var(--text-muted); font-size: 13px; }
.cmdk-foot {
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
}
body.cmdk-open { overflow: hidden; }
@media (prefers-reduced-motion: no-preference) {
  .cmdk-box { animation: cmdk-in .14s ease-out; }
  @keyframes cmdk-in { from { opacity: 0; transform: translateY(-6px) scale(.985); } to { opacity: 1; transform: none; } }
}

/* ============================================================
   Submit feedback global (ux-forms.js) · spinner en el botón
   mientras el formulario se envía + bloqueo de doble submit
   ============================================================ */
button.is-submitting,
input[type="submit"].is-submitting {
  position: relative;
  opacity: .75;
  pointer-events: none;
  cursor: progress;
}
button.is-submitting::after {
  content: '';
  display: inline-block;
  width: 13px;
  height: 13px;
  margin-left: 8px;
  vertical-align: -2px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: ig-submit-spin .65s linear infinite;
}
@keyframes ig-submit-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  button.is-submitting::after { animation: none; opacity: .55; }
}

/* ============================================
 * I18N · selector de idioma ES/CA/EN
 * Vive en el pie del drawer móvil y en login.
 * ============================================ */
.lang-switch { display: flex; gap: 6px; padding: 8px 0; }
.lang-switch-btn {
  min-height: 44px; min-width: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border, rgba(128,128,128,.35));
  border-radius: 8px; font-size: 13px; text-decoration: none;
  color: inherit; opacity: .75;
}
.lang-switch-btn:hover { opacity: 1; }
.lang-switch-btn.is-active { font-weight: 700; border-color: currentColor; opacity: 1; }

/* Dropdown compacto para la topbar de escritorio (ratón, no táctil → más
   pequeño que el .lang-switch de pills). En ≤900px se oculta: ahí el
   selector vive en el pie del drawer (.lang-switch a secas). */
.lang-dd { position: relative; flex-shrink: 0; }
.lang-dd-trigger {
  display: inline-flex; align-items: center; gap: 5px;
  height: 30px; padding: 0 8px;
  border: 1px solid rgba(255,255,255,.22); border-radius: 100px;
  background: rgba(255,255,255,.08); color: rgba(255,255,255,.9);
  font: inherit; font-size: 12px; font-weight: 600; letter-spacing: .01em;
  cursor: pointer; transition: background .15s ease, border-color .15s ease;
}
.lang-dd-trigger:hover { background: rgba(255,255,255,.16); }
.lang-dd.is-open .lang-dd-trigger { background: rgba(255,255,255,.18); border-color: rgba(255,255,255,.4); }
.lang-dd-current { min-width: 16px; }
.lang-dd-caret { transition: transform .15s ease; opacity: .8; }
.lang-dd.is-open .lang-dd-caret { transform: rotate(180deg); }

.lang-dd-menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 1000;
  min-width: 168px;
  background: var(--bg-elevated, #fff); color: var(--text, #0F2A44);
  border: 1px solid var(--border, #E4E4E7); border-radius: 10px;
  box-shadow: 0 10px 32px rgba(15,42,68,.22);
  padding: 6px;
  transform: translateY(-6px); opacity: 0; pointer-events: none;
  transition: transform .15s ease, opacity .15s ease;
}
.lang-dd.is-open .lang-dd-menu { transform: translateY(0); opacity: 1; pointer-events: auto; }
.lang-dd-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 7px;
  font-size: 13px; color: inherit; text-decoration: none;
}
.lang-dd-item:hover { background: var(--bg-soft, #F9FAFB); }
.lang-dd-item.is-active { background: rgba(34,197,94,.12); color: var(--green, #22C55E); font-weight: 700; }
.lang-dd-item-code { font-family: var(--font-mono); font-size: 11px; font-weight: 700; opacity: .7; width: 20px; }
.lang-dd-item.is-active .lang-dd-item-code { opacity: 1; }
@media (max-width: 900px) { .lang-dd { display: none; } }

/* ============================================
 * LÍNEAS DE DOCUMENTO · descripción ampliada + meta (ref · tipo)
 * Propuestas: la descripción es la información del servicio o producto que
 * el cliente lee bajo el concepto. La meta es interna (referencia y tipo).
 * ============================================ */
.doc-lines .linea-desc-txt {
  margin-top: 4px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-muted);
  white-space: normal;
  max-width: 62ch;
}
.doc-lines .linea-meta-txt {
  margin-top: 5px;
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.doc-lines .linea-meta-txt .lmt-ref,
.doc-lines .linea-meta-txt .lmt-tipo {
  font-size: 10.5px;
  line-height: 1.6;
  padding: 0 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.doc-lines .linea-meta-txt .lmt-ref { font-family: var(--font-mono, monospace); }
.doc-lines .linea-meta-txt .lmt-tipo { text-transform: uppercase; letter-spacing: .04em; }

/* Adjuntos en la ficha de propuesta (aside) */
.adj-ficha-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.adj-ficha-list li { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.adj-ficha-list a { color: var(--brand); text-decoration: none; font-weight: 600; word-break: break-word; }
.adj-ficha-list a:hover { text-decoration: underline; }
.adj-ficha-list .adj-f-meta { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono, monospace); }
.adj-ficha-list li.is-oculto a { color: var(--text-muted); }
.adj-ficha-list .adj-f-int { text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }
