/* ============================================================
   Demo COTIZADOR — Sistema visual Demo Construcción
   Tokens: azul #2357F2 · Inter · flat (sin gradientes ni sombras)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

@font-face {
  font-family: 'DecimaMonoPro';
  src: url('fonts/DecimaMonoPro-Regular.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Brand Demo Construcción */
  --yellow: #F4C430;
  --yellow-dark: #C9A300;
  --yellow-darker: #8F7400;
  --yellow-light: #FFE88A;
  --yellow-soft: #FFF4D1;
  --yellow-50: #FFFBEB;

  /* Para retrocompat: aliases a yellow (variables --blue usadas por el código) */
  --blue: #F4C430;
  --blue-dark: #C9A300;
  --blue-light: #FFF4D1;
  --blue-50: #FFFBEB;

  /* Neutrals */
  --black: #0A0A0A;
  --white: #FFFFFF;
  --gray-50: #FAFAFA;
  --gray-100: #F5F5F5;
  --gray-200: #E5E5E5;
  --gray-300: #D4D4D4;
  --gray-400: #A3A3A3;
  --gray-500: #6B7280;
  --gray-600: #5F6368;
  --gray-700: #404040;
  --gray-900: #1A1A1A;

  /* Acentos secundarios */
  --info: #2357F2;
  --info-bg: #E8EEFF;
  --lime: #AACC44;
  --purple: #9B5CF5;
  --terracotta: #C85A35;
  --pink: #F0E8F8;

  /* Status */
  --success: #10B981;
  --success-bg: #ECFDF5;
  --warning: #F59E0B;
  --warning-bg: #FFFBEB;
  --danger: #EF4444;
  --danger-bg: #FEF2F2;

  /* Layout */
  --container: 1440px;
  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 12px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-8: 48px;
  --space-10: 64px;

  /* Type */
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-display: 'DecimaMonoPro', 'JetBrains Mono', ui-monospace, monospace;
}

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01', 'ss03';
}

body {
  font-family: var(--font-sans);
  font-weight: 400;
  font-size: 15px;
  line-height: 1.5;
  color: var(--black);
  background: var(--white);
  min-height: 100vh;
}

/* ============================================================
   TYPOGRAPHY
   ============================================================ */
h1, h2, h3, h4, h5 {
  font-family: var(--font-display);
  font-weight: 400;
  color: var(--black);
  font-feature-settings: 'kern' on, 'liga' on, 'calt' on, 'ss01' on, 'ss03' on;
  text-rendering: optimizeLegibility;
}

h1 { font-size: 58px; line-height: 1.0; letter-spacing: -0.04em; }
h2 { font-size: 40px; line-height: 1.05; letter-spacing: -0.035em; }
h3 { font-size: 28px; line-height: 1.15; letter-spacing: -0.03em; }
h4 { font-size: 20px; line-height: 1.25; letter-spacing: -0.025em; }
h5 { font-size: 16px; line-height: 1.4; letter-spacing: -0.015em; }

.eyebrow {
  font-family: var(--font-display);
  font-weight: 400;
}

p { color: var(--gray-700); }

.eyebrow {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--gray-500);
}

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================================================
   LAYOUT
   ============================================================ */
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: 12px 32px;
  padding-top: max(12px, env(safe-area-inset-top));
  padding-left: max(32px, env(safe-area-inset-left));
  padding-right: max(32px, env(safe-area-inset-right));
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-inner {
  max-width: var(--container);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 500;
  font-size: 16px;
  color: var(--black);
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.brand-mark svg, .brand-mark img {
  width: 100%;
  height: 100%;
  display: block;
}

.brand-creai {
  font-size: 11px;
  color: var(--gray-500);
  margin-left: auto;
  font-family: var(--font-mono);
}

.topbar-logo {
  height: 64px;
  width: auto;
  display: block;
  object-fit: contain;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: auto;
}

.topbar-right-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  text-align: right;
}

.topbar-right-meta .meta-tag {
  font-size: 10px;
  color: var(--gray-500);
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mode-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--blue-light);
  color: var(--blue-dark);
  padding: 6px 12px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 500;
}

.mode-pill.cliente { background: var(--pink); color: var(--purple); }

main { padding: 32px; max-width: var(--container); margin: 0 auto; width: 100%; }

footer.app-foot {
  border-top: 1px solid var(--gray-200);
  padding: 24px 32px;
  padding-bottom: max(24px, env(safe-area-inset-bottom));
  padding-left: max(32px, env(safe-area-inset-left));
  padding-right: max(32px, env(safe-area-inset-right));
  font-size: 12px;
  color: var(--gray-500);
  text-align: center;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease, transform 120ms ease;
  white-space: nowrap;
  text-decoration: none;
}

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

.btn-primary {
  background: var(--yellow);
  color: var(--black);
}
.btn-primary:hover { background: var(--yellow-dark); color: var(--black); }

.btn-dark { background: var(--black); color: var(--white); }
.btn-dark:hover { background: var(--gray-900); }

.btn-secondary {
  background: var(--white);
  color: var(--black);
  border-color: var(--gray-300);
}
.btn-secondary:hover { background: var(--gray-50); border-color: var(--gray-400); }

.btn-ghost {
  background: transparent;
  color: var(--gray-700);
}
.btn-ghost:hover { background: var(--gray-100); color: var(--black); }

.btn-danger {
  background: var(--white);
  color: var(--danger);
  border-color: var(--gray-300);
}
.btn-danger:hover { background: var(--danger-bg); border-color: var(--danger); }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 14px 24px; font-size: 15px; }
.btn-block { width: 100%; }

.btn .icon { width: 16px; height: 16px; }

/* ============================================================
   FORM CONTROLS
   ============================================================ */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-700);
}
.field .hint { font-size: 11px; color: var(--gray-500); }

.input, .select, .textarea {
  font-family: inherit;
  font-size: 14px;
  padding: 10px 12px;
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  color: var(--black);
  width: 100%;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(35, 87, 242, 0.12);
}

.input.is-number, .table-input.is-number {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.textarea { min-height: 80px; resize: vertical; }

.input-group {
  display: flex;
  align-items: center;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  background: var(--white);
  overflow: hidden;
}
.input-group:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(35, 87, 242, 0.12);
}
.input-group .input {
  border: none;
  border-radius: 0;
}
.input-group .input:focus { box-shadow: none; }
.input-group .addon {
  padding: 0 12px;
  font-size: 12px;
  color: var(--gray-500);
  background: var(--gray-50);
  align-self: stretch;
  display: grid;
  place-items: center;
  font-weight: 500;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.card-flat {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.card-blue {
  background: var(--blue-50);
  border: 1px solid var(--blue-light);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.card-dark {
  background: var(--black);
  color: var(--white);
  border-radius: var(--radius-lg);
  padding: 24px;
}
.card-dark h1, .card-dark h2, .card-dark h3, .card-dark h4 { color: var(--white); }
.card-dark p { color: var(--gray-300); }

/* ============================================================
   BADGES & PILLS
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 500;
  border-radius: 4px;
  letter-spacing: 0;
}

.badge-blue { background: var(--blue-light); color: var(--blue-dark); }
.badge-yellow { background: var(--yellow); color: var(--black); }
.badge-lime { background: var(--lime); color: var(--black); }
.badge-purple { background: var(--pink); color: var(--purple); }
.badge-gray { background: var(--gray-100); color: var(--gray-700); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }

/* ============================================================
   LANDING — Mode selector
   ============================================================ */
.hero {
  padding: 80px 0 56px;
  text-align: left;
  max-width: 900px;
}

.hero .eyebrow { margin-bottom: 24px; }
.hero h1 {
  margin-bottom: 24px;
  letter-spacing: -0.03em;
}
.hero h1 em {
  font-style: normal;
  color: var(--blue);
}
.hero p {
  font-size: 18px;
  line-height: 1.55;
  color: var(--gray-700);
  max-width: 620px;
}

.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 24px;
}

.mode-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 36px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: border-color 160ms ease, transform 160ms ease, background 160ms ease;
  min-height: 280px;
}

.mode-card:hover {
  transform: translateY(-2px);
}

.mode-card.mode-card-blue:hover {
  border-color: var(--yellow);
  background: var(--yellow-soft);
}

.mode-card.mode-card-pink:hover {
  border-color: var(--purple);
  background: var(--pink);
}

.mode-card .mode-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  margin-bottom: 24px;
}

.mode-card.mode-card-blue .mode-icon { background: var(--blue); color: var(--white); }
.mode-card.mode-card-pink .mode-icon { background: var(--purple); color: var(--white); }

.mode-card h3 { margin-bottom: 8px; }
.mode-card p { color: var(--gray-500); font-size: 14px; }

.mode-card .mode-bullets {
  list-style: none;
  margin-top: 20px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.mode-card .mode-bullets li {
  font-size: 13px;
  color: var(--gray-700);
  padding-left: 18px;
  position: relative;
}
.mode-card .mode-bullets li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  width: 8px;
  height: 1px;
  background: var(--yellow);
}
.mode-card.mode-card-pink .mode-bullets li::before {
  background: var(--purple);
}

.mode-card .mode-cta {
  margin-top: auto;
  padding-top: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--black);
}

/* ============================================================
   ADMIN — Tabulator
   ============================================================ */
.admin-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 24px;
  align-items: start;
}

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

.client-block {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  padding: 24px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
}

@media (max-width: 720px) {
  .client-block { grid-template-columns: 1fr; }
}

.section-block {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  overflow: hidden;
}

.section-head {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--gray-200);
  background: var(--gray-50);
}

.section-head .section-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--blue-light);
  color: var(--blue);
  display: grid;
  place-items: center;
}

.section-head .section-title {
  flex: 1;
}

.section-head .section-title input {
  font-family: inherit;
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.01em;
  border: none;
  padding: 4px 6px;
  margin-left: -6px;
  width: 100%;
  border-radius: var(--radius-sm);
  background: transparent;
}

.section-head .section-title input:focus {
  outline: none;
  background: var(--white);
  box-shadow: 0 0 0 2px var(--blue-light);
}

.section-head .section-meta {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 2px;
}

.section-totals {
  display: flex;
  gap: 16px;
  align-items: center;
}

.section-totals .total-chip {
  background: var(--white);
  border: 1px solid var(--gray-200);
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.section-totals .total-chip strong {
  font-weight: 600;
  color: var(--black);
  margin-left: 6px;
}

.section-body {
  padding: 0;
}

.subsection {
  border-bottom: 1px solid var(--gray-200);
}
.subsection:last-child { border-bottom: none; }

.subsection-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--white);
}

.subsection-head .sub-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gray-700);
}

.subsection-head .sub-label .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.subsection-head .sub-label .dot.dot-mo { background: var(--blue); }
.subsection-head .sub-label .dot.dot-mat { background: var(--terracotta); }

.subsection-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.subsection-controls .pct-input {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--white);
}
.subsection-controls .pct-input label {
  font-size: 11px;
  color: var(--gray-500);
  padding: 6px 8px;
  border-right: 1px solid var(--gray-200);
}
.subsection-controls .pct-input input {
  width: 56px;
  border: none;
  padding: 6px 8px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.subsection-controls .pct-input input:focus { outline: none; background: var(--blue-50); }
.subsection-controls .pct-input .addon {
  background: var(--gray-50);
  padding: 6px 8px;
  font-size: 11px;
  color: var(--gray-500);
}

/* ============================================================
   ITEMS TABLE
   ============================================================ */
.items-table {
  width: 100%;
  border-collapse: collapse;
}

.items-table thead th {
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-500);
  padding: 8px 12px;
  border-bottom: 1px solid var(--gray-200);
  background: var(--gray-50);
}

.items-table thead th.col-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.items-table tbody tr {
  border-bottom: 1px solid var(--gray-100);
  transition: background 100ms ease;
}
.items-table tbody tr:hover { background: var(--blue-50); }
.items-table tbody tr:last-child { border-bottom: none; }

.items-table td {
  padding: 6px 12px;
  vertical-align: middle;
}

.table-input {
  width: 100%;
  font-family: inherit;
  font-size: 13px;
  border: 1px solid transparent;
  background: transparent;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  color: var(--black);
}

.table-input:hover { background: var(--white); border-color: var(--gray-200); }
.table-input:focus {
  outline: none;
  background: var(--white);
  border-color: var(--blue);
  box-shadow: 0 0 0 2px var(--blue-light);
}

.table-input.is-number {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.items-table .col-importe {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  padding-right: 12px;
}

.col-actions { text-align: right; width: 40px; }

.row-delete {
  background: none;
  border: none;
  padding: 6px;
  cursor: pointer;
  color: var(--gray-400);
  border-radius: var(--radius-sm);
  display: inline-grid;
  place-items: center;
  transition: background 120ms ease, color 120ms ease;
}
.row-delete:hover { background: var(--danger-bg); color: var(--danger); }

.add-row {
  padding: 12px 20px;
  background: var(--white);
  border-top: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--gray-500);
  cursor: pointer;
  width: 100%;
  border-left: none;
  border-right: none;
  border-bottom: none;
  font-family: inherit;
  transition: background 120ms ease, color 120ms ease;
}
.add-row:hover { background: var(--blue-50); color: var(--blue); }

.subsection-foot {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  background: var(--gray-50);
  border-top: 1px solid var(--gray-200);
  font-size: 13px;
}

.subsection-foot .label { color: var(--gray-500); }
.subsection-foot .value {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  color: var(--black);
  min-width: 110px;
  text-align: right;
}

/* ============================================================
   SIDEBAR SUMMARY
   ============================================================ */
.summary {
  position: sticky;
  top: 90px;
  background: var(--black);
  color: var(--white);
  border-radius: var(--radius-lg);
  padding: 28px;
}

.summary h3 {
  color: var(--white);
  font-weight: 400;
  margin-bottom: 24px;
  letter-spacing: -0.01em;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  font-size: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.summary-row:last-of-type { border-bottom: none; }
.summary-row .label { color: var(--gray-400); }
.summary-row .value {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.summary-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.12);
  margin: 12px 0;
}

.summary-grand {
  background: var(--yellow);
  color: var(--black);
  margin: 24px -28px -28px;
  padding: 24px 28px;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.summary-grand .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 600;
  color: var(--black);
}
.summary-grand .value {
  font-size: 28px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--black);
}

.summary-actions {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.summary-actions .btn-primary {
  background: var(--yellow);
  color: var(--black);
}
.summary-actions .btn-primary:hover { background: var(--yellow-dark); color: var(--black); }

.summary-actions .btn-secondary {
  background: transparent;
  color: var(--white);
  border-color: rgba(255, 255, 255, 0.2);
}
.summary-actions .btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.4);
}

.summary-toggles {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 13px;
  color: var(--gray-300);
}

.toggle-switch {
  width: 36px;
  height: 20px;
  background: rgba(255, 255, 255, 0.16);
  border-radius: 100px;
  position: relative;
  cursor: pointer;
  transition: background 160ms ease;
}
.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: var(--white);
  border-radius: 50%;
  transition: transform 160ms ease;
}
.toggle-switch.is-on { background: var(--blue); }
.toggle-switch.is-on::after { transform: translateX(16px); }

/* ============================================================
   TOOLBAR
   ============================================================ */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.toolbar h2 { font-size: 28px; }
.toolbar p { font-size: 13px; color: var(--gray-500); margin-top: 4px; }

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

/* ============================================================
   ADD-SECTION POPOVER
   ============================================================ */
.popover {
  position: relative;
}

.popover-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 6px;
  min-width: 260px;
  z-index: 40;
  display: none;
  box-shadow: 0 6px 24px rgba(10, 10, 10, 0.08);
}
.popover-menu.is-open { display: block; }

.popover-menu button {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--gray-700);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 10px;
}
.popover-menu button:hover { background: var(--blue-50); color: var(--blue-dark); }
.popover-menu .divider { height: 1px; background: var(--gray-200); margin: 6px 0; }
.popover-menu .label { font-size: 10px; padding: 6px 12px; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.1em; font-weight: 600; }

/* ============================================================
   CLIENT WIZARD
   ============================================================ */
.wizard-shell {
  max-width: 880px;
  margin: 0 auto;
}

.stepper {
  display: flex;
  align-items: center;
  margin-bottom: 40px;
  gap: 8px;
}

.step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--gray-500);
}
.step.is-active { color: var(--black); }
.step.is-done { color: var(--blue); }

.step .step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--gray-100);
  display: grid;
  place-items: center;
  font-weight: 500;
  font-size: 12px;
  color: var(--gray-500);
}
.step.is-active .step-num {
  background: var(--black);
  color: var(--white);
}
.step.is-done .step-num {
  background: var(--yellow);
  color: var(--black);
}
.step-line {
  flex: 1;
  height: 1px;
  background: var(--gray-200);
}
.step.is-done + .step-line { background: var(--blue); }

.wizard-card { padding: 40px; }

.wizard-card h2 {
  margin-bottom: 8px;
}
.wizard-card .subtitle {
  color: var(--gray-500);
  margin-bottom: 32px;
}

.service-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
@media (max-width: 640px) {
  .service-grid { grid-template-columns: 1fr; }
}

.service-card {
  display: flex;
  gap: 16px;
  padding: 20px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}
.service-card:hover { border-color: var(--blue); background: var(--blue-50); }
.service-card.is-selected {
  border-color: var(--blue);
  background: var(--blue-50);
}

.service-card .icon-wrap {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  background: var(--blue-light);
  color: var(--blue);
  display: grid;
  place-items: center;
}

.service-card .body {
  flex: 1;
}
.service-card h4 { font-size: 15px; margin-bottom: 2px; }
.service-card p { font-size: 12px; color: var(--gray-500); margin: 0; }
.service-card .price {
  margin-top: 8px;
  font-size: 12px;
  color: var(--gray-700);
}
.service-card .price strong { color: var(--blue); font-weight: 500; }

.wizard-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--gray-200);
}

.calc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 640px) {
  .calc-grid { grid-template-columns: 1fr; }
}

.calc-card {
  padding: 20px;
  background: var(--gray-50);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.calc-card h4 {
  margin-bottom: 4px;
}
.calc-card .meta {
  font-size: 12px;
  color: var(--gray-500);
  margin-bottom: 16px;
}

.estimate-box {
  background: var(--black);
  color: var(--white);
  padding: 24px;
  border-radius: var(--radius);
  margin-top: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.estimate-box .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--gray-400);
}
.estimate-box .total {
  font-size: 32px;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.estimate-box .hint { font-size: 11px; color: var(--gray-400); margin-top: 4px; }

/* ============================================================
   HISTORY MODAL
   ============================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 10, 0.6);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 32px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 200ms ease;
}
.modal-backdrop.is-open {
  display: flex;
  opacity: 1;
}

.modal {
  background: var(--white);
  border-radius: 16px;
  width: 100%;
  max-width: 760px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(8px) scale(0.98);
  transition: transform 200ms ease;
}
.modal-backdrop.is-open .modal {
  transform: translateY(0) scale(1);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 24px 28px 16px;
  border-bottom: 1px solid var(--gray-200);
  gap: 16px;
}
.modal-header h3 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.025em;
  margin-bottom: 4px;
}
.modal-header .modal-subtitle {
  font-size: 13px;
  color: var(--gray-500);
}
.modal-close {
  background: var(--gray-100);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  color: var(--gray-700);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: background 120ms ease, color 120ms ease;
}
.modal-close:hover { background: var(--gray-200); color: var(--black); }

.modal-search {
  padding: 16px 28px;
  border-bottom: 1px solid var(--gray-100);
}
.modal-search .input-group {
  background: var(--gray-50);
  border-color: transparent;
}
.modal-search .input-group:focus-within {
  background: var(--white);
  border-color: var(--gray-300);
}
.modal-search .input {
  background: transparent;
  font-size: 14px;
}

.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px 16px;
}

.history-item {
  display: grid;
  grid-template-columns: 60px 1fr auto;
  gap: 16px;
  padding: 14px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 100ms ease;
  position: relative;
  border-bottom: 1px solid var(--gray-100);
}
.history-item:last-child { border-bottom: none; }
.history-item:hover { background: var(--gray-50); }

.history-item .h-num {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--yellow-dark);
  background: var(--yellow-soft);
  padding: 4px 8px;
  border-radius: 4px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  align-self: center;
  letter-spacing: 0.02em;
}

.history-item .h-info {
  min-width: 0;
}
.history-item .h-info .h-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--black);
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: -0.015em;
}
.history-item .h-info .h-meta {
  font-size: 12px;
  color: var(--gray-500);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.history-item .h-info .h-meta .dot-sep {
  color: var(--gray-300);
}

.history-item .h-total {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  font-weight: 600;
  color: var(--black);
  text-align: right;
  align-self: center;
  white-space: nowrap;
}
.history-item .h-total .h-date {
  font-size: 11px;
  color: var(--gray-500);
  font-weight: 400;
  margin-top: 2px;
}

.history-item .h-actions {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: none;
  gap: 4px;
  background: var(--white);
  padding: 4px;
  border-radius: 6px;
  border: 1px solid var(--gray-200);
  box-shadow: 0 4px 12px rgba(10, 10, 10, 0.08);
}
.history-item:hover .h-actions {
  display: flex;
}

.h-actions .btn {
  padding: 6px 10px;
  font-size: 12px;
}
.h-actions .btn-icon {
  padding: 6px;
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  color: var(--gray-700);
  display: grid;
  place-items: center;
  transition: background 100ms ease, color 100ms ease;
}
.h-actions .btn-icon:hover { background: var(--gray-100); color: var(--black); }
.h-actions .btn-icon.danger:hover { background: var(--danger-bg); color: var(--danger); }

.history-empty {
  text-align: center;
  padding: 64px 32px;
  color: var(--gray-500);
}
.history-empty .icon-wrap {
  width: 48px;
  height: 48px;
  background: var(--gray-100);
  border-radius: 50%;
  display: grid;
  place-items: center;
  margin: 0 auto 16px;
  color: var(--gray-500);
}
.history-empty h4 {
  font-size: 16px;
  margin-bottom: 4px;
  color: var(--black);
}
.history-empty p { font-size: 13px; color: var(--gray-500); }

.modal-foot {
  border-top: 1px solid var(--gray-200);
  padding: 16px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--gray-50);
}
.modal-foot .foot-hint {
  font-size: 12px;
  color: var(--gray-500);
}

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--black);
  color: var(--white);
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* Spinner para loading states */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Section entry/exit animations */
@keyframes section-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes row-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.section-block { animation: section-in 240ms cubic-bezier(0.2, 0, 0, 1); }
.items-table tbody tr { animation: row-in 180ms ease-out; }

/* History item subtle entry */
.history-item { animation: section-in 220ms ease-out backwards; }
.history-item:nth-child(1) { animation-delay: 0ms; }
.history-item:nth-child(2) { animation-delay: 30ms; }
.history-item:nth-child(3) { animation-delay: 60ms; }
.history-item:nth-child(4) { animation-delay: 90ms; }
.history-item:nth-child(5) { animation-delay: 120ms; }
.history-item:nth-child(n+6) { animation-delay: 150ms; }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty {
  text-align: center;
  padding: 80px 32px;
  border: 1px dashed var(--gray-300);
  border-radius: var(--radius-lg);
  background: var(--gray-50);
}
.empty h3 {
  margin-bottom: 8px;
  font-size: 22px;
}
.empty p {
  color: var(--gray-500);
  font-size: 14px;
  margin-bottom: 24px;
  max-width: 380px;
  margin-left: auto;
  margin-right: auto;
}

/* ============================================================
   SCROLLBAR (subtle)
   ============================================================ */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--gray-50); }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 100px; border: 2px solid var(--gray-50); }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ============================================================
   UTILITIES
   ============================================================ */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.text-gray { color: var(--gray-500); }
.text-blue { color: var(--blue); }
.text-right { text-align: right; }
.full-width { width: 100%; }
.hidden { display: none !important; }

/* ============================================================
   MOBILE & RESPONSIVE
   ============================================================ */

/* Touch targets globales (mínimo 44px en móvil) */
@media (hover: none) and (pointer: coarse) {
  .btn { min-height: 44px; }
  .btn-sm { min-height: 38px; }
  .row-delete, .btn-icon { min-height: 36px; min-width: 36px; }
  /* Prevenir zoom en iOS al focus input */
  .input, .select, .textarea, .table-input { font-size: 16px; }
}

/* Tablet (1024px) */
@media (max-width: 1024px) {
  .admin-grid { grid-template-columns: 1fr; }
  .summary { position: static; }
}

/* Mobile (768px) */
@media (max-width: 768px) {
  /* Layout */
  main { padding: 16px; }
  .app-foot { padding: 16px; font-size: 11px; }

  /* Topbar */
  .topbar { padding: 10px 16px; }
  .topbar-inner { gap: 12px; }
  .topbar-logo { height: 44px; }
  .brand-creai { display: none; }
  .topbar-right-meta { display: none; }
  .brand > div > div:last-child { font-size: 10px; }

  /* Hero */
  .hero { padding: 32px 0 24px; }
  .hero .eyebrow { margin-bottom: 16px; }
  .hero h1 {
    font-size: 32px;
    line-height: 1.0;
    letter-spacing: -0.03em;
    word-break: normal;
    overflow-wrap: break-word;
  }
  .hero p { font-size: 15px; }

  /* Mode grid → 1 columna */
  .mode-grid { grid-template-columns: 1fr; gap: 16px; }
  .mode-card { padding: 24px; min-height: auto; }
  .mode-card .mode-icon { width: 48px; height: 48px; margin-bottom: 16px; }
  .mode-card h3 { font-size: 24px; }
  .mode-card p { font-size: 13px; }

  /* Headings */
  h2 { font-size: 26px; line-height: 1.1; letter-spacing: -0.03em; }
  h3 { font-size: 22px; }
  h4 { font-size: 17px; }

  /* Toolbar admin */
  .toolbar { gap: 12px; }
  .toolbar h2 { font-size: 22px; }
  .toolbar p { font-size: 12px; }
  .toolbar-actions { width: 100%; }
  .toolbar-actions .btn { flex: 1; }

  /* Topbar admin: icon-only botones (oculta .btn-label, mantiene SVG accesible) */
  .topbar-actions { gap: 4px; }
  .topbar-actions .btn-sm {
    padding: 9px;
    min-width: 40px;
    min-height: 40px;
    position: relative;
  }
  .topbar-actions .btn-sm .btn-label { display: none; }
  .topbar-actions .btn-sm .badge {
    position: absolute;
    top: -4px;
    right: -4px;
    font-size: 9px;
    padding: 0 5px;
    border-radius: 8px;
    min-width: 16px;
    height: 16px;
    line-height: 16px;
    font-weight: 700;
  }
  .mode-pill { display: none; }

  /* Wizard cliente */
  .wizard-card { padding: 20px; border-radius: 12px; }
  .wizard-card h2 { font-size: 22px; }
  .wizard-card .subtitle { font-size: 13px; margin-bottom: 20px; }
  .wizard-foot { flex-direction: column-reverse; gap: 12px; align-items: stretch; padding-top: 20px; margin-top: 20px; }
  .wizard-foot .btn { width: 100%; justify-content: center; }
  .wizard-foot .btn-ghost { order: 2; }

  /* Stepper compacto: solo números visibles */
  .stepper { margin-bottom: 24px; gap: 4px; }
  .step { gap: 4px; font-size: 0; }
  .step .step-num { width: 28px; height: 28px; font-size: 12px; }
  .step.is-active::after {
    content: attr(data-label);
    font-size: 12px;
    color: var(--black);
    font-weight: 500;
  }
  .step-line { min-width: 12px; }

  /* Service cards */
  .service-grid { grid-template-columns: 1fr; gap: 12px; }
  .service-card { padding: 16px; }
  .service-card .icon-wrap { width: 40px; height: 40px; }
  .service-card h4 { font-size: 14px; }
  .service-card p { font-size: 12px; }

  /* Size cards */
  .calc-grid { grid-template-columns: 1fr; gap: 12px; }
  .calc-card { padding: 16px; }

  /* Estimate box */
  .estimate-box { padding: 20px; flex-direction: column; align-items: flex-start; gap: 12px; }
  .estimate-box .total { font-size: 28px; }

  /* Client block (admin) */
  .client-block { padding: 18px; gap: 12px; grid-template-columns: 1fr; }

  /* Section block */
  .section-block { border-radius: 10px; }
  .section-head { padding: 12px 14px; gap: 10px; flex-wrap: wrap; }
  .section-head .section-icon { width: 32px; height: 32px; }
  .section-head .section-title input { font-size: 16px; }
  .section-totals { display: none; }
  .subsection-head { padding: 10px 14px; flex-wrap: wrap; gap: 10px; }
  .add-row { padding: 14px 14px; }
  .subsection-foot { padding: 10px 14px; font-size: 12px; }

  /* TABLA: scroll horizontal con hint visual */
  .items-table-wrap {
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    margin: 0;
    position: relative;
  }
  .items-table {
    min-width: 720px; /* Fuerza scroll en móvil */
  }
  .items-table thead th { font-size: 10px; padding: 8px 10px; white-space: nowrap; }
  .items-table td { padding: 6px 10px; }
  .table-input { font-size: 14px; padding: 8px 10px; }

  /* Sidebar admin */
  .summary { padding: 20px; border-radius: 12px; }
  .summary h3 { font-size: 20px; margin-bottom: 16px; }
  .summary-grand { margin: 20px -20px -20px; padding: 20px; }
  .summary-grand .value { font-size: 24px; }

  /* Card del término */
  .card { padding: 18px; border-radius: 12px; }
  .card-flat, .card-blue { padding: 16px; }

  /* Modal histórico full screen */
  .modal-backdrop { padding: 0; }
  .modal { border-radius: 0; max-height: 100vh; max-width: 100%; height: 100%; }
  .modal-header { padding: 18px 18px 14px; }
  .modal-header h3 { font-size: 18px; }
  .modal-search { padding: 12px 18px; }
  .history-list { padding: 8px; }
  .history-item { grid-template-columns: auto 1fr; padding: 14px 10px; row-gap: 6px; }
  .history-item .h-total { grid-column: 1 / -1; text-align: left; }
  .history-item .h-actions { position: static; transform: none; display: flex; grid-column: 1 / -1; margin-top: 8px; border: none; padding: 0; box-shadow: none; background: transparent; }
  .h-actions .btn-icon { padding: 10px; }
  .modal-foot { padding: 14px 18px; flex-direction: column; gap: 10px; align-items: stretch; }
  .modal-foot .btn { width: 100%; justify-content: center; }
  .modal-foot .foot-hint { text-align: center; }

  /* Popover de plantillas mejor en mobile */
  .popover-menu { min-width: 240px; right: -8px; }
  .popover-menu button { padding: 12px; font-size: 14px; }

  /* Toast más grande en mobile */
  .toast { bottom: 16px; left: 16px; right: 16px; text-align: center; justify-content: center; font-size: 14px; }
}

/* Pantallas muy pequeñas (≤380px) */
@media (max-width: 380px) {
  .hero h1 { font-size: 28px; }
  .hero p { font-size: 14px; }
  .topbar-logo { height: 40px; }
  .stepper { gap: 2px; }
  .step .step-num { width: 24px; height: 24px; font-size: 11px; }
}

/* Animaciones suaves globales */
@media (prefers-reduced-motion: no-preference) {
  .btn, .service-card, .mode-card, .section-block, .history-item, .modal {
    transition: all 180ms cubic-bezier(0.4, 0, 0.2, 1);
  }
  .btn:active { transform: scale(0.97); }
  .service-card:active, .mode-card:active { transform: scale(0.99); }
}

/* Focus visible accesible */
.btn:focus-visible, .input:focus-visible, .select:focus-visible, .textarea:focus-visible,
.mode-card:focus-visible, .service-card:focus-visible, .table-input:focus-visible {
  outline: 2px solid var(--yellow);
  outline-offset: 2px;
}

/* Smooth scroll */
html { scroll-behavior: smooth; }

/* Prevent body scroll when modal open */
body.modal-open { overflow: hidden; }

/* ============================================================
   PRINT (for fallback)
   ============================================================ */
@media print {
  .topbar, .summary, .toolbar-actions, .add-row, .row-delete { display: none !important; }
}
