/* =========================================================================
   Sistema de diseño — red social de mantenimiento predictivo
   Layout de tres columnas tipo Facebook, con lenguaje visual industrial.
   ========================================================================= */

:root {
  /* Superficies */
  --bg: #f0f2f5;
  --surface: #ffffff;
  --surface-2: #f5f6f8;
  --surface-hover: #eef0f3;
  --border: #dde1e7;
  --border-strong: #c8ced8;

  /* Texto */
  --text: #14181f;
  --text-2: #5a6474;
  --text-3: #8b93a1;

  /* Marca y estados */
  --primary: #1668e3;
  --primary-hover: #1257c0;
  --primary-soft: #e8f0fe;
  --critical: #d93025;
  --critical-soft: #fdecea;
  --warning: #e8890c;
  --warning-soft: #fef3e2;
  --success: #1a8b52;
  --success-soft: #e6f4ec;
  --info: #5a6474;

  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 1px 2px rgba(20, 24, 31, .08), 0 1px 3px rgba(20, 24, 31, .06);
  --shadow-lg: 0 8px 28px rgba(20, 24, 31, .16);
  --header-height: 58px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

[data-theme="dark"] {
  --bg: #12151a;
  --surface: #1b1f26;
  --surface-2: #232830;
  --surface-hover: #2a3039;
  --border: #2e343d;
  --border-strong: #3d4552;
  --text: #e8eaed;
  --text-2: #a7b0bd;
  --text-3: #78828f;
  --primary: #4a8cf7;
  --primary-hover: #6ba1f9;
  --primary-soft: #1c2c46;
  --critical: #f07167;
  --critical-soft: #3a1f1d;
  --warning: #f0a94a;
  --warning-soft: #3a2c14;
  --success: #4cbd82;
  --success-soft: #16301f;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-lg: 0 8px 28px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; font-size: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: inherit; }
[hidden] { display: none !important; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

/* ============================ Utilidades ============================ */

.muted { color: var(--text-2); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.bold { font-weight: 600; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.col { display: flex; flex-direction: column; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.wrap { flex-wrap: wrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.center { text-align: center; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 14px; } .mt-4 { margin-top: 20px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 14px; }

/* ============================ Botones ============================ */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px; border-radius: 8px; border: 1px solid transparent;
  background: var(--surface-2); color: var(--text); font-weight: 600; font-size: 14px;
  transition: background .15s, transform .06s, border-color .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-hover); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--surface-hover); }
.btn-outline { background: transparent; border-color: var(--border-strong); }
.btn-outline:hover { background: var(--surface-hover); }
.btn-danger { background: var(--critical); color: #fff; }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 7px; }
.btn-block { width: 100%; }
.btn-icon {
  width: 38px; height: 38px; padding: 0; border-radius: 50%;
  background: var(--surface-2); font-size: 17px;
}
.btn-icon:hover { background: var(--surface-hover); }

/* ============================ Formularios ============================ */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-2); }

.input, .textarea, .select {
  width: 100%; padding: 11px 13px; border: 1px solid var(--border-strong);
  border-radius: 8px; background: var(--surface); color: var(--text); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
.textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
.field-error { color: var(--critical); font-size: 13px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ============================ Cabecera ============================ */

.topbar {
  position: sticky; top: 0; z-index: 100; height: var(--header-height);
  background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px; padding: 0 16px;
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 17px;
         color: var(--text); letter-spacing: -.3px; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), #17b8a6); color: #fff; font-size: 17px;
}
.brand-name { display: none; }

.search-wrap { position: relative; flex: 1; max-width: 340px; }
.search-input {
  width: 100%; padding: 9px 13px 9px 36px; border-radius: 999px;
  border: 1px solid transparent; background: var(--surface-2); color: var(--text); outline: none;
}
.search-input:focus { border-color: var(--primary); background: var(--surface); }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
               color: var(--text-3); font-size: 14px; pointer-events: none; }

.search-results {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 200;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); max-height: 420px; overflow-y: auto; padding: 6px;
}
.search-group-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--text-3);
  padding: 8px 10px 4px; font-weight: 700;
}
.search-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: 8px; cursor: pointer; color: var(--text);
}
.search-item:hover { background: var(--surface-hover); text-decoration: none; }

.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.demo-logout { color: var(--critical); border-color: color-mix(in srgb, var(--critical) 45%, transparent); }
.demo-logout:hover { background: var(--critical-soft); }

@media (max-width: 600px) {
  .demo-logout { padding: 6px 9px; }
  .demo-logout-label { display: none; }
}

.bell { position: relative; }
.badge-dot {
  position: absolute; top: -3px; right: -3px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--critical); color: #fff; font-size: 11px;
  font-weight: 700; display: grid; place-items: center; border: 2px solid var(--surface);
}

.dropdown {
  position: absolute; top: calc(100% + 10px); right: 16px; width: 360px; max-width: calc(100vw - 24px);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); z-index: 200; overflow: hidden;
}
.dropdown-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 15px; border-bottom: 1px solid var(--border); font-weight: 700;
}
.dropdown-body { max-height: 440px; overflow-y: auto; padding: 6px; }
.dropdown-item {
  display: flex; gap: 11px; padding: 10px; border-radius: 9px; cursor: pointer;
  color: var(--text);
}
.dropdown-item:hover { background: var(--surface-hover); text-decoration: none; }
.dropdown-item.unread { background: var(--primary-soft); }

/* ============================ Layout ============================ */

.layout {
  display: grid; grid-template-columns: 1fr; gap: 18px;
  max-width: 1480px; margin: 0 auto; padding: 18px 14px 60px;
}
.sidebar-left, .sidebar-right { display: none; }

@media (min-width: 900px) {
  .brand-name { display: block; }
  .layout { grid-template-columns: 250px minmax(0, 1fr); padding: 18px; }
  .sidebar-left { display: block; }
}
@media (min-width: 1250px) {
  .layout { grid-template-columns: 250px minmax(0, 620px) 1fr; }
  .sidebar-right { display: block; }
}

.sidebar-left, .sidebar-right {
  position: sticky; top: calc(var(--header-height) + 18px);
  max-height: calc(100vh - var(--header-height) - 36px); overflow-y: auto;
  align-self: start;
}

.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 9px 11px; border-radius: 9px;
  color: var(--text); font-weight: 600; font-size: 14.5px; cursor: pointer;
}
.nav-item:hover { background: var(--surface-hover); text-decoration: none; }
.nav-item.active { background: var(--primary-soft); color: var(--primary); }
.nav-icon {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  background: var(--surface-2); font-size: 16px; flex-shrink: 0;
}
.nav-item.active .nav-icon { background: var(--primary); color: #fff; }
.nav-count { margin-left: auto; font-size: 12px; font-weight: 700; color: var(--text-3); }
.nav-divider { height: 1px; background: var(--border); margin: 12px 4px; }
.nav-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .7px;
  color: var(--text-3); padding: 8px 11px 4px;
}

/* ============================ Tarjetas ============================ */

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow); margin-bottom: 16px;
}
.card-pad { padding: 15px; }
.card-header {
  padding: 13px 15px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.card-title { font-weight: 700; font-size: 15.5px; }
.card-body { padding: 15px; }

/* ============================ Avatares ============================ */

.avatar {
  border-radius: 50%; object-fit: cover; background: var(--surface-2); flex-shrink: 0;
  display: grid; place-items: center; font-weight: 700; color: var(--text-2);
  overflow: hidden; border: 1px solid var(--border);
}
.avatar-sm { width: 32px; height: 32px; font-size: 12px; }
.avatar-md { width: 40px; height: 40px; font-size: 14px; }
.avatar-lg { width: 56px; height: 56px; font-size: 18px; }
.avatar-xl { width: 110px; height: 110px; font-size: 34px; border-width: 4px; border-color: var(--surface); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-machine { border-radius: 12px; }

/* ============================ Insignias y estados ============================ */

.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px;
  border-radius: 999px; font-size: 12px; font-weight: 700;
  background: var(--surface-2); color: var(--text-2); white-space: nowrap;
}
.chip-critical { background: var(--critical-soft); color: var(--critical); }
.chip-warning { background: var(--warning-soft); color: var(--warning); }
.chip-success { background: var(--success-soft); color: var(--success); }
.chip-primary { background: var(--primary-soft); color: var(--primary); }

.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex-shrink: 0; }
.status-operational { background: var(--success); }
.status-degraded { background: var(--warning); }
.status-critical { background: var(--critical); }
.status-maintenance { background: var(--primary); }
.status-offline { background: var(--text-3); }

/* Anillo de salud (SVG) */
.health-ring { position: relative; display: grid; place-items: center; flex-shrink: 0; }
.health-ring svg { transform: rotate(-90deg); }
.health-ring-value {
  position: absolute; font-weight: 800; line-height: 1;
  display: flex; flex-direction: column; align-items: center;
}
.health-ring-value small { font-size: .55em; font-weight: 600; color: var(--text-3); }

/* ============================ Publicaciones ============================ */

.composer-trigger {
  flex: 1; text-align: left; padding: 10px 16px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-2); border: none;
}
.composer-trigger:hover { background: var(--surface-hover); }
.composer-actions { display: flex; gap: 6px; border-top: 1px solid var(--border);
                    margin-top: 12px; padding-top: 10px; }
.composer-action {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px; border-radius: 8px; background: transparent; border: none;
  color: var(--text-2); font-weight: 600; font-size: 13.5px;
}
.composer-action:hover { background: var(--surface-hover); }

.post-header { display: flex; gap: 11px; padding: 14px 15px 10px; }
.post-author { font-weight: 700; font-size: 14.5px; color: var(--text); }
.post-author:hover { text-decoration: underline; }
.post-meta { font-size: 12.5px; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.post-body {
  padding: 0 15px 12px; white-space: pre-wrap; word-wrap: break-word; font-size: 15px;
  line-height: 1.5;
}
.post-alert-bar { height: 4px; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.post-alert-bar.critical { background: var(--critical); }
.post-alert-bar.warning { background: var(--warning); }
.post-alert-bar.info { background: var(--primary); }

.post-attachment {
  margin: 0 15px 12px; padding: 12px 14px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface-2);
}
.post-media { display: grid; gap: 3px; grid-template-columns: 1fr; margin-bottom: 12px; }
.post-media img { width: 100%; max-height: 480px; object-fit: cover; display: block; }
.post-media.multi { grid-template-columns: 1fr 1fr; }

.post-stats {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 15px; font-size: 13px; color: var(--text-2);
}
.reaction-summary { display: flex; align-items: center; gap: 4px; }
.reaction-bubble {
  width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center;
  font-size: 11px; background: var(--surface-2); border: 2px solid var(--surface);
  margin-right: -6px;
}

.post-actions { display: flex; border-top: 1px solid var(--border); padding: 4px 8px; }
.post-action {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px; border-radius: 8px; background: transparent; border: none;
  color: var(--text-2); font-weight: 600; font-size: 14px;
}
.post-action:hover { background: var(--surface-hover); }
.post-action.active { color: var(--primary); }

.reaction-picker {
  position: absolute; bottom: calc(100% + 6px); left: 0; z-index: 50;
  display: flex; gap: 3px; padding: 6px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 999px; box-shadow: var(--shadow-lg);
}
.reaction-option {
  width: 38px; height: 38px; border-radius: 50%; border: none; background: transparent;
  font-size: 20px; display: grid; place-items: center; transition: transform .12s;
}
.reaction-option:hover { transform: scale(1.25) translateY(-3px); background: var(--surface-2); }

.comments { border-top: 1px solid var(--border); padding: 12px 15px; }
.comment { display: flex; gap: 9px; margin-bottom: 11px; }
.comment-bubble {
  background: var(--surface-2); border-radius: 16px; padding: 8px 13px; max-width: 100%;
}
.comment-author { font-weight: 700; font-size: 13px; }
.comment-text { font-size: 14px; white-space: pre-wrap; word-wrap: break-word; }
.comment-actions { display: flex; gap: 12px; padding: 3px 13px; font-size: 12px;
                   font-weight: 600; color: var(--text-3); }
.comment-actions button { background: none; border: none; color: inherit; font-weight: 600;
                          padding: 0; font-size: 12px; }
.comment-actions button:hover { text-decoration: underline; }
.comment-solution { border: 1.5px solid var(--success); background: var(--success-soft); }

.comment-form { display: flex; gap: 9px; align-items: flex-start; }
.comment-input {
  flex: 1; padding: 9px 14px; border-radius: 18px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); outline: none; resize: none;
  min-height: 38px; max-height: 140px; line-height: 1.4;
}
.comment-input:focus { border-color: var(--primary); background: var(--surface); }

/* ============================ Perfil de activo ============================ */

.profile-cover {
  height: 220px; border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  background: linear-gradient(135deg, #1e3a5f, #2d6a8f 55%, #17b8a6);
  position: relative; overflow: hidden;
}
.profile-cover::after {
  /* Trama técnica sutil, evoca un plano de planta */
  content: ''; position: absolute; inset: 0; opacity: .16;
  background-image: linear-gradient(rgba(255,255,255,.5) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(255,255,255,.5) 1px, transparent 1px);
  background-size: 42px 42px;
}
.profile-head { padding: 0 22px 16px; position: relative; z-index: 1; }
/* Solo el avatar monta sobre la portada; el texto queda siempre sobre el fondo del card. */
.profile-head > .row > .avatar-xl { margin-top: -52px; }
.profile-name { font-size: 26px; font-weight: 800; letter-spacing: -.5px; margin: 12px 0 4px; }
.profile-tabs { display: flex; gap: 4px; border-top: 1px solid var(--border); padding: 4px 12px; overflow-x: auto; }
.profile-tab {
  padding: 12px 15px; border: none; background: none; font-weight: 700; font-size: 14px;
  color: var(--text-2); border-bottom: 3px solid transparent; white-space: nowrap;
}
.profile-tab:hover { background: var(--surface-hover); border-radius: 8px 8px 0 0; }
.profile-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.spec-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 12px; }
.spec-item { background: var(--surface-2); border-radius: var(--radius); padding: 11px 13px; }
.spec-label { font-size: 11.5px; color: var(--text-3); text-transform: uppercase;
              letter-spacing: .5px; font-weight: 700; }
.spec-value { font-weight: 700; font-size: 15px; margin-top: 3px; word-break: break-word; }

/* ============================ Sensores y gráficos ============================ */

.sensor-card {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 13px;
  background: var(--surface); cursor: pointer; transition: border-color .15s, transform .08s;
}
.sensor-card:hover { border-color: var(--primary); transform: translateY(-1px); }
.sensor-card.state-critical { border-left: 4px solid var(--critical); }
.sensor-card.state-warning { border-left: 4px solid var(--warning); }
.sensor-card.state-normal { border-left: 4px solid var(--success); }
.sensor-card.state-no_data { border-left: 4px solid var(--text-3); }
.sensor-value { font-size: 25px; font-weight: 800; letter-spacing: -.6px; }
.sensor-unit { font-size: 14px; font-weight: 600; color: var(--text-3); }

.chart-wrap { position: relative; width: 100%; overflow-x: auto; }
.chart-svg { width: 100%; height: 220px; display: block; }
.chart-line { fill: none; stroke: var(--primary); stroke-width: 2; stroke-linejoin: round; }
.chart-area { fill: var(--primary); opacity: .1; }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-threshold-warning { stroke: var(--warning); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart-threshold-critical { stroke: var(--critical); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart-label { font-size: 10.5px; fill: var(--text-3); }
.chart-trend { stroke: var(--critical); stroke-width: 1.5; stroke-dasharray: 3 3; fill: none; }

/* ============================ Listas ============================ */

.list-item {
  display: flex; align-items: center; gap: 11px; padding: 10px;
  border-radius: 9px; cursor: pointer; color: var(--text);
}
.list-item:hover { background: var(--surface-hover); text-decoration: none; }

.wo-card {
  border: 1px solid var(--border); border-left-width: 4px; border-radius: var(--radius);
  padding: 13px 15px; margin-bottom: 10px; background: var(--surface); cursor: pointer;
}
.wo-card:hover { border-color: var(--primary); }
.wo-card.priority-urgent { border-left-color: var(--critical); }
.wo-card.priority-high { border-left-color: var(--warning); }
.wo-card.priority-medium { border-left-color: var(--primary); }
.wo-card.priority-low { border-left-color: var(--text-3); }
.wo-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px;
           font-weight: 700; color: var(--text-3); }

.checklist-item {
  display: flex; align-items: flex-start; gap: 10px; padding: 9px 11px;
  border-radius: 8px; cursor: pointer;
}
.checklist-item:hover { background: var(--surface-hover); }
.checklist-item.done { color: var(--text-3); text-decoration: line-through; }
.checkbox {
  width: 19px; height: 19px; border-radius: 5px; border: 2px solid var(--border-strong);
  display: grid; place-items: center; flex-shrink: 0; margin-top: 1px; font-size: 12px;
  color: transparent;
}
.checklist-item.done .checkbox { background: var(--success); border-color: var(--success); color: #fff; }

/* ============================ Estadísticas ============================ */

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stat-tile { background: var(--surface-2); border-radius: var(--radius); padding: 13px 15px; }
.stat-value { font-size: 27px; font-weight: 800; letter-spacing: -.8px; line-height: 1.1; }
.stat-label { font-size: 12.5px; color: var(--text-2); margin-top: 3px; font-weight: 600; }

/* ============================ Administración ============================ */

.admin-member-row { align-items: center; gap: 14px; }
.admin-member-disabled { opacity: .72; }
.admin-member-meta { display: flex; flex-wrap: wrap; gap: 5px 14px; margin-top: 7px; }
.admin-member-meta span:not(:last-child)::after { content: '·'; margin-left: 14px; }
.admin-member-actions { display: flex; flex-direction: column; gap: 7px; }

@media (max-width: 640px) {
  .admin-member-row { align-items: flex-start; flex-wrap: wrap; }
  .admin-member-row > .grow { min-width: calc(100% - 72px); }
  .admin-member-actions { width: 100%; flex-direction: row; }
  .admin-member-actions .btn { flex: 1; }
}

.bar-track { height: 7px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; transition: width .4s ease; }

/* ============================ Modal ============================ */

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(10, 14, 20, .6); z-index: 300;
  display: grid; place-items: center; padding: 16px; backdrop-filter: blur(2px);
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 560px; max-height: 90vh; display: flex; flex-direction: column;
  animation: modal-in .16s ease-out;
}
.modal-wide { max-width: 820px; }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.modal-header {
  padding: 15px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.modal-title { font-weight: 700; font-size: 17px; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-footer {
  padding: 13px 18px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* ============================ Toasts ============================ */

.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 400; display: flex;
          flex-direction: column; gap: 10px; max-width: 380px; }
.toast {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--primary);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 12px 15px;
  animation: toast-in .18s ease-out; font-size: 14px;
}
.toast.error { border-left-color: var(--critical); }
.toast.success { border-left-color: var(--success); }
.toast.warning { border-left-color: var(--warning); }
@keyframes toast-in { from { opacity: 0; transform: translateX(24px); } }

/* ============================ Autenticación ============================ */

.auth-screen {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1100px 560px at 12% -8%, #1e3a5f 0%, transparent 62%),
              radial-gradient(900px 480px at 108% 108%, #17b8a6 0%, transparent 58%),
              var(--bg);
}
.auth-wrap {
  display: grid; grid-template-columns: 1fr; gap: 34px; align-items: center;
  max-width: 1000px; width: 100%;
}
@media (min-width: 940px) { .auth-wrap { grid-template-columns: 1.05fr .95fr; gap: 56px; } }
.auth-pitch h1 { font-size: 38px; line-height: 1.12; margin: 0 0 14px; letter-spacing: -1.2px; }
.auth-pitch p { font-size: 17px; color: var(--text-2); margin: 0 0 22px; max-width: 460px; }
.auth-feature { display: flex; gap: 13px; margin-bottom: 15px; align-items: flex-start; }
.auth-feature-icon {
  width: 38px; height: 38px; border-radius: 10px; background: var(--primary-soft);
  color: var(--primary); display: grid; place-items: center; font-size: 17px; flex-shrink: 0;
}
.auth-card { background: var(--surface); border-radius: var(--radius-lg); padding: 26px;
             box-shadow: var(--shadow-lg); border: 1px solid var(--border); }
.auth-tabs { display: flex; gap: 4px; margin-bottom: 20px; background: var(--surface-2);
             padding: 4px; border-radius: 10px; }
.auth-tab { flex: 1; padding: 9px; border: none; background: none; border-radius: 7px;
            font-weight: 700; color: var(--text-2); font-size: 14px; }
.auth-tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.demo-hint {
  margin-top: 16px; padding: 11px 13px; border-radius: 9px; background: var(--primary-soft);
  color: var(--primary); font-size: 13px; line-height: 1.5;
}

/* ============================ Estados vacíos y carga ============================ */

.empty { text-align: center; padding: 44px 22px; color: var(--text-2); }
.empty-icon { font-size: 42px; margin-bottom: 12px; opacity: .55; }
.empty-title { font-weight: 700; font-size: 16px; color: var(--text); margin-bottom: 5px; }

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-hover) 50%, var(--surface-2) 75%);
  background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 7px;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.skeleton-line { height: 12px; margin-bottom: 9px; }

.spinner {
  width: 19px; height: 19px; border: 2.5px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================ Copiloto ============================ */

.copilot-fab {
  position: fixed; bottom: 22px; right: 22px; z-index: 150;
  width: 56px; height: 56px; border-radius: 50%; border: none;
  background: linear-gradient(135deg, var(--primary), #17b8a6); color: #fff;
  font-size: 24px; box-shadow: var(--shadow-lg); display: grid; place-items: center;
}
.copilot-fab:hover { transform: scale(1.06); }

.chat-messages {
  display: flex; flex-direction: column; gap: 12px; max-height: 50vh;
  overflow-y: auto; padding: 4px;
}
.chat-msg { display: flex; gap: 9px; max-width: 88%; }
.chat-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.chat-bubble {
  padding: 10px 14px; border-radius: 15px; background: var(--surface-2);
  white-space: pre-wrap; line-height: 1.5; font-size: 14.5px;
}
.chat-msg.user .chat-bubble { background: var(--primary); color: #fff; }

@media (max-width: 640px) {
  .layout { padding: 12px 8px 80px; }
  .card { border-radius: var(--radius); }
  .profile-cover { height: 150px; }
  .profile-head { padding: 0 14px 14px; }
  .auth-pitch { display: none; }
  .field-row { grid-template-columns: 1fr; }
}
