/* =====================================================================
   ERP TALLER — Sistema de diseño
   Estilo profesional, industrial-elegante (automoción).
   Navegación superior por categorías + rejilla de módulos táctil.
   ===================================================================== */

:root {
  /* Marca */
  --brand-900: #0b1f33;
  --brand-800: #12314f;
  --brand-700: #17406a;
  --brand-600: #1d5285;
  --brand-500: #2b6cb0;
  --brand-400: #4a90d9;
  --accent-600: #d97706;   /* ámbar */
  --accent-500: #f59e0b;
  --accent-400: #fbbf24;

  /* Neutros */
  --bg:         #eef2f7;
  --surface:    #ffffff;
  --surface-2:  #f7f9fc;
  --border:     #dbe3ec;
  --border-2:   #c7d3e0;
  --text:       #1b2733;
  --text-soft:  #55647a;
  --text-mute:  #8a97a8;

  /* Estados */
  --green-600:#16794a; --green-100:#dff5ea;
  --amber-600:#b45309; --amber-100:#fdf0d5;
  --red-600:#c0392b;   --red-100:#fbe3e0;
  --blue-600:#1d5285;  --blue-100:#e2edf8;
  --gray-600:#5b6b7d;  --gray-100:#e9eef4;
  --purple-600:#6b46c1;--purple-100:#ece6fa;

  /* Colores de categoría */
  --cat-taller: #1d5285;
  --cat-fichas: #0f766e;
  --cat-admin:  #6b46c1;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16,35,60,.06), 0 1px 3px rgba(16,35,60,.08);
  --shadow-md: 0 4px 14px rgba(16,35,60,.10);
  --shadow-lg: 0 12px 40px rgba(11,31,51,.18);
  --font: 'Segoe UI', system-ui, -apple-system, 'Roboto', 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3,h4 { margin: 0 0 .4em; color: var(--brand-900); font-weight: 700; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
small { color: var(--text-mute); }

/* ------------------------------- Layout app ------------------------------- */
.app { min-height: 100vh; display: flex; flex-direction: column; }

/* ---- Barra de navegación superior ---- */
.topnav {
  background: linear-gradient(180deg, var(--brand-900), var(--brand-800));
  position: sticky; top: 0; z-index: 40;
  box-shadow: 0 2px 12px rgba(11,31,51,.28);
}
.topnav__inner {
  max-width: 1360px; margin: 0 auto;
  display: flex; align-items: center; gap: 1rem;
  padding: .6rem 1.25rem;
}

/* Marca */
.brand { display: flex; align-items: center; gap: .7rem; text-decoration: none; flex-shrink: 0; }
.brand:hover { text-decoration: none; }
.brand__logo {
  width: 40px; height: 40px; border-radius: 11px;
  background: linear-gradient(135deg, var(--accent-500), var(--accent-600));
  display: grid; place-items: center; color: #fff; flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(217,119,6,.4);
}
.brand__logo svg { width: 23px; height: 23px; }
.brand__text b { color: #fff; font-size: 1.02rem; letter-spacing: .3px; display: block; line-height: 1.1; }
.brand__text span { font-size: .67rem; color: var(--accent-400); text-transform: uppercase; letter-spacing: 1.2px; }

/* Navegación principal */
.mainnav { display: flex; align-items: center; gap: .25rem; flex: 1; }
.navlink, .navgroup__btn {
  display: flex; align-items: center; gap: .5rem;
  padding: .6rem .85rem; min-height: 44px;
  border-radius: var(--radius-sm);
  color: #c2d0df; font-weight: 600; font-size: .92rem;
  text-decoration: none; background: none; border: none; cursor: pointer;
  font-family: inherit; white-space: nowrap;
  transition: background .15s, color .15s;
}
.navlink svg, .navgroup__btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.navlink:hover, .navgroup__btn:hover { background: rgba(255,255,255,.09); color: #fff; text-decoration: none; }
.navlink.active, .navgroup.active > .navgroup__btn { background: var(--brand-600); color: #fff; }
.navlink:focus-visible, .navgroup__btn:focus-visible { outline: 2px solid var(--accent-400); outline-offset: 2px; }
.navgroup__btn .chev { width: 15px; height: 15px; opacity: .75; transition: transform .18s; }
.navgroup.open > .navgroup__btn { background: rgba(255,255,255,.13); color: #fff; }
.navgroup.open > .navgroup__btn .chev { transform: rotate(180deg); }

/* Desplegable de categoría */
.navgroup { position: relative; }
.navgroup__menu {
  position: absolute; top: calc(100% + 7px); left: 0; min-width: 265px;
  background: var(--surface); border: 1px solid var(--border);
  border-top: 3px solid var(--cat, var(--brand-500));
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: .4rem; display: none; z-index: 60;
}
.navgroup.open .navgroup__menu { display: block; animation: navdrop .16s ease; }
@keyframes navdrop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.navgroup__menu a {
  display: flex; align-items: center; gap: .7rem;
  padding: .65rem .75rem; min-height: 44px;
  border-radius: var(--radius-sm);
  color: var(--text); font-weight: 600; font-size: .9rem; text-decoration: none;
}
.navgroup__menu a svg { width: 19px; height: 19px; color: var(--cat, var(--brand-500)); flex-shrink: 0; }
.navgroup__menu a:hover { background: var(--surface-2); text-decoration: none; }
.navgroup__menu a.active { background: color-mix(in srgb, var(--cat) 13%, #fff); color: var(--cat); }

/* Usuario */
.navuser { display: flex; align-items: center; gap: .55rem; flex-shrink: 0; }
.navuser .avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--brand-500); color: #fff; font-size: .95rem;
  display: grid; place-items: center; font-weight: 700; flex-shrink: 0;
}
.navuser .meta { min-width: 0; }
.navuser .meta b { color: #fff; font-size: .84rem; display: block; line-height: 1.15; white-space: nowrap; }
.navuser .meta span { font-size: .67rem; color: var(--accent-400); }
.navuser .logout {
  color: #9fb1c4; display: grid; place-items: center;
  width: 42px; height: 42px; border-radius: 10px;
}
.navuser .logout:hover { background: rgba(255,255,255,.1); color: #fff; }
.navuser .logout svg { width: 20px; height: 20px; }

/* Botón menú (móvil/tablet) */
.navtoggle {
  display: none; background: rgba(255,255,255,.09); border: none; color: #fff;
  width: 44px; height: 44px; border-radius: 10px; cursor: pointer;
  place-items: center; flex-shrink: 0;
}
.navtoggle svg { width: 22px; height: 22px; }

/* ---- Barra de página (título + acciones) ---- */
.pagebar { background: var(--surface); border-bottom: 1px solid var(--border); padding: .8rem 1.25rem; }
.pagebar__inner {
  max-width: 1360px; margin: 0 auto;
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.pagebar .page-title {
  font-size: 1.15rem; font-weight: 700; color: var(--brand-900);
  display: flex; align-items: center; gap: .55rem; margin: 0;
}
.pagebar .page-title svg { width: 22px; height: 22px; color: var(--brand-500); }
.pagebar .spacer { flex: 1; }

.content { padding: 1.5rem 1.25rem; flex: 1; }
.container { max-width: 1360px; margin: 0 auto; }

/* Breadcrumb */
.breadcrumb { font-size: .82rem; color: var(--text-mute); margin-bottom: 1rem; }
.breadcrumb a { color: var(--text-soft); }

/* ------------------------------- Botones ------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .55rem .95rem; border-radius: var(--radius-sm);
  border: 1px solid transparent; font-size: .9rem; font-weight: 600;
  cursor: pointer; text-decoration: none; transition: all .15s; line-height: 1;
  background: var(--surface-2); color: var(--text); border-color: var(--border-2);
  font-family: inherit;
}
.btn svg { width: 17px; height: 17px; }
.btn:hover { text-decoration: none; box-shadow: var(--shadow-sm); }
.btn-primary { background: linear-gradient(135deg, var(--brand-600), var(--brand-700)); color:#fff; border-color: transparent; }
.btn-primary:hover { background: linear-gradient(135deg, var(--brand-500), var(--brand-600)); }
.btn-accent { background: linear-gradient(135deg, var(--accent-500), var(--accent-600)); color:#fff; }
.btn-success { background: var(--green-600); color:#fff; }
.btn-danger  { background: var(--red-600); color:#fff; }
.btn-ghost   { background: transparent; border-color: var(--border-2); }
.btn-sm { padding: .38rem .6rem; font-size: .82rem; }
.btn-lg { padding: .85rem 1.35rem; font-size: 1rem; border-radius: var(--radius); }
.btn-lg svg { width: 20px; height: 20px; }
.btn-icon { padding: .45rem; }
.btn-icon svg { width: 18px; height: 18px; }
.btn-block { width: 100%; justify-content: center; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* Rejilla simple reutilizable (bloques de firmas, etc.) */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1.1rem; }

/* ---- Módulos por categoría (pantalla de inicio) ---- */
.modsec { margin-bottom: 2rem; }
.modsec__head { display: flex; align-items: center; gap: .8rem; margin-bottom: 1rem; }
.modsec__badge {
  width: 36px; height: 36px; border-radius: 11px; flex-shrink: 0;
  background: var(--cat); color: #fff; display: grid; place-items: center;
  box-shadow: 0 5px 14px color-mix(in srgb, var(--cat) 40%, transparent);
}
.modsec__badge svg { width: 19px; height: 19px; }
.modsec__head h2 {
  margin: 0; font-size: .84rem; font-weight: 800; white-space: nowrap;
  text-transform: uppercase; letter-spacing: 1.7px; color: var(--cat);
}
.modsec__line { flex: 1; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--cat) 38%, transparent), transparent); }

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

.modtile {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 1.5rem 1rem 1.3rem;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .8rem;
  text-align: center; text-decoration: none; color: var(--text);
  box-shadow: var(--shadow-sm); min-height: 172px;
  transition: transform .16s, box-shadow .16s, border-color .16s;
}
.modtile::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 4px;
  background: linear-gradient(90deg, var(--cat), color-mix(in srgb, var(--cat) 22%, transparent));
}
.modtile:hover {
  transform: translateY(-5px); box-shadow: var(--shadow-md); text-decoration: none;
  border-color: color-mix(in srgb, var(--cat) 45%, var(--border));
}
.modtile:active { transform: translateY(-1px) scale(.985); }
.modtile:focus-visible { outline: 3px solid color-mix(in srgb, var(--cat) 55%, transparent); outline-offset: 2px; }
.modtile__icon {
  width: 64px; height: 64px; border-radius: 18px;
  display: grid; place-items: center; color: #fff; flex-shrink: 0;
  background: linear-gradient(140deg, color-mix(in srgb, var(--cat) 78%, #fff), var(--cat));
  box-shadow: 0 8px 20px color-mix(in srgb, var(--cat) 36%, transparent);
  transition: transform .16s;
}
.modtile:hover .modtile__icon { transform: scale(1.07); }
.modtile__icon svg { width: 31px; height: 31px; }
.modtile b { font-size: 1rem; color: var(--brand-900); line-height: 1.25; }
.modtile small { font-size: .78rem; color: var(--text-mute); line-height: 1.35; }

/* Colores por categoría */
.cat-taller { --cat: var(--cat-taller); }
.cat-fichas { --cat: var(--cat-fichas); }
.cat-admin  { --cat: var(--cat-admin); }

/* ---- Acciones rápidas (mismo lenguaje visual que las baldosas) ---- */
.quickgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(245px, 1fr)); gap: .85rem; }
.quickact {
  display: flex; align-items: center; gap: .85rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: .85rem 1rem; min-height: 70px;
  text-decoration: none; color: var(--text); box-shadow: var(--shadow-sm);
  transition: transform .16s, box-shadow .16s, border-color .16s;
}
.quickact:hover {
  transform: translateY(-3px); box-shadow: var(--shadow-md); text-decoration: none;
  border-color: color-mix(in srgb, var(--cat) 45%, var(--border));
}
.quickact:active { transform: translateY(0) scale(.99); }
.quickact:focus-visible { outline: 3px solid color-mix(in srgb, var(--cat) 55%, transparent); outline-offset: 2px; }
.quickact__icon {
  width: 46px; height: 46px; border-radius: 13px; flex-shrink: 0;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(140deg, color-mix(in srgb, var(--cat) 78%, #fff), var(--cat));
  box-shadow: 0 5px 14px color-mix(in srgb, var(--cat) 35%, transparent);
  transition: transform .16s;
}
.quickact:hover .quickact__icon { transform: scale(1.06); }
.quickact__icon svg { width: 23px; height: 23px; }
.quickact__txt { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.quickact__txt b { font-size: .96rem; color: var(--brand-900); line-height: 1.2; }
.quickact__txt small { font-size: .76rem; color: var(--text-mute); line-height: 1.3; }
.quickact__plus {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--text-mute); border: 1px solid var(--border);
  transition: background .16s, color .16s, border-color .16s;
}
.quickact__plus svg { width: 16px; height: 16px; }
.quickact:hover .quickact__plus { background: var(--cat); color: #fff; border-color: var(--cat); }

/* Color de la sección de acciones (ámbar = crear, frente a los colores de navegación) */
.cat-accion { --cat: var(--accent-600); }

/* ------------------------------- Tarjetas ------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); margin-bottom: 1.25rem;
}
.card__head {
  padding: .95rem 1.25rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: .6rem;
}
.card__head h2, .card__head h3 { margin: 0; }
.card__head svg { width: 20px; height: 20px; color: var(--brand-500); }
.card__head .spacer { flex: 1; }
/* Cabecera con chip de icono y subtítulo */
.card__head--rich { padding: 1.1rem 1.25rem; gap: .8rem; background: linear-gradient(180deg, var(--surface-2), var(--surface)); }
.card__ico {
  width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(140deg, var(--fs, var(--brand-500)), color-mix(in srgb, var(--fs, var(--brand-500)) 62%, #000));
  box-shadow: 0 5px 15px color-mix(in srgb, var(--fs, var(--brand-500)) 35%, transparent);
}
.card__ico svg { width: 21px; height: 21px; color: #fff; }
.card__head .ttl { display: flex; flex-direction: column; min-width: 0; }
.card__head .ttl h2 { font-size: 1.05rem; line-height: 1.2; }
.card__head .ttl small { font-size: .78rem; color: var(--text-mute); }
.card__body { padding: 1.25rem; }
.card__body.pad0 { padding: 0; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px,1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.25rem; box-shadow: var(--shadow-sm); display: flex; align-items: center; gap: 1rem; }
.kpi__icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; color:#fff; flex-shrink:0; }
.kpi__icon svg { width: 24px; height: 24px; }
.kpi b { font-size: 1.7rem; line-height: 1; color: var(--brand-900); display:block; }
.kpi span { font-size: .8rem; color: var(--text-mute); }

/* ------------------------------- Tablas ------------------------------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th, table.data td { padding: .7rem .9rem; text-align: left; border-bottom: 1px solid var(--border); }
table.data thead th { background: var(--surface-2); color: var(--text-soft); font-size: .74rem; text-transform: uppercase; letter-spacing: .5px; font-weight: 700; white-space: nowrap; }
table.data tbody tr { transition: background .12s; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .actions { display: flex; gap: .3rem; justify-content: flex-end; }
.table-empty { padding: 2.5rem 1rem; text-align: center; color: var(--text-mute); }
.table-empty svg { width: 48px; height: 48px; opacity: .4; margin-bottom: .5rem; }

/* ------------------------------- Badges ------------------------------- */
.badge { display: inline-flex; align-items: center; gap: .35rem; padding: .22rem .6rem; border-radius: 999px; font-size: .74rem; font-weight: 700; white-space: nowrap; }
.badge::before { content:''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.b-green  { background: var(--green-100);  color: var(--green-600); }
.b-amber  { background: var(--amber-100);  color: var(--amber-600); }
.b-red    { background: var(--red-100);    color: var(--red-600); }
.b-blue   { background: var(--blue-100);   color: var(--blue-600); }
.b-gray   { background: var(--gray-100);   color: var(--gray-600); }
.b-purple { background: var(--purple-100); color: var(--purple-600); }

/* ------------------------------- Formularios ------------------------------- */
/* Rejilla de 12 columnas: cada campo declara su anchura (.sp-N) */
.fgrid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 1.05rem 1.15rem; }
.field { display: flex; flex-direction: column; gap: .4rem; min-width: 0; grid-column: span 12; }
.sp-2 { grid-column: span 2; }  .sp-3 { grid-column: span 3; }
.sp-4 { grid-column: span 4; }  .sp-5 { grid-column: span 5; }
.sp-6 { grid-column: span 6; }  .sp-7 { grid-column: span 7; }
.sp-8 { grid-column: span 8; }  .sp-9 { grid-column: span 9; }
.sp-10 { grid-column: span 10; } .sp-12 { grid-column: span 12; }

/* Compatibilidad con la rejilla anterior */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.05rem 1.15rem; }
.field.col-2 { grid-column: span 2; }
.field.col-full { grid-column: 1 / -1; }

label { font-size: .82rem; font-weight: 650; color: var(--text-soft); display: flex; align-items: center; gap: .35rem; }
label .req { color: var(--red-600); font-weight: 800; }

/* Etiquetas de los campos de formulario (no afecta al login) */
.fgrid .field > label:not(.checkcard),
.form-grid .field > label:not(.checkcard) {
  font-size: .71rem; font-weight: 800; color: #5b6b80;
  text-transform: uppercase; letter-spacing: .7px;
}

input, select, textarea {
  font-family: inherit; font-size: .94rem; color: var(--text);
  padding: .7rem .8rem; min-height: 46px;
  border: 1px solid #b8c6d6; border-radius: 10px;
  background: #fff; width: 100%;
  box-shadow: 0 1px 2px rgba(16,35,60,.05);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input::placeholder, textarea::placeholder { color: #9aa8ba; }
input:hover, select:hover, textarea:hover { border-color: #93a6bd; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(43,108,176,.18), 0 1px 2px rgba(16,35,60,.05);
}
textarea { resize: vertical; min-height: 96px; line-height: 1.5; }

/* Campos rellenables con fondo de color de su categoría (no afecta al login) */
.fsection input, .fsection select, .fsection textarea,
.card--form .fgrid input, .card--form .fgrid select, .card--form .fgrid textarea,
.card--form .field input, .card--form .field select, .card--form .field textarea {
  background: color-mix(in srgb, var(--fs, var(--brand-500)) 11%, #fff);
  border-color: color-mix(in srgb, var(--fs, var(--brand-500)) 34%, #b8c6d6);
}
.fsection input:hover, .fsection select:hover, .fsection textarea:hover,
.card--form .field input:hover, .card--form .field select:hover, .card--form .field textarea:hover {
  border-color: color-mix(in srgb, var(--fs, var(--brand-500)) 60%, #93a6bd);
  background: color-mix(in srgb, var(--fs, var(--brand-500)) 16%, #fff);
}
/* Al escribir, el campo activo se aclara a blanco: queda claro dónde estás */
.fsection input:focus, .fsection select:focus, .fsection textarea:focus,
.card--form .field input:focus, .card--form .field select:focus, .card--form .field textarea:focus {
  background: #fff;
  border-color: var(--fs, var(--brand-500));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--fs, var(--brand-500)) 25%, transparent), 0 1px 2px rgba(16,35,60,.05);
}

/* Desplegables con flecha propia */
select {
  appearance: none; -webkit-appearance: none; padding-right: 2.3rem;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2355647a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right .75rem center; background-size: 16px;
}

/* Campo con icono delante */
.ctrl { position: relative; }
.ctrl__ico {
  position: absolute; left: .8rem; top: 50%; transform: translateY(-50%);
  color: var(--text-mute); pointer-events: none; display: grid; place-items: center;
  transition: color .15s;
}
.ctrl__ico svg { width: 18px; height: 18px; }
.ctrl input, .ctrl select { padding-left: 2.55rem; }
.ctrl:focus-within .ctrl__ico { color: var(--brand-500); }

.field-hint { font-size: .75rem; color: var(--text-mute); }

/* Aviso destacado bajo un campo (más visible que .field-hint) */
.field-note {
  display: flex; align-items: center; gap: .5rem;
  font-size: .79rem; font-weight: 700; line-height: 1.35;
  padding: .5rem .65rem; border-radius: 9px;
  background: var(--amber-100); color: var(--amber-600);
  border: 1px solid color-mix(in srgb, var(--amber-600) 30%, transparent);
  border-left: 4px solid var(--amber-600);
}
.field-note[hidden] { display: none; }
.field-note svg { width: 16px; height: 16px; flex-shrink: 0; }
.field-note--ok { background: var(--green-100); color: var(--green-600);
  border-color: color-mix(in srgb, var(--green-600) 30%, transparent); border-left-color: var(--green-600); }
.field-note--error { background: var(--red-100); color: var(--red-600);
  border-color: color-mix(in srgb, var(--red-600) 30%, transparent); border-left-color: var(--red-600); }

/* ---- Desplegable propio (sustituye al datalist del navegador) ---- */
.combo { position: relative; }
.combo input { padding-right: 2.9rem; }
.combo__toggle {
  position: absolute; right: .45rem; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; min-height: 0; border-radius: 8px; border: none;
  background: transparent; color: var(--text-soft); cursor: pointer;
  display: grid; place-items: center; padding: 0;
}
.combo__toggle:hover { background: rgba(16,35,60,.07); color: var(--fs, var(--brand-600)); }
.combo__toggle svg { width: 19px; height: 19px; transition: transform .18s; }
.combo.open .combo__toggle svg { transform: rotate(180deg); }
.combo.open .combo__toggle { background: var(--fs, var(--brand-600)); color: #fff; }

.combo__menu {
  position: absolute; z-index: 70; top: calc(100% + 7px); left: 0; right: 0;
  background: #fff; border: 1px solid var(--border-2);
  border-top: 4px solid var(--fs, var(--brand-500));
  border-radius: 12px; box-shadow: var(--shadow-lg);
  max-height: 330px; overflow-y: auto; padding: .35rem; display: none;
}
.combo.open .combo__menu { display: block; animation: navdrop .16s ease; }
.combo__head {
  padding: .5rem .65rem .55rem; margin-bottom: .3rem;
  font-size: .68rem; font-weight: 800; letter-spacing: .7px; text-transform: uppercase;
  color: var(--fs, var(--brand-600)); border-bottom: 1px solid var(--border);
}
.combo__opt {
  display: flex; align-items: center; gap: .6rem;
  padding: .62rem .7rem; min-height: 44px; border-radius: 8px;
  font-size: .91rem; color: var(--text); cursor: pointer;
}
.combo__opt:hover, .combo__opt.activa { background: color-mix(in srgb, var(--fs, var(--brand-500)) 13%, #fff); }
.combo__opt.elegida { font-weight: 800; color: var(--fs, var(--brand-600)); }
.combo__opt .tick { margin-left: auto; opacity: 0; color: var(--fs, var(--brand-600)); }
.combo__opt .tick svg { width: 16px; height: 16px; }
.combo__opt.elegida .tick { opacity: 1; }
.combo__vacio { padding: .85rem .7rem; color: var(--text-mute); font-size: .87rem; }

/* Destello verde al autorrellenarse un campo */
.autofilled { animation: autofillFlash 1.4s ease; }
@keyframes autofillFlash {
  0%, 35% { background-color: #dff5ea; border-color: var(--green-600); }
  100% { }
}

/* Secciones dentro de un formulario: cada una es un panel con fondo propio,
   de modo que los campos (blancos) resalten claramente sobre él. */
/* El cuerpo del formulario va en gris; las secciones, en blanco;
   y los campos, con fondo de color. Tres niveles bien diferenciados. */
.card--form > .card__body { background: #eef3f8; }
.card--form > .card__body.pad0 { background: transparent; }

.fsection {
  background: #fff;
  border: 1px solid var(--border);
  border-left: 4px solid var(--fs, var(--brand-500));
  border-radius: 14px;
  padding: 1.2rem 1.3rem 1.35rem;
  margin-bottom: 1.1rem;
  box-shadow: var(--shadow-sm);
}
.fsection__head {
  display: flex; align-items: center; gap: .7rem;
  margin-bottom: 1.15rem; padding-bottom: .85rem;
  border-bottom: 1px solid color-mix(in srgb, var(--fs, var(--brand-500)) 18%, var(--border));
}
.fsection__ico {
  width: 36px; height: 36px; border-radius: 11px; flex-shrink: 0;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(140deg, var(--fs, var(--brand-500)), color-mix(in srgb, var(--fs, var(--brand-500)) 65%, #000));
  box-shadow: 0 5px 14px color-mix(in srgb, var(--fs, var(--brand-500)) 35%, transparent);
}
.fsection__ico svg { width: 18px; height: 18px; }
.fsection__head h3 { margin: 0; font-size: .98rem; color: var(--brand-900); line-height: 1.2; }
.fsection__head small { font-size: .77rem; color: var(--text-mute); }
.fsection__head .txt { display: flex; flex-direction: column; }

/* Selector segmentado (alternativa táctil al desplegable) */
.segmented {
  display: inline-flex; padding: 4px; gap: 4px; flex-wrap: wrap; border-radius: 12px;
  background: color-mix(in srgb, var(--fs, var(--brand-500)) 11%, #fff);
  border: 1px solid color-mix(in srgb, var(--fs, var(--brand-500)) 34%, #b8c6d6);
  box-shadow: 0 1px 2px rgba(16,35,60,.05);
}
.segmented input { position: absolute; opacity: 0; width: 0; height: 0; }
.segmented label {
  display: flex; align-items: center; gap: .45rem; cursor: pointer;
  padding: .58rem 1.1rem; min-height: 42px; border-radius: 9px;
  font-size: .9rem; font-weight: 700; color: var(--text-soft);
  text-transform: none; letter-spacing: 0;
  transition: background .15s, color .15s, box-shadow .15s;
}
.segmented label svg { width: 17px; height: 17px; }
.segmented label:hover { background: var(--surface-2); }
.segmented input:checked + label {
  background: linear-gradient(140deg, var(--fs, var(--brand-600)), color-mix(in srgb, var(--fs, var(--brand-600)) 70%, #000));
  color: #fff; box-shadow: 0 3px 10px color-mix(in srgb, var(--fs, var(--brand-600)) 35%, transparent);
}
.segmented input:focus-visible + label { outline: 2px solid var(--brand-500); outline-offset: 2px; }

/* Casilla de verificación con aspecto de tarjeta */
.checkcard {
  display: flex; align-items: center; gap: .7rem; cursor: pointer;
  border-radius: 10px; padding: .72rem .85rem; min-height: 46px;
  background: color-mix(in srgb, var(--fs, var(--brand-500)) 11%, #fff);
  border: 1px solid color-mix(in srgb, var(--fs, var(--brand-500)) 34%, #b8c6d6);
  font-size: .88rem; font-weight: 600; color: var(--text-soft);
  text-transform: none; letter-spacing: 0;
  box-shadow: 0 1px 2px rgba(16,35,60,.05);
  transition: border-color .15s, background .15s;
}
.checkcard input { accent-color: var(--fs, var(--brand-600)); }
.checkcard:hover { border-color: var(--fs, var(--brand-400)); }
.checkcard:has(input:checked) {
  border-color: var(--fs, var(--brand-500));
  background: color-mix(in srgb, var(--fs, var(--brand-500)) 18%, #fff);
  color: var(--brand-900);
}
.checkcard input { width: 18px; height: 18px; min-height: 0; flex-shrink: 0; accent-color: var(--brand-600); }

/* Pie de formulario */
.form-footer, .form-actions {
  display: flex; gap: .6rem; justify-content: flex-end; align-items: center; flex-wrap: wrap;
  margin-top: 1.7rem; padding-top: 1.25rem; border-top: 1px solid var(--border);
}
.form-footer .hint { margin-right: auto; font-size: .78rem; color: var(--text-mute); display: flex; align-items: center; gap: .4rem; }
.form-footer .hint svg { width: 15px; height: 15px; }

/* input con "ojo" para contraseña */
.pass-wrap { position: relative; }
.pass-wrap input { padding-right: 2.6rem; }
.pass-toggle {
  position: absolute; right: .5rem; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; color: var(--text-mute);
  padding: .3rem; border-radius: 6px; display: grid; place-items: center;
}
.pass-toggle:hover { color: var(--brand-600); background: var(--surface-2); }
.pass-toggle svg { width: 19px; height: 19px; }

/* ------------------------------- Alertas / flash ------------------------------- */
.flash { position: fixed; top: 1rem; right: 1rem; z-index: 100; display: flex; flex-direction: column; gap: .5rem; max-width: 360px; }
.alert { padding: .8rem 1rem; border-radius: var(--radius-sm); font-size: .88rem; display: flex; align-items: center; gap: .6rem; box-shadow: var(--shadow-md); animation: slidein .3s ease; }
.alert svg { width: 20px; height: 20px; flex-shrink: 0; }
.alert-success { background: #eafaf1; color: var(--green-600); border-left: 4px solid var(--green-600); }
.alert-error { background: #fdecea; color: var(--red-600); border-left: 4px solid var(--red-600); }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ------------------------------- Toolbar listados ------------------------------- */
.toolbar { display: flex; align-items: center; gap: .75rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.search { position: relative; flex: 1; max-width: 380px; }
.search svg { position: absolute; left: .65rem; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--text-mute); }
.search input { padding-left: 2.3rem; }

/* Descripción listado / ficha */
.dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .9rem 1.5rem; }
.dl div { display: flex; flex-direction: column; }
.dl dt { font-size: .74rem; text-transform: uppercase; letter-spacing: .5px; color: var(--text-mute); font-weight: 700; }
.dl dd { margin: 0; font-size: .95rem; color: var(--text); }

/* Tabs */
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; flex-wrap: wrap; }
.tabs a { padding: .6rem .95rem; font-weight: 600; color: var(--text-soft); border-bottom: 3px solid transparent; }
.tabs a.active { color: var(--brand-600); border-bottom-color: var(--brand-600); }

.muted { color: var(--text-mute); }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.row-split { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }

/* Totales */
.totales { margin-left: auto; max-width: 340px; }
.totales .line { display: flex; justify-content: space-between; padding: .35rem 0; }
.totales .line.total { border-top: 2px solid var(--border-2); margin-top: .3rem; padding-top: .6rem; font-size: 1.15rem; font-weight: 800; color: var(--brand-900); }

/* ------------------------------- Responsive ------------------------------- */
@media (max-width: 980px) {
  .navtoggle { display: grid; }
  .topnav__inner { flex-wrap: wrap; }
  .mainnav {
    display: none; order: 3; flex-basis: 100%;
    flex-direction: column; align-items: stretch; gap: .15rem;
    padding: .5rem 0 .6rem; margin-top: .5rem;
    border-top: 1px solid rgba(255,255,255,.12);
  }
  .mainnav.open { display: flex; }
  .navlink, .navgroup__btn { width: 100%; justify-content: flex-start; }
  .navgroup__btn .chev { margin-left: auto; }
  .navgroup__menu {
    position: static; display: none; min-width: 0; width: 100%;
    background: rgba(255,255,255,.06); border: none; box-shadow: none;
    border-radius: var(--radius-sm); margin: .1rem 0 .4rem; padding: .25rem;
  }
  .navgroup.open .navgroup__menu { display: block; animation: none; }
  .navgroup__menu a { color: #dbe6f1; }
  .navgroup__menu a svg { color: var(--accent-400); }
  .navgroup__menu a:hover { background: rgba(255,255,255,.1); }
  .navgroup__menu a.active { background: var(--brand-600); color: #fff; }
  .navuser .meta { display: none; }
  .field.col-2 { grid-column: span 1; }
  /* Formularios: los campos estrechos pasan a media fila */
  .fgrid > .sp-2, .fgrid > .sp-3, .fgrid > .sp-4, .fgrid > .sp-5 { grid-column: span 6; }
  .fgrid > .sp-7, .fgrid > .sp-8, .fgrid > .sp-9, .fgrid > .sp-10 { grid-column: span 12; }
}

@media (max-width: 640px) {
  .modgrid { grid-template-columns: repeat(2, 1fr); gap: .75rem; }
  .modtile { min-height: 148px; padding: 1.15rem .7rem 1rem; gap: .6rem; }
  .modtile__icon { width: 54px; height: 54px; border-radius: 15px; }
  .modtile__icon svg { width: 26px; height: 26px; }
  .modtile b { font-size: .88rem; }
  .modtile small { display: none; }
  .content { padding: 1rem .8rem; }
  .brand__text span { display: none; }
  .totales { max-width: none; }
  /* Formularios a una sola columna */
  .fgrid > .field { grid-column: span 12; }
  .segmented { display: flex; width: 100%; }
  .segmented label { flex: 1; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
