/* =========================================================
   NEXENG DUCT SIZER TABLE V4
   App tipo Excel: filas/columnas editables + resultados automáticos.
   ========================================================= */

:root {
    --nx-bg: #eef6fb;
    --nx-card: rgba(255,255,255,.94);
    --nx-text: #102033;
    --nx-muted: #58708a;
    --nx-line: #c8e5f5;
    --nx-line-strong: #9ed4ee;
    --nx-accent: #009bd4;
    --nx-accent-2: #13bdd6;
    --nx-edit: #fffbe1;
    --nx-calc: #e7f4fc;
    --nx-ok: #059669;
    --nx-warn: #d97706;
    --nx-shadow: 0 18px 48px rgba(15, 35, 60, .11);
    --nx-header-h: 76px;
    --nx-actions-h: 54px;
    --nx-summary-h: 60px;
    --nx-max: 1880px;
}

* { box-sizing: border-box; }

html {
    min-height: 100%;
    scroll-padding-top: calc(var(--nx-header-h) + var(--nx-actions-h) + var(--nx-summary-h) + 54px);
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--nx-text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-weight: 700;
    background:
        radial-gradient(circle at 7% 12%, rgba(14,165,233,.16), transparent 34%),
        radial-gradient(circle at 95% 26%, rgba(249,115,22,.12), transparent 33%),
        linear-gradient(180deg, #f8fbff 0%, #eaf4fb 100%);
    overflow-x: hidden;
}

button, input, select, textarea { font: inherit; }

.nx-app-shell {
    width: min(calc(100% - 26px), var(--nx-max));
    margin: 0 auto;
    padding-top: calc(var(--nx-header-h) + var(--nx-actions-h) + 12px);
    padding-bottom: 40px;
}

.nx-topbar {
    position: fixed;
    inset: 0 0 auto 0;
    width: 100%;
    min-height: var(--nx-header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 10px clamp(18px, 2vw, 34px);
    background: rgba(255,255,255,.965);
    border-bottom: 1px solid rgba(15, 87, 130, .12);
    border-radius: 0 0 14px 14px;
    box-shadow: 0 12px 30px rgba(15, 35, 60, .09);
    backdrop-filter: blur(18px);
    z-index: 1000;
}

.nx-brand {
    display: flex;
    align-items: center;
    min-width: 0;
    text-decoration: none;
}

.nx-brand-logo {
    display: block;
    width: 250px;
    height: 48px;
    object-fit: contain;
    object-position: left center;
}

.nx-header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
}

.nx-btn {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 0 14px;
    border: 1px solid rgba(15, 87, 130, .17);
    border-radius: 999px;
    background: rgba(255,255,255,.9);
    color: #29445f;
    font-size: .82rem;
    font-weight: 950;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}

.nx-btn:hover { transform: translateY(-1px); box-shadow: 0 12px 26px rgba(15,35,60,.10); }

.nx-btn-primary {
    border-color: transparent;
    color: white;
    background: linear-gradient(135deg, var(--nx-accent), var(--nx-accent-2));
    box-shadow: 0 12px 28px rgba(0, 155, 212, .22);
}

.nx-btn-ghost { background: rgba(255,255,255,.86); }

.nx-action-dock {
    position: fixed;
    left: 0;
    right: 0;
    top: var(--nx-header-h);
    min-height: var(--nx-actions-h);
    padding: 7px clamp(18px, 2vw, 34px);
    border-bottom: 1px solid rgba(15, 87, 130, .13);
    background: rgba(255,255,255,.958);
    box-shadow: 0 10px 24px rgba(15, 35, 60, .075);
    backdrop-filter: blur(18px);
    z-index: 990;
}

.nx-action-dock-inner {
    width: min(calc(100vw - 28px), var(--nx-max));
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.nx-action-label {
    flex: 0 0 auto;
    color: var(--nx-accent);
    font-size: .72rem;
    font-weight: 950;
    letter-spacing: .16em;
    text-transform: uppercase;
}

.nx-action-list {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 7px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 2px 2px 3px;
    scrollbar-width: thin;
}

.nx-action-dock .nx-btn {
    min-height: 32px;
    padding: 0 12px;
    font-size: .79rem;
}

.nx-selection-status {
    display: none;
    min-height: 30px;
    align-items: center;
    padding: 0 10px;
    border: 1px solid rgba(2,132,199,.18);
    border-radius: 999px;
    color: #315879;
    background: rgba(240,249,255,.86);
    font-size: .74rem;
    font-weight: 900;
    white-space: nowrap;
}

body.nx-select-mode .nx-selection-status { display: inline-flex; }

.nx-main { width: 100%; }

.nx-hero {
    display: grid;
    grid-template-columns: minmax(0,1fr) minmax(260px,320px);
    gap: 16px;
    padding: 8px 0 12px;
}

.nx-hero-content,
.nx-hero-summary,
.nx-summary-card,
.nx-sheet-panel,
.nx-info-panel,
.nx-quick,
.nx-disclaimer {
    border: 1px solid rgba(130, 205, 240, .58);
    background: var(--nx-card);
    box-shadow: var(--nx-shadow);
}

.nx-hero-content,
.nx-hero-summary {
    min-height: 150px;
    border-radius: 26px;
    padding: clamp(18px, 2vw, 26px);
}

.nx-kicker,
.nx-sheet-title span,
.nx-info-panel > span,
.nx-quick > span,
.nx-disclaimer > span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--nx-accent);
    font-size: .70rem;
    font-weight: 950;
    letter-spacing: .14em;
    text-transform: uppercase;
}

.nx-kicker span {
    width: 9px;
    height: 9px;
    border-radius: 99px;
    background: var(--nx-ok);
}

.nx-hero h1 {
    max-width: 920px;
    margin: 10px 0 0;
    color: var(--nx-text);
    font-size: clamp(2rem, 3.2vw, 3.55rem);
    line-height: .96;
    letter-spacing: -.06em;
}

.nx-hero p {
    max-width: 880px;
    margin: 12px 0 0;
    color: #395a78;
    font-size: .95rem;
    line-height: 1.52;
    font-weight: 650;
}

.nx-hero-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 12px;
}

.nx-hero-tags span {
    min-height: 26px;
    display: inline-flex;
    align-items: center;
    padding: 0 10px;
    border: 1px solid rgba(15, 87, 130, .15);
    border-radius: 999px;
    color: #29445f;
    background: rgba(255,255,255,.75);
    font-size: .70rem;
    font-weight: 900;
}

.nx-hero-summary {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.nx-hero-summary span {
    color: #6a7e93;
    font-size: .72rem;
    font-weight: 950;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.nx-hero-summary strong {
    margin-top: 9px;
    color: var(--nx-accent);
    font-size: clamp(2rem, 3vw, 3.2rem);
    line-height: 1;
    letter-spacing: -.04em;
}

.nx-hero-summary small {
    margin-top: 10px;
    color: #526a82;
    line-height: 1.45;
    font-weight: 650;
}

.nx-summary-grid {
    position: sticky;
    top: calc(var(--nx-header-h) + var(--nx-actions-h));
    z-index: 970;
    display: grid;
    grid-template-columns: repeat(4, minmax(0,1fr));
    gap: 10px;
    margin: 0 -8px 12px;
    padding: 8px;
    background: linear-gradient(180deg, rgba(245,248,252,.986), rgba(245,248,252,.945));
    border-bottom: 1px solid rgba(15, 87, 130, .10);
    box-shadow: 0 8px 20px rgba(15,35,60,.055);
    backdrop-filter: blur(16px);
}

.nx-summary-card {
    min-height: 48px;
    padding: 8px 14px;
    border-radius: 18px;
    box-shadow: none;
}

.nx-summary-card span {
    display: block;
    color: #6a7e93;
    font-size: .66rem;
    line-height: 1.05;
    font-weight: 950;
    letter-spacing: .10em;
    text-transform: uppercase;
}

.nx-summary-card strong {
    display: block;
    margin-top: 5px;
    color: var(--nx-text);
    font-size: 1.08rem;
    line-height: 1.05;
    letter-spacing: -.02em;
}

.nx-summary-card small { font-size: .68rem; color: #60778e; }

.nx-sheet-panel {
    border-radius: 24px;
    overflow: visible;
}

.nx-sheet-title {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 18px 12px;
    border-bottom: 1px solid rgba(15,87,130,.11);
    background:
        radial-gradient(circle at 8% 0%, rgba(14,165,233,.08), transparent 36%),
        rgba(255,255,255,.96);
    border-radius: 24px 24px 0 0;
}

.nx-sheet-title h2 {
    margin: 4px 0 0;
    font-size: 1.08rem;
    letter-spacing: -.03em;
}

.nx-sheet-title p {
    margin: 3px 0 0;
    color: #6a7e93;
    font-size: .78rem;
    font-weight: 650;
}

.nx-sheet-scroll {
    width: 100%;
    min-height: 340px;
    overflow-x: auto;
    overflow-y: visible;
    border-radius: 0 0 24px 24px;
}

.nx-sheet {
    width: 100%;
    min-width: 1720px;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
    background:
        linear-gradient(rgba(14,165,233,.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(14,165,233,.035) 1px, transparent 1px),
        #ffffff;
    background-size: 36px 36px;
}

.nx-sheet th,
.nx-sheet td {
    height: 38px;
    padding: 4px 8px;
    border-right: 1px solid rgba(120,184,215,.42);
    border-bottom: 1px solid rgba(120,184,215,.36);
    vertical-align: middle;
    font-size: .78rem;
    line-height: 1.15;
    box-sizing: border-box;
}

.nx-sheet thead th {
    position: sticky;
    top: calc(var(--nx-header-h) + var(--nx-actions-h) + var(--nx-summary-h));
    z-index: 120;
    height: 39px;
    color: #3b5872;
    font-size: .68rem;
    font-weight: 950;
    text-align: center;
    text-transform: uppercase;
    background: linear-gradient(180deg, rgba(226,243,252,1), rgba(211,234,246,1));
    box-shadow: inset 0 -1px 0 rgba(2,132,199,.25), 0 8px 18px rgba(15,35,60,.07);
}

.nx-sheet th:first-child,
.nx-sheet td:first-child {
    position: sticky;
    left: 0;
}

.nx-sheet thead th:first-child { z-index: 135; }

.nx-sheet td:first-child {
    z-index: 35;
    text-align: center;
    color: #60778e;
    background: #eef8fd;
    font-weight: 950;
}

.nx-sheet tfoot td {
    background: #e4f3fb;
    font-weight: 950;
}

.nx-sheet input,
.nx-sheet select {
    width: 100%;
    min-width: 0;
    height: 28px;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--nx-text);
    font-size: .78rem;
    font-weight: 900;
}

.nx-sheet input { text-align: right; }

.nx-sheet input[type="text"] { text-align: left; }

.nx-edit {
    background: var(--nx-edit);
}

.nx-calc {
    background: var(--nx-calc);
    text-align: right;
    color: var(--nx-text);
    font-weight: 950;
}

.nx-center { text-align: center; }

.nx-row-name { width: 150px; }
.nx-method { width: 120px; }
.nx-flow { width: 130px; }
.nx-length { width: 115px; }
.nx-fric { width: 145px; }
.nx-velocity { width: 130px; }
.nx-unitout { width: 120px; }
.nx-diamcalc { width: 125px; }
.nx-diamcomm { width: 135px; }
.nx-velreal { width: 120px; }
.nx-fricreal { width: 130px; }
.nx-loss { width: 120px; }
.nx-rect { width: 160px; }
.nx-status-col { width: 100px; }
.nx-actions-col { width: 105px; }

.nx-inline {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 62px;
    align-items: center;
    gap: 0;
}

.nx-inline select {
    color: #60778e;
    font-size: .66rem;
    text-align: center;
    border-left: 1px solid rgba(120,184,215,.42);
    padding-left: 5px;
}

.nx-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 48px;
    min-height: 22px;
    padding: 0 8px;
    border-radius: 999px;
    font-size: .67rem;
    font-weight: 950;
    white-space: nowrap;
}

.nx-badge-ok {
    color: #008664;
    background: #d8f8ec;
    border: 1px solid #9be7cb;
}

.nx-badge-warn {
    color: #d97706;
    background: #fff1d6;
    border: 1px solid #f5c27a;
}

.nx-row-actions {
    display: flex;
    justify-content: center;
    gap: 5px;
}

.nx-icon-btn {
    width: 26px;
    height: 26px;
    display: inline-grid;
    place-items: center;
    border: 1px solid rgba(15,87,130,.13);
    border-radius: 9px;
    background: rgba(255,255,255,.86);
    color: #385472;
    font-size: .78rem;
    font-weight: 950;
    cursor: pointer;
}

.nx-icon-btn:hover { background: #eaf8ff; }

.nx-selected-row td {
    box-shadow: inset 0 2px 0 rgba(2,132,199,.28), inset 0 -2px 0 rgba(2,132,199,.28);
}

.nx-detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(280px, .66fr) minmax(280px, .66fr);
    gap: 16px;
    margin-top: 16px;
}

.nx-info-panel {
    min-height: 210px;
    padding: 18px;
    border-radius: 24px;
}

.nx-info-panel h2 {
    margin: 8px 0 0;
    font-size: 1.15rem;
    letter-spacing: -.03em;
}

.nx-info-panel strong {
    display: block;
    margin-top: 10px;
    color: var(--nx-accent);
    font-size: 1.7rem;
    line-height: 1;
    letter-spacing: -.04em;
}

.nx-info-panel p {
    margin: 9px 0 0;
    color: #526a82;
    font-size: .86rem;
    line-height: 1.55;
    font-weight: 650;
}

.nx-note-label {
    display: block;
    margin-top: 14px;
    color: #6a7e93;
    font-size: .70rem;
    font-weight: 950;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.nx-note-box {
    width: 100%;
    min-height: 78px;
    margin-top: 8px;
    padding: 10px 12px;
    border: 1px solid rgba(15,87,130,.16);
    border-radius: 14px;
    resize: vertical;
    background: #fffbe1;
    color: var(--nx-text);
    font-size: .86rem;
    line-height: 1.45;
}

.nx-quick,
.nx-disclaimer {
    margin-top: 16px;
    padding: 18px;
    border-radius: 24px;
}

.nx-quick h2 {
    margin: 8px 0 0;
    font-size: 1.25rem;
}

.nx-quick-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0,1fr));
    gap: 12px;
    margin-top: 14px;
}

.nx-quick-grid article {
    padding: 14px;
    border: 1px solid rgba(15,87,130,.12);
    border-radius: 18px;
    background: rgba(255,255,255,.62);
}

.nx-quick-grid strong { display: block; }

.nx-quick-grid p,
.nx-disclaimer p {
    margin: 8px 0 0;
    color: #526a82;
    font-size: .86rem;
    line-height: 1.55;
    font-weight: 650;
}

.nx-toast-container {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 2000;
    display: grid;
    gap: 8px;
}

.nx-toast {
    max-width: 360px;
    padding: 12px 14px;
    border: 1px solid rgba(2,132,199,.22);
    border-radius: 16px;
    color: #102033;
    background: rgba(255,255,255,.96);
    box-shadow: 0 18px 40px rgba(15,35,60,.14);
    font-size: .85rem;
    font-weight: 800;
    transition: opacity .24s ease, transform .24s ease;
}

.nx-toast.is-out {
    opacity: 0;
    transform: translateY(10px);
}

.nx-selection-help {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 1100;
    display: none;
    max-width: min(390px, calc(100vw - 44px));
    padding: 13px 15px;
    border: 1px solid rgba(2,132,199,.22);
    border-radius: 18px;
    color: #385472;
    background: rgba(255,255,255,.96);
    box-shadow: 0 18px 45px rgba(15,35,60,.14);
    backdrop-filter: blur(18px);
    font-size: .82rem;
    line-height: 1.35;
    font-weight: 750;
}

.nx-selection-help strong {
    display: block;
    color: var(--nx-text);
    margin-bottom: 4px;
}

body.nx-select-mode .nx-selection-help { display: block; }

body.nx-select-mode .nx-sheet { cursor: crosshair; user-select: none; }
body.nx-select-mode .nx-sheet input,
body.nx-select-mode .nx-sheet select,
body.nx-select-mode .nx-sheet button { pointer-events: none; }

.nx-cell-selected {
    background:
        linear-gradient(180deg, rgba(14,165,233,.24), rgba(14,165,233,.18)) !important;
    box-shadow:
        inset 0 0 0 2px rgba(2,132,199,.68),
        inset 0 0 0 999px rgba(14,165,233,.08) !important;
}

.nx-cell-anchor {
    box-shadow:
        inset 0 0 0 3px rgba(2,132,199,.95),
        inset 0 0 0 999px rgba(14,165,233,.10) !important;
}

@media (max-width: 1180px) {
    .nx-app-shell { width: min(calc(100% - 16px), var(--nx-max)); }
    .nx-hero { grid-template-columns: 1fr; }
    .nx-detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
    :root {
        --nx-header-h: 106px;
        --nx-actions-h: 56px;
        --nx-summary-h: 98px;
    }

    .nx-app-shell { padding-top: calc(var(--nx-header-h) + var(--nx-actions-h) + 10px); }

    .nx-topbar {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
        padding: 8px 12px;
    }

    .nx-brand-logo { width: 212px; height: 42px; }
    .nx-header-actions { justify-content: center; }
    .nx-summary-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .nx-quick-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
    :root {
        --nx-header-h: 118px;
        --nx-actions-h: 58px;
    }

    .nx-action-label { display: none; }
    .nx-hero h1 { font-size: 2.1rem; }
    .nx-hero-content,
    .nx-hero-summary,
    .nx-info-panel,
    .nx-quick,
    .nx-disclaimer { padding: 16px; border-radius: 20px; }
    .nx-summary-grid { grid-template-columns: 1fr; position: static; }
}
