/* =====================================================
   The Code Hex CRM — Design System (TCH)
   Fuentes: PPRader, PPFormula, PPFormula Narrow, PPSupplyMono
   Paleta: Dark Editorial + Single Accent #6DBF2A + Light Theme
   ===================================================== */

/* -----------------------------------------------------
   1. Tipografías autohospedadas
   ----------------------------------------------------- */
@font-face {
  font-family: 'Rader';
  src: url('/static/fonts/PPRader-Thin.woff2') format('woff2');
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Rader';
  src: url('/static/fonts/PPRader-ThinItalic.woff2') format('woff2');
  font-weight: 300;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: 'Rader';
  src: url('/static/fonts/PPRader-Medium.woff2') format('woff2');
  font-weight: 400 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Rader';
  src: url('/static/fonts/PPRader-Bold.woff2') format('woff2');
  font-weight: 600 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Rader';
  src: url('/static/fonts/PPRader-BoldItalic.woff2') format('woff2');
  font-weight: 600 800;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: 'Formula';
  src: url('/static/fonts/PPFormula-Light.woff2') format('woff2');
  font-weight: 200 300;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Formula';
  src: url('/static/fonts/PPFormula-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Formula';
  src: url('/static/fonts/PPFormula-RegularItalic.woff2') format('woff2');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: 'Formula';
  src: url('/static/fonts/PPFormula-Medium.woff2') format('woff2');
  font-weight: 500 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Formula Narrow';
  src: url('/static/fonts/PPFormula-NarrowRegular.woff2') format('woff2');
  font-weight: 300 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Formula Narrow';
  src: url('/static/fonts/PPFormula-NarrowSemibold.woff2') format('woff2');
  font-weight: 500 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Formula Narrow';
  src: url('/static/fonts/PPFormula-NarrowBold.woff2') format('woff2');
  font-weight: 700 800;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Supply Mono';
  src: url('/static/fonts/PPSupplyMono-Regular.woff2') format('woff2');
  font-weight: 300 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Supply Mono';
  src: url('/static/fonts/PPSupplyMono-Medium.woff2') format('woff2');
  font-weight: 500 700;
  font-style: normal;
  font-display: swap;
}

/* -----------------------------------------------------
   2. Tokens de diseño
   ----------------------------------------------------- */
:root {
  color-scheme: light;

  /* Fondos y superficies */
  --background:        #ffffff;
  --foreground:        #1d1d1f;
  --surface:           #f5f5f7;
  --surface-2:         #ffffff;
  --surface-3:         rgba(245, 245, 247, 0.85);
  --muted-foreground:  #6e6e73;
  --border:            #d2d2d7;
  --border-light:      #e5e5ea;
  --hairline:          rgba(0, 0, 0, 0.08);
  --dashed:            #d2d2d7;

  /* Marca TCH */
  --brand:             #6DBF2A;
  --brand-hover:       #5ea824;
  --brand-ink:         #2F7A1A; /* Contraste AA en claro */
  --brand-soft:        rgba(109, 191, 42, 0.12);
  --brand-forest:      #1f3a28;

  /* Controles e inputs */
  --input-background:  #f5f5f7;
  --ring:              rgba(47, 122, 26, 0.35);

  /* Semánticos */
  --destructive:       #dc2626;
  --destructive-soft:  rgba(220, 38, 38, 0.1);
  --success:           #16a34a;
  --success-soft:      rgba(22, 163, 74, 0.1);
  --warning:           #d97706;
  --warning-soft:      rgba(217, 119, 6, 0.1);

  /* Sombras */
  --shadow-sm:         0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md:         0 8px 24px rgba(0, 0, 0, 0.08);
  --shadow-lg:         0 20px 48px rgba(0, 0, 0, 0.12);

  /* Constantes */
  --font-display:      'Rader', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-sans:         'Formula', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-narrow:       'Formula Narrow', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:         'Supply Mono', ui-monospace, SFMono-Regular, monospace;

  --radius-card:       28px;
  --radius-tile:       20px;
  --radius-md:         10px;
  --radius-sm:         6px;
  --radius-full:       9999px;

  --gradient-forest:   linear-gradient(135deg, #1f3a28 0%, #0b0b0b 100%);
  --gradient-card:     linear-gradient(180deg, rgba(255, 255, 255, 0.02) 0%, rgba(255, 255, 255, 0) 100%);

  /* Capa de alias para compatibilidad retroactiva durante migración */
  --bg:                var(--background);
  --text:              var(--foreground);
  --fg:                var(--foreground);
  --surface2:          var(--surface-2);
  --surface3:          var(--surface-2);
  --border2:           var(--border);
  --border-color:      var(--border);
  --accent:            var(--brand);
  --accent2:           var(--brand);
  --accent-h:          var(--brand-hover);
  --accent-hover:      var(--brand-hover);
  --accent-dim:        var(--brand-soft);
  --accent-dark:       var(--brand-ink);
  --accent-glow:       rgba(109, 191, 42, 0.25);
  --muted:             var(--muted-foreground);
  --muted2:            var(--muted-foreground);
  --danger:            var(--destructive);
  --danger-dim:        var(--destructive-soft);
  --blue:              var(--muted-foreground);
  --blue-dim:          rgba(0, 0, 0, 0.05);
  --purple:            var(--muted-foreground);
  --canopy:            var(--brand-forest);
}

html.dark,
body.dark,
[data-theme="dark"] {
  color-scheme: dark;

  /* Fondos y superficies */
  --background:        #0b0b0b;
  --foreground:        #f5f5f7;
  --surface:           #141414;
  --surface-2:         #1c1c1e;
  --surface-3:         rgba(28, 28, 30, 0.7);
  --muted-foreground:  #a1a1a6;
  --border:            #2a2a2c;
  --border-light:      #3a3a3c;
  --hairline:          rgba(255, 255, 255, 0.08);
  --dashed:            #4a4a4e;

  /* Marca TCH */
  --brand:             #6DBF2A;
  --brand-hover:       #7acc30;
  --brand-ink:         #6DBF2A;
  --brand-soft:        rgba(109, 191, 42, 0.14);
  --brand-forest:      #1f3a28;

  /* Controles e inputs */
  --input-background:  #141414;
  --ring:              rgba(109, 191, 42, 0.4);

  /* Semánticos */
  --destructive:       #ef4444;
  --destructive-soft:  rgba(239, 68, 68, 0.12);
  --success:           #22c55e;
  --success-soft:      rgba(34, 197, 94, 0.12);
  --warning:           #f59e0b;
  --warning-soft:      rgba(245, 158, 11, 0.12);

  /* Sombras */
  --shadow-sm:         0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md:         0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-lg:         0 20px 48px rgba(0, 0, 0, 0.6);

  /* Capa de alias para modo oscuro */
  --bg:                var(--background);
  --text:              var(--foreground);
  --fg:                var(--foreground);
  --surface2:          var(--surface-2);
  --surface3:          var(--surface-2);
  --border2:           var(--border);
  --border-color:      var(--border);
  --accent:            var(--brand);
  --accent2:           var(--brand);
  --accent-h:          var(--brand-hover);
  --accent-hover:      var(--brand-hover);
  --accent-dim:        var(--brand-soft);
  --accent-dark:       var(--brand-ink);
  --accent-glow:       rgba(109, 191, 42, 0.25);
  --muted:             var(--muted-foreground);
  --muted2:            var(--muted-foreground);
  --danger:            var(--destructive);
  --danger-dim:        var(--destructive-soft);
  --blue:              var(--muted-foreground);
  --blue-dim:          rgba(255, 255, 255, 0.05);
  --purple:            var(--muted-foreground);
  --canopy:            var(--brand-forest);
}

/* -----------------------------------------------------
   3. Estilos base y resets
   ----------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-family: var(--font-sans);
  background-color: var(--background);
  color: var(--foreground);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-weight: 300;
  line-height: 1.5;
  transition: background-color 0.2s ease, color 0.2s ease;
}

::selection {
  background: var(--brand);
  color: #0b0b0b;
}

svg.lucide {
  stroke-width: 1.75;
}

/* Reducción de movimiento */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* Keyframes */
@keyframes arc-drift {
  0%   { transform: translateY(0px) rotate(0deg); }
  50%  { transform: translateY(-12px) rotate(0.8deg); }
  100% { transform: translateY(0px) rotate(0deg); }
}

.animate-arc-drift {
  animation: arc-drift 24s ease-in-out infinite alternate;
}

@keyframes pageFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.page-enter {
  animation: pageFadeIn 0.5s ease-out;
}

/* Visibilidad de logo según tema */
html.dark .tch-logo-light,
[data-theme="dark"] .tch-logo-light {
  display: none !important;
}
html.dark .tch-logo-dark,
[data-theme="dark"] .tch-logo-dark {
  display: inline-block !important;
}
html:not(.dark) .tch-logo-dark {
  display: none !important;
}
html:not(.dark) .tch-logo-light {
  display: inline-block !important;
}

/* -----------------------------------------------------
   4. Tipografía utilitaria
   ----------------------------------------------------- */
.display-hero {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 7vw, 4.5rem);
  line-height: 0.95;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  margin: 0;
}

.display-hero .strong {
  font-weight: 700;
  font-style: italic;
  color: var(--foreground);
  display: block;
}

.display-hero .soft {
  font-weight: 300;
  font-style: italic;
  color: var(--muted-foreground);
  display: block;
}

.h-section {
  font-family: var(--font-display);
  font-weight: 700;
  font-style: italic;
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  line-height: 0.95;
  letter-spacing: -0.01em;
  text-transform: uppercase;
  color: var(--foreground);
  margin: 0;
}

.h-card {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.25rem;
  line-height: 1.2;
  color: var(--foreground);
  margin: 0;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted-foreground);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.eyebrow .sep {
  opacity: 0.4;
  margin: 0 4px;
}

.subtitle {
  font-family: var(--font-narrow);
  font-size: 1.125rem;
  line-height: 1.4;
  color: var(--muted-foreground);
}

.body {
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--foreground);
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

/* -----------------------------------------------------
   5. Componentes: Botones
   ----------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-narrow);
  font-weight: 600;
  border-radius: var(--radius-full);
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
  background: transparent;
  color: var(--foreground);
}

.btn:active {
  transform: scale(0.98);
}

.btn-sm {
  height: 32px;
  padding: 0 14px;
  font-size: 13px;
}

.btn-md {
  height: 40px;
  padding: 0 20px;
  font-size: 14px;
}

.btn-lg {
  height: 48px;
  padding: 0 26px;
  font-size: 15px;
}

/* Primario: verde TCH con texto #0b0b0b. UN SOLO PRIMARIO POR VISTA */
.btn-primary {
  background-color: var(--brand);
  color: #0b0b0b !important;
  border-color: var(--brand);
}

.btn-primary:hover {
  background-color: var(--brand-hover);
  border-color: var(--brand-hover);
  color: #0b0b0b !important;
}

/* Contraste: foreground sobre background */
.btn-contrast {
  background-color: var(--foreground);
  color: var(--background) !important;
  border-color: var(--foreground);
}

.btn-contrast:hover {
  opacity: 0.9;
}

/* Ghost: borde hairline, fondo transparente */
.btn-ghost {
  background-color: transparent;
  color: var(--foreground);
  border-color: var(--hairline);
}

.btn-ghost:hover {
  background-color: var(--surface);
  border-color: var(--border);
}

/* Link: sin borde ni fondo */
.btn-link {
  background-color: transparent;
  color: var(--muted-foreground);
  border-color: transparent;
  padding-left: 0;
  padding-right: 0;
}

.btn-link:hover {
  color: var(--foreground);
}

/* Flecha animada en hover */
.btn .btn-arrow {
  display: inline-block;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn:hover .btn-arrow {
  transform: translateX(2px);
}

/* -----------------------------------------------------
   6. Form Controls: Inputs, selects, textareas
   ----------------------------------------------------- */
.input,
.select,
.textarea,
.form-control {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  background-color: var(--input-background);
  color: var(--foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.textarea {
  height: auto;
  min-height: 96px;
  padding: 12px 14px;
  resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus,
.form-control:focus,
.input:focus-visible,
.select:focus-visible,
.textarea:focus-visible,
.form-control:focus-visible {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--ring);
}

.input::placeholder,
.textarea::placeholder,
.form-control::placeholder {
  color: var(--muted-foreground);
  opacity: 0.7;
}

.input:disabled,
.select:disabled,
.textarea:disabled,
.form-control:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* -----------------------------------------------------
   7. Badges y chips
   ----------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background-color: transparent;
  color: var(--muted-foreground);
  border: 1px solid var(--hairline);
  white-space: nowrap;
}

.badge-positive,
.badge-brand {
  background-color: var(--brand-soft);
  color: var(--brand-ink);
  border-color: transparent;
}

.badge-destructive {
  background-color: var(--destructive-soft);
  color: var(--destructive);
  border-color: transparent;
}

.badge-neutral {
  background-color: var(--surface);
  color: var(--muted-foreground);
  border-color: var(--hairline);
}

/* Icon Tile */
.icon-tile {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-tile);
  background-color: var(--brand-soft);
  color: var(--brand-ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* -----------------------------------------------------
   8. Tarjetas
   ----------------------------------------------------- */
/* Tarjeta punteada editorial TCH */
.card-dashed,
.card {
  border: 2px dashed var(--dashed);
  border-radius: var(--radius-card);
  padding: 32px;
  background-color: transparent;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.2s ease;
}

.card-dashed:hover,
.card:hover {
  transform: translateY(-4px);
  border-color: var(--brand);
}

/* Tarjeta sin contenedor */
.card-bare {
  background-color: transparent;
  border: none;
  padding: 0;
  border-radius: 0;
}

/* -----------------------------------------------------
   9. Tablas
   ----------------------------------------------------- */
.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table,
table.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.table thead th,
table.data-table thead th {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted-foreground);
  text-align: left;
  padding: 14px 18px;
  border-bottom: 1px solid var(--hairline);
  background: transparent;
}

.table tbody td,
table.data-table tbody td {
  padding: 16px 18px;
  border-bottom: none;
  font-size: 14px;
  color: var(--foreground);
  transition: background-color 0.15s ease;
}

.table tbody tr:hover td,
table.data-table tbody tr:hover td {
  background-color: var(--surface);
}

/* -----------------------------------------------------
   10. Modales
   ----------------------------------------------------- */
/* Ya no hay modales flotantes: .modal-overlay es un panel en línea dentro de la
   página. crm-ui.js lo mueve al inicio de .page-content y lo muestra con .open. */
.modal-overlay {
  display: none;
  margin-bottom: 20px;
}

.modal-overlay.open {
  display: block;
}

.modal-content,
.modal {
  background-color: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  padding: 24px;
  position: relative;
}

.modal-overlay .modal,
.modal-overlay .modal-content {
  width: 100% !important;
  max-width: none !important;
  background-color: var(--surface-2) !important;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
}

.modal-head h2,
.modal-head h3 {
  margin: 0;
}

.modal-close {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  color: var(--muted-foreground);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s, background-color 0.15s;
}

.modal-close:hover {
  color: var(--foreground);
  background-color: var(--surface);
}

/* Paneles en línea: formularios que se abren dentro de la página (sin overlay) */
.inline-panel {
  display: none;
}

.inline-panel.open {
  display: block;
}

.inline-panel .panel-card {
  background-color: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  padding: 22px;
}

.inline-panel .modal-head {
  margin-bottom: 16px;
}

/* -----------------------------------------------------
   11. Estados vacíos
   ----------------------------------------------------- */
.empty {
  position: relative;
  border: 2px dashed var(--dashed);
  border-radius: var(--radius-card);
  padding: 64px 32px;
  text-align: center;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.empty-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.5rem;
  margin: 16px 0 8px 0;
  color: var(--foreground);
}

.empty-sub {
  font-family: var(--font-narrow);
  font-size: 1rem;
  color: var(--muted-foreground);
  max-width: 440px;
  margin-bottom: 24px;
}

/* -----------------------------------------------------
   12. Layouts y Utilidades
   ----------------------------------------------------- */
.container {
  width: 100%;
  max-width: 1536px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 24px;
  padding-right: 24px;
}

@media (min-width: 768px) {
  .container {
    padding-left: 48px;
    padding-right: 48px;
  }
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 24px;
}

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

@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .grid-4, .grid-3, .grid-2 {
    grid-template-columns: 1fr;
  }
}

.span-2 {
  grid-column: span 2 / span 2;
}

@media (max-width: 640px) {
  .span-2 {
    grid-column: span 1 / span 1;
  }
}

.row {
  display: flex;
  align-items: center;
}

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

.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }
.gap-8 { gap: 32px; }

.stack-xs { display: flex; flex-direction: column; gap: 4px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.stack-md { display: flex; flex-direction: column; gap: 16px; }
.stack-lg { display: flex; flex-direction: column; gap: 24px; }

.text-brand { color: var(--brand) !important; }
.text-brand-ink { color: var(--brand-ink) !important; }
.text-muted { color: var(--muted-foreground) !important; }
.text-danger { color: var(--destructive) !important; }

/* Arc background container */
.arc-wrap {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

/* Subnav horizontal scroll on mobile without dragging page */
.subnav-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  flex-wrap: nowrap;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.subnav-scroll::-webkit-scrollbar {
  display: none;
}
.subnav-scroll > * {
  flex-shrink: 0;
}

/* -----------------------------------------------------
   13. Responsive Utilities del CRM
   ----------------------------------------------------- */
@media (max-width: 900px) {
  /* 2-column detail & compose layouts become 1-column */
  [style*="grid-template-columns:360px 1fr"],
  [style*="grid-template-columns: 360px 1fr"],
  [style*="grid-template-columns:320px 1fr"],
  [style*="grid-template-columns: 320px 1fr"],
  [style*="grid-template-columns:1fr 400px"],
  [style*="grid-template-columns: 1fr 400px"],
  [style*="grid-template-columns:1fr 340px"],
  [style*="grid-template-columns: 1fr 340px"] {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 768px) {
  /* Form 2-columns collapse on mobile */
  [style*="grid-template-columns:1fr 1fr"],
  [style*="grid-template-columns: 1fr 1fr"],
  [style*="grid-template-columns:2fr 1fr"],
  [style*="grid-template-columns: 2fr 1fr"],
  [style*="grid-template-columns:1.8fr 1.2fr 1.6fr"],
  [style*="grid-template-columns: 1.8fr 1.2fr 1.6fr"],
  [style*="grid-template-columns:1.2fr 1.2fr 1.2fr"],
  [style*="grid-template-columns: 1.2fr 1.2fr 1.2fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Multi-column metric strips become 2-columns */
  [style*="grid-template-columns:repeat(4,1fr)"],
  [style*="grid-template-columns:repeat(4, 1fr)"],
  [style*="grid-template-columns: repeat(4, 1fr)"],
  [style*="grid-template-columns:repeat(5,1fr)"],
  [style*="grid-template-columns:repeat(5, 1fr)"],
  [style*="grid-template-columns: repeat(5, 1fr)"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .card-dashed, .card-bare, .card-solid {
    max-width: 100%;
    word-break: break-word;
  }
}

@media (max-width: 640px) {
  .table-wrap {
    margin: 0 -12px;
    padding: 0 12px;
  }
  .filters-bar,
  .filters-group {
    width: 100%;
  }
  .filters-group > input,
  .filters-group > select {
    width: 100% !important;
  }
}

@media (max-width: 480px) {
  [style*="grid-template-columns:repeat(4,1fr)"],
  [style*="grid-template-columns:repeat(4, 1fr)"],
  [style*="grid-template-columns: repeat(4, 1fr)"],
  [style*="grid-template-columns:repeat(5,1fr)"],
  [style*="grid-template-columns:repeat(5, 1fr)"],
  [style*="grid-template-columns: repeat(5, 1fr)"],
  [style*="grid-template-columns:repeat(2,1fr)"],
  [style*="grid-template-columns:repeat(2, 1fr)"],
  [style*="grid-template-columns: repeat(2, 1fr)"] {
    grid-template-columns: 1fr !important;
  }
}
