/* ================================================================
   D Life — Global Design System
   Aesthetic: Warm Obsidian + Amber Gold
   Fonts: Fraunces (display) · Outfit (body) · JetBrains Mono (data)
   ================================================================ */

:root {
  /* ── Backgrounds ─────────────────────────────── */
  --bg:          #0b0906;
  --bg-card:     #111009;
  --bg-elevated: #1b1713;
  --bg-hover:    #231f19;

  /* ── Borders ─────────────────────────────────── */
  --border:        #282218;
  --border-bright: #3c3428;

  /* ── Text ────────────────────────────────────── */
  --text:       #ede9df;
  --text-muted: #87796a;
  --text-faint: #453e34;

  /* ── Accent — Warm Amber Gold ────────────────── */
  --accent:        #d4922a;
  --accent-hover:  #e8a840;
  --accent-dim:    rgba(212, 146, 42, 0.10);
  --accent-border: rgba(212, 146, 42, 0.28);

  /* ── Semantic colours ────────────────────────── */
  --success:      #6ee7b7;
  --success-dim:  rgba(110, 231, 183, 0.12);
  --warning:      #fbbf24;
  --warning-dim:  rgba(251, 191, 36, 0.12);
  --danger:       #f87171;
  --danger-dim:   rgba(248, 113, 113, 0.12);

  /* ── Typography ──────────────────────────────── */
  --font:         'Outfit', system-ui, sans-serif;
  --font-display: 'Fraunces', Georgia, serif;
  --font-mono:    'JetBrains Mono', monospace;

  /* ── Layout ──────────────────────────────────── */
  --radius:    12px;
  --radius-sm:  8px;
  --radius-xs:  4px;
  --sidebar-w: 240px;

  /* ── Shadows ─────────────────────────────────── */
  --shadow:      0 8px 40px rgba(0, 0, 0, 0.55);
  --shadow-sm:   0 2px 16px rgba(0, 0, 0, 0.35);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.2);

  /* ── Transitions ─────────────────────────────── */
  --ease: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset ───────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ================================================================
   LOGIN PAGE
   ================================================================ */

body.login-body {
  overflow: hidden;
  height: 100vh;
}

#login-page.login-page {
  display: flex;
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
}

/* ── Brand panel (left) ──────────────────────── */
.login-brand-panel {
  width: 42%;
  flex-shrink: 0;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 3rem;
  position: relative;
  overflow: hidden;
}

.login-brand-panel::before {
  content: '';
  position: absolute;
  top: -40%;
  left: -30%;
  width: 80%;
  height: 80%;
  background: radial-gradient(ellipse, rgba(212, 146, 42, 0.09) 0%, transparent 70%);
  pointer-events: none;
}

.login-brand-panel::after {
  content: '';
  position: absolute;
  bottom: -25%;
  right: -25%;
  width: 65%;
  height: 65%;
  background: radial-gradient(ellipse, rgba(212, 146, 42, 0.05) 0%, transparent 70%);
  pointer-events: none;
}

.login-brand-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: auto;
  position: relative;
}

.login-brand-mark {
  width: 36px;
  height: 36px;
  background: var(--accent);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  color: #0b0906;
  flex-shrink: 0;
  letter-spacing: -0.03em;
}

.login-brand-name {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
}

.login-brand-tagline {
  margin-top: auto;
  margin-bottom: 2.5rem;
  position: relative;
}

.login-brand-tagline h2 {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  font-weight: 300;
  font-style: italic;
  line-height: 1.2;
  color: var(--text);
  margin-bottom: 1.5rem;
  letter-spacing: -0.02em;
}

.login-brand-tagline h2 em {
  color: var(--accent);
  font-style: normal;
}

.login-brand-modules {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.login-brand-module {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 0.22rem 0.55rem;
}

/* ── Form panel (right) ──────────────────────── */
.login-form-panel {
  flex: 1;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  overflow-y: auto;
}

.login-card {
  width: 100%;
  max-width: 380px;
}

.login-header {
  margin-bottom: 2rem;
}

.login-header h1 {
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--text);
  letter-spacing: -0.025em;
}

.login-header p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.login-form label {
  display: block;
  font-size: 0.76rem;
  font-weight: 600;
  margin-bottom: 0.45rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.login-form input {
  width: 100%;
  padding: 0.8rem 1rem;
  margin-bottom: 1.1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.95rem;
  font-family: var(--font);
  transition: border-color var(--ease), box-shadow var(--ease);
}

.login-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.login-form .error {
  color: var(--danger);
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
  padding: 0.55rem 0.85rem;
  background: var(--danger-dim);
  border-radius: var(--radius-xs);
  border-left: 2px solid var(--danger);
}

.login-form .error.hidden { display: none; }

.login-switch {
  text-align: center;
  margin-top: 1.25rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.login-switch a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.login-switch a:hover { color: var(--accent-hover); }

/* ── Powered by (login) ──────────────────────── */
.powered-by {
  display: block;
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-faint);
  text-decoration: none;
  padding: 0.75rem 0 0.25rem;
  transition: color var(--ease);
  letter-spacing: 0.02em;
}

.powered-by:hover { color: var(--text-muted); }

/* ── Mobile login ────────────────────────────── */
@media (max-width: 768px) {
  body.login-body { overflow: auto; }

  #login-page.login-page {
    flex-direction: column;
    position: relative;
    height: auto;
    min-height: 100dvh;
    overflow-y: auto;
  }

  .login-brand-panel {
    width: 100%;
    flex-shrink: 0;
    padding: 2rem;
  }

  .login-brand-tagline {
    margin-top: 2rem;
    margin-bottom: 0;
  }

  .login-brand-tagline h2 { font-size: 1.7rem; }

  .login-brand-modules { display: none; }

  .login-form-panel {
    flex: none;
    padding: 2rem;
    align-items: stretch;
    justify-content: flex-start;
  }

  .login-card { max-width: 100%; }
}

@media (max-width: 480px) {
  .login-brand-panel { padding: 1.5rem 1.25rem; }
  .login-form-panel { padding: 1.5rem 1.25rem; }
  .login-brand-tagline h2 { font-size: 1.4rem; }
  .login-brand-logo { margin-bottom: 0.75rem; }
}

/* ================================================================
   BUTTONS
   ================================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.65rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: var(--font);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--ease), color var(--ease), box-shadow var(--ease), transform var(--ease);
  text-decoration: none;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent);
  color: #0b0906;
  width: 100%;
  margin-top: 0.5rem;
  font-weight: 700;
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 20px rgba(212, 146, 42, 0.35);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
}

.btn-ghost:hover {
  color: var(--text);
  background: var(--bg-elevated);
  border-color: var(--border);
}

.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.82rem;
  width: auto;
  margin-top: 0;
}

/* ================================================================
   DASHBOARD LAYOUT
   ================================================================ */

#app { min-height: 100vh; }

.page { display: none; min-height: 100vh; }
.page.active { display: flex; }

#dashboard-page {
  flex: 1;
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 0 1rem;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  overflow-y: auto;
  scrollbar-width: none;
}

.sidebar::-webkit-scrollbar { display: none; }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0 1rem;
  margin-bottom: 2rem;
}

.sidebar-brand-mark {
  width: 30px;
  height: 30px;
  background: var(--accent);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  color: #0b0906;
  flex-shrink: 0;
  letter-spacing: -0.02em;
}

.sidebar-brand-text {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0 0.6rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.75rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: color var(--ease), background var(--ease), border-color var(--ease);
}

.nav-link:hover {
  color: var(--text);
  background: var(--bg-elevated);
}

.nav-link.active {
  color: var(--accent);
  background: var(--accent-dim);
  border-color: var(--accent-border);
}

.nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.65;
  transition: opacity var(--ease);
}

.nav-link.active .nav-icon,
.nav-link:hover .nav-icon { opacity: 1; }

/* ── Drag & Drop reordering ──────────────────── */
.nav-link[draggable="true"] { cursor: grab; }
.nav-link[draggable="true"]:active { cursor: grabbing; }

.nav-link.dragging {
  opacity: 0.35;
  border-style: dashed;
  background: var(--bg-elevated);
}

.nav-link.drag-over-top {
  box-shadow: inset 0 2px 0 0 var(--accent);
}

.nav-link.drag-over-bottom {
  box-shadow: inset 0 -2px 0 0 var(--accent);
}

.nav-drag-handle {
  width: 10px;
  height: 14px;
  margin-left: auto;
  flex-shrink: 0;
  opacity: 0.25;
  transition: opacity var(--ease);
  color: var(--text-faint);
}

.nav-link[draggable="true"]:hover .nav-drag-handle { opacity: 0.7; }
.nav-link[draggable="true"].active .nav-drag-handle { opacity: 0.5; }

/* ── Sidebar footer ──────────────────────────── */
.sidebar-footer {
  padding: 0.6rem 0.6rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  border-top: 1px solid var(--border);
  margin-top: 0.5rem;
}

.logout-btn {
  width: 100%;
  justify-content: flex-start;
  gap: 0.65rem;
  padding: 0.6rem 0.75rem;
  font-size: 0.875rem;
  border-radius: var(--radius-sm);
}

/* ── Main content ────────────────────────────── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  padding: 1.1rem 2rem;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 9, 6, 0.85);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(10px);
}

.topbar h2 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--text);
}

.content-area {
  flex: 1;
  padding: 1.75rem 2rem;
  overflow-y: auto;
}

.section { display: none; }
.section.active { display: block; }

/* ================================================================
   SKELETON LOADING
   ================================================================ */

.section-skeleton {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.section-skeleton .skeleton-block {
  background: linear-gradient(
    90deg,
    var(--bg-card) 0%,
    var(--bg-elevated) 50%,
    var(--bg-card) 100%
  );
  background-size: 200% 100%;
  border-radius: var(--radius-sm);
  height: 120px;
  animation: skeleton-wave 1.5s ease-in-out infinite;
}

.section-skeleton .skeleton-block.wide {
  grid-column: span 2;
  height: 160px;
}

@keyframes skeleton-wave {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.section-error {
  color: var(--danger);
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: var(--danger-dim);
  border-radius: var(--radius-sm);
  border-left: 2px solid var(--danger);
  font-size: 0.9rem;
}

.section-retry-wrap { margin-top: 1rem; }

/* ================================================================
   CARDS
   ================================================================ */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.card h3 {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.9rem;
  color: var(--text-muted);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

.card-link {
  cursor: pointer;
  transition: border-color var(--ease), transform var(--ease), box-shadow var(--ease);
  text-decoration: none;
  display: block;
  color: inherit;
}

.card-link:hover {
  border-color: var(--accent-border);
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.3), 0 0 0 1px var(--accent-border);
}

.card-link .card-goto {
  font-size: 0.7rem;
  color: var(--accent);
  opacity: 0;
  transition: opacity var(--ease);
  float: right;
  margin-top: 0.1rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.card-link:hover .card-goto { opacity: 1; }

/* Placeholder cuando una card está vacía (listas, resultados, etc.) */
.empty-placeholder,
.card .text-muted.empty-placeholder {
  padding: 0.75rem 0;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text);
  letter-spacing: -0.02em;
}

.stat-value.positive { color: var(--success); }
.stat-value.negative { color: var(--danger); }

/* ================================================================
   RESUMEN — KPI Strip
   ================================================================ */

.resumen-kpi-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.75rem;
  margin-bottom: 1.5rem;
  padding: 1.1rem 1.5rem 1.1rem 1.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
}

.resumen-kpi-strip::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 3px; height: 100%;
  background: var(--accent);
  border-radius: 2px 0 0 2px;
}

.resumen-kpi-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.resumen-kpi-label {
  font-size: 0.67rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.resumen-kpi-value {
  font-size: 1rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text);
}

.resumen-kpi-value.resumen-kpi-accent { color: var(--accent); }

.resumen-sparkline {
  width: 100%;
  height: 56px;
  display: block;
  margin-top: 0.5rem;
}

.resumen-chart-wrap { margin-bottom: 1rem; }

.resumen-bars-chart {
  display: block;
  max-height: 60px;
}

.resumen-hbar-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.resumen-hbar-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  min-width: 2.5rem;
}

.resumen-hbar-track {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.resumen-hbar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.resumen-hbar-fill-alt { background: var(--success); }

.resumen-hbar-val {
  font-size: 0.8rem;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text);
  min-width: 2.5rem;
}

.resumen-donut-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.resumen-donut {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
}

.resumen-donut-legend {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.resumen-donut-legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.resumen-donut-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Grid base: controlado por CSS para poder sobrescribir en media queries */
.resumen-card-grid {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.resumen-estado-hoy-inner {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
  align-items: center;
}

.resumen-hbar-label-fixed {
  width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 768px) {
  .resumen-kpi-strip { padding: 0.85rem 1rem; }
  .resumen-card-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
}

@media (max-width: 600px) {
  .resumen-kpi-strip { flex-direction: column; gap: 0.75rem; }
  .resumen-card-grid .resumen-card-fin { grid-column: 1; }
  .resumen-estado-hoy-inner { gap: 1rem; }
}

@media (max-width: 480px) {
  .resumen-kpi-strip { padding: 0.75rem 0.85rem; }
  .resumen-kpi-value { font-size: 0.9rem; }
  .resumen-card-grid { grid-template-columns: 1fr; }
  .resumen-hbar-label-fixed { width: auto; min-width: 0; max-width: 4.5rem; }
}

/* ================================================================
   FORMS
   ================================================================ */

.form-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.form-group {
  flex: 1;
  min-width: 140px;
}

.form-group label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  font-weight: 500;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 0.55rem 0.85rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9rem;
  font-family: var(--font);
  transition: border-color var(--ease), box-shadow var(--ease);
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

input[type="checkbox"] {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Content-area inputs */
.content-area input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="color"]),
.content-area select,
.content-area textarea {
  padding: 0.5rem 0.75rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9rem;
  font-family: var(--font);
  transition: border-color var(--ease), box-shadow var(--ease);
}

.content-area input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="color"]):focus,
.content-area select:focus,
.content-area textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.content-area input[type="checkbox"] {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--accent);
  cursor: pointer;
}

.label-with-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
}

/* ================================================================
   TABLES
   ================================================================ */

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th, td {
  padding: 0.65rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

tr:hover td { background: var(--bg-elevated); }

/* ================================================================
   BADGES
   ================================================================ */

.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.badge-por_hacer { background: var(--danger-dim);  color: var(--danger);  }
.badge-en_curso  { background: var(--warning-dim); color: var(--warning); }
.badge-entregado { background: var(--success-dim); color: var(--success); }

/* ================================================================
   UTILITIES
   ================================================================ */

.hidden { display: none !important; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }

/* ── Confirm dialog ─────────────────────────────── */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.confirm-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  min-width: 260px;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}
.confirm-msg {
  margin: 0 0 1rem;
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.5;
}
.confirm-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* ── Guía por sección (nuevos usuarios) ───────────────────────── */
.guide-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.guide-overlay .guide-modal {
  min-width: 280px;
  max-width: 420px;
  margin: 1rem;
}
.guide-overlay .guide-text {
  margin: 0 0 1rem;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.5;
}
.guide-overlay .guide-section-counter {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0 0 0.5rem;
}

.guide-overlay .guide-actions {
  display: flex;
  justify-content: flex-end;
}
.guide-overlay .guide-tour-body {
  overflow-y: auto;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.55;
}
.guide-overlay .guide-tour-body p { margin: 0 0 0.5rem; }
.guide-overlay .guide-tour-body ul { margin: 0 0 0.5rem; padding-left: 1.25rem; }
.guide-overlay .guide-tour-body li { margin-bottom: 0.25rem; }

/* ── Tour guiado (guía completa por secciones y tabs) ───────────────────────── */
.guide-tour-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1rem;
  box-sizing: border-box;
}
.guide-tour-overlay .guide-tour-panel {
  min-width: 280px;
  max-width: 480px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.guide-tour-overlay .guide-tour-counter {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.guide-tour-overlay .guide-tour-title {
  margin-bottom: 0.75rem;
}
.guide-tour-overlay .guide-tour-body {
  flex: 1;
  overflow-y: auto;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.55;
  margin-bottom: 1rem;
}
.guide-tour-overlay .guide-tour-body p { margin: 0 0 0.5rem; }
.guide-tour-overlay .guide-tour-body ul { margin: 0 0 0.5rem; padding-left: 1.25rem; }
.guide-tour-overlay .guide-tour-body li { margin-bottom: 0.25rem; }
.guide-tour-overlay .guide-tour-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: space-between;
  align-items: center;
}
.guide-tour-overlay .guide-tour-skip {
  margin-left: auto;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border: none;
}
.btn-danger:hover { background: #dc2626; }

/* ── Toasts ── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  font-family: var(--font);
  z-index: 10000;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.22s, transform 0.22s;
  pointer-events: none;
  max-width: 300px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.toast-visible { opacity: 1; transform: translateY(0); }
.toast-success { background: var(--success); color: #fff; }
.toast-error   { background: var(--danger);  color: #fff; }
.toast-info    { background: var(--accent);  color: #0b0906; font-weight: 600; }

.mb-2 { margin-bottom: 1rem; }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.success { color: var(--success); font-size: 0.875rem; margin-top: 0.5rem; }

/* ================================================================
   MULTI-USER ONBOARDING
   ================================================================ */

.login-switch {
  text-align: center;
  margin-top: 1.25rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.login-switch a { color: var(--accent); text-decoration: none; font-weight: 500; }
.login-switch a:hover { color: var(--accent-hover); }

/* Tab checkboxes grid (onboarding) */
.tab-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.tab-checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  cursor: pointer;
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: background var(--ease), border-color var(--ease), color var(--ease);
  color: var(--text-muted);
}

.tab-checkbox-label:hover {
  background: var(--bg-elevated);
  color: var(--text);
}

.tab-checkbox-label:has(input:checked) {
  background: var(--accent-dim);
  border-color: var(--accent-border);
  color: var(--accent);
}

.tab-checkbox-label input[type=checkbox] {
  accent-color: var(--accent);
  width: 1rem;
  height: 1rem;
  margin: 0;
}

/* Sidebar footer powered-by (sidebar context) */
.sidebar-footer .powered-by {
  padding: 0.75rem 0.75rem 0.25rem;
  text-align: center;
}

/* Ajustes layout */
.ajustes-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

@media (max-width: 700px) {
  .ajustes-grid { grid-template-columns: 1fr; }
}

/* ================================================================
   RESPONSIVE — LAYOUT PRINCIPAL
   ================================================================ */

/* ── Botón hamburguesa (oculto en escritorio) ── */
.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
  flex-shrink: 0;
}
.menu-toggle:hover { background: var(--accent-dim); }
.menu-toggle svg { width: 1.3rem; height: 1.3rem; display: block; }

/* ── Backdrop del sidebar en móvil ── */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 499;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

/* ── Utilidad global: contenedor con scroll horizontal ── */
.scroll-x {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
  /* Topbar: muestra hamburguesa */
  .topbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.85rem 1rem;
    position: sticky;
    top: 0;
  }
  .topbar h2 { font-size: 1.1rem; flex: 1; min-width: 0; }
  .menu-toggle { display: flex; }

  /* Sidebar: drawer deslizable y con scroll para llegar al footer (Ajustes, Salir) */
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    height: 100vh;
    z-index: 500;
    width: 260px;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 30px rgba(0, 0, 0, 0.5);
    border-right: 1px solid var(--border);
    flex-direction: column;
    padding: 1.5rem 0 1rem;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }
  .sidebar-open .sidebar { transform: translateX(0); }

  .sidebar-backdrop { display: block; }
  .sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: all; }

  /* Contenido principal ocupa todo el ancho */
  #dashboard-page { flex-direction: row; }
  .main-content { width: 100%; min-width: 0; }

  /* Nav dentro del drawer: altura según contenido para que el sidebar haga scroll y se llegue al footer */
  .sidebar-nav {
    flex: 0 0 auto;
    flex-direction: column;
    padding: 0;
  }
  .nav-link { padding: 0.65rem 1.25rem; font-size: 0.9rem; border-radius: 0; }
  .nav-icon { display: inline-block; }

  .sidebar-brand { margin-bottom: 1.5rem; }

  .sidebar-footer {
    flex: 0 0 auto;
    flex-direction: column;
    border-top: 1px solid var(--border);
    padding: 0.75rem 0 0;
    margin-top: 0.5rem;
    gap: 0;
  }
  .logout-btn { width: 100%; border-radius: 0; padding: 0.65rem 1.25rem; font-size: 0.9rem; }
  .powered-by { display: none; }

  /* Área de contenido */
  .content-area { padding: 1.25rem 1rem; }

  /* Grids globales */
  .section-skeleton .skeleton-block.wide { grid-column: span 1; }

  /* FAB feedback */
  .fab-menu-wrap { bottom: 1rem; right: 1rem; }
}

@media (max-width: 480px) {
  .content-area { padding: 1rem 0.75rem; }
  .topbar { padding: 0.7rem 0.75rem; }
  .topbar h2 { font-size: 0.95rem; }
  .card { padding: 1rem; }
  .card-header { margin-bottom: 0.85rem; }
  .card-header h3 { font-size: 0.85rem; }
}

/* ================================================================
   Feedback — botón flotante + modal
   ================================================================ */

.feedback-fab {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 900;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: var(--accent);
  color: #0b0906;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(212, 146, 42, 0.35);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.feedback-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 28px rgba(212, 146, 42, 0.5);
}
.feedback-fab svg { width: 1.2rem; height: 1.2rem; flex-shrink: 0; }

/* Modal overlay */
.feedback-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.feedback-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.feedback-modal {
  background: var(--bg-elevated);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 460px;
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transform: translateY(12px) scale(0.98);
  transition: transform 0.2s ease;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.feedback-overlay.open .feedback-modal {
  transform: translateY(0) scale(1);
}

.feedback-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.feedback-modal-header h3 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}
.feedback-modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  padding: 0.2rem;
  transition: color 0.15s;
}
.feedback-modal-close:hover { color: var(--text); }

.feedback-modal label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.feedback-category-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.feedback-cat-btn {
  padding: 0.35rem 0.8rem;
  border-radius: 2rem;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.15s;
}
.feedback-cat-btn:hover { border-color: var(--accent); color: var(--text); }
.feedback-cat-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 500;
}

.feedback-modal input[type="text"],
.feedback-modal textarea {
  width: 100%;
  background: var(--bg-sunken, rgba(255,255,255,0.03));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.9rem;
  padding: 0.6rem 0.8rem;
  box-sizing: border-box;
  transition: border-color 0.15s;
  resize: vertical;
}
.feedback-modal input[type="text"]:focus,
.feedback-modal textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.feedback-modal textarea { min-height: 120px; }

.feedback-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-top: 0.25rem;
}
.feedback-modal-footer small {
  font-size: 0.78rem;
  color: var(--text-muted);
}
.feedback-success-msg {
  display: none;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: #6fcf97;
  font-weight: 500;
}
.feedback-success-msg.show { display: flex; }
