/* ==========================================================================
   ESTILOS GENERALES & ARQUITECTÓNICOS · CALLE ALCÓN 9, VALDEMORILLO
   Laura & Alex · Control de Materiales, Calidades e Inspiración
   ========================================================================== */

:root {
  --primary: #1e293b;        /* Slate 800 - Fondo profundo y profesional */
  --primary-dark: #0f172a;   /* Slate 900 */
  --primary-light: #334155;  /* Slate 700 */
  --accent: #d97706;         /* Ámbar / Terracota arquitectónico */
  --accent-hover: #b45309;
  --accent-soft: #fef3c7;
  --accent-text: #92400e;

  --bg-page: #f8fafc;        /* Slate 50 - Fondo suave */
  --bg-card: #ffffff;
  --bg-card-alt: #f1f5f9;
  --border-color: #e2e8f0;
  --border-focus: #cbd5e1;

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  --status-pending: #f59e0b;
  --status-pending-bg: #fffbeb;
  --status-reviewing: #3b82f6;
  --status-reviewing-bg: #eff6ff;
  --status-selected: #10b981;
  --status-selected-bg: #ecfdf5;

  --criteria-badge: #8b5cf6;
  --criteria-badge-bg: #f5f3ff;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);

  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --primary: #cbd5e1;
  --primary-dark: #e2e8f0;
  --primary-light: #94a3b8;
  --accent: #fbbf24;
  --accent-hover: #fcd34d;
  --accent-soft: #422006;
  --accent-text: #fde68a;
  --bg-page: #0b1120;
  --bg-card: #111827;
  --bg-card-alt: #1e293b;
  --border-color: #334155;
  --border-focus: #475569;
  --text-main: #e2e8f0;
  --text-muted: #cbd5e1;
  --text-light: #94a3b8;
  --status-pending-bg: #422006;
  --status-reviewing-bg: #172554;
  --status-selected-bg: #052e24;
  --criteria-badge-bg: #2e1065;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  padding-bottom: 2rem;
}

/* ==========================================================================
   CABECERA PRINCIPAL (HEADER)
   ========================================================================== */
.main-header {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #ffffff;
  padding: 0.85rem 1.5rem;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-container {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: white;
  box-shadow: 0 2px 8px rgba(217, 119, 6, 0.4);
  flex-shrink: 0;
}

.header-titles h1 {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.header-titles p {
  color: #94a3b8;
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.15rem;
  flex-wrap: wrap;
}

.owners-tag {
  color: #f1f5f9;
  font-weight: 700;
}

.header-tag {
  background: rgba(255, 255, 255, 0.12);
  color: #cbd5e1;
  padding: 0.1rem 0.45rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}

.tag-energy-a {
  background: #059669;
  color: white;
}

/* Navegación Desktop */
.main-nav {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(255, 255, 255, 0.08);
  padding: 0.25rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.825rem;
  font-weight: 600;
  color: #cbd5e1;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.nav-btn:hover {
  color: white;
  background: rgba(255, 255, 255, 0.12);
}

.nav-btn.active {
  color: #0f172a;
  background: #ffffff;
  box-shadow: var(--shadow-sm);
}

.nav-btn-highlight.active {
  color: #7c2d12;
  background: #ffedd5;
  border: 1px solid #fdba74;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.theme-control {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.theme-select {
  min-height: 2.25rem;
  padding: 0.35rem 1.6rem 0.35rem 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-main);
  font: inherit;
}

.theme-select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.theme-storage-status {
  max-width: 1440px;
  margin: 0.4rem auto 0;
  padding: 0 1.5rem;
  color: #fde68a;
  font-size: 0.75rem;
}

.theme-storage-status:empty {
  display: none;
}

/* ==========================================================================
   BOTONES
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-md);
  font-size: 0.825rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background-color: var(--accent);
  color: white;
  box-shadow: 0 2px 4px rgba(217, 119, 6, 0.25);
}

.btn-primary:hover {
  background-color: var(--accent-hover);
}

.btn-secondary {
  background-color: rgba(255, 255, 255, 0.12);
  color: white;
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

.btn-outline {
  background-color: white;
  color: var(--text-main);
  border-color: var(--border-color);
}

.btn-outline:hover {
  background-color: var(--bg-card-alt);
  border-color: var(--border-focus);
}

.btn-success {
  background-color: #10b981;
  color: white;
}

.btn-success:hover {
  background-color: #059669;
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.775rem;
}

/* ==========================================================================
   DASHBOARD DE PRESUPUESTO & KPIs
   ========================================================================== */
.kpi-section {
  max-width: 1440px;
  margin: 1rem auto 0 auto;
  padding: 0 1.5rem;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.9rem 1.1rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
}

.kpi-card.kpi-total::before { background: var(--accent); }
.kpi-card.kpi-closed::before { background: #10b981; }
.kpi-card.kpi-pending::before { background: #f59e0b; }
.kpi-card.kpi-criteria::before { background: #8b5cf6; }

.kpi-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.kpi-value {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
  margin: 0.2rem 0;
}

.kpi-subtext {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.kpi-progress-bar {
  width: 100%;
  height: 5px;
  background-color: #e2e8f0;
  border-radius: 9999px;
  overflow: hidden;
  margin-top: 0.4rem;
}

.kpi-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #059669);
  border-radius: 9999px;
  transition: width 0.4s ease;
}

/* ==========================================================================
   BARRA DE CONTROLES, FILTROS Y BÚSQUEDA
   ========================================================================== */
.controls-section {
  max-width: 1440px;
  margin: 1rem auto 0 auto;
  padding: 0 1.5rem;
}

.controls-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.filter-tabs-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.filter-tabs-scroll::-webkit-scrollbar {
  display: none;
}

.filter-tabs {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.6rem;
  white-space: nowrap;
}

.filter-tab {
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  border: none;
  color: var(--text-muted);
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.filter-tab:hover {
  background: var(--bg-card-alt);
  color: var(--text-main);
}

.filter-tab.active {
  background: var(--primary);
  color: white;
}

.filter-tab.tab-criteria {
  background: var(--criteria-badge-bg);
  color: var(--criteria-badge);
  border: 1px solid rgba(139, 92, 246, 0.3);
}

.filter-tab.tab-criteria.active {
  background: var(--criteria-badge);
  color: white;
}

.badge-count {
  background: rgba(0, 0, 0, 0.12);
  padding: 0.1rem 0.4rem;
  border-radius: 9999px;
  font-size: 0.7rem;
}

.filter-tab.active .badge-count {
  background: rgba(255, 255, 255, 0.25);
}

.filter-inputs-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.search-box {
  flex: 2;
  min-width: 200px;
  position: relative;
}

.search-icon {
  position: absolute;
  left: 0.8rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  width: 16px;
  height: 16px;
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 0.5rem 0.8rem 0.5rem 2.2rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  font-size: 0.825rem;
  color: var(--text-main);
  background: #ffffff;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.15);
}

.select-chapter, .select-sort {
  flex: 1;
  min-width: 160px;
  padding: 0.5rem 0.8rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  font-size: 0.825rem;
  background-color: white;
  color: var(--text-main);
  outline: none;
  cursor: pointer;
}

/* ==========================================================================
   LISTADO DE MATERIALES (CARDS & GRID)
   ========================================================================== */
.content-section {
  max-width: 1440px;
  margin: 1rem auto 2rem auto;
  padding: 0 1.5rem;
}

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

.material-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: box-shadow 0.2s;
  position: relative;
}

.material-card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  padding: 1rem 1.15rem 0.65rem 1.15rem;
  border-bottom: 1px solid var(--bg-card-alt);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.card-top-badges {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chapter-pill {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-card-alt);
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.criteria-pill {
  font-size: 0.7rem;
  font-weight: 700;
  color: #6d28d9;
  background: #ede9fe;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border: 1px solid rgba(139, 92, 246, 0.3);
}

.status-dropdown {
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  outline: none;
}

.status-pending {
  background-color: var(--status-pending-bg);
  color: #b45309;
  border-color: #fde68a;
}

.status-reviewing {
  background-color: var(--status-reviewing-bg);
  color: #1d4ed8;
  border-color: #bfdbfe;
}

.status-selected {
  background-color: var(--status-selected-bg);
  color: #047857;
  border-color: #a7f3d0;
}

.material-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.3;
}

.material-location {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.card-body {
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
  flex: 1;
}

/* Acordeón explicativo */
.info-accordion {
  border-radius: var(--radius-md);
  background: var(--bg-card-alt);
  border: 1px solid var(--border-color);
  overflow: hidden;
}

.accordion-header {
  padding: 0.55rem 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main);
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
}

.accordion-content {
  padding: 0.7rem 0.8rem;
  border-top: 1px solid var(--border-color);
  font-size: 0.8rem;
  color: var(--text-main);
  background: #ffffff;
  line-height: 1.45;
}

.callout-criteria {
  background: #fdf4ff;
  border-left: 3px solid #c084fc;
  padding: 0.5rem 0.75rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.8rem;
  color: #581c87;
}

.callout-builder {
  background: #fffbeb;
  border-left: 3px solid #f59e0b;
  padding: 0.5rem 0.75rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.8rem;
  color: #78350f;
}

/* Calculadora de medición */
.calc-box {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.calc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.calc-inputs {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  flex-wrap: wrap;
}

.calc-input-small {
  width: 60px;
  padding: 0.25rem 0.4rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  text-align: right;
  font-weight: 600;
}

.calc-input-unit {
  padding: 0.25rem 0.4rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  background: white;
}

.calc-total {
  text-align: right;
  margin-left: auto;
}

.calc-total-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
}

.calc-total-amount {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.02em;
}

/* Opciones / Referencias */
.options-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.options-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.options-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.option-card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.65rem;
  background: #ffffff;
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  position: relative;
}

.option-card.option-selected {
  border-color: #10b981;
  background: #f0fdf4;
  box-shadow: 0 0 0 1px #10b981;
}

.option-radio {
  margin-top: 0.2rem;
  accent-color: #10b981;
  cursor: pointer;
  width: 16px;
  height: 16px;
}

.option-thumb {
  width: 58px;
  height: 58px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background-color: #f1f5f9;
  border: 1px solid var(--border-color);
  cursor: pointer;
  flex-shrink: 0;
}

.option-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.option-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.4rem;
}

.option-name {
  font-size: 0.825rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.option-price {
  font-size: 0.875rem;
  font-weight: 800;
  color: var(--text-main);
  white-space: nowrap;
}

.option-provider {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.option-notes {
  font-size: 0.75rem;
  color: #475569;
  margin-top: 0.15rem;
  line-height: 1.3;
}

.option-links {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
  font-size: 0.72rem;
}

.option-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

/* Comentarios */
.comments-box {
  background: #fdfefe;
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.65rem;
}

.comment-item {
  font-size: 0.78rem;
  margin-bottom: 0.3rem;
  line-height: 1.35;
}

.comment-author {
  font-weight: 700;
  color: var(--accent-hover);
}

.comment-date {
  font-size: 0.68rem;
  color: var(--text-light);
  margin-left: 0.25rem;
}

.add-comment-row {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.4rem;
}

.comment-input {
  flex: 1;
  padding: 0.3rem 0.5rem;
  font-size: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  outline: none;
}

.card-footer {
  padding: 0.65rem 1.15rem;
  background: var(--bg-card-alt);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ==========================================================================
   SECCIÓN 2: INSPIRACIÓN DE ESPACIOS (MOODBOARD)
   ========================================================================== */
.spaces-section {
  max-width: 1440px;
  margin: 1rem auto 3rem auto;
  padding: 0 1.5rem;
}

.spaces-nav-wrapper {
  margin-bottom: 1rem;
}

.spaces-nav-scroll {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 0.2rem 0;
  white-space: nowrap;
}

.spaces-nav-scroll::-webkit-scrollbar {
  display: none;
}

.space-pill {
  padding: 0.5rem 0.9rem;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  background: white;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.space-pill:hover {
  background: var(--bg-card-alt);
  border-color: var(--border-focus);
}

.space-pill.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 2px 4px rgba(15, 23, 42, 0.2);
}

.space-pill-surface {
  font-size: 0.68rem;
  background: rgba(0, 0, 0, 0.08);
  padding: 0.05rem 0.35rem;
  border-radius: 9999px;
  color: inherit;
}

.space-pill.active .space-pill-surface {
  background: rgba(255, 255, 255, 0.25);
  color: white;
}

/* Tarjeta Hero de la Estancia */
.room-hero-card {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.35rem 1.5rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.25rem;
  position: relative;
  overflow: hidden;
}

.room-hero-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 5px;
  height: 100%;
  background: linear-gradient(180deg, #f59e0b, #d97706);
}

.room-hero-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.85rem;
}

.room-plan-tag {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.room-title {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--primary-dark);
  line-height: 1.2;
}

.room-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.35rem;
  flex-wrap: wrap;
}

.room-badge-surface, .room-badge-orient {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  padding: 0.15rem 0.55rem;
  border-radius: 9999px;
  font-weight: 600;
}

.room-badge-surface {
  background: #f1f5f9;
  color: var(--primary);
  border: 1px solid #e2e8f0;
}

.room-badge-orient {
  background: #fff7ed;
  color: #c2410c;
  border: 1px solid #ffedd5;
}

.room-description {
  font-size: 0.85rem;
  color: #475569;
  margin-top: 0.75rem;
  line-height: 1.5;
}

.room-constructive-checklist {
  background: #fafaf9;
  border: 1px solid #e7e5e4;
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  margin-top: 0.9rem;
}

.constructive-checklist-title {
  font-size: 0.8rem;
  color: #292524;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.4rem;
}

.constructive-checklist-items {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.constructive-checklist-items li {
  font-size: 0.78rem;
  color: #57534e;
  position: relative;
  padding-left: 1.1rem;
  line-height: 1.4;
}

.constructive-checklist-items li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: #059669;
  font-weight: 700;
}

/* Filtros de Categorías Específicas de la Estancia */
.room-categories-bar {
  margin-bottom: 1rem;
}

.room-categories-scroll {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 0.2rem 0;
  white-space: nowrap;
}

.room-categories-scroll::-webkit-scrollbar {
  display: none;
}

.room-cat-chip {
  padding: 0.35rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: white;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.room-cat-chip:hover {
  background: var(--bg-card-alt);
  color: var(--text-main);
  border-color: var(--border-focus);
}

.room-cat-chip.active {
  background: #fef3c7;
  color: #92400e;
  border-color: #fde68a;
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(217, 119, 6, 0.1);
}

.room-cat-count {
  font-size: 0.68rem;
  opacity: 0.85;
}

/* Grid de Inspiraciones */
.inspirations-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.inspirations-count-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

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

.inspiration-card {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s, box-shadow 0.2s;
}

.inspiration-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.inspiration-media-box {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  background: #0f172a;
  overflow: hidden;
  cursor: pointer;
}

.inspiration-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.inspiration-media-box:hover .inspiration-img {
  transform: scale(1.03);
}

.inspiration-cat-badge {
  position: absolute;
  top: 0.65rem;
  left: 0.65rem;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  text-transform: uppercase;
}

.inspiration-zoom-hint {
  position: absolute;
  bottom: 0.65rem;
  right: 0.65rem;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
}

.inspiration-body {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  flex: 1;
}

.inspiration-title {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.3;
}

.inspiration-desc {
  font-size: 0.8rem;
  color: #475569;
  line-height: 1.45;
}

/* Bloque destacado de requisitos constructivos */
.constructive-box {
  background: #fffbeb;
  border-left: 3px solid #f59e0b;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 0.6rem 0.8rem;
  font-size: 0.78rem;
  color: #78350f;
  line-height: 1.4;
  margin-top: auto;
}

.constructive-box-title {
  font-weight: 700;
  margin-bottom: 0.2rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  color: #92400e;
}

.inspiration-footer {
  padding: 0.6rem 1rem;
  background: var(--bg-card-alt);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pinterest-link {
  color: #e60023;
  font-size: 0.75rem;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.pinterest-link:hover {
  text-decoration: underline;
}

/* Previsualizador de imagen en modal */
.image-preview-box {
  width: 100%;
  min-height: 130px;
  max-height: 220px;
  background: #f8fafc;
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  overflow: hidden;
  margin-top: 0.35rem;
}

.image-preview-box img {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
}

.url-helper-tip {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: #f8fafc;
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius-sm);
  margin-top: 0.35rem;
  border: 1px solid var(--border-color);
  line-height: 1.35;
}

/* ==========================================================================
   MODO DOSSIER TÉCNICO (APAREJADOR Y CONSTRUCTOR)
   ========================================================================== */
.dossier-view {
  max-width: 1440px;
  margin: 1rem auto 3rem auto;
  padding: 0 1.5rem;
}

.dossier-card {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-sm);
}

.dossier-header {
  border-bottom: 2px solid var(--primary);
  padding-bottom: 1.25rem;
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 1rem;
}

.dossier-header h2 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
}

.dossier-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.55;
  margin-top: 0.35rem;
}

.dossier-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.dossier-table th {
  background-color: var(--primary);
  color: white;
  text-align: left;
  padding: 0.65rem 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.72rem;
}

.dossier-table td {
  padding: 0.75rem 0.8rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: top;
}

.dossier-table tr:nth-child(even) td {
  background-color: #f8fafc;
}

/* ==========================================================================
   MODALES (POPUPS)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  padding: 1rem;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-box {
  background: white;
  border-radius: var(--radius-xl);
  max-width: 620px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary);
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text-light);
  line-height: 1;
}

.modal-close:hover {
  color: var(--text-main);
}

.modal-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.form-group label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-main);
}

.form-control {
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  font-size: 0.825rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.15);
}

.form-row {
  display: flex;
  gap: 0.75rem;
}

.form-row .form-group {
  flex: 1;
}

.modal-footer {
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--border-color);
  background: var(--bg-card-alt);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* Lightbox de fotos */
.lightbox-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.lightbox-modal.open {
  opacity: 1;
  pointer-events: auto;
}

.lightbox-img {
  max-width: 90vw;
  max-height: 85vh;
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  display: block;
}

.lightbox-close-btn {
  position: absolute;
  top: -36px;
  right: -10px;
  background: transparent;
  border: none;
  color: white;
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
}

/* ==========================================================================
   BARRA MÓVIL INFERIOR (TAB BAR FLOTANTE)
   ========================================================================== */
.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 999;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding: 0 0.5rem;
}

.mobile-tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 0.68rem;
  font-weight: 600;
  cursor: pointer;
  flex: 1;
  height: 100%;
}

.mobile-tab-btn i {
  width: 20px;
  height: 20px;
}

.mobile-tab-btn.active {
  color: #f59e0b;
}

/* Toggle KPIs en móvil */
.kpi-mobile-toggle {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  margin-bottom: 0.5rem;
}

/* ==========================================================================
   UTILIDADES RESPONSIVE & ADAPTACIONES MÓVIL
   ========================================================================== */
.mobile-only {
  display: none !important;
}

.desktop-only {
  display: flex !important;
}

@media (max-width: 768px) {
  body {
    padding-bottom: 70px; /* Espacio para barra de navegación inferior móvil */
  }

  .mobile-only {
    display: flex !important;
  }

  .desktop-only {
    display: none !important;
  }

  .main-header {
    padding: 0.6rem 1rem;
  }

  .header-container {
    gap: 0.5rem;
    flex-wrap: wrap;
  }

  .mobile-header-quick {
    width: 100%;
    justify-content: space-between;
  }

  .theme-select {
    width: 92px;
    padding-right: 0.25rem;
  }

  .header-titles h1 {
    font-size: 1rem;
  }

  .kpi-section, .controls-section, .content-section, .spaces-section, .dossier-view {
    padding: 0 0.85rem;
    margin-top: 0.65rem;
  }

  /* KPIs colapsables en móvil */
  .kpi-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }

  .kpi-grid.collapsed {
    display: none !important;
  }

  .kpi-card {
    padding: 0.65rem 0.75rem;
  }

  .kpi-value {
    font-size: 1.15rem;
  }

  .controls-card {
    padding: 0.75rem;
  }

  .materials-grid {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }

  .material-card {
    border-radius: var(--radius-md);
  }

  .card-header {
    padding: 0.85rem 0.9rem 0.5rem 0.9rem;
  }

  .card-body {
    padding: 0.85rem 0.9rem;
    gap: 0.75rem;
  }

  .info-accordion .accordion-content {
    display: none; /* Cerrado por defecto en móvil para ahorrar scroll */
  }

  .calc-box {
    padding: 0.65rem;
  }

  .calc-inputs {
    gap: 0.25rem;
  }

  .room-hero-card {
    padding: 1rem;
  }

  .room-title {
    font-size: 1.2rem;
  }

  .room-hero-actions {
    width: 100%;
  }

  .room-hero-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .inspirations-grid {
    grid-template-columns: 1fr;
    gap: 0.95rem;
  }

  .form-row {
    flex-direction: column;
    gap: 0.65rem;
  }
}

  :root[data-theme="dark"] .nav-btn.active,
  :root[data-theme="dark"] .btn-outline,
  :root[data-theme="dark"] .search-input,
  :root[data-theme="dark"] .select-chapter,
  :root[data-theme="dark"] .select-sort,
  :root[data-theme="dark"] .accordion-content,
  :root[data-theme="dark"] .calc-input-unit,
  :root[data-theme="dark"] .option-card,
  :root[data-theme="dark"] .space-pill,
  :root[data-theme="dark"] .room-hero-card,
  :root[data-theme="dark"] .room-cat-chip,
  :root[data-theme="dark"] .inspiration-card,
  :root[data-theme="dark"] .dossier-card,
  :root[data-theme="dark"] .modal-box {
    background-color: var(--bg-card);
    color: var(--text-main);
  }

  :root[data-theme="dark"] .nav-btn.active {
    color: var(--text-main);
  }

  :root[data-theme="dark"] .filter-tab.active,
  :root[data-theme="dark"] .space-pill.active,
  :root[data-theme="dark"] .dossier-table th {
    background-color: #334155;
    border-color: #475569;
    color: #f8fafc;
  }

  :root[data-theme="dark"] .btn-primary {
    background-color: #92400e;
    color: #fff7ed;
  }

  :root[data-theme="dark"] .btn-primary:hover {
    background-color: #78350f;
  }

  :root[data-theme="dark"] .kpi-card,
  :root[data-theme="dark"] .controls-card,
  :root[data-theme="dark"] .material-card,
  :root[data-theme="dark"] .calc-box,
  :root[data-theme="dark"] .comments-box,
  :root[data-theme="dark"] .image-preview-box,
  :root[data-theme="dark"] .url-helper-tip {
    background-color: var(--bg-card-alt);
    color: var(--text-main);
  }

  :root[data-theme="dark"] .option-card.option-selected {
    background: #12352d;
  }

  :root[data-theme="dark"] .callout-criteria {
    background: #2b1d39;
    color: #e9d5ff;
  }

  :root[data-theme="dark"] .callout-builder,
  :root[data-theme="dark"] .constructive-box,
  :root[data-theme="dark"] .room-cat-chip.active {
    background: #422006;
    color: #fde68a;
  }

  :root[data-theme="dark"] .room-badge-surface,
  :root[data-theme="dark"] .room-badge-orient {
    background: #1e293b;
    color: #e2e8f0;
    border-color: #475569;
  }

  :root[data-theme="dark"] .room-constructive-checklist {
    background: #1c1917;
    border-color: #44403c;
  }

  :root[data-theme="dark"] .constructive-checklist-title,
  :root[data-theme="dark"] .constructive-checklist-items li,
  :root[data-theme="dark"] .room-description,
  :root[data-theme="dark"] .option-notes {
    color: #e2e8f0;
  }

  :root[data-theme="dark"] .dossier-table tr:nth-child(even) td {
    background-color: var(--bg-card-alt);
  }

  /* ==========================================================================
     ESTILOS DE IMPRESIÓN (PRINT STYLESHEET)
   ========================================================================== */
@media print {
  body {
    background: white !important;
    color: black !important;
    font-size: 9.5pt;
    padding-bottom: 0 !important;
  }

  .main-header,
  .kpi-section,
  .controls-section,
  .content-section,
  .spaces-section,
  .modal-overlay,
  .lightbox-modal,
  .mobile-bottom-nav,
  .no-print {
    display: none !important;
  }

  .dossier-view {
    display: block !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .dossier-card {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
  }

  .dossier-table {
    page-break-inside: auto;
  }

  .dossier-table tr {
    page-break-inside: avoid;
    page-break-after: auto;
  }

  .dossier-table th {
    background-color: #1e293b !important;
    color: white !important;
  }
}

/* Visual refresh: cálido, despejado y centrado en las decisiones de la obra. */
:root {
  --primary: #183e39;
  --primary-dark: #102c29;
  --primary-light: #315f57;
  --accent: #b44c32;
  --accent-hover: #963e2a;
  --accent-soft: #ffede4;
  --accent-text: #79331f;
  --bg-page: #f6f5f1;
  --bg-card: #ffffff;
  --bg-card-alt: #f0f2ed;
  --border-color: #e4e7e0;
  --border-focus: #b6c3b7;
  --text-main: #202c28;
  --text-muted: #5b6962;
  --text-light: #697970;
  --criteria-badge: #8a4a2c;
  --criteria-badge-bg: #f7eee8;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-xl: 28px;
  --shadow-sm: 0 2px 8px rgba(24, 62, 57, 0.05);
  --shadow-md: 0 8px 24px rgba(24, 62, 57, 0.08);
  --shadow-lg: 0 18px 48px rgba(24, 62, 57, 0.12);
}

:root[data-theme="dark"] {
  --primary: #b8d6c8;
  --primary-dark: #d5e7df;
  --primary-light: #9ebead;
  --accent: #f39a73;
  --accent-hover: #ffb294;
  --accent-soft: #42271e;
  --accent-text: #ffd3c2;
  --bg-page: #111a18;
  --bg-card: #1b2723;
  --bg-card-alt: #24332e;
  --border-color: #34463f;
  --border-focus: #536b61;
  --text-main: #ecf2ee;
  --text-muted: #c0cec5;
  --text-light: #94a69b;
  --status-pending-bg: #42271e;
  --status-reviewing-bg: #1e3446;
  --status-selected-bg: #16382c;
  --criteria-badge-bg: #342743;
  --criteria-badge: #e2c3ad;
}

html {
  scroll-behavior: smooth;
}

body {
  background:
    radial-gradient(ellipse at 84% 8%, rgba(228, 123, 79, 0.07), transparent 24rem),
    var(--bg-page);
  letter-spacing: -0.01em;
}

.main-header {
  position: sticky;
  background: color-mix(in srgb, var(--bg-card) 94%, transparent);
  color: var(--text-main);
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0 4px 18px rgba(24, 62, 57, 0.045);
  backdrop-filter: blur(18px);
  padding: 0.7rem 1.5rem;
}

.header-container {
  max-width: 1500px;
}

.brand-icon {
  width: 44px;
  height: 44px;
  color: #fff7ed;
  background: linear-gradient(145deg, #315f57, #183e39);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 15px 15px 15px 5px;
  box-shadow: 0 6px 16px rgba(24, 62, 57, 0.22);
  overflow: hidden;
}

.brand-icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.brand-icon text {
  fill: currentColor;
  stroke: none;
  font-family: inherit;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.header-titles h1 {
  color: var(--primary);
  font-size: 1.03rem;
  font-weight: 800;
  letter-spacing: -0.045em;
}

.header-titles p {
  gap: 0.5rem;
  color: var(--text-muted);
  font-size: 0.7rem;
}

.owners-tag {
  color: var(--text-muted);
  font-weight: 600;
}

.header-tag {
  background: var(--bg-card-alt);
  color: var(--primary);
  letter-spacing: 0.02em;
}

.tag-energy-a {
  background: #e5f3e9;
  color: #25613e;
}

:root[data-theme="dark"] .tag-energy-a {
  background: #1c3a2a;
  color: #c4f0d2;
}

.main-nav {
  gap: 0.2rem;
  padding: 0.25rem;
  border: 0;
  background: var(--bg-card-alt);
  border-radius: 14px;
}

.nav-btn {
  padding: 0.58rem 0.8rem;
  border-radius: 11px;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.nav-btn:hover {
  color: var(--primary);
  background: color-mix(in srgb, var(--bg-card) 75%, transparent);
}

.nav-btn.active,
:root[data-theme="dark"] .nav-btn.active,
.nav-btn-highlight.active {
  color: #fff;
  background: var(--primary);
  border: 0;
  box-shadow: 0 3px 10px rgba(24, 62, 57, 0.14);
}

.header-actions {
  gap: 0.75rem;
}

.theme-control {
  gap: 0.45rem;
  color: var(--text-muted);
}

.theme-control svg {
  width: 17px;
  height: 17px;
}

.theme-select {
  border-color: transparent;
  border-radius: 11px;
  background: var(--bg-card-alt);
  color: var(--text-main);
}

.btn {
  border-radius: 12px;
  font-weight: 700;
  transition: transform 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

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

.btn:focus-visible,
button:focus-visible,
select:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 60%, white);
  outline-offset: 3px;
}

.btn-save {
  min-height: 42px;
  padding: 0.55rem 1rem;
  border: 0;
  background: var(--primary);
  color: white;
  box-shadow: 0 5px 14px rgba(24, 62, 57, 0.18);
}

.btn-save:hover {
  background: var(--primary-light);
}

:root[data-theme="dark"] .btn-save,
:root[data-theme="dark"] .nav-btn.active,
:root[data-theme="dark"] .nav-btn-highlight.active {
  background: #315f57;
  color: #fff;
}

.btn-save:disabled {
  opacity: 0.88;
  cursor: default;
  transform: none;
}

.btn-save svg {
  width: 17px;
  height: 17px;
}

.welcome-hero {
  position: relative;
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 2rem;
  align-items: center;
  max-width: 1440px;
  min-height: 310px;
  margin: 1.5rem auto 0;
  padding: 2.4rem clamp(1.4rem, 4vw, 3.5rem);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 30px;
  color: #fff;
  background:
    radial-gradient(circle at 86% 23%, rgba(244, 174, 128, 0.34), transparent 14rem),
    linear-gradient(118deg, #173e38 0%, #22544a 57%, #327366 100%);
  box-shadow: 0 18px 44px rgba(24, 62, 57, 0.15);
}

.welcome-copy {
  position: relative;
  z-index: 1;
  max-width: 620px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: #f4bc96;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.13em;
}

.eyebrow svg {
  width: 15px;
  height: 15px;
}

.welcome-copy h2 {
  margin-top: 0.8rem;
  font-size: clamp(2rem, 4vw, 3.25rem);
  font-weight: 800;
  letter-spacing: -0.065em;
  line-height: 1.03;
}

.welcome-copy h2 span {
  color: #f4bc96;
}

.welcome-copy p {
  max-width: 470px;
  margin-top: 0.85rem;
  color: #d5e3dd;
  font-size: 0.96rem;
  line-height: 1.65;
}

.btn-hero {
  margin-top: 1.2rem;
  padding: 0.72rem 1rem;
  background: #fff;
  color: #1d5045;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

.btn-hero:hover {
  background: #fff5ed;
}

.welcome-art {
  position: relative;
  align-self: stretch;
  min-height: 235px;
}

.art-sun {
  position: absolute;
  top: 6%;
  right: 15%;
  width: clamp(80px, 11vw, 132px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: linear-gradient(145deg, #ffd9aa, #e99c6b);
  box-shadow: 0 0 70px rgba(255, 203, 156, 0.25);
}

.art-window {
  position: absolute;
  top: 17%;
  right: 21%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: clamp(120px, 15vw, 178px);
  aspect-ratio: 0.78;
  gap: 7px;
  padding: 8px;
  border: 7px solid #f5eee3;
  border-bottom-width: 12px;
  border-radius: 90px 90px 5px 5px;
  background: #f5eee3;
  box-shadow: 15px 19px 0 rgba(13, 46, 40, 0.22);
}

.art-window span {
  background: linear-gradient(150deg, #f7cf9e 0 31%, #8db39c 32% 60%, #497b67 61%);
  border-radius: 4px;
}

.art-plant {
  position: absolute;
  right: 8%;
  bottom: 10%;
  display: grid;
  width: 62px;
  height: 78px;
  place-items: center;
  color: #d6e6c1;
}

.art-plant svg {
  width: 54px;
  height: 64px;
  stroke-width: 1.5;
}

.art-caption {
  position: absolute;
  right: 4%;
  bottom: 2%;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: #d5e3dd;
  font-size: 0.7rem;
  font-weight: 600;
}

.art-caption svg {
  width: 14px;
  height: 14px;
}

.kpi-section {
  margin-top: 1.15rem;
}

.kpi-grid {
  gap: 0.9rem;
}

.kpi-card {
  min-height: 124px;
  padding: 1rem 1.15rem;
  border-color: transparent;
  border-radius: 18px;
  box-shadow: var(--shadow-sm);
}

.kpi-card::before {
  width: 3px;
  border-radius: 0 4px 4px 0;
}

.kpi-title {
  font-size: 0.68rem;
  letter-spacing: 0.075em;
}

.kpi-title svg {
  width: 18px;
  height: 18px;
  color: var(--primary-light);
}

.kpi-value {
  margin: 0.4rem 0 0.15rem;
  font-size: clamp(1.3rem, 2vw, 1.7rem);
}

.controls-section {
  margin-top: 1rem;
}

.controls-card {
  padding: 1rem;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
}

.filter-tabs {
  gap: 0.4rem;
}

.filter-tab {
  gap: 0.45rem;
  padding: 0.62rem 0.8rem;
  border-radius: 12px;
  font-size: 0.76rem;
}

.filter-tab.active {
  background: var(--primary);
  color: white;
}

.filter-tab svg {
  width: 16px;
  height: 16px;
}

.badge-count {
  min-width: 22px;
  min-height: 22px;
  display: inline-grid;
  place-items: center;
  border-radius: 99px;
  background: rgba(24, 62, 57, 0.08);
  font-size: 0.68rem;
}

.filter-tab.active .badge-count {
  background: rgba(255, 255, 255, 0.18);
}

.filter-tab.tab-criteria.active {
  background: #f7eee8;
  color: #713b26;
  box-shadow: inset 0 0 0 1px #ead3c4;
}

:root[data-theme="dark"] .filter-tab.tab-criteria.active {
  background: #3b2b24;
  color: #f5d4c0;
  box-shadow: inset 0 0 0 1px #654936;
}

.filter-inputs-row {
  margin-top: 0.75rem;
  gap: 0.6rem;
}

.search-input,
.select-chapter,
.select-sort {
  min-height: 44px;
  border-radius: 12px;
  border-color: var(--border-color);
  background-color: var(--bg-page);
  color: var(--text-main);
}

.content-section {
  margin-top: 1rem;
}

.materials-grid {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr));
  gap: 1rem;
}

#materials-container {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.chapter-browser-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 0.85rem;
}

.chapter-browser-heading h2 {
  margin: 0;
  color: var(--text-main);
  font-size: clamp(1.05rem, 2vw, 1.3rem);
  letter-spacing: -0.03em;
}

.chapter-browser-heading p:last-child {
  margin: 0.25rem 0 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.chapter-browser-eyebrow {
  margin: 0 0 0.2rem;
  color: var(--accent-text);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.09em;
}

.chapter-browser-total {
  flex: 0 0 auto;
  padding: 0.4rem 0.7rem;
  border-radius: 99px;
  background: var(--bg-card-alt);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.chapter-group {
  overflow: hidden;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
}

.chapter-group-toggle {
  width: 100%;
  min-height: 68px;
  display: grid;
  grid-template-columns: 38px minmax(170px, 1fr) minmax(180px, auto) 20px;
  align-items: center;
  gap: 0.8rem;
  padding: 0.8rem 1rem;
  border: 0;
  background: transparent;
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
  transition: background-color 150ms ease;
}

.chapter-group-toggle:hover,
.chapter-group-toggle:focus-visible {
  background: var(--bg-card-alt);
}

.chapter-group-toggle:focus-visible {
  outline: 3px solid var(--border-focus);
  outline-offset: -3px;
}

.chapter-group-toggle > :first-child {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  padding: 9px;
  border-radius: 12px;
  background: var(--bg-card-alt);
  color: var(--primary);
}

.chapter-group-title-block {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.chapter-group-title {
  font-size: 0.88rem;
  font-weight: 750;
  line-height: 1.3;
}

.chapter-group-count {
  color: var(--text-muted);
  font-size: 0.68rem;
}

.chapter-group-details {
  color: var(--text-muted);
  font-size: 0.68rem;
  text-align: right;
}

.chapter-group-chevron {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  transition: transform 160ms ease;
}

.chapter-group.is-expanded .chapter-group-chevron {
  transform: rotate(180deg);
}

.chapter-materials-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr));
  gap: 1rem;
  padding: 0 0.85rem 0.85rem;
}

.chapter-materials-grid[hidden] {
  display: none;
}

.chapter-group.is-expanded .chapter-group-toggle {
  border-bottom: 1px solid var(--border-color);
}

.search-results-group .chapter-group-toggle {
  grid-template-columns: 38px minmax(0, 1fr) 20px;
}

.dossier-intro {
  margin: 0.4rem 0 0.75rem;
  color: var(--text-muted);
  font-size: 0.86rem;
}

.dossier-editing-note {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  margin: 0 0 1.25rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 14px;
  background: var(--bg-card-alt);
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.55;
}

.dossier-editing-note > svg {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin-top: 0.08rem;
  color: var(--primary);
}

.dossier-editing-note p {
  margin: 0;
}

.dossier-editing-note strong {
  color: var(--text-main);
}

.material-card {
  border: 1px solid var(--border-color);
  border-radius: 20px;
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.material-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-focus);
  box-shadow: var(--shadow-md);
}

.card-header {
  padding: 1rem 1rem 0.65rem;
}

.card-body {
  padding: 0.8rem 1rem 1rem;
}

.material-title {
  font-size: 1.05rem;
  letter-spacing: -0.025em;
}

.chapter-pill,
.criteria-pill {
  padding: 0.28rem 0.55rem;
  border-radius: 99px;
}

.status-dropdown {
  min-height: 34px;
  padding: 0.3rem 1.8rem 0.3rem 0.65rem;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 700;
}

.options-section,
.comments-box,
.calc-box,
.info-accordion {
  border-radius: 14px;
}

.spaces-section,
.dossier-view {
  max-width: 1440px;
  margin-left: auto;
  margin-right: auto;
}

.spaces-nav-scroll {
  gap: 0.55rem;
  padding: 0.45rem 0 0.9rem;
}

.space-pill {
  padding: 0.62rem 0.9rem;
  border-radius: 14px;
  background: var(--bg-card);
}

.space-pill.active {
  background: var(--primary);
}

.room-hero-card,
.dossier-card {
  border: 1px solid var(--border-color);
  border-radius: 22px;
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
}

.room-hero-card {
  padding: clamp(1rem, 3vw, 1.8rem);
}

.room-title {
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  letter-spacing: -0.05em;
}

.room-badge-surface,
.room-badge-orient {
  padding: 0.4rem 0.65rem;
  border-radius: 99px;
}

.room-constructive-checklist {
  border-radius: 16px;
}

.inspiration-card {
  border: 1px solid var(--border-color);
  border-radius: 20px;
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
}

.dossier-card {
  padding: clamp(1rem, 3vw, 2rem);
  overflow-x: auto;
}

.dossier-table th {
  background: var(--primary);
}

.dossier-table th:first-child {
  border-radius: 10px 0 0 0;
}

.dossier-table th:last-child {
  border-radius: 0 10px 0 0;
}

.app-toast {
  position: fixed;
  z-index: 2100;
  left: 50%;
  bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.75rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background: #183e39;
  color: #fff;
  font-size: 0.84rem;
  font-weight: 700;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: transform 180ms ease;
}

.app-toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

:root[data-theme="dark"] .app-toast {
  background: #315f57;
}

@media (max-width: 900px) {
  .welcome-hero {
    margin-right: 1rem;
    margin-left: 1rem;
  }

  .header-container {
    max-width: none;
  }
}

@media (max-width: 768px) {
  body {
    padding-bottom: calc(78px + env(safe-area-inset-bottom));
  }

  .main-header {
    padding: 0.55rem 0.9rem;
  }

  .header-container {
    flex-wrap: nowrap;
    gap: 0.75rem;
  }

  .header-brand {
    min-width: 0;
  }

  .brand-icon {
    width: 39px;
    height: 39px;
    border-radius: 13px;
  }

  .header-titles h1 {
    font-size: 0.95rem;
  }

  .header-titles p {
    font-size: 0.65rem;
  }

  .mobile-header-quick {
    width: auto;
    flex: 0 0 auto;
    gap: 0.5rem;
  }

  .theme-select {
    width: 92px;
    min-height: 40px;
    padding-right: 0.25rem;
  }

  .btn-save {
    min-height: 40px;
    padding: 0.5rem 0.75rem;
  }

  .welcome-hero {
    grid-template-columns: 1fr 0.55fr;
    gap: 0.3rem;
    min-height: 250px;
    margin: 0.85rem 0.85rem 0;
    padding: 1.35rem;
    border-radius: 23px;
  }

  .welcome-copy h2 {
    font-size: clamp(1.7rem, 7vw, 2.35rem);
  }

  .welcome-copy p {
    max-width: 340px;
    font-size: 0.82rem;
  }

  .welcome-art {
    min-height: 180px;
  }

  .art-window {
    right: 4%;
    top: 21%;
  }

  .art-sun {
    right: 2%;
  }

  .art-plant {
    right: -3%;
  }

  .art-caption {
    display: none;
  }

  .kpi-section {
    margin-top: 0.8rem;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem;
  }

  .kpi-card {
    min-height: 106px;
    padding: 0.75rem;
    border-radius: 15px;
  }

  .kpi-title {
    gap: 0.3rem;
    font-size: 0.59rem;
  }

  .kpi-title svg {
    width: 15px;
    height: 15px;
    flex: 0 0 auto;
  }

  .kpi-value {
    font-size: 1.18rem;
  }

  .controls-section,
  .content-section,
  .spaces-section,
  .dossier-view {
    padding-right: 0.85rem;
    padding-left: 0.85rem;
  }

  .controls-card {
    padding: 0.75rem;
    border-radius: 17px;
  }

  .filter-tab {
    padding: 0.55rem 0.65rem;
    font-size: 0.72rem;
  }

  .filter-inputs-row {
    gap: 0.45rem;
  }

  .search-input,
  .select-chapter {
    min-height: 43px;
  }

  .materials-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.7rem;
  }

  #materials-container {
    gap: 0.55rem;
  }

  .chapter-browser-heading {
    align-items: flex-start;
    margin-bottom: 0.65rem;
  }

  .chapter-browser-heading p:last-child {
    max-width: 34ch;
    font-size: 0.72rem;
  }

  .chapter-browser-total {
    padding: 0.35rem 0.55rem;
    font-size: 0.64rem;
  }

  .chapter-group-toggle {
    min-height: 63px;
    grid-template-columns: 34px minmax(0, 1fr) 18px;
    gap: 0.6rem;
    padding: 0.7rem;
  }

  .chapter-group-toggle > :first-child {
    width: 34px;
    height: 34px;
    padding: 8px;
  }

  .chapter-group-title {
    font-size: 0.78rem;
  }

  .chapter-group-count {
    font-size: 0.64rem;
  }

  .chapter-group-details {
    grid-column: 2;
    grid-row: 2;
    margin-top: -0.45rem;
    text-align: left;
    font-size: 0.6rem;
    line-height: 1.35;
  }

  .chapter-group-chevron {
    grid-column: 3;
    grid-row: 1;
  }

  .search-results-group .chapter-group-toggle {
    grid-template-columns: 34px minmax(0, 1fr) 18px;
  }

  .chapter-materials-grid {
    gap: 0.7rem;
    padding: 0 0.55rem 0.55rem;
  }

  .material-card:hover {
    transform: none;
  }

  .mobile-bottom-nav {
    height: calc(66px + env(safe-area-inset-bottom));
    padding: 0 0.3rem env(safe-area-inset-bottom);
    border-top: 1px solid var(--border-color);
    background: color-mix(in srgb, var(--bg-card) 94%, transparent);
    box-shadow: 0 -8px 28px rgba(24, 62, 57, 0.08);
    backdrop-filter: blur(16px);
  }

  .app-toast {
    bottom: calc(78px + env(safe-area-inset-bottom));
  }

  .mobile-tab-btn {
    gap: 0.25rem;
    color: var(--text-muted);
    font-size: 0.65rem;
  }

  .mobile-tab-btn svg {
    width: 20px;
    height: 20px;
    stroke-width: 1.8;
  }

  .mobile-tab-btn.active {
    color: var(--primary);
  }

  .mobile-save-tab {
    color: var(--accent-hover);
  }

  .mobile-save-tab.active {
    color: var(--accent-hover);
  }

  .room-hero-card,
  .dossier-card {
    border-radius: 18px;
  }

  .dossier-table {
    min-width: 780px;
  }
}

@media (max-width: 420px) {
  .chapter-browser-heading {
    flex-direction: column;
    gap: 0.45rem;
  }

  .chapter-browser-total {
    align-self: flex-start;
  }

  .welcome-hero {
    grid-template-columns: minmax(0, 1fr) 100px;
    gap: 0;
    min-height: 230px;
    padding: 1.1rem;
  }

  .welcome-copy h2 {
    font-size: 1.7rem;
  }

  .welcome-copy p {
    font-size: 0.76rem;
  }

  .eyebrow {
    font-size: 0.57rem;
  }

  .art-window {
    right: -10%;
    width: 105px;
  }

  .art-sun {
    right: -8%;
    width: 72px;
  }

  .art-plant {
    right: -18%;
    bottom: 6%;
  }

  .theme-control {
    gap: 0.25rem;
  }

  .theme-select {
    width: 84px;
    font-size: 0.68rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
