/* ═══════════════════════════════════════════════════════════════════════════
   ALUMED · App Comercial — hoja de estilos
   Tipografía Montserrat · Colores corporativos · Responsive (tablet/móvil)
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --azul: #444D97;
  --azul-dark: #373F7D;
  --azul-soft: #EEF0F9;
  --dorado: #B88B4A;
  --dorado-soft: #F5ECDD;
  --bg: #F8F9FC;
  --surface: #FFFFFF;
  --text: #2D2D2D;
  --muted: #7A7A7A;
  --border: #E7E9F2;
  --verde: #28A745;
  --verde-soft: #E7F6EC;
  --rojo: #D64545;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 2px 10px rgba(45,45,60,.06), 0 8px 24px rgba(45,45,60,.05);
  --shadow-hover: 0 6px 18px rgba(68,77,151,.16);
  --topbar-h: 64px;
  --sidebar-w: 230px;
  --font: 'Montserrat', system-ui, sans-serif;
}

[data-theme="dark"] {
  --azul: #7480D6;
  --azul-dark: #5A66C0;
  --azul-soft: #232842;
  --dorado: #D2A765;
  --dorado-soft: #2E2820;
  --bg: #14161F;
  --surface: #1D2030;
  --text: #E8E9F0;
  --muted: #9A9DB0;
  --border: #2C3046;
  --verde: #3FBF5F;
  --verde-soft: #16301F;
  --shadow: 0 2px 12px rgba(0,0,0,.35);
  --shadow-hover: 0 6px 20px rgba(0,0,0,.5);
}

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

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;            /* sin desplazamiento horizontal de página */
  overscroll-behavior-y: contain; /* evita el rebote/pull al tocar */
  max-width: 100vw;
}
.content, .app-shell, .global-search { min-width: 0; }   /* permite encoger en flex */

button, input, select { font-family: inherit; }
a { color: inherit; text-decoration: none; }

/* ── Top bar ──────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 18px;
  background: var(--azul);
  box-shadow: 0 2px 12px rgba(68,77,151,.25);
}
.brand { display: flex; align-items: center; flex-shrink: 0; }
.brand-logo { height: 34px; width: auto; display: block; }
.brand-fallback { color: #fff; font-weight: 800; font-size: 22px; letter-spacing: 1px; }

.menu-toggle { display: none; }

.icon-btn {
  background: rgba(255,255,255,.14); color: #fff; border: none;
  width: 40px; height: 40px; border-radius: 10px; font-size: 18px;
  cursor: pointer; flex-shrink: 0; transition: background .15s;
}
.icon-btn:hover { background: rgba(255,255,255,.26); }

.global-search {
  position: relative; flex: 1; max-width: 520px;
  display: flex; align-items: center;
  background: rgba(255,255,255,.16); border-radius: 12px; padding: 0 12px;
}
.global-search .search-icon { opacity: .9; font-size: 14px; }
.global-search input {
  flex: 1; background: transparent; border: none; outline: none;
  color: #fff; font-size: 14px; padding: 11px 10px;
}
.global-search input::placeholder { color: rgba(255,255,255,.7); }

.search-results {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0;
  background: var(--surface); border-radius: 12px; box-shadow: var(--shadow);
  max-height: 60vh; overflow-y: auto; z-index: 60; padding: 6px;
  border: 1px solid var(--border);
}
.sr-group-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  color: var(--muted); padding: 8px 10px 4px;
}
.sr-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px;
  border-radius: 8px; cursor: pointer;
}
.sr-item:hover { background: var(--azul-soft); }
.sr-item .sr-ico { font-size: 15px; }
.sr-item .sr-main { font-weight: 600; font-size: 14px; }
.sr-item .sr-sub { font-size: 12px; color: var(--muted); }
.sr-empty { padding: 16px; text-align: center; color: var(--muted); font-size: 13px; }

.topbar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.client-pill {
  display: flex; align-items: center; gap: 8px;
  background: #fff; border-radius: 999px; padding: 5px 6px 5px 14px;
  max-width: 260px;
}
.client-pill-name {
  font-weight: 600; font-size: 13px; color: var(--azul);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px;
}
.client-pill-dto {
  background: var(--verde); color: #fff; font-weight: 700; font-size: 12px;
  padding: 2px 9px; border-radius: 999px;
}
.client-pill-x {
  background: var(--azul-soft); border: none; color: var(--azul);
  width: 24px; height: 24px; border-radius: 50%; cursor: pointer; font-size: 15px; line-height: 1;
}

/* ── Shell / sidebar ──────────────────────────────────────────────────────── */
.app-shell { display: flex; min-height: calc(100vh - var(--topbar-h)); }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 18px 12px; position: sticky; top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
}
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: var(--radius-sm);
  font-weight: 600; font-size: 14.5px; color: var(--text);
  cursor: pointer; transition: background .15s, color .15s;
}
.nav-item .nav-ico { font-size: 18px; width: 22px; text-align: center; }
.nav-item:hover { background: var(--azul-soft); }
.nav-item.active { background: var(--azul); color: #fff; }

.sidebar-foot {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--muted); padding: 10px 14px;
}
.conn-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.conn-dot.ok { background: var(--verde); box-shadow: 0 0 0 3px var(--verde-soft); }
.conn-dot.err { background: var(--rojo); }

.sidebar-backdrop {
  display: none; position: fixed; inset: var(--topbar-h) 0 0 0;
  background: rgba(0,0,0,.4); z-index: 40;
}

/* ── Content ──────────────────────────────────────────────────────────────── */
.content { flex: 1; padding: 26px clamp(16px, 4vw, 40px); min-width: 0; }

.page-head { margin-bottom: 22px; }
.page-title { font-size: 26px; font-weight: 800; letter-spacing: -.3px; }
.page-sub { color: var(--muted); font-size: 14px; margin-top: 3px; }

.back-btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--surface); border: 1px solid var(--border); color: var(--azul);
  font-weight: 600; font-size: 14px; padding: 9px 16px; border-radius: 999px;
  cursor: pointer; margin-bottom: 18px; box-shadow: var(--shadow);
}
.back-btn:hover { border-color: var(--azul); }

/* ── Home cards ───────────────────────────────────────────────────────────── */
.home-hero {
  background: linear-gradient(135deg, var(--azul) 0%, var(--azul-dark) 100%);
  color: #fff; border-radius: var(--radius); padding: 30px 32px;
  margin-bottom: 26px; box-shadow: var(--shadow);
}
.home-hero h1 { font-size: 27px; font-weight: 800; }
.home-hero p { opacity: .9; margin-top: 6px; font-size: 15px; }
.home-stats { display: flex; gap: 26px; margin-top: 20px; flex-wrap: wrap; }
.home-stat .n { font-size: 28px; font-weight: 800; line-height: 1; }
.home-stat .l { font-size: 12.5px; opacity: .85; text-transform: uppercase; letter-spacing: .5px; }

.card-grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.access-card {
  background: var(--surface); border-radius: var(--radius); padding: 24px;
  box-shadow: var(--shadow); cursor: pointer; border: 1px solid var(--border);
  transition: transform .15s, box-shadow .15s, border-color .15s;
  display: flex; flex-direction: column; gap: 10px;
}
.access-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); border-color: var(--azul); }
.access-ico {
  width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center;
  font-size: 26px; background: var(--azul-soft);
}
.access-card h3 { font-size: 18px; font-weight: 700; }
.access-card p { color: var(--muted); font-size: 13.5px; }
.access-card .go { color: var(--azul); font-weight: 700; font-size: 13px; margin-top: auto; }

.recent-wrap { margin-top: 28px; display: grid; gap: 18px; grid-template-columns: 1fr 1fr; }
.recent-box { background: var(--surface); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); border: 1px solid var(--border); }
.recent-box h4 { font-size: 14px; font-weight: 700; margin-bottom: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.recent-item { display: flex; align-items: center; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 14px; }
.recent-item:last-child { border-bottom: none; }
.recent-item:hover { color: var(--azul); }
.recent-empty { color: var(--muted); font-size: 13px; padding: 8px 0; }

/* ── Search / filter bar ──────────────────────────────────────────────────── */
.filter-bar { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; align-items: center; }
.input-search {
  flex: 1; min-width: 220px; display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 0 14px; box-shadow: var(--shadow);
}
.input-search input { flex: 1; border: none; outline: none; background: transparent; color: var(--text); font-size: 15px; padding: 13px 0; }
.input-search .search-icon { color: var(--muted); }
.result-count { color: var(--muted); font-size: 13px; font-weight: 600; }

select.select-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; font-size: 14px; color: var(--text); cursor: pointer; box-shadow: var(--shadow);
}

/* ── Cards: clientes / series list ────────────────────────────────────────── */
.list-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

.client-card, .serie-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); cursor: pointer;
  transition: transform .12s, box-shadow .12s, border-color .12s;
}
.client-card:hover, .serie-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); border-color: var(--azul); }
.client-card .cc-name { font-weight: 700; font-size: 15.5px; }
.client-card .cc-meta { color: var(--muted); font-size: 13px; margin-top: 4px; display: flex; gap: 10px; flex-wrap: wrap; }
.client-card .cc-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; }
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--azul-soft); color: var(--azul); font-weight: 600; font-size: 12px;
  padding: 4px 10px; border-radius: 999px;
}
.tag.code { background: var(--dorado-soft); color: var(--dorado); }
.dto-badge { background: var(--verde); color: #fff; font-weight: 700; font-size: 13px; padding: 5px 12px; border-radius: 999px; }

.serie-card { display: flex; flex-direction: column; gap: 8px; }
.serie-card .sc-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.serie-card .sc-name { font-weight: 700; font-size: 16px; }
.serie-card .sc-cat { color: var(--muted); font-size: 12.5px; }
.serie-card .sc-tags { display: flex; gap: 6px; flex-wrap: wrap; }

.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; }
.badge-rpt { background: var(--dorado); color: #fff; }
.badge-refs { background: var(--azul-soft); color: var(--azul); }
.badge-ficha { background: var(--verde-soft); color: var(--verde); }
.badge-cat { background: var(--dorado-soft); color: var(--dorado); }

/* ── Control segmentado (filtro de categoría en Series) ──────────────────────── */
.seg { display: inline-flex; gap: 4px; background: var(--azul-soft); border: 1px solid var(--border); border-radius: 999px; padding: 4px; margin-bottom: 14px; flex-wrap: wrap; }
.seg-btn { border: none; background: transparent; color: var(--azul); font-family: var(--font); font-weight: 700; font-size: 13px; padding: 7px 14px; border-radius: 999px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.seg-btn:hover { background: rgba(68,77,151,.10); }
.seg-btn.active { background: var(--azul); color: #fff; }
.seg-n { font-size: 11px; font-weight: 700; opacity: .75; }
.seg-select { border: 1px solid var(--border); background: var(--surface); color: var(--text); font-family: var(--font); font-size: 14px; font-weight: 600; padding: 12px; border-radius: var(--radius-sm); cursor: pointer; outline: none; }
.forfait-panel { margin-top: 18px; border-left: 4px solid var(--dorado); }

/* ── Campo de descuento manual (override) en el detalle de serie ─────────────── */
.dto-override { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 10px 0 14px; padding: 10px 14px; background: var(--azul-soft); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.dto-override label { font-weight: 700; font-size: 13.5px; color: var(--azul); }
.dto-override input { width: 90px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-family: var(--font); font-size: 15px; font-weight: 700; padding: 8px 10px; border-radius: 8px; outline: none; }
.dto-hint { font-size: 12px; color: var(--muted); }
.ov-tag { display: inline-block; background: var(--dorado); color: #fff; font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 999px; margin-left: 4px; text-transform: uppercase; letter-spacing: .03em; }

/* ── Doble descuento (perfiles / accesorios) en el detalle de cliente ─────────── */
.dto-split { display: flex; gap: 24px; text-align: right; flex-wrap: wrap; justify-content: flex-end; }
.dto-split-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.dto-split-val { font-size: 32px; font-weight: 800; color: var(--verde); line-height: 1.1; }
.dto-split-val.none { font-size: 16px; font-weight: 600; color: var(--muted); }

/* ── Detail panels ────────────────────────────────────────────────────────── */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 18px; }
.detail-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.detail-name { font-size: 24px; font-weight: 800; }
.detail-cat { color: var(--muted); font-size: 14px; margin-top: 2px; }
.detail-badges { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.source-link { color: var(--azul); font-weight: 600; font-size: 13px; border: 1px solid var(--border); padding: 8px 14px; border-radius: 999px; }
.source-link:hover { border-color: var(--azul); }

/* Cliente bar (precio context) */
.client-context {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--azul-soft); border-radius: 12px; padding: 12px 16px; margin: 16px 0;
  font-size: 14px;
}
.client-context.empty { color: var(--muted); background: var(--bg); border: 1px dashed var(--border); }
.client-context b { color: var(--azul); }

/* Prestaciones bar */
.prest-bar { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px,1fr)); gap: 12px; margin: 16px 0; }
.prest-item { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.prest-item .pl { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.prest-item .pv { font-size: 16px; font-weight: 700; margin-top: 3px; overflow-wrap: anywhere; }
.prest-item.wide { grid-column: span 2; }
@media (max-width: 600px) { .prest-item.wide { grid-column: span 1; } }

/* ── Tables ───────────────────────────────────────────────────────────────── */
/* Scroll interno (vertical + horizontal) con cabecera y 1ª columna inmovilizadas */
.table-wrap {
  overflow: auto; max-height: 70vh; -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
}
table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
table.data thead th {
  background: var(--azul); color: #fff; text-align: left; font-weight: 600;
  padding: 12px 14px; position: sticky; top: 0; z-index: 3; white-space: nowrap; font-size: 13px;
  border-bottom: 1px solid var(--azul-dark);
}
table.data tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); }
table.data tbody tr:nth-child(even) td { background: var(--bg); }
table.data tbody tr:hover td { background: var(--azul-soft); }

/* 1ª columna (código) inmovilizada al hacer scroll horizontal */
table.data thead th:first-child { left: 0; z-index: 5; }
table.data tbody td:first-child {
  position: sticky; left: 0; z-index: 2; background: var(--surface);
  box-shadow: 1px 0 0 var(--border);
}
table.data tbody tr:nth-child(even) td:first-child { background: var(--bg); }
table.data tbody tr:hover td:first-child { background: var(--azul-soft); }

.ref-codigo { font-weight: 700; color: var(--azul); white-space: nowrap; }
.ref-precio { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.th-dto { background: var(--verde) !important; }
.th-dto-tag { background: var(--verde); color: #fff; font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 999px; margin-left: 4px; }
.precio-dto { color: var(--verde); font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; }
.precio-tachado { color: var(--muted); font-size: 11.5px; text-decoration: line-through; text-align: right; font-variant-numeric: tabular-nums; }

/* Precio calculator highlight */
.price-calc {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px,1fr)); gap: 12px;
  background: var(--bg); border-radius: 12px; padding: 16px; margin-top: 14px;
}
.price-cell { text-align: center; }
.price-cell .pl { font-size: 12px; color: var(--muted); }
.price-cell .pv { font-size: 20px; font-weight: 800; margin-top: 4px; }
.price-cell.final .pv { color: var(--verde); }
.price-cell.save .pv { color: var(--dorado); }

/* ── Ficha técnica render ─────────────────────────────────────────────────── */
.ficha-content { font-size: 14.5px; line-height: 1.65; }
.ficha-content h1 { font-size: 22px; margin: 4px 0 10px; }
.ficha-content h2 { font-size: 17px; margin: 22px 0 10px; color: var(--azul); border-bottom: 2px solid var(--azul-soft); padding-bottom: 6px; }
.ficha-content h3 { font-size: 15px; margin: 16px 0 8px; }
.ficha-content blockquote { color: var(--muted); border-left: 3px solid var(--dorado); padding: 4px 14px; margin: 10px 0; font-size: 13.5px; }
.ficha-content table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 14px; }
.ficha-content th, .ficha-content td { border: 1px solid var(--border); padding: 9px 12px; text-align: left; }
.ficha-content thead th { background: var(--azul-soft); color: var(--azul); }
.ficha-content ul { padding-left: 22px; margin: 8px 0; }
.ficha-content li { margin: 3px 0; }
.ficha-content strong { color: var(--text); }
.ficha-content p { margin: 8px 0; }

/* ── Comparador ───────────────────────────────────────────────────────────── */
.cmp-intro { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 18px; }
.cmp-suggest { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.cmp-chip {
  background: var(--azul-soft); color: var(--azul); border: 1px solid transparent;
  border-radius: 999px; padding: 8px 14px; font-weight: 600; font-size: 13px; cursor: pointer;
}
.cmp-chip:hover { border-color: var(--azul); }
.cmp-chip.active { background: var(--azul); color: #fff; }

.cmp-pick-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(200px,1fr)); margin-bottom: 18px; }
.cmp-pick {
  display: flex; align-items: center; gap: 10px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; padding: 11px 14px; cursor: pointer; font-size: 14px; font-weight: 600;
}
.cmp-pick:hover { border-color: var(--azul); }
.cmp-pick.selected { border-color: var(--azul); background: var(--azul-soft); }
.cmp-pick input { accent-color: var(--azul); width: 18px; height: 18px; }

.cmp-table th.serie-col { background: var(--azul-dark) !important; }
.cmp-table td.best { background: var(--verde-soft); font-weight: 700; }
.cmp-table td.best::after { content: " ★"; color: var(--dorado); }
.cmp-row-label { font-weight: 700; background: var(--bg); }

.reco-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(240px,1fr)); margin-top: 18px; }
.reco-card { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--dorado); border-radius: var(--radius-sm); padding: 16px; box-shadow: var(--shadow); }
.reco-card .rc-tag { font-size: 12px; font-weight: 700; color: var(--dorado); text-transform: uppercase; letter-spacing: .4px; }
.reco-card .rc-serie { font-size: 18px; font-weight: 800; margin: 6px 0 4px; }
.reco-card .rc-why { font-size: 13px; color: var(--muted); }

/* ── States ───────────────────────────────────────────────────────────────── */
.boot-loading, .empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.spinner {
  width: 38px; height: 38px; border: 4px solid var(--azul-soft); border-top-color: var(--azul);
  border-radius: 50%; margin: 0 auto 16px; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state .big-ico { font-size: 42px; display: block; margin-bottom: 12px; }
.error-msg { background: #FDECEC; color: var(--rojo); border-radius: 12px; padding: 18px; text-align: center; }
[data-theme="dark"] .error-msg { background: #3a1f1f; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .menu-toggle { display: block; }
  .sidebar {
    position: fixed; top: var(--topbar-h); left: 0; z-index: 45;
    transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow-hover);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar.open + .sidebar-backdrop { display: block; }
  .recent-wrap { grid-template-columns: 1fr; }
  .global-search { max-width: none; }
  .client-pill-name { max-width: 90px; }
}
/* Header a dos filas en móvil (la búsqueda baja a su propia línea) */
@media (max-width: 600px) {
  :root { --topbar-h: 112px; }
  .topbar {
    height: var(--topbar-h);
    flex-wrap: wrap; align-items: center; row-gap: 8px; padding: 9px 10px;
  }
  .menu-toggle { order: 1; }
  .brand { order: 2; flex: 1; }
  .topbar-right { order: 3; }
  .global-search { order: 4; flex-basis: 100%; max-width: none; }
  .brand-logo { height: 30px; }
  .icon-btn { width: 38px; height: 38px; }
  .client-pill { padding: 4px 5px 4px 11px; }
  .client-pill-name { max-width: 110px; }
  /* el desplegable de resultados se ancla bajo la barra completa */
  .search-results { max-height: 50vh; }
}

@media (max-width: 560px) {
  .page-title { font-size: 22px; }
  .home-hero { padding: 22px; }
  .topbar { gap: 8px; padding: 0 10px; }
  .content { padding: 18px 12px; }

  /* Tablas de tarifa más compactas y legibles en móvil */
  .table-wrap { max-height: 72vh; }
  table.data { font-size: 12.5px; }
  table.data thead th { padding: 9px 9px; font-size: 11.5px; }
  table.data tbody td { padding: 8px 9px; }
  .precio-tachado { font-size: 10.5px; }
  .th-dto-tag { display: block; margin: 2px 0 0; }

  /* La descripción no debe ensanchar la tabla en exceso */
  table.data td:nth-child(2) { min-width: 130px; max-width: 180px; white-space: normal; }
}
