/* Panel de gestión — Virtual Bit Universal Technology */

:root {
    --navy: #0B2D5B;
    --navy-2: #143D72;
    --navy-line: rgba(255, 255, 255, 0.08);
    --primary: #0A64A8;
    --primary-2: #084F86;
    --cyan: #00AAEF;
    --accent: #00C896;
    --accent-text: #007A5E;
    --bg: #F3F6FA;
    --card: #ffffff;
    --line: #e3e7ef;
    --text: #0B2D5B;
    --muted: #4F6A8F;
    --ok: #16794a;
    --ok-bg: #e5f6ed;
    --warn: #8a5300;
    --warn-bg: #fff3dd;
    --err: #b42318;
    --err-bg: #fdecea;
    --info: #0b5cad;
    --info-bg: #e6f0fb;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(11, 45, 91, 0.06), 0 4px 16px rgba(11, 45, 91, 0.05);
    --sidebar-w: 248px;
    --font-title: 'Montserrat', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); }
a:hover { color: var(--primary-2); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.88em; background: #eef1f7; padding: 0.1em 0.35em; border-radius: 5px; }

:focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; }

.skip-link { position: absolute; left: -9999px; top: 8px; z-index: 100; background: var(--navy); color: #fff; padding: 0.6rem 1rem; border-radius: 8px; }
.skip-link:focus { left: 8px; }

.icon { width: 20px; height: 20px; flex-shrink: 0; }

/* ---------- Estructura ---------- */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--navy);
    color: #C9D6E8;
    display: flex;
    flex-direction: column;
    z-index: 40;
}

.brand { display: flex; align-items: center; gap: 0.75rem; padding: 1.25rem 1.25rem 1.5rem; }
.brand-mark {
    width: 38px; height: 38px; border-radius: 10px;
    display: grid; place-items: center;
    font-weight: 800; font-size: 0.95rem; color: #fff; letter-spacing: 0.02em;
    background: linear-gradient(135deg, var(--cyan), var(--primary));
}
.brand-text { display: flex; flex-direction: column; font-weight: 700; color: #fff; line-height: 1.2; }
.brand-text small { font-weight: 500; color: #9FB3CF; font-size: 0.78rem; }

.nav { display: flex; flex-direction: column; gap: 2px; padding: 0 0.75rem; flex: 1; }
.nav-link {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.65rem 0.75rem; border-radius: 10px;
    color: #C9D6E8; text-decoration: none; font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease;
}
.nav-link:hover { background: var(--navy-2); color: #fff; }
.nav-link.is-active { background: rgba(0, 170, 239, 0.12); color: #fff; box-shadow: inset 3px 0 0 var(--cyan); }
.nav-link.is-active .icon { color: var(--cyan); }
.nav-count { margin-left: auto; background: var(--accent); color: var(--navy); font-size: 0.75rem; font-weight: 700; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; display: grid; place-items: center; }

.sidebar-foot { padding: 0.75rem; border-top: 1px solid var(--navy-line); }

.shell { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; gap: 1rem;
    padding: 0.85rem 2rem;
    background: rgba(243, 246, 250, 0.92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
}
.page-title { font-size: 1.3rem; font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.user-area { display: flex; align-items: center; gap: 0.5rem; }
.user-chip { display: flex; align-items: center; gap: 0.6rem; text-decoration: none; color: var(--text); padding: 0.3rem 0.6rem 0.3rem 0.3rem; border-radius: 999px; }
.user-chip:hover, .user-chip.is-active { background: #e6eaf3; color: var(--text); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff; background: linear-gradient(135deg, var(--navy), var(--primary)); }
.user-meta { display: flex; flex-direction: column; line-height: 1.15; }
.user-meta strong { font-size: 0.9rem; }
.user-meta small { color: var(--muted); font-size: 0.78rem; }

.icon-btn { width: 40px; height: 40px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { background: #e6eaf3; color: var(--text); }
.menu-toggle { display: none; }
.inline-form { display: inline; }

.content { padding: 1.75rem 2rem 3rem; flex: 1; width: 100%; max-width: 1280px; }
.app-footer { padding: 1rem 2rem 1.5rem; color: var(--muted); font-size: 0.82rem; }

.sidebar-backdrop { display: none; }

/* ---------- Bloques ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 1.5rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.1rem 1.5rem; border-bottom: 1px solid var(--line); }
.card-head h2 { font-size: 1.02rem; font-weight: 700; }
.card-head a { font-size: 0.88rem; font-weight: 600; text-decoration: none; }
.card-body { padding: 1.25rem 1.5rem; }
.card + .card, .grid + .card, .card + .grid, .toolbar + .card { margin-top: 1.25rem; }

.grid { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid > * { min-width: 0; }
.grid + .grid { margin-top: 1.25rem; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1.25rem; margin-bottom: 1.25rem; }
.kpi { padding: 1.25rem 1.4rem; position: relative; overflow: hidden; }
.kpi::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 3px; background: linear-gradient(90deg, var(--cyan), var(--accent)); }
.kpi-label { color: var(--muted); font-size: 0.85rem; font-weight: 600; }
.kpi-value { font-size: 1.9rem; font-weight: 800; line-height: 1.2; margin-top: 0.35rem; letter-spacing: -0.01em; }
.kpi-hint { color: var(--muted); font-size: 0.8rem; margin-top: 0.2rem; }
.kpi-hot .kpi-value { color: var(--accent-text); }

/* Embudo */
.funnel { display: grid; gap: 0.85rem; }
.funnel-row { display: grid; grid-template-columns: 110px 1fr 40px; align-items: center; gap: 0.75rem; text-decoration: none; color: var(--text); }
.funnel-row:hover .funnel-label { color: var(--primary); }
.funnel-label { font-weight: 600; font-size: 0.9rem; }
.funnel-track { height: 10px; background: #edf0f6; border-radius: 6px; overflow: hidden; }
.funnel-bar { display: block; height: 100%; width: 0; border-radius: 6px; background: var(--primary); transition: width 0.6s ease; }
.funnel-bar.is-nuevo { background: var(--accent); }
.funnel-bar.is-contactado { background: #0ea5c6; }
.funnel-bar.is-cotizado { background: #6d5bd0; }
.funnel-bar.is-ganado { background: #1f9d60; }
.funnel-bar.is-perdido { background: #9aa3b8; }
.funnel-num { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Listas simples */
.list { list-style: none; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.8rem 1.5rem; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list-main { min-width: 0; }
.list-main a, .list-main strong { font-weight: 600; text-decoration: none; color: var(--text); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-main a:hover { color: var(--primary); }
.list-sub { color: var(--muted); font-size: 0.83rem; }
.list-side { text-align: right; flex-shrink: 0; font-size: 0.85rem; color: var(--muted); }

.empty { padding: 2.5rem 1.5rem; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--text); font-size: 1.02rem; margin-bottom: 0.25rem; }

/* ---------- Barra de herramientas y filtros ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 1.25rem; }
.search { display: flex; gap: 0.5rem; flex: 1; max-width: 460px; }
.search input { flex: 1; }

.tabs { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1rem; }
.tab { padding: 0.45rem 0.9rem; border-radius: 999px; background: #fff; border: 1px solid var(--line); color: var(--muted); text-decoration: none; font-weight: 600; font-size: 0.86rem; }
.tab:hover { color: var(--text); border-color: #c9d0de; }
.tab.is-active { background: var(--navy); border-color: var(--navy); color: #fff; }
.tab-count { opacity: 0.7; margin-left: 0.25rem; font-weight: 500; }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table th { text-align: left; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 700; padding: 0.75rem 1rem; border-bottom: 1px solid var(--line); background: #fafbfd; white-space: nowrap; }
.table td { padding: 0.85rem 1rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #f8faff; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .nowrap { white-space: nowrap; }
.cell-title { font-weight: 600; color: var(--text); text-decoration: none; }
.cell-title:hover { color: var(--primary); }
.cell-sub { color: var(--muted); font-size: 0.84rem; }
.truncate { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 420px; color: var(--muted); }

/* ---------- Insignias ---------- */
.badge { display: inline-block; padding: 0.2rem 0.6rem; border-radius: 999px; font-size: 0.78rem; font-weight: 700; white-space: nowrap; background: #eef1f6; color: #4a5370; }
.badge-nuevo { background: #fff0e8; color: #c2410c; }
.badge-contactado { background: #e3f6fa; color: #0e7490; }
.badge-cotizado { background: #efebfd; color: #5b3fc4; }
.badge-ganado, .badge-entregado { background: var(--ok-bg); color: var(--ok); }
.badge-perdido, .badge-cancelado { background: #eef0f4; color: #687088; }
.badge-propuesta { background: #fff7e0; color: #8a5a00; }
.badge-en_desarrollo { background: #e6f0fb; color: #0b5cad; }
.badge-en_pruebas { background: #efebfd; color: #5b3fc4; }
.badge-soporte { background: #e3f6fa; color: #0e7490; }
.badge-pausado { background: #fdf0e6; color: #9a4b0b; }
.badge-admin { background: #e6f0fb; color: #0b5cad; }
.badge-editor { background: #eef1f6; color: #4a5370; }
.badge-inactivo { background: var(--err-bg); color: var(--err); }

/* ---------- Formularios ---------- */
.form { display: grid; gap: 1rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.25rem; }
.form-grid .span-2 { grid-column: span 2; }
.field { display: grid; gap: 0.35rem; }
.field > span { font-weight: 600; font-size: 0.88rem; }
.field small { color: var(--muted); font-size: 0.8rem; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=url], input[type=date], input[type=search], select, textarea {
    width: 100%;
    font: inherit;
    color: var(--text);
    background: #fff;
    border: 1px solid #cfd5e2;
    border-radius: 10px;
    padding: 0.62rem 0.8rem;
    min-height: 42px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(10, 100, 168, 0.15); }
.check { display: flex; align-items: center; gap: 0.5rem; font-weight: 500; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.form-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
.form-actions .spacer { flex: 1; }

/* ---------- Botones ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
    min-height: 42px; padding: 0.55rem 1.1rem;
    border-radius: 10px; border: 1px solid transparent;
    font: inherit; font-weight: 600; font-size: 0.92rem;
    text-decoration: none; cursor: pointer; white-space: nowrap;
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.btn .icon { width: 18px; height: 18px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-2); color: #fff; }
.btn-secondary { background: #fff; color: var(--text); border-color: #cfd5e2; }
.btn-secondary:hover { border-color: #aab3c6; color: var(--text); background: #fafbfd; }
.btn-danger { background: #fff; color: var(--err); border-color: #f1c4bf; }
.btn-danger:hover { background: var(--err-bg); color: var(--err); }
.btn-whatsapp { background: #1fa855; color: #fff; }
.btn-whatsapp:hover { background: #178a45; color: #fff; }
.btn-sm { min-height: 34px; padding: 0.35rem 0.75rem; font-size: 0.85rem; }
.btn-block { width: 100%; }

/* ---------- Alertas ---------- */
.alert { padding: 0.85rem 1rem; border-radius: 10px; margin-bottom: 1rem; font-size: 0.92rem; border: 1px solid transparent; }
.alert-success { background: var(--ok-bg); color: var(--ok); border-color: #bfe6cf; }
.alert-error { background: var(--err-bg); color: var(--err); border-color: #f4c7c1; }
.alert-info { background: var(--info-bg); color: var(--info); border-color: #c4dbf3; }
.alert-warn { background: var(--warn-bg); color: var(--warn); border-color: #f1d9a8; }
.alert strong { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.05em; letter-spacing: 0.03em; user-select: all; }

/* ---------- Detalle ---------- */
.detail-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.detail-head h2 { font-size: 1.45rem; line-height: 1.25; }
.detail-head .meta { color: var(--muted); font-size: 0.88rem; margin-top: 0.2rem; }
.back { display: inline-flex; gap: 0.3rem; font-weight: 600; text-decoration: none; font-size: 0.9rem; margin-bottom: 0.75rem; }

.dl { display: grid; grid-template-columns: 130px 1fr; gap: 0.55rem 1rem; font-size: 0.92rem; }
.dl dt { color: var(--muted); font-weight: 600; }
.dl dd { min-width: 0; overflow-wrap: anywhere; }

.message-box { white-space: pre-wrap; overflow-wrap: anywhere; background: #f8f9fc; border: 1px solid var(--line); border-radius: 10px; padding: 1rem; font-size: 0.95rem; }

.contact-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }

.timeline { list-style: none; display: grid; gap: 0.9rem; }
.timeline li { border-left: 3px solid #d7deeb; padding: 0.15rem 0 0.15rem 0.9rem; }
.timeline .t-meta { color: var(--muted); font-size: 0.8rem; }
.timeline .t-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.93rem; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.mt { margin-top: 1rem; }
.section-title { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; margin: 1.5rem 0 0.6rem; }

.danger-zone { border-color: #f4d3cf; }
.danger-zone .card-head h2 { color: var(--err); }

.pagination { display: flex; justify-content: center; align-items: center; gap: 1rem; padding: 1rem; font-size: 0.9rem; color: var(--muted); }
.pagination a { font-weight: 600; text-decoration: none; }

/* ---------- Pantalla de acceso ---------- */
body.auth {
    min-height: 100vh;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 2rem 1rem;
    background: radial-gradient(1200px 600px at 10% -10%, rgba(0, 170, 239, 0.18), transparent 60%),
                radial-gradient(900px 500px at 110% 110%, rgba(0, 200, 150, 0.25), transparent 60%),
                var(--navy);
}
.auth-card { width: 100%; max-width: 410px; background: #fff; border-radius: 18px; padding: 2rem; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35); }
.brand-auth { padding: 0 0 1.25rem; }
.brand-auth .brand-text { color: var(--text); }
.brand-auth .brand-text small { color: var(--muted); }
.auth-title { font-size: 1.35rem; margin-bottom: 0.5rem; }
.auth-card .muted { margin-bottom: 1.1rem; }
.auth-card .form { margin-top: 1rem; }
.auth-foot { margin-top: 1.25rem; }
.auth-foot a { color: #b8c0dc; text-decoration: none; font-size: 0.9rem; }
.auth-foot a:hover { color: #fff; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
    .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-3 { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.25s ease; box-shadow: none; }
    body.nav-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, 0.35); }
    body.nav-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(10, 12, 24, 0.5); z-index: 35; }
    .shell { margin-left: 0; }
    .menu-toggle { display: grid; }
    .topbar { padding: 0.7rem 1rem; gap: 0.5rem; }
    .content { padding: 1.25rem 1rem 2.5rem; }
    .app-footer { padding: 1rem; }
    .user-meta { display: none; }
    .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 640px) {
    .kpis { gap: 0.75rem; }
    .kpi { padding: 1rem; }
    .kpi-value { font-size: 1.5rem; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .span-2 { grid-column: auto; }
    .dl { grid-template-columns: 1fr; gap: 0.1rem; }
    .dl dd { margin-bottom: 0.6rem; }
    .search { max-width: none; width: 100%; }
    .toolbar > .btn { width: 100%; }
    .card-head, .card-body, .card-pad { padding-left: 1rem; padding-right: 1rem; }
    .list li { padding: 0.8rem 1rem; }
    .funnel-row { grid-template-columns: 92px 1fr 32px; }

    /* Tablas como tarjetas en el celular */
    .table thead { display: none; }
    .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
    .table tr { padding: 0.75rem 1rem; border-bottom: 1px solid var(--line); }
    .table tr:last-child { border-bottom: 0; }
    .table td { border: 0; padding: 0.2rem 0; }
    .table td[data-label]::before { content: attr(data-label) ': '; color: var(--muted); font-size: 0.8rem; font-weight: 600; }
    .table td.num { text-align: left; }
    .truncate { max-width: none; }
}

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

/* Tarjetas de indicador enlazables */
a.kpi { text-decoration: none; color: inherit; transition: border-color 0.15s ease, transform 0.15s ease; }
a.kpi:hover { border-color: #b9c6dd; color: inherit; transform: translateY(-1px); }

/* Las tarjetas dentro de cuadrículas no llevan margen de apilado */
.kpis > .card, .grid > .card { margin-top: 0; }

/* Campañas */
.send-log { list-style: none; margin-top: 1rem; max-height: 320px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; background: #fafbfd; font-size: 0.86rem; }
.send-log li { padding: 0.45rem 0.8rem; border-bottom: 1px solid var(--line); display: flex; gap: 0.5rem; overflow-wrap: anywhere; }
.send-log li:last-child { border-bottom: 0; }
.send-log .ok::before { content: '✓'; color: var(--ok); font-weight: 700; }
.send-log .err::before { content: '✕'; color: var(--err); font-weight: 700; }
.send-log .info { color: var(--muted); }
.send-log .info::before { content: '•'; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.tips { padding-left: 1.1rem; display: grid; gap: 0.5rem; color: var(--muted); }

/* Alineación de campos y selector de archivo */
.form-grid { align-items: start; }
.field { align-content: start; }
input[type=file] { font: inherit; font-size: 0.9rem; padding: 0.55rem; border: 1px dashed #b9c3d6; border-radius: 10px; background: #fafbfd; width: 100%; cursor: pointer; }
input[type=file]::file-selector-button { font: inherit; font-weight: 600; margin-right: 0.75rem; padding: 0.4rem 0.9rem; border-radius: 8px; border: 1px solid #cfd5e2; background: #fff; cursor: pointer; }
.check { align-items: flex-start; }
.check input { margin-top: 0.2rem; flex-shrink: 0; }

/* Identidad Virtual Bit (oct 2026) */
h1, h2, h3, .brand-text, .kpi-value { font-family: var(--font-title); }
.brand-logo { width: 40px; height: 40px; display: block; flex: 0 0 auto; }
.brand-text small { font-family: var(--font); }

/* ---------- Cotizaciones (oct 2026) ---------- */
.badge-cot-borrador { background: #eef1f6; color: #4a5370; }
.badge-cot-enviada { background: #e6f0fb; color: #0b5cad; }
.badge-cot-aceptada { background: var(--ok-bg); color: var(--ok); }
.badge-cot-rechazada { background: #eef0f4; color: #687088; }
.badge-vencida { background: var(--warn-bg); color: var(--warn); }

.cot-form { display: grid; gap: 1.25rem; max-width: 980px; }
.cot-form .card + .card { margin-top: 0; }
.cot-form .card-body.form { display: grid; }
.items-tools { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.items-tools select { width: auto; min-width: 230px; min-height: 34px; padding: 0.3rem 0.6rem; font-size: 0.88rem; }

.items { display: grid; gap: 0.75rem; counter-reset: item; }
.item-row {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr) 80px 150px 120px 40px;
    gap: 0.75rem; align-items: start;
    padding: 0.85rem; border: 1px solid var(--line); border-radius: 12px; background: #fbfcfe;
}
.item-row:focus-within { border-color: #b9c6dd; background: #fff; }
.item-num { width: 28px; height: 28px; border-radius: 8px; background: var(--navy); color: #fff; font-weight: 700; font-size: 0.85rem; display: grid; place-items: center; margin-top: 7px; }
.item-main { display: grid; gap: 0.5rem; }
.item-main textarea { min-height: 62px; font-size: 0.9rem; }
.item-qty, .item-price { display: grid; gap: 0.3rem; }
.item-qty span, .item-price span, .item-total span { font-size: 0.75rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.item-qty input, .item-price input { text-align: right; font-variant-numeric: tabular-nums; }
.item-total { display: grid; gap: 0.3rem; text-align: right; }
.item-total strong { font-variant-numeric: tabular-nums; padding-top: 0.6rem; }
.item-del { margin-top: 2px; }
.item-del:hover { color: var(--err); background: var(--err-bg); }

.totals { margin: 1.25rem 0 0 auto; max-width: 380px; display: grid; gap: 0.5rem; }
.totals-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; font-size: 0.95rem; }
.totals-row > span, .totals-row > label:not(.check) { color: var(--muted); font-weight: 600; }
.totals-row strong { font-variant-numeric: tabular-nums; }
.totals-row input[type=text] { width: 160px; text-align: right; min-height: 38px; }
.totals-row .check { color: var(--muted); font-weight: 600; align-items: center; }
.totals-row .check input { margin-top: 0; }
.iva-pct { display: inline-flex; align-items: center; gap: 0.35rem; color: var(--muted); }
.totals-row .iva-pct input[type=text] { width: 64px; }
.totals-final { margin-top: 0.4rem; padding: 0.8rem 1rem; border-radius: 12px; background: var(--navy); color: #fff; box-shadow: inset 0 -3px 0 var(--accent); }
.totals-final > span { color: #C9D6E8 !important; }
.totals-final strong { font-family: var(--font-title); font-size: 1.3rem; }
.totals-static { margin-top: 0; }

.sticky-actions { position: sticky; bottom: 0; z-index: 5; padding: 0.85rem 1rem; background: rgba(243, 246, 250, 0.95); backdrop-filter: blur(6px); border-top: 1px solid var(--line); margin: 0 -1rem; }

.detail-side { display: flex; flex-direction: column; align-items: flex-end; gap: 0.35rem; }
.detail-total { font-family: var(--font-title); font-size: 1.5rem; line-height: 1.1; }
.stack { display: grid; gap: 0.6rem; }
.pre { white-space: pre-wrap; }
.file-name { font-family: var(--font); font-size: 1em; letter-spacing: 0; user-select: text; }
.btn-accept { background: var(--accent); color: var(--navy); }
.btn-accept:hover { background: #00b386; color: var(--navy); }
details.reject > summary { list-style: none; }
details.reject > summary::-webkit-details-marker { display: none; }
details.reject[open] > summary { background: #fafbfd; }

@media (max-width: 900px) {
    .item-row { grid-template-columns: 28px minmax(0, 1fr) 40px; }
    .item-row .item-main { grid-column: 2 / 3; }
    .item-row .item-del { grid-column: 3; grid-row: 1; }
    .item-row .item-qty, .item-row .item-price, .item-row .item-total { grid-column: 2 / 4; }
    .item-row .item-qty, .item-row .item-price { grid-template-columns: 110px 1fr; align-items: center; }
    .item-row .item-total { display: flex; justify-content: space-between; align-items: center; }
    .item-total strong { padding-top: 0; }
    .totals { max-width: none; }
    .detail-side { align-items: flex-start; }
}
@media (max-width: 640px) {
    .items-tools { width: 100%; }
    .items-tools select { flex: 1; min-width: 0; }
    .card-head:has(.items-tools) { flex-wrap: wrap; }
    .sticky-actions .muted { display: none; }
}
