/* =====================================================================
   Plexoraid ERP · hoja de estilos
   Tokens tomados de la web corporativa (cinta azul sobre tinta).
   ===================================================================== */
@font-face { font-family: "Lexend"; src: url(../fonts/lexend.woff2) format("woff2"); font-weight: 100 900; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215; }
@font-face { font-family: "Lexend"; src: url(../fonts/lexend-ext.woff2) format("woff2"); font-weight: 100 900; font-display: swap; unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Instrument Sans"; src: url(../fonts/instrument.woff2) format("woff2"); font-weight: 400 700; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215; }
@font-face { font-family: "Instrument Sans"; src: url(../fonts/instrument-ext.woff2) format("woff2"); font-weight: 400 700; font-display: swap; unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF; }

:root {
  --cinta: linear-gradient(115deg, #A3DAFC 0%, #5DB0FF 45%, #2A8CFF 70%, #0B3EB8 100%);
  --f-display: "Lexend", ui-sans-serif, system-ui, sans-serif;
  --f-ui: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --r-s: 6px; --r-m: 10px; --r-l: 14px;
  --side-w: 252px;
  --ok: #3DD68C; --warn: #F5B544; --bad: #FF6B6B; --info: #5DB0FF;
}
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #061131;          /* tinta */
  --surface: #0A1B47;     /* abismo */
  --surface-2: #0D2257;
  --sunken: #050E29;
  --line: #1B2D5E;        /* linea */
  --line-soft: #13244F;
  --text: #E8F1FB;        /* niebla */
  --muted: #97A9C9;       /* bruma */
  --accent: #2A8CFF;      /* azul */
  --accent-strong: #A3DAFC;
  --accent-ink: #061131;
  --focus: #A3DAFC;
  --row-hover: #0E2459;
}
[data-theme="light"] {
  color-scheme: light;
  --bg: #F2F6FC;
  --surface: #FFFFFF;
  --surface-2: #F7FAFE;
  --sunken: #E9F0FA;
  --line: #D5E0F0;
  --line-soft: #E6EDF7;
  --text: #0A1B47;
  --muted: #52658C;
  --accent: #0B3EB8;      /* real */
  --accent-strong: #0B3EB8;
  --accent-ink: #FFFFFF;
  --focus: #0B3EB8;
  --row-hover: #F0F5FD;
  --ok: #138A55; --warn: #A86A00; --bad: #C93434; --info: #0B5FD6;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 15px/1.5 var(--f-ui); font-feature-settings: "ss01", "cv11"; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { font-family: var(--f-display); font-weight: 500; letter-spacing: -0.015em; margin: 0; line-height: 1.2; text-wrap: balance; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: 0 0 .75em; text-wrap: pretty; }
a { color: var(--accent-strong); text-decoration: none; }
[data-theme="light"] a { color: var(--accent); }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--accent); color: var(--accent-ink); }
.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sr, .skip:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip:focus { position: fixed; z-index: 99; top: 8px; left: 8px; background: var(--surface); padding: 8px 12px; border-radius: var(--r-s); }
.num, td.num, th.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.dim { color: var(--muted); }
kbd { font: 500 11px/1 var(--f-ui); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 2px 5px; color: var(--muted); background: var(--sunken); }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
[hidden] { display: none !important; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--sunken); border-right: 1px solid var(--line); z-index: 40; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 12px; }
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--text); }
.brand:hover { text-decoration: none; }
.wordmark { font: 600 1.18rem/1 var(--f-display); letter-spacing: -0.03em; }
.wordmark span { color: var(--text); } .wordmark b { font-weight: 600; color: #2A8CFF; }
.brand-tag { font: 500 11px/1 var(--f-display); color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 3px 7px; }
[data-theme="dark"] .brand-light, [data-theme="light"] .brand-dark { display: none; }

.company { display: flex; align-items: center; gap: 10px; margin: 0 12px 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-m); background: var(--surface); }
.company-mark { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; font: 600 12px/1 var(--f-display); background: var(--cinta); color: #061131; flex: none; }
.company select { flex: 1; min-width: 0; background: transparent; border: 0; color: var(--text); font: 500 14px var(--f-ui); padding: 2px 0; cursor: pointer; }
.company select option { background: var(--surface); }
.company-name { font-weight: 500; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.menu-filter { position: relative; margin: 0 12px 6px; }
.menu-filter .i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted); }
.menu-filter input[type=search] { width: 100%; padding: 7px 10px 7px 32px; border-radius: var(--r-s); border: 1px solid transparent; background: transparent; color: var(--text); font: 14px var(--f-ui); }
.menu-filter input:hover { border-color: var(--line); }
.menu-filter input:focus { border-color: var(--accent); background: var(--surface); outline: none; }

.menu { overflow-y: auto; padding: 4px 8px 24px; flex: 1; scrollbar-width: thin; }
.menu-group { margin-top: 6px; }
.menu-group-title { all: unset; box-sizing: border-box; display: flex; width: 100%; align-items: center; justify-content: space-between; padding: 8px 10px 4px; font: 500 12.5px/1.2 var(--f-display); color: var(--muted); cursor: pointer; border-radius: var(--r-s); }
.menu-group-title .i { width: 14px; height: 14px; transition: transform .15s; }
.menu-group-title:focus-visible { outline: 2px solid var(--focus); }
.menu-group[data-collapsed] ul { display: none; }
.menu-group[data-collapsed] .menu-group-title .i { transform: rotate(-90deg); }
.menu ul { list-style: none; margin: 0; padding: 0; }
.menu a { position: relative; display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--r-s); color: var(--text); font-size: 14px; opacity: .86; }
.menu a .i { color: var(--muted); }
.menu a:hover { background: var(--surface); text-decoration: none; opacity: 1; }
.menu a.active { background: var(--surface); opacity: 1; font-weight: 500; }
.menu a.active .i { color: var(--accent-strong); }
[data-theme="light"] .menu a.active .i { color: var(--accent); }
/* La cinta del logotipo marca dónde estás */
.menu a.active::before { content: ""; position: absolute; left: -8px; top: 6px; bottom: 6px; width: 3px; border-radius: 0 3px 3px 0; background: var(--cinta); }
.menu-empty { font-size: 13px; color: var(--muted); padding: 10px; }

.main-col { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; padding: 10px 28px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line-soft); }
.omni-trigger { flex: 1; max-width: 560px; display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--r-m); background: var(--surface); color: var(--muted); font: 14px var(--f-ui); cursor: text; text-align: left; }
.omni-trigger span { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.omni-trigger:hover { border-color: var(--accent); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-s); border: 1px solid transparent; background: transparent; color: var(--text); cursor: pointer; }
.icon-btn:hover { background: var(--surface); border-color: var(--line); }
[data-theme="dark"] .when-light, [data-theme="light"] .when-dark { display: none; }
.usermenu { position: relative; }
.usermenu summary { list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 4px 8px 4px 4px; border-radius: 999px; font-size: 14px; }
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu summary:hover { background: var(--surface); }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font: 600 12px var(--f-display); background: var(--surface-2); border: 1px solid var(--line); }
.usermenu-pop { position: absolute; right: 0; top: calc(100% + 6px); width: 250px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); padding: 6px; box-shadow: 0 18px 40px -12px rgba(0,0,0,.45); }
.usermenu-who { display: grid; gap: 2px; padding: 8px 10px 10px; margin: 0 0 4px; border-bottom: 1px solid var(--line); font-size: 13px; }
.usermenu-who span { color: var(--muted); }
.usermenu-pop a, .usermenu-pop button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-s); color: var(--text); font: 14px var(--f-ui); background: none; border: 0; cursor: pointer; text-align: left; }
.usermenu-pop a:hover, .usermenu-pop button:hover { background: var(--surface-2); text-decoration: none; }
.usermenu-pop form { margin: 0; }

.content { padding: 24px 28px 64px; max-width: 1480px; width: 100%; }
.content:focus { outline: none; }
.scrim { display: none; }
.only-mobile { display: none; }

/* ---------- Encabezado de página ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 20px; margin-bottom: 20px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 6px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.crumbs a { color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions form { margin: 0; }

/* ---------- Botones ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 14px; border-radius: var(--r-s); border: 1px solid var(--line); background: var(--surface); color: var(--text); font: 500 14px/1.2 var(--f-ui); cursor: pointer; white-space: nowrap; text-decoration: none !important; }
.btn .i { width: 16px; height: 16px; }
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--cinta); background-size: 140% 100%; border-color: transparent; color: #061131; }
.btn-primary:hover { filter: brightness(1.08); border-color: transparent; }
[data-theme="light"] .btn-primary { background: var(--accent); color: #fff; }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--bad); }
.btn-danger:hover { border-color: var(--bad); }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent-strong); font: inherit; cursor: pointer; }
[data-theme="light"] .link-btn { color: var(--accent); }
.link-btn:hover { text-decoration: underline; }

/* ---------- Paneles ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line-soft); }
.panel-head h2 { font-size: 1rem; }
.panel-head .dim { font-size: 13px; }
.panel-body { padding: 18px; }
.panel-body.flush { padding: 0; }
.stack { display: grid; gap: 20px; }
.cols-2 { display: grid; gap: 20px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { display: grid; gap: 20px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-main { display: grid; gap: 20px; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); align-items: start; }

/* KPIs: tira continua, no tarjetas sueltas */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); overflow: hidden; }
.kpi { padding: 16px 18px; border-right: 1px solid var(--line-soft); min-width: 0; }
.kpi:last-child { border-right: 0; }
.kpi-label { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi-label .i { width: 15px; height: 15px; }
.kpi-value { font: 500 1.5rem/1.2 var(--f-display); letter-spacing: -0.02em; margin-top: 6px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.kpi a { color: inherit; }
.up { color: var(--ok); } .down { color: var(--bad); }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
.t th { text-align: left; font: 500 12.5px/1.3 var(--f-ui); color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface); position: sticky; top: 0; }
.t th a { color: inherit; display: inline-flex; gap: 4px; align-items: center; }
.t th a .i { width: 12px; height: 12px; }
.t td { padding: 10px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.t tbody tr:hover { background: var(--row-hover); }
.t tbody tr:last-child td { border-bottom: 0; }
.t td.actions-cell { text-align: right; white-space: nowrap; width: 1%; }
.t .row-link { color: var(--text); font-weight: 500; }
.t tfoot td { font-weight: 600; border-top: 1px solid var(--line); }
.t .sub { display: block; font-size: 12.5px; color: var(--muted); font-weight: 400; }
.t-compact td, .t-compact th { padding: 7px 12px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line-soft); }
.toolbar .search { position: relative; flex: 1 1 240px; max-width: 380px; }
.toolbar .search .i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted); }
.toolbar .search input { padding-left: 32px; }
.toolbar select, .toolbar input[type=date] { width: auto; }
.toolbar .count { margin-left: auto; font-size: 13px; color: var(--muted); }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--line-soft); font-size: 13px; color: var(--muted); }
.pager .actions { gap: 6px; }

/* ---------- Formularios ---------- */
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px 16px; }
.fg { grid-column: span 12; display: grid; gap: 6px; align-content: start; }
.fg.half { grid-column: span 6; } .fg.third { grid-column: span 4; } .fg.quarter { grid-column: span 3; } .fg.two-thirds { grid-column: span 8; }
.form-section { grid-column: span 12; font: 500 .95rem var(--f-display); padding-top: 10px; margin-top: 4px; border-top: 1px solid var(--line-soft); }
.form-section:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
label, .label { font-size: 13px; font-weight: 500; color: var(--muted); }
.req { color: var(--bad); }
input:not([type]), input[type=text], input[type=email], input[type=tel], input[type=url], input[type=number], input[type=password], input[type=date], input[type=search], input[type=datetime-local], select, textarea {
  width: 100%; padding: 8px 11px; border-radius: var(--r-s); border: 1px solid var(--line); background: var(--sunken); color: var(--text); font: 14px/1.4 var(--f-ui);
}
[data-theme="light"] :is(input, select, textarea):not([type=checkbox]):not([type=radio]) { background: #fff; }
textarea { min-height: 90px; resize: vertical; }
:is(input, select, textarea):focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
:is(input, select, textarea)[readonly] { opacity: .7; }
.help { font-size: 12.5px; color: var(--muted); }
.err { font-size: 12.5px; color: var(--bad); }
.has-err :is(input, select, textarea) { border-color: var(--bad); }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text); font-weight: 400; cursor: pointer; padding: 6px 0; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.form-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--line-soft); }

/* ---------- Badges, avisos ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; font: 500 12px/1 var(--f-ui); padding: 4px 8px; border-radius: 999px; border: 1px solid currentColor; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-ok { color: var(--ok); } .badge-warn { color: var(--warn); } .badge-bad { color: var(--bad); } .badge-info { color: var(--info); }
.badge-neutral { color: var(--muted); } .badge-muted { color: var(--muted); opacity: .7; }
.flash { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--r-m); border: 1px solid var(--line); background: var(--surface); margin-bottom: 16px; font-size: 14px; }
.flash span { flex: 1; }
.flash-ok .i:first-child { color: var(--ok); } .flash-error { border-color: color-mix(in srgb, var(--bad) 50%, var(--line)); } .flash-error .i:first-child { color: var(--bad); }
.flash-info .i:first-child { color: var(--info); }
.flash-x { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 2px; display: grid; }
.note { padding: 12px 14px; border-radius: var(--r-m); background: var(--surface-2); border: 1px dashed var(--line); font-size: 14px; color: var(--muted); }
.note b { color: var(--text); font-weight: 600; }
.note-warn { border-style: solid; border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }

/* ---------- Estados vacíos ---------- */
.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-state h2, .empty-state h1 { color: var(--text); margin-bottom: 8px; }
.empty-state .actions { justify-content: center; margin-top: 14px; }
.error-state { max-width: 520px; margin: 40px auto; }
.err-code { font: 600 4rem/1 var(--f-display); letter-spacing: -0.04em; background: var(--cinta); -webkit-background-clip: text; background-clip: text; color: transparent; margin-bottom: 8px; }

/* ---------- Ficha 360 ---------- */
.profile { display: flex; gap: 16px; align-items: center; }
.profile-mark { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; font: 600 18px var(--f-display); background: var(--surface-2); border: 1px solid var(--line); flex: none; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; font-size: 14px; }
.dl dt { color: var(--muted); } .dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding: 0 10px; overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 12px 12px 10px; color: var(--muted); font: 500 14px var(--f-ui); cursor: pointer; white-space: nowrap; }
.tabs button[aria-selected=true] { color: var(--text); border-bottom-color: var(--accent); }
.tabs .count { font-size: 12px; color: var(--muted); margin-left: 4px; }
.timeline { list-style: none; padding: 0; margin: 0; display: grid; gap: 0; }
.timeline li { display: grid; grid-template-columns: 28px 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.timeline li:last-child { border-bottom: 0; }
.timeline .tl-icon { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line); }
.timeline .tl-icon .i { width: 14px; height: 14px; }
.timeline .tl-meta { font-size: 12.5px; color: var(--muted); }
.timeline p { margin: 2px 0 0; white-space: pre-wrap; }

/* ---------- Gráfico de barras (SVG del servidor) ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart .bar { fill: var(--accent); opacity: .85; }
.chart .bar-2 { fill: var(--muted); opacity: .45; }
.chart .bar:hover { opacity: 1; }
.chart text { fill: var(--muted); font: 11px var(--f-ui); }
.chart .grid { stroke: var(--line-soft); stroke-width: 1; }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.meter { height: 6px; border-radius: 6px; background: var(--sunken); overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--cinta); }

/* ---------- Editor de documentos ---------- */
.doc-lines td { padding: 6px 6px; vertical-align: top; }
.doc-lines th { padding: 8px 6px; }
.doc-lines input { padding: 7px 8px; }
.doc-lines .c-desc { min-width: 260px; }
.doc-lines .c-num { width: 104px; } .doc-lines .c-pct { width: 78px; } .doc-lines .c-tot { width: 120px; text-align: right; padding-top: 14px; font-variant-numeric: tabular-nums; }
.doc-lines .c-x { width: 40px; }
.doc-lines input.n { text-align: right; font-variant-numeric: tabular-nums; }
.ac { position: relative; }
.ac-list { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); box-shadow: 0 18px 40px -12px rgba(0,0,0,.5); max-height: 280px; overflow-y: auto; padding: 4px; }
.ac-item { display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: var(--r-s); background: none; border: 0; color: var(--text); font: 14px var(--f-ui); cursor: pointer; }
.ac-item small { display: block; color: var(--muted); font-size: 12.5px; }
.ac-item:hover, .ac-item[aria-selected=true] { background: var(--surface-2); }
.totals { display: grid; grid-template-columns: 1fr auto; gap: 6px 24px; font-size: 14px; min-width: 280px; margin-left: auto; }
.totals dt { color: var(--muted); } .totals dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.totals .grand { font: 600 1.25rem var(--f-display); color: var(--text); padding-top: 8px; border-top: 1px solid var(--line); }
.doc-status { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------- Buscador global (el ojo) ---------- */
.omni { position: fixed; inset: 0; z-index: 100; background: rgba(3, 8, 26, .62); backdrop-filter: blur(3px); display: flex; justify-content: center; align-items: flex-start; padding: 10vh 16px 16px; }
.omni-box { width: 100%; max-width: 680px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); overflow: hidden; box-shadow: 0 30px 80px -20px rgba(0,0,0,.6); position: relative; }
.omni-box::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 2px; background: var(--cinta); }
.omni-input { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.omni-input .i { width: 20px; height: 20px; color: var(--accent-strong); }
[data-theme="light"] .omni-input .i { color: var(--accent); }
.omni-input input { border: 0 !important; background: transparent !important; box-shadow: none !important; font-size: 17px; padding: 4px 0; }
.omni-results { max-height: 60vh; overflow-y: auto; padding: 6px; }
.omni-hint { color: var(--muted); font-size: 13.5px; padding: 14px 12px; margin: 0; }
.omni-group { font: 500 12.5px var(--f-display); color: var(--muted); padding: 10px 12px 4px; }
.omni-item { display: flex; gap: 12px; align-items: center; padding: 9px 12px; border-radius: var(--r-s); color: var(--text); }
.omni-item:hover { text-decoration: none; }
.omni-item[aria-selected=true] { background: var(--surface-2); outline: 1px solid var(--line); }
.omni-item .i { color: var(--muted); }
.omni-item b { font-weight: 500; display: block; }
.omni-item small { color: var(--muted); font-size: 12.5px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.omni-item > span { min-width: 0; }
.result-groups { display: grid; gap: 20px; }

/* ---------- Asistente ---------- */
.chat { display: grid; gap: 14px; }
.msg { padding: 14px 16px; border-radius: var(--r-m); border: 1px solid var(--line); background: var(--surface); white-space: pre-wrap; line-height: 1.6; }
.msg-user { background: var(--surface-2); margin-left: 15%; }
.msg-meta { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Acceso ---------- */
body.bare { min-height: 100vh; display: grid; place-items: center; background:
  radial-gradient(1200px 600px at 85% -10%, color-mix(in srgb, #2A8CFF 18%, transparent), transparent 60%), var(--bg); }
.bare-main { width: 100%; max-width: 420px; padding: 32px 20px; display: grid; gap: 20px; }
.brand-lg .wordmark { font-size: 1.5rem; }
.auth-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); padding: 26px; display: grid; gap: 16px; }
.auth-card h1 { font-size: 1.35rem; }
.auth-card p { color: var(--muted); margin: 0; font-size: 14px; }
.auth-card .btn { width: 100%; padding: 10px 14px; }
.auth-foot { text-align: center; font-size: 12.5px; color: var(--muted); }
.code-input { font: 500 1.6rem/1 var(--f-display) !important; letter-spacing: .4em; text-align: center; }

/* Matriz de permisos */
.perm-group { border-top: 1px solid var(--line-soft); padding: 12px 0; display: grid; grid-template-columns: 200px 1fr; gap: 10px; }
.perm-group:first-child { border-top: 0; }
.perm-group h3 { font-size: 14px; font-weight: 500; padding-top: 6px; }
.perm-opts { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.module-list { display: grid; gap: 0; }
.module-list label { display: grid; grid-template-columns: 24px 1fr; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line-soft); color: var(--text); font-size: 14px; cursor: pointer; }
.module-list label:last-child { border-bottom: 0; }
.module-list small { display: block; color: var(--muted); font-weight: 400; font-size: 13px; margin-top: 2px; }
.qr { background: #fff; padding: 12px; border-radius: var(--r-m); display: inline-block; line-height: 0; }
.qr img, .qr svg { width: 180px; height: 180px; }
.secret { font: 500 14px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; padding: 8px 10px; background: var(--sunken); border-radius: var(--r-s); border: 1px solid var(--line); }
.token-box { display: flex; gap: 8px; align-items: center; }
.token-box code { flex: 1; }
.clock { font: 500 2.6rem/1 var(--f-display); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .cols-main, .cols-3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; left: 0; top: 0; width: min(86vw, 300px); transform: translateX(-100%); transition: transform .2s ease; }
  body.side-open .side { transform: none; box-shadow: 20px 0 60px rgba(0,0,0,.45); }
  body.side-open .scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(3,8,26,.5); }
  .only-mobile { display: inline-grid; }
  .top { padding: 10px 14px; }
  .content { padding: 18px 14px 56px; }
  .cols-2 { grid-template-columns: minmax(0, 1fr); }
  .fg.half, .fg.third, .fg.two-thirds { grid-column: span 12; }
  .fg.quarter { grid-column: span 6; }
  .perm-group { grid-template-columns: 1fr; }
  .omni-trigger kbd { display: none; }
}
@media (max-width: 560px) {
  .hide-sm { display: none !important; }
  .kpi { border-right: 0; border-bottom: 1px solid var(--line-soft); }
  .msg-user { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* ---------- Impresión (factura en PDF desde el navegador) ---------- */
.print-body { margin: 0; background: #E9F0FA; min-height: 100vh; }
.print-doc { box-sizing: border-box; width: calc(100% - 32px); background: #fff; color: #0A1B47; max-width: 860px; margin: 24px auto; padding: 48px; border-radius: 8px; font-size: 13.5px; }
.print-doc h1 { font-size: 1.6rem; color: #0A1B47; }
.print-doc .pd-head { display: flex; justify-content: space-between; gap: 30px; margin-bottom: 30px; }
.print-doc .pd-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; margin-bottom: 26px; }
.print-doc .pd-box { border-top: 2px solid #0B3EB8; padding-top: 10px; }
.print-doc .pd-label { font-size: 12px; color: #52658C; margin-bottom: 4px; }
.print-doc table { width: 100%; border-collapse: collapse; }
.print-doc th { text-align: left; font-size: 12px; color: #52658C; border-bottom: 1px solid #C9D6EA; padding: 8px 6px; font-weight: 500; }
.print-doc td { border-bottom: 1px solid #E6EDF7; padding: 8px 6px; vertical-align: top; }
.print-doc .pd-totals { display: flex; justify-content: flex-end; margin-top: 18px; }
.print-doc .pd-totals dl { display: grid; grid-template-columns: auto auto; gap: 6px 30px; margin: 0; }
.print-doc .pd-totals dt { color: #52658C; } .print-doc .pd-totals dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.print-doc .pd-grand { font: 600 1.15rem var(--f-display); border-top: 2px solid #0A1B47; padding-top: 6px; }
.print-doc .pd-foot { margin-top: 36px; font-size: 12px; color: #52658C; white-space: pre-wrap; }
.print-bar { display: flex; justify-content: center; gap: 10px; margin: 20px; }
@media print {
  @page { margin: 14mm; }
  body, body.bare, .print-body { background: #fff !important; display: block; }
  .print-doc { width: 100%; }
  .print-bar, .skip { display: none !important; }
  .print-doc { margin: 0; padding: 0; max-width: none; border-radius: 0; }
}
.i.flip { transform: rotate(180deg); }
.usermenu summary.btn { border-radius: var(--r-s); padding: 8px 14px; font-size: 14px; }
.usermenu summary.btn:hover { background: var(--surface); }
.usermenu-pop .btn-danger { color: var(--bad); }

.t .nowrap, .t .row-link.code { white-space: nowrap; }
.toolbar .search input[type=search] { padding-left: 32px; }
.omni-input input::-webkit-search-cancel-button { display: none; }
.stack > *, .cols-2 > *, .cols-3 > *, .cols-main > *, .form-grid > * { min-width: 0; }
.omni-trigger { min-width: 0; }
@media (max-width: 560px) { .omni-trigger span { font-size: 13px; } .top { gap: 6px; } }

/* ---------- Barra de herramientas y menús de acciones ---------- */
.tool-group { display: inline-flex; align-items: stretch; border: 1px solid var(--line); border-radius: var(--r-s); background: var(--surface); }
.tool-group > form { display: flex; }
.tool-group > * + * { border-left: 1px solid var(--line); }
.tool { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 12px; background: transparent; border: 0; color: var(--text); font: 500 14px/1 var(--f-ui); cursor: pointer; text-decoration: none !important; list-style: none; white-space: nowrap; }
.tool::-webkit-details-marker { display: none; }
.tool .i { width: 17px; height: 17px; }
.tool:hover { background: var(--surface-2); }
.tool[aria-busy=true] { opacity: .55; pointer-events: none; }
.tool-group .tool { border-radius: 0; }
.tool-group > :first-child .tool, .tool-group > .tool:first-child { border-radius: var(--r-s) 0 0 var(--r-s); }
.tool-group > :last-child > .tool, .tool-group > .tool:last-child { border-radius: 0 var(--r-s) var(--r-s) 0; }
.row-tools { display: inline-flex; gap: 2px; justify-content: flex-end; }
.tool-sm { height: 30px; width: 30px; padding: 0; border-radius: var(--r-s); color: var(--muted); }
.tool-sm:hover { color: var(--text); }
.dropdown { position: relative; }
.dropdown[open] > summary { background: var(--surface-2); color: var(--text); }
.dropdown-pop { z-index: 90; min-width: 210px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); padding: 6px; box-shadow: 0 18px 40px -12px rgba(0,0,0,.45); text-align: left; }
.dropdown-pop form { margin: 0; }
.dropdown-pop a, .dropdown-pop button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-s); color: var(--text); font: 14px var(--f-ui); background: none; border: 0; cursor: pointer; text-align: left; white-space: nowrap; text-decoration: none !important; }
.dropdown-pop .i { width: 16px; height: 16px; color: var(--muted); }
.dropdown-pop a:hover, .dropdown-pop button:hover, .dropdown-pop a:focus-visible, .dropdown-pop button:focus-visible { background: var(--surface-2); }
.dropdown-pop .danger, .dropdown-pop .danger .i { color: var(--bad); }
.print-frame { position: fixed; right: 0; bottom: 0; width: 0; height: 0; border: 0; visibility: hidden; }
.toast { position: fixed; z-index: 200; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: var(--r-m); font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.3); transition: opacity .3s; max-width: calc(100vw - 32px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast.out { opacity: 0; }
@media (max-width: 700px) { .tool-group .tool span { display: none; } .tool-group .tool { padding: 0 11px; } }

/* ---------- Imprimir cualquier pantalla del ERP (listados, informes…) ---------- */
@media print {
  .side, .top, .scrim, .omni, .flash, .actions, .toolbar button, .toolbar .btn, .pager .actions, .row-tools, .actions-cell, .tabs, .skip, .menu-filter, .form-foot { display: none !important; }
  .shell { display: block; }
  .content { padding: 0; max-width: none; }
  body:not(.print-body) { background: #fff !important; color: #000; }
  .panel, .kpis { border-color: #ccc; background: #fff; break-inside: avoid-page; }
  .t th { position: static; background: #fff; color: #333; }
  .t td, .t th { border-color: #ddd; color: #000; }
  a { color: #000 !important; }
  .badge { border-color: #999; color: #333 !important; }
  .toolbar { padding: 0 0 8px; border: 0; }
  .toolbar .search, .toolbar select, .toolbar input { display: none; }
  .t tbody tr, .t tbody tr:hover { background: none !important; }
  .t tbody tr:hover td { color: #000; }
  .page-head h1 { color: #000; }
}
