/* css/core.css — design tokens + shell + shared components for Mapa de Tiendas.
 *
 * Direction: quiet, precise "analyst's workbench". Neutral zinc greys carry the UI; the crimson of
 * the slide's legend panel is the only accent (primary actions, active states, focus). Type:
 * Instrument Sans (UI) + Bricolage Grotesque (brand/display); both inlined in vendor/fonts/fonts.css.
 * Module stylesheets (maps.css, maps-ui.css, db.css) reuse these tokens and components — see
 * docs/styleguide.html for a live catalogue.
 */

/* ============================== Tokens ============================== */
:root {
  /* Accent (slide crimson) */
  --mt-accent: #C62842;
  --mt-accent-hover: #AE2139;
  --mt-accent-press: #8E1631;
  --mt-accent-soft: #FBECEF;
  --mt-accent-soft-2: #F6D5DC;
  --mt-accent-ring: rgba(212, 42, 76, 0.28);
  --mt-accent-gradient: linear-gradient(160deg, #D42A4C 0%, #8E1631 100%);
  --mt-navy: #1F3864;

  /* Neutrals (zinc) */
  --mt-g0: #FFFFFF;
  --mt-g25: #FCFCFC;
  --mt-g50: #FAFAFA;
  --mt-g100: #F4F4F5;
  --mt-g150: #EDEDEF;
  --mt-g200: #E4E4E7;
  --mt-g300: #D4D4D8;
  --mt-g400: #A1A1AA;
  --mt-g500: #71717A;
  --mt-g600: #52525B;
  --mt-g700: #3F3F46;
  --mt-g800: #27272A;
  --mt-g900: #18181B;

  /* Semantic */
  --mt-bg: var(--mt-g100);
  --mt-surface: var(--mt-g0);
  --mt-surface-2: var(--mt-g50);
  --mt-border: var(--mt-g200);
  --mt-border-strong: var(--mt-g300);
  --mt-text: var(--mt-g900);
  --mt-text-2: var(--mt-g600);
  --mt-text-3: var(--mt-g500);
  --mt-success: #15803D; --mt-success-soft: #EAF6EE;
  --mt-warn: #B45309;    --mt-warn-soft: #FDF4E7;
  --mt-danger: #B91C1C;  --mt-danger-soft: #FCEDED;
  --mt-info: #1D4ED8;    --mt-info-soft: #EDF2FD;

  /* Type */
  --mt-font: 'Instrument Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --mt-font-display: 'Bricolage Grotesque', 'Instrument Sans', 'Segoe UI', sans-serif;
  --mt-font-slide: Calibri, Carlito, 'Segoe UI', Arial, sans-serif;
  --mt-font-mono: 'Cascadia Mono', Consolas, 'SFMono-Regular', Menlo, monospace;
  --mt-fs-xs: 11.5px;
  --mt-fs-sm: 12.5px;
  --mt-fs: 14px;
  --mt-fs-md: 15px;
  --mt-fs-lg: 17px;
  --mt-fs-xl: 21px;
  --mt-lh: 1.45;

  /* Space, radius, elevation, motion */
  --mt-s1: 4px; --mt-s2: 8px; --mt-s3: 12px; --mt-s4: 16px; --mt-s5: 20px; --mt-s6: 24px; --mt-s8: 32px; --mt-s10: 40px;
  --mt-r-xs: 4px; --mt-r-sm: 6px; --mt-r: 8px; --mt-r-lg: 12px; --mt-r-xl: 16px; --mt-r-pill: 999px;
  --mt-shadow-xs: 0 1px 1px rgba(24, 24, 27, 0.05);
  --mt-shadow-sm: 0 1px 2px rgba(24, 24, 27, 0.06), 0 1px 1px rgba(24, 24, 27, 0.04);
  --mt-shadow: 0 4px 12px -2px rgba(24, 24, 27, 0.10), 0 2px 4px -2px rgba(24, 24, 27, 0.06);
  --mt-shadow-lg: 0 18px 40px -12px rgba(24, 24, 27, 0.28), 0 6px 14px -6px rgba(24, 24, 27, 0.12);
  --mt-ease: cubic-bezier(.2, .7, .2, 1);
  --mt-fast: 120ms;
  --mt-med: 200ms;

  /* Layout */
  --mt-topbar-h: 58px;
  --mt-sidebar-w: 340px;
  --mt-control-h: 36px;
  --mt-control-h-sm: 30px;
}

/* ============================== Base ============================== */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--mt-font);
  font-size: var(--mt-fs);
  line-height: var(--mt-lh);
  color: var(--mt-text);
  background: var(--mt-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'ss01', 'cv11';
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img, svg, canvas { display: block; }
a { color: var(--mt-accent); text-underline-offset: 2px; }
code, kbd, pre { font-family: var(--mt-font-mono); font-size: 0.92em; }
::selection { background: var(--mt-accent-soft-2); color: var(--mt-g900); }
:focus-visible { outline: 2px solid var(--mt-accent); outline-offset: 2px; border-radius: var(--mt-r-xs); }
* { scrollbar-width: thin; scrollbar-color: var(--mt-g300) transparent; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0 0 var(--mt-s3); }
.mt-sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mt-muted { color: var(--mt-text-3); }
.mt-small { font-size: var(--mt-fs-sm); }
.mt-mono { font-family: var(--mt-font-mono); font-size: var(--mt-fs-sm); }
.mt-nowrap { white-space: nowrap; }
.mt-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.mt-icon { display: inline-flex; align-items: center; justify-content: center; flex: none; }
.mt-svg { flex: none; }

/* ============================== Splash ============================== */
.mt-splash {
  position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center;
  background: var(--mt-bg); transition: opacity 260ms var(--mt-ease);
}
.mt-splash.is-gone { opacity: 0; pointer-events: none; }
.mt-splash__box { display: grid; justify-items: center; gap: var(--mt-s3); max-width: 640px; padding: var(--mt-s6); text-align: center; }
.mt-splash__mark { width: 52px; height: 52px; border-radius: 14px; background: var(--mt-accent-gradient); box-shadow: var(--mt-shadow); position: relative; overflow: hidden; }
.mt-splash__mark::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(255,255,255,.35) 50%, transparent 80%);
  transform: translateX(-100%); animation: mt-sheen 1.3s var(--mt-ease) infinite;
}
.mt-splash__title { font-family: var(--mt-font-display); font-size: var(--mt-fs-lg); font-weight: 600; color: var(--mt-g700); }
.mt-splash__detail { text-align: left; white-space: pre-wrap; font-size: var(--mt-fs-xs); color: var(--mt-g600); background: var(--mt-surface); border: 1px solid var(--mt-border); border-radius: var(--mt-r); padding: var(--mt-s3); max-height: 40vh; overflow: auto; }
.mt-splash.is-error .mt-splash__title { color: var(--mt-danger); }
@keyframes mt-sheen { to { transform: translateX(100%); } }

/* ============================== Shell ============================== */
#mt-app { height: 100%; display: grid; grid-template-rows: auto auto minmax(0, 1fr); }
.mt-topbar {
  position: relative; z-index: 20;
  height: var(--mt-topbar-h);
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: var(--mt-s6);
  padding: 0 var(--mt-s4) 0 var(--mt-s5);
  background: var(--mt-surface);
  border-bottom: 1px solid var(--mt-border);
}
/* Signature detail: a hairline of the slide gradient along the very top. */
.mt-topbar::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: linear-gradient(90deg, #D42A4C, #8E1631 60%, #D42A4C); }
.mt-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mt-brand__mark svg { width: 30px; height: 30px; filter: drop-shadow(0 1px 1px rgba(142, 22, 49, .25)); }
.mt-brand__name { font-family: var(--mt-font-display); font-size: 18px; font-weight: 650; letter-spacing: -0.02em; white-space: nowrap; color: var(--mt-g900); }

.mt-tabs { display: flex; align-items: stretch; gap: 2px; height: 100%; justify-self: start; }
.mt-tab {
  position: relative; display: inline-flex; align-items: center; gap: 8px;
  padding: 0 14px; border: 0; background: none; color: var(--mt-text-2);
  font-weight: 550; font-size: var(--mt-fs); letter-spacing: -0.005em;
  transition: color var(--mt-fast) var(--mt-ease);
}
.mt-tab .mt-icon { color: var(--mt-g400); transition: color var(--mt-fast) var(--mt-ease); }
.mt-tab::after {
  content: ''; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px 2px 0 0;
  background: var(--mt-accent); transform: scaleX(0); transition: transform var(--mt-med) var(--mt-ease);
}
.mt-tab:hover { color: var(--mt-g900); }
.mt-tab:hover .mt-icon { color: var(--mt-g600); }
.mt-tab.is-active { color: var(--mt-g900); }
.mt-tab.is-active .mt-icon { color: var(--mt-accent); }
.mt-tab.is-active::after { transform: scaleX(1); }
.mt-tab:focus-visible { outline-offset: -6px; }

.mt-topbar__right { display: flex; align-items: center; gap: var(--mt-s3); min-width: 0; }
.mt-project { display: flex; align-items: center; gap: 2px; min-width: 0; padding-left: var(--mt-s3); border-left: 1px solid var(--mt-border); }
.mt-project__icon { color: var(--mt-g400); margin-right: 4px; }
.mt-project__name {
  max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border: 0; background: none; padding: 6px 8px; border-radius: var(--mt-r-sm);
  font-weight: 600; color: var(--mt-g800);
}
.mt-project__name:hover { background: var(--mt-g100); }
.mt-project__dirty { width: 7px; height: 7px; border-radius: 50%; background: var(--mt-accent); margin: 0 4px 0 -2px; box-shadow: 0 0 0 3px var(--mt-accent-soft); }
.mt-changes {
  display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 11px;
  border: 1px solid #F1D3A8; background: var(--mt-warn-soft); color: #8A4108; border-radius: var(--mt-r-pill);
  font-size: var(--mt-fs-sm); font-weight: 600; white-space: nowrap;
}
.mt-changes:hover { border-color: #E5B577; }
.mt-changes__dot { width: 6px; height: 6px; border-radius: 50%; background: #D97706; }

.mt-banners { display: grid; }
.mt-banner {
  display: flex; align-items: flex-start; gap: var(--mt-s3); padding: 10px var(--mt-s5);
  border-bottom: 1px solid var(--mt-border); font-size: var(--mt-fs-sm); line-height: 1.5;
}
.mt-banner > .mt-icon { margin-top: 1px; }
.mt-banner__body { flex: 1; min-width: 0; }
.mt-banner__files { display: inline-flex; flex-wrap: wrap; gap: 4px; vertical-align: baseline; }
.mt-banner__files code { background: rgba(255,255,255,.7); border: 1px solid rgba(0,0,0,.08); padding: 0 5px; border-radius: 4px; font-size: 11.5px; }
.mt-banner__hint { color: inherit; opacity: .8; margin-top: 2px; }
.mt-banner--warn { background: var(--mt-warn-soft); color: #7C3A06; }
.mt-banner--warn > .mt-icon { color: var(--mt-warn); }
.mt-banner--info { background: var(--mt-info-soft); color: #1E3A8A; }
.mt-banner--info > .mt-icon { color: var(--mt-info); }
.mt-banner--error { background: var(--mt-danger-soft); color: #7F1D1D; }
.mt-banner--error > .mt-icon { color: var(--mt-danger); }
.mt-banner__actions { display: flex; flex-wrap: wrap; gap: var(--mt-s2); margin-top: var(--mt-s2); }
/* "Hay una versión nueva de la herramienta" (MT.app.checkVersion): text and «Recargar» on one line. */
.mt-banner__body--row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px var(--mt-s3); }
.mt-banner--update { align-items: center; }
/* Unnamed project: the name button shows the placeholder in the current language, muted. */
.mt-project__name.is-placeholder, .mt-maps-proj__name.is-placeholder { color: var(--mt-text-3); font-style: italic; }

.mt-main { position: relative; min-height: 0; overflow: hidden; }
.mt-tabpanel { position: absolute; inset: 0; overflow: auto; }
body.is-ready .mt-tabpanel:not([hidden]) { animation: mt-fade-in 220ms var(--mt-ease); }
@keyframes mt-fade-in { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* ============================== Layout helpers ============================== */
/* Sidebar + content split used by the Mapas and Base de datos tabs. */
.mt-split { display: grid; grid-template-columns: var(--mt-sidebar-w) minmax(0, 1fr); height: 100%; min-height: 0; }
.mt-split--right { grid-template-columns: minmax(0, 1fr) var(--mt-sidebar-w); }
.mt-sidebar { background: var(--mt-surface); border-right: 1px solid var(--mt-border); overflow: auto; min-height: 0; }
.mt-split--right .mt-sidebar { border-right: 0; border-left: 1px solid var(--mt-border); }
.mt-content { min-width: 0; min-height: 0; overflow: auto; padding: var(--mt-s5); }
.mt-stack { display: flex; flex-direction: column; gap: var(--mt-s3); }
.mt-stack--sm { gap: var(--mt-s2); }
.mt-stack--lg { gap: var(--mt-s5); }
.mt-row { display: flex; align-items: center; gap: var(--mt-s2); min-width: 0; }
.mt-row--wrap { flex-wrap: wrap; }
.mt-row--between { justify-content: space-between; }
.mt-spacer { flex: 1; }
.mt-divider { height: 1px; background: var(--mt-border); border: 0; margin: var(--mt-s3) 0; }

.mt-panel { background: var(--mt-surface); border: 1px solid var(--mt-border); border-radius: var(--mt-r-lg); box-shadow: var(--mt-shadow-xs); }
.mt-panel__header { display: flex; align-items: center; gap: var(--mt-s2); padding: var(--mt-s3) var(--mt-s4); border-bottom: 1px solid var(--mt-border); }
.mt-panel__title { font-size: var(--mt-fs-md); font-weight: 650; }
.mt-panel__body { padding: var(--mt-s4); }
.mt-card { background: var(--mt-surface); border: 1px solid var(--mt-border); border-radius: var(--mt-r); padding: var(--mt-s3); box-shadow: var(--mt-shadow-xs); }
/* Collapsible settings section inside a sidebar. */
.mt-section { padding: var(--mt-s4) var(--mt-s4) var(--mt-s4); border-bottom: 1px solid var(--mt-g150); }
.mt-section:last-child { border-bottom: 0; }
.mt-section-title {
  display: flex; align-items: center; gap: var(--mt-s2); margin: 0 0 var(--mt-s3);
  font-size: var(--mt-fs-xs); font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--mt-g500);
}
.mt-section-title .mt-count { margin-left: auto; text-transform: none; letter-spacing: 0; }
.mt-toolbar {
  display: flex; align-items: center; gap: var(--mt-s2); flex-wrap: wrap;
  padding: var(--mt-s2) var(--mt-s3); background: var(--mt-surface); border-bottom: 1px solid var(--mt-border);
}
.mt-toolbar__group { display: flex; align-items: center; gap: var(--mt-s1); }
.mt-toolbar__sep { width: 1px; align-self: stretch; margin: 4px var(--mt-s1); background: var(--mt-border); }
.mt-count { font-size: var(--mt-fs-xs); font-weight: 600; color: var(--mt-g500); font-variant-numeric: tabular-nums; }

/* ============================== Buttons ============================== */
.mt-btn {
  --_h: var(--mt-control-h);
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: var(--_h); padding: 0 14px; border-radius: var(--mt-r);
  border: 1px solid transparent; background: none;
  font-weight: 600; font-size: var(--mt-fs); letter-spacing: -0.005em; white-space: nowrap;
  transition: background var(--mt-fast) var(--mt-ease), border-color var(--mt-fast) var(--mt-ease), color var(--mt-fast) var(--mt-ease), box-shadow var(--mt-fast) var(--mt-ease), transform 60ms;
  user-select: none;
}
.mt-btn:active:not(:disabled) { transform: translateY(0.5px); }
.mt-btn:disabled { opacity: .45; cursor: not-allowed; }
.mt-btn--primary { background: var(--mt-accent); color: #fff; box-shadow: 0 1px 2px rgba(142, 22, 49, .25), inset 0 1px 0 rgba(255,255,255,.12); }
.mt-btn--primary:hover:not(:disabled) { background: var(--mt-accent-hover); }
.mt-btn--primary:active:not(:disabled) { background: var(--mt-accent-press); }
.mt-btn--secondary { background: var(--mt-surface); border-color: var(--mt-border-strong); color: var(--mt-g800); box-shadow: var(--mt-shadow-xs); }
.mt-btn--secondary:hover:not(:disabled) { background: var(--mt-g50); border-color: var(--mt-g400); }
.mt-btn--ghost { color: var(--mt-g700); }
.mt-btn--ghost:hover:not(:disabled) { background: var(--mt-g100); color: var(--mt-g900); }
.mt-btn--danger { background: var(--mt-danger); color: #fff; }
.mt-btn--danger:hover:not(:disabled) { background: #991B1B; }
.mt-btn--soft { background: var(--mt-accent-soft); color: var(--mt-accent-press); }
.mt-btn--soft:hover:not(:disabled) { background: var(--mt-accent-soft-2); }
.mt-btn--sm { --_h: var(--mt-control-h-sm); padding: 0 10px; font-size: var(--mt-fs-sm); border-radius: var(--mt-r-sm); gap: 6px; }
.mt-btn--icon { width: var(--_h); padding: 0; }
.mt-btn--block { width: 100%; }
.mt-btn .mt-icon { margin-left: -2px; }
.mt-btn--icon .mt-icon { margin: 0; }
.mt-btn-group { display: inline-flex; }
.mt-btn-group > .mt-btn { border-radius: 0; }
.mt-btn-group > .mt-btn:first-child { border-radius: var(--mt-r) 0 0 var(--mt-r); }
.mt-btn-group > .mt-btn:last-child { border-radius: 0 var(--mt-r) var(--mt-r) 0; }
.mt-btn-group > .mt-btn + .mt-btn { margin-left: -1px; }

/* ============================== Forms ============================== */
.mt-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.mt-field--inline { flex-direction: row; align-items: center; justify-content: space-between; gap: var(--mt-s3); }
.mt-label { font-size: var(--mt-fs-sm); font-weight: 600; color: var(--mt-g700); }
.mt-label small, .mt-hint { font-weight: 400; color: var(--mt-text-3); font-size: var(--mt-fs-xs); }
.mt-field__error { min-height: 0; font-size: var(--mt-fs-xs); color: var(--mt-danger); }
.mt-field__error:empty { display: none; }
.mt-input, .mt-select, .mt-textarea {
  width: 100%; height: var(--mt-control-h); padding: 0 11px;
  background: var(--mt-surface); border: 1px solid var(--mt-border-strong); border-radius: var(--mt-r);
  color: var(--mt-text); box-shadow: var(--mt-shadow-xs) inset;
  transition: border-color var(--mt-fast) var(--mt-ease), box-shadow var(--mt-fast) var(--mt-ease);
}
.mt-textarea { height: auto; min-height: 76px; padding: 8px 11px; resize: vertical; line-height: 1.45; }
.mt-input::placeholder, .mt-textarea::placeholder { color: var(--mt-g400); }
.mt-input:hover, .mt-select:hover, .mt-textarea:hover { border-color: var(--mt-g400); }
.mt-input:focus, .mt-select:focus, .mt-textarea:focus { outline: none; border-color: var(--mt-accent); box-shadow: 0 0 0 3px var(--mt-accent-ring); }
.mt-input.is-invalid { border-color: var(--mt-danger); box-shadow: 0 0 0 3px rgba(185, 28, 28, .15); }
.mt-input--sm, .mt-select--sm { height: var(--mt-control-h-sm); font-size: var(--mt-fs-sm); border-radius: var(--mt-r-sm); }
.mt-input--num { font-variant-numeric: tabular-nums; }
.mt-select {
  appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2371717A' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
}
/* Input with a leading icon / trailing button: <div class="mt-input-group"><span class="mt-icon">…</span><input class="mt-input">…</div> */
.mt-input-group { position: relative; display: flex; align-items: center; }
.mt-input-group > .mt-icon { position: absolute; left: 10px; color: var(--mt-g400); pointer-events: none; }
.mt-input-group > .mt-icon + .mt-input { padding-left: 34px; }
.mt-input-group > .mt-btn { position: absolute; right: 3px; height: calc(var(--mt-control-h) - 6px); }
.mt-input-group > .mt-input:has(+ .mt-btn) { padding-right: 40px; }

/* Checkbox */
.mt-check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.mt-check input { width: 16px; height: 16px; margin: 0; accent-color: var(--mt-accent); cursor: pointer; }

/* Switch: <label class="mt-switch"><input type="checkbox" role="switch"><span class="mt-switch__track"></span><span class="mt-switch__label">…</span></label> */
.mt-switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; min-width: 0; }
.mt-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.mt-switch__track {
  position: relative; flex: none; width: 34px; height: 20px; border-radius: 999px; background: var(--mt-g300);
  transition: background var(--mt-med) var(--mt-ease);
}
.mt-switch__track::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform var(--mt-med) var(--mt-ease);
}
.mt-switch input:checked + .mt-switch__track { background: var(--mt-accent); }
.mt-switch input:checked + .mt-switch__track::after { transform: translateX(14px); }
.mt-switch input:focus-visible + .mt-switch__track { box-shadow: 0 0 0 3px var(--mt-accent-ring); }
.mt-switch input:disabled + .mt-switch__track { opacity: .5; }
.mt-switch__label { font-size: var(--mt-fs); color: var(--mt-g800); }

/* Segmented control (radio group) */
.mt-seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--mt-g100); border: 1px solid var(--mt-border); border-radius: var(--mt-r); }
.mt-seg__opt { position: relative; display: inline-flex; }
.mt-seg__input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.mt-seg__face {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 11px; border-radius: 6px;
  font-size: var(--mt-fs-sm); font-weight: 600; color: var(--mt-g600); cursor: pointer; white-space: nowrap;
  transition: background var(--mt-fast) var(--mt-ease), color var(--mt-fast) var(--mt-ease), box-shadow var(--mt-fast) var(--mt-ease);
}
.mt-seg__face:hover { color: var(--mt-g900); }
.mt-seg__input:checked + .mt-seg__face { background: var(--mt-surface); color: var(--mt-g900); box-shadow: var(--mt-shadow-sm); }
.mt-seg__input:focus-visible + .mt-seg__face { box-shadow: 0 0 0 2px var(--mt-accent); }
.mt-seg--compact .mt-seg__face { height: 24px; padding: 0 9px; font-size: 12px; letter-spacing: .02em; }
.mt-seg--block { display: flex; }
.mt-seg--block .mt-seg__opt { flex: 1; }
.mt-seg--block .mt-seg__face { width: 100%; justify-content: center; }

/* Range slider */
.mt-range { width: 100%; accent-color: var(--mt-accent); }

/* ============================== Chips & badges ============================== */
.mt-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.mt-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 6px 0 11px; max-width: 100%;
  background: var(--mt-g100); border: 1px solid var(--mt-border); border-radius: var(--mt-r-pill);
  font-size: var(--mt-fs-sm); font-weight: 550; color: var(--mt-g800);
}
.mt-chip__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-chip__sub { color: var(--mt-g500); font-weight: 400; }
.mt-chip__x {
  display: inline-grid; place-items: center; width: 20px; height: 20px; border: 0; border-radius: 50%;
  background: none; color: var(--mt-g500); padding: 0;
}
.mt-chip__x:hover { background: var(--mt-g200); color: var(--mt-g900); }
.mt-chip--accent { background: var(--mt-accent-soft); border-color: var(--mt-accent-soft-2); color: var(--mt-accent-press); }
.mt-chip--plain { padding-right: 11px; }

.mt-badge {
  display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: var(--mt-r-xs);
  font-size: 11px; font-weight: 650; letter-spacing: .02em; white-space: nowrap;
  background: var(--mt-g100); color: var(--mt-g700);
}
.mt-badge--success { background: var(--mt-success-soft); color: var(--mt-success); }
.mt-badge--warn { background: var(--mt-warn-soft); color: var(--mt-warn); }
.mt-badge--danger { background: var(--mt-danger-soft); color: var(--mt-danger); }
.mt-badge--info { background: var(--mt-info-soft); color: var(--mt-info); }
.mt-badge--accent { background: var(--mt-accent-soft); color: var(--mt-accent-press); }
.mt-badge--dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* Chain logo chip (MT.ui.chainChip) */
.mt-chain-chip { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.mt-chain-chip__logo { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--mt-g300); background: #fff; object-fit: cover; flex: none; }
.mt-chain-chip.is-compact .mt-chain-chip__logo { width: 20px; height: 20px; border-width: 1.5px; }
.mt-chain-chip__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.mt-swatch { width: 14px; height: 14px; border-radius: 4px; border: 1px solid rgba(0,0,0,.12); flex: none; }

/* ============================== Lists ============================== */
.mt-list { display: flex; flex-direction: column; gap: 2px; margin: 0; padding: 0; list-style: none; }
.mt-list__item {
  position: relative; display: flex; align-items: center; gap: var(--mt-s2); min-height: 40px; padding: 6px 8px 6px 10px;
  border-radius: var(--mt-r); color: var(--mt-g800); cursor: pointer; border: 1px solid transparent;
  transition: background var(--mt-fast) var(--mt-ease), border-color var(--mt-fast) var(--mt-ease);
}
.mt-list__item:hover { background: var(--mt-g100); }
.mt-list__item.is-active { background: var(--mt-accent-soft); border-color: var(--mt-accent-soft-2); color: var(--mt-g900); }
.mt-list__item.is-active::before { content: ''; position: absolute; left: -1px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--mt-accent); }
.mt-list__index { flex: none; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 6px; background: var(--mt-g150); font-size: 11.5px; font-weight: 700; color: var(--mt-g600); font-variant-numeric: tabular-nums; }
.mt-list__item.is-active .mt-list__index { background: var(--mt-accent); color: #fff; }
.mt-list__main { flex: 1; min-width: 0; }
.mt-list__title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-list__sub { font-size: var(--mt-fs-xs); color: var(--mt-g500); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-list__actions { display: flex; gap: 2px; opacity: 0; transition: opacity var(--mt-fast); }
.mt-list__item:hover .mt-list__actions, .mt-list__item:focus-within .mt-list__actions, .mt-list__item.is-active .mt-list__actions { opacity: 1; }
.mt-grip { color: var(--mt-g400); cursor: grab; }
.mt-list__item.is-dragging { opacity: .5; }
.mt-list__item.is-drop-target { box-shadow: 0 -2px 0 var(--mt-accent) inset; }

/* ============================== Tables ============================== */
.mt-table-wrap { overflow: auto; min-height: 0; background: var(--mt-surface); }
.mt-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--mt-fs-sm); font-variant-numeric: tabular-nums; }
.mt-table th, .mt-table td { padding: 0 12px; height: 38px; text-align: left; border-bottom: 1px solid var(--mt-g150); white-space: nowrap; }
.mt-table th {
  position: sticky; top: 0; z-index: 1; height: 36px; background: var(--mt-g50);
  font-size: var(--mt-fs-xs); font-weight: 650; color: var(--mt-g600); letter-spacing: .02em; text-transform: uppercase;
  border-bottom: 1px solid var(--mt-border);
}
.mt-table th.is-sortable { cursor: pointer; user-select: none; }
.mt-table th.is-sortable:hover { color: var(--mt-g900); }
.mt-table th[aria-sort='ascending']::after { content: ' ↑'; color: var(--mt-accent); }
.mt-table th[aria-sort='descending']::after { content: ' ↓'; color: var(--mt-accent); }
.mt-table tbody tr { transition: background var(--mt-fast); }
.mt-table tbody tr:hover { background: var(--mt-g50); }
.mt-table tbody tr.is-selected { background: var(--mt-accent-soft); }
.mt-table tbody tr.is-muted td { color: var(--mt-g400); }
.mt-table td.is-num, .mt-table th.is-num { text-align: right; }
/* A distance inside an upper-case label keeps its case: "HASTA 500 m" ("500 M" reads as 500 mil in Peru),
   and never breaks between the number and its unit ("1" / "km" on two lines). */
.mt-unit { text-transform: none; letter-spacing: 0; white-space: nowrap; }
.mt-table td.is-wrap { white-space: normal; }
.mt-table .mt-truncate { display: block; max-width: 320px; }

/* ============================== Drawer ============================== */
.mt-drawer {
  position: absolute; top: 0; right: 0; bottom: 0; z-index: 30; width: min(440px, 92vw);
  display: flex; flex-direction: column; background: var(--mt-surface); border-left: 1px solid var(--mt-border);
  box-shadow: var(--mt-shadow-lg); transform: translateX(105%); transition: transform 240ms var(--mt-ease);
}
.mt-drawer.is-open { transform: none; }
.mt-drawer__header { display: flex; align-items: center; gap: var(--mt-s2); padding: var(--mt-s3) var(--mt-s4); border-bottom: 1px solid var(--mt-border); }
.mt-drawer__title { flex: 1; font-size: var(--mt-fs-md); font-weight: 650; }
.mt-drawer__body { flex: 1; overflow: auto; padding: var(--mt-s4); }
.mt-drawer__footer { display: flex; justify-content: flex-end; gap: var(--mt-s2); padding: var(--mt-s3) var(--mt-s4); border-top: 1px solid var(--mt-border); background: var(--mt-g50); }

/* ============================== Modal ============================== */
.mt-modal-backdrop {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: var(--mt-s6);
  background: rgba(24, 24, 27, 0.42); backdrop-filter: blur(2px);
  opacity: 0; transition: opacity 160ms var(--mt-ease);
}
.mt-modal-backdrop.is-open { opacity: 1; }
.mt-modal {
  width: 100%; max-height: calc(100vh - 48px); display: flex; flex-direction: column;
  background: var(--mt-surface); border-radius: var(--mt-r-lg); box-shadow: var(--mt-shadow-lg);
  transform: translateY(8px) scale(.985); transition: transform 200ms var(--mt-ease);
}
.mt-modal-backdrop.is-open .mt-modal { transform: none; }
.mt-modal:focus { outline: none; }
.mt-modal--sm { max-width: 420px; }
.mt-modal--md { max-width: 560px; }
.mt-modal--lg { max-width: 820px; }
.mt-modal--xl { max-width: 1120px; }
.mt-modal__header { display: flex; align-items: center; gap: var(--mt-s2); padding: var(--mt-s4) var(--mt-s4) var(--mt-s2) var(--mt-s5); }
.mt-modal__title { flex: 1; font-family: var(--mt-font-display); font-size: var(--mt-fs-lg); font-weight: 650; letter-spacing: -0.015em; }
.mt-modal__x { margin-right: -6px; }
.mt-modal__body { padding: var(--mt-s2) var(--mt-s5) var(--mt-s5); overflow: auto; }
.mt-modal__text { color: var(--mt-g700); margin: 0; }
.mt-modal__footer { display: flex; justify-content: flex-end; gap: var(--mt-s2); padding: var(--mt-s3) var(--mt-s5); border-top: 1px solid var(--mt-border); background: var(--mt-g50); border-radius: 0 0 var(--mt-r-lg) var(--mt-r-lg); }
body.mt-has-modal { overflow: hidden; }

/* ============================== Menu ============================== */
.mt-menu {
  position: fixed; z-index: 300; min-width: 200px; max-width: 340px; padding: 5px;
  background: var(--mt-surface); border: 1px solid var(--mt-border); border-radius: var(--mt-r);
  box-shadow: var(--mt-shadow-lg); opacity: 0; transform: translateY(-4px); transition: opacity 120ms, transform 160ms var(--mt-ease);
}
.mt-menu.is-open { opacity: 1; transform: none; }
.mt-menu__item {
  display: flex; align-items: center; gap: 9px; width: 100%; min-height: 34px; padding: 5px 9px 5px 7px;
  border: 0; border-radius: var(--mt-r-sm); background: none; text-align: left; color: var(--mt-g800); font-size: var(--mt-fs);
}
.mt-menu__item:hover:not(:disabled), .mt-menu__item:focus { background: var(--mt-g100); outline: none; }
.mt-menu__item:focus-visible { box-shadow: inset 0 0 0 2px var(--mt-accent); }
.mt-menu__item:disabled { opacity: .45; cursor: not-allowed; }
.mt-menu__item.is-danger { color: var(--mt-danger); }
.mt-menu__icon { width: 18px; display: grid; place-items: center; color: var(--mt-g500); flex: none; }
.mt-menu__item.is-danger .mt-menu__icon { color: var(--mt-danger); }
.mt-menu__label { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mt-menu__hint { color: var(--mt-g500); font-size: var(--mt-fs-xs); }
.mt-menu__kbd { font-family: var(--mt-font); font-size: 11px; color: var(--mt-g500); background: var(--mt-g100); border: 1px solid var(--mt-border); border-radius: 4px; padding: 1px 5px; }
.mt-menu__sep { height: 1px; margin: 5px 4px; background: var(--mt-border); }
.mt-menu__heading { padding: 6px 9px 3px; font-size: var(--mt-fs-xs); font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--mt-g500); }

/* ============================== Toasts ============================== */
.mt-toasts { position: fixed; z-index: 400; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; width: min(560px, calc(100vw - 32px)); }
.mt-toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; max-width: 100%; padding: 9px 8px 9px 13px;
  background: var(--mt-g900); color: #F4F4F5; border-radius: 10px; box-shadow: var(--mt-shadow-lg);
  font-size: var(--mt-fs); animation: mt-toast-in 220ms var(--mt-ease);
}
.mt-toast.is-leaving { opacity: 0; transform: translateY(6px); transition: opacity 160ms, transform 160ms; }
.mt-toast > .mt-icon { color: #A1A1AA; }
.mt-toast--success > .mt-icon { color: #4ADE80; }
.mt-toast--warn > .mt-icon { color: #FBBF24; }
.mt-toast--error > .mt-icon { color: #F87171; }
.mt-toast--info > .mt-icon { color: #93C5FD; }
.mt-toast__msg { flex: 1; min-width: 0; line-height: 1.4; }
.mt-toast__action { border: 0; background: none; color: #FCA5B5; font-weight: 650; padding: 4px 8px; border-radius: 6px; }
.mt-toast__action:hover { background: rgba(255,255,255,.08); }
.mt-toast__close { border: 0; background: none; color: #A1A1AA; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 6px; }
.mt-toast__close:hover { background: rgba(255,255,255,.08); color: #fff; }
@keyframes mt-toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ============================== Busy / progress ============================== */
.mt-busy-backdrop { position: fixed; inset: 0; z-index: 250; display: grid; place-items: center; background: rgba(250, 250, 250, .72); backdrop-filter: blur(3px); opacity: 0; transition: opacity 160ms; }
.mt-busy-backdrop.is-open { opacity: 1; }
.mt-busy-backdrop.is-closing, .mt-modal-backdrop.is-closing { pointer-events: none; }
.mt-busy { width: min(420px, calc(100vw - 32px)); padding: var(--mt-s5); background: var(--mt-surface); border: 1px solid var(--mt-border); border-radius: var(--mt-r-lg); box-shadow: var(--mt-shadow-lg); display: grid; gap: var(--mt-s2); }
.mt-busy__title { font-weight: 650; font-size: var(--mt-fs-md); }
.mt-busy__msg { color: var(--mt-g600); font-size: var(--mt-fs-sm); min-height: 1.4em; }
.mt-busy__actions { display: flex; justify-content: flex-end; margin-top: var(--mt-s1); }
.mt-progress { position: relative; height: 6px; border-radius: 999px; background: var(--mt-g150); overflow: hidden; }
.mt-progress__bar { height: 100%; width: 0; border-radius: inherit; background: var(--mt-accent-gradient); transition: width 200ms var(--mt-ease); }
.mt-progress.is-indeterminate .mt-progress__bar { width: 36%; animation: mt-indet 1.15s var(--mt-ease) infinite; }
@keyframes mt-indet { from { transform: translateX(-110%); } to { transform: translateX(290%); } }
.mt-spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--mt-g200); border-top-color: var(--mt-accent); animation: mt-spin .7s linear infinite; }
@keyframes mt-spin { to { transform: rotate(360deg); } }

/* ============================== Empty states ============================== */
.mt-empty { display: grid; justify-items: center; gap: var(--mt-s2); padding: var(--mt-s10) var(--mt-s6); text-align: center; color: var(--mt-g600); }
.mt-empty__icon { width: 56px; height: 56px; display: grid; place-items: center; border-radius: 16px; background: var(--mt-surface); border: 1px solid var(--mt-border); color: var(--mt-accent); box-shadow: var(--mt-shadow-sm); margin-bottom: var(--mt-s2); }
.mt-empty__title { font-family: var(--mt-font-display); font-size: var(--mt-fs-lg); font-weight: 650; color: var(--mt-g900); letter-spacing: -0.015em; }
.mt-empty__text { max-width: 440px; }
.mt-empty > :last-child:not(.mt-empty__text):not(.mt-empty__title) { margin-top: var(--mt-s3); }

/* ============================== Inline error box (MT.app.guard, ARCHITECTURE §16) ============================== */
/* A part of the UI that failed to render: says so, offers «Recargar» (and «Reintentar»); the rest keeps working. */
.mt-errbox {
  display: grid; gap: 6px; margin: var(--mt-s3); padding: 10px 14px; text-align: left;
  background: var(--mt-danger-soft); color: #7F1D1D; border: 1px solid #F3C9C9; border-left: 4px solid var(--mt-danger);
  border-radius: var(--mt-r); font-size: var(--mt-fs-sm); line-height: 1.45;
}
.mt-errbox__head { display: flex; align-items: center; gap: 8px; font-weight: 650; }
.mt-errbox__head > .mt-icon { color: var(--mt-danger); flex: none; }
.mt-errbox__x { margin-left: auto; margin-right: -6px; color: inherit; }
.mt-errbox__details summary { cursor: pointer; font-size: var(--mt-fs-xs); opacity: .85; }
.mt-errbox__details code { display: block; margin-top: 4px; max-height: 96px; overflow: auto; white-space: pre-wrap; word-break: break-word; font-size: 11.5px; color: #52525B; }
.mt-errbox__actions { display: flex; flex-wrap: wrap; gap: var(--mt-s2); margin-top: 2px; }
.mt-errbox--compact { margin: 0; padding: 7px 10px; box-shadow: var(--mt-shadow); }
.mt-errbox--compact .mt-errbox__text { display: none; }
.mt-errbox--compact .mt-errbox__actions { margin-top: 0; }
.mt-errbox--tab { max-width: 560px; margin: var(--mt-s8) auto; padding: var(--mt-s4) var(--mt-s5); }

/* ============================== Popover (store popups, small cards) ============================== */
.mt-popover { background: var(--mt-surface); border: 1px solid var(--mt-border); border-radius: var(--mt-r); box-shadow: var(--mt-shadow-lg); padding: var(--mt-s3); min-width: 220px; max-width: 320px; }
.mt-popover__title { font-weight: 650; }
.mt-popover__sub { color: var(--mt-g500); font-size: var(--mt-fs-sm); }
.mt-popover__actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--mt-s3); }

/* ============================== Kbd ============================== */
kbd, .mt-kbd { font-family: var(--mt-font); font-size: 11px; font-weight: 600; color: var(--mt-g600); background: var(--mt-surface); border: 1px solid var(--mt-border-strong); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; }

/* ============================== Motion preferences ============================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
