:root{--primary:#1f2937;--bg:#f4f6f8;--surface:#fff;--border:#d1d5db;--muted:#6b7280;--success:#15803d;--danger:#b91c1c;--warning:#b45309;--radius:10px;--shadow:0 2px 8px rgb(0 0 0/8%)}
html{font-size:16px}html[data-font-size="small"]{font-size:14px}html[data-font-size="large"]{font-size:18px}html[data-theme="dia"]{--bg:#fff8ed;--surface:#fffdf7;--border:#d8cbb8;--primary:#283548;--muted:#756b5d;--shadow:0 2px 8px rgb(116 83 35/12%)}html[data-theme="oscuro"]{--bg:#111827;--surface:#1f2937;--border:#4b5563;--primary:#f3f4f6;--muted:#c0c7d1;--shadow:0 2px 8px rgb(0 0 0/30%)}
*{box-sizing:border-box}body{margin:0;font-family:Inter,system-ui,"Segoe UI",sans-serif;background:var(--bg);color:var(--primary);line-height:1.5}button,input,select{font:inherit}button{min-height:42px;padding:10px 16px;border:1px solid transparent;border-radius:7px;cursor:pointer;font-weight:600}button:disabled{cursor:wait;opacity:.65}:focus-visible{outline:3px solid rgb(37 99 235/30%);outline-offset:2px}.btn-primary{background:#1f2937;color:#fff}.btn-secondary{background:var(--surface);color:var(--primary);border-color:var(--border)}
.site-header{background:var(--primary);color:#fff;padding:18px max(20px,calc((100% - 1280px)/2))}.header-inner{display:flex;align-items:center;justify-content:space-between;gap:24px}.brand h1{margin:0;font-size:clamp(1.25rem,2vw,1.5rem)}.brand p{margin:3px 0 0;color:#d1d5db;font-size:.9rem}.header-user{display:flex;align-items:center;gap:12px;font-size:.875rem}.header-user button{min-height:36px;padding:7px 12px}.page{width:min(100% - 40px,1280px);margin:auto;padding:28px 0 40px}.toolbar{display:flex;flex-wrap:wrap;align-items:center;gap:10px;margin-bottom:22px}.toolbar-meta{margin-left:auto;color:var(--muted);font-size:.875rem}
.summary{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:18px;margin-bottom:26px}.card,.panel{background:#fff;border:1px solid #e5e7eb;border-radius:var(--radius);box-shadow:var(--shadow)}.card{padding:20px;border-top:3px solid #2563eb}.card.warning{border-top-color:#f59e0b}.card-label{color:var(--muted);font-size:.78rem;font-weight:700;text-transform:uppercase}.card-value{margin-top:6px;font-size:clamp(1.65rem,3vw,2rem);font-weight:750;font-variant-numeric:tabular-nums}.panel{padding:22px;margin-bottom:24px}.panel-heading{display:flex;justify-content:space-between;align-items:baseline;gap:16px;margin-bottom:16px}.panel h2{margin:0;font-size:1.18rem}.subtitle{color:var(--muted);font-size:.875rem}
.table-scroll{overflow-x:auto;border:1px solid #e5e7eb;border-radius:8px}table{width:100%;border-collapse:collapse;background:#fff}caption{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)}th{background:#f3f4f6;text-align:left;padding:11px 12px;font-size:.78rem;white-space:nowrap}td{padding:12px;border-top:1px solid #e5e7eb}tbody tr:hover{background:#f9fafb}.numeric{text-align:right;font-variant-numeric:tabular-nums}.needs-production{background:#fff7ed}.production{color:var(--warning);font-weight:750}.badge{display:inline-flex;padding:4px 9px;border-radius:999px;background:#e5e7eb;font-size:.75rem;font-weight:700}.badge-success{background:#f0fdf4;color:var(--success)}.badge-danger{background:#fef2f2;color:var(--danger)}
.form-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px}label{display:block;margin-bottom:6px;font-size:.85rem;font-weight:650}input,select{width:100%;min-height:43px;padding:10px 11px;border:1px solid var(--border);border-radius:7px;background:#fff}.field{margin-bottom:16px}.field-help{margin:5px 0 0;color:var(--muted);font-size:.78rem}.form-actions{margin-top:18px}.message{min-height:24px;margin-top:14px;font-size:.875rem}.message:not(:empty){padding:10px 12px;border-radius:7px}.message.error{color:var(--danger);background:#fef2f2}.message.success{color:var(--success);background:#f0fdf4}.empty{padding:30px 16px;color:var(--muted);text-align:center}
.login-page{min-height:100dvh;display:grid;place-items:center;padding:24px;background:radial-gradient(circle at top,#e8eef7,var(--bg) 55%)}.login-card{width:min(100%,400px);padding:32px;background:#fff;border:1px solid #e5e7eb;border-radius:14px;box-shadow:0 12px 35px rgb(31 41 55/12%)}.login-mark{width:44px;height:44px;display:grid;place-items:center;margin-bottom:18px;border-radius:10px;background:var(--primary);color:#fff;font-weight:800}.login-card h1{margin:0 0 6px}.login-card>p{margin:0 0 24px;color:var(--muted)}.login-card .btn-primary{width:100%}
@media(max-width:900px){.summary{grid-template-columns:repeat(2,1fr)}}@media(max-width:620px){.site-header{padding:16px 20px}.header-inner{align-items:flex-start;flex-direction:column}.header-user{width:100%;justify-content:space-between}.page{width:calc(100% - 28px);padding-top:18px}.summary,.form-grid{grid-template-columns:1fr}.toolbar-meta{width:100%;margin-left:0}.panel{padding:16px}.panel-heading{align-items:flex-start;flex-direction:column}.login-card{padding:25px}}

/* Panel lateral compartido */
.app-layout{--sidebar-width:250px;min-height:100dvh}.sidebar{position:fixed;inset:0 auto 0 0;z-index:20;width:var(--sidebar-width);display:flex;flex-direction:column;background:#111827;color:#fff;border-right:1px solid rgb(255 255 255/8%);transition:width .2s ease,transform .2s ease}.sidebar-brand{height:76px;display:flex;align-items:center;gap:12px;padding:0 16px;border-bottom:1px solid rgb(255 255 255/9%)}.sidebar-logo{width:40px;height:40px;flex:0 0 40px;display:grid;place-items:center;border-radius:10px;background:#2563eb;font-size:.8rem;font-weight:800}.sidebar-brand-text{min-width:0;overflow:hidden;white-space:nowrap}.sidebar-brand-text strong,.sidebar-brand-text small{display:block}.sidebar-brand-text small{color:#9ca3af}.sidebar-toggle{width:36px;min-width:36px;min-height:36px;margin-left:auto;padding:7px;display:grid;place-items:center;background:transparent;color:#d1d5db;border-color:rgb(255 255 255/12%)}.sidebar-toggle:hover{background:rgb(255 255 255/8%);color:#fff}.sidebar-toggle svg{width:18px;height:18px;transition:transform .2s}.sidebar-nav{display:flex;flex-direction:column;gap:5px;padding:18px 12px}.sidebar-link{height:46px;display:flex;align-items:center;gap:13px;padding:0 12px;border-radius:8px;color:#d1d5db;text-decoration:none;white-space:nowrap;overflow:hidden}.sidebar-link:hover{background:rgb(255 255 255/7%);color:#fff}.sidebar-link.active{background:#2563eb;color:#fff;box-shadow:0 5px 15px rgb(37 99 235/22%)}.nav-icon{width:21px;height:21px;flex:0 0 21px;display:grid;place-items:center}.nav-icon svg{width:21px;height:21px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}.nav-label{overflow:hidden}.sidebar-footer{margin-top:auto;padding:14px 18px 20px;border-top:1px solid rgb(255 255 255/9%);color:#9ca3af;font-size:.75rem;white-space:nowrap;overflow:hidden}.app-content{min-width:0;margin-left:var(--sidebar-width);transition:margin-left .2s}.app-content .site-header{padding-left:max(20px,calc((100vw - var(--sidebar-width) - 1280px)/2));padding-right:max(20px,calc((100vw - var(--sidebar-width) - 1280px)/2))}.sidebar-collapsed{--sidebar-width:76px}.sidebar-collapsed .sidebar-brand{padding:0 18px}.sidebar-collapsed .sidebar-brand-text,.sidebar-collapsed .nav-label,.sidebar-collapsed .sidebar-footer{display:none}.sidebar-collapsed .sidebar-toggle{position:absolute;top:82px;left:20px;margin:0}.sidebar-collapsed .sidebar-nav{padding-top:62px}.sidebar-collapsed .sidebar-link{justify-content:center;padding:0}.sidebar-collapsed .sidebar-toggle svg{transform:rotate(180deg)}.sidebar-backdrop,.mobile-menu{display:none}.mobile-menu{width:40px;min-width:40px;padding:8px;background:transparent;color:#fff;border-color:rgb(255 255 255/20%)}.mobile-menu svg{width:21px;height:21px;fill:none;stroke:currentColor;stroke-width:2}
@media(max-width:760px){.app-layout{--sidebar-width:250px}.sidebar{transform:translateX(-100%);box-shadow:12px 0 32px rgb(0 0 0/25%)}.sidebar-collapsed .sidebar{width:var(--sidebar-width)}.sidebar-collapsed .sidebar-brand{padding:0 16px}.sidebar-collapsed .sidebar-brand-text,.sidebar-collapsed .nav-label,.sidebar-collapsed .sidebar-footer{display:block}.sidebar-collapsed .sidebar-toggle{position:static;margin-left:auto}.sidebar-collapsed .sidebar-nav{padding-top:18px}.sidebar-collapsed .sidebar-link{justify-content:flex-start;padding:0 12px}.sidebar-collapsed .sidebar-toggle svg{transform:none}.app-content{margin-left:0}.sidebar-open .sidebar{transform:translateX(0)}.sidebar-open .sidebar-backdrop{position:fixed;inset:0;z-index:15;display:block;background:rgb(17 24 39/45%);border:0;padding:0}.mobile-menu{display:grid}.header-inner{position:relative}.brand{padding-left:52px}.mobile-menu{position:absolute;left:0;top:0}}

.panel-actions{display:flex;align-items:center;gap:10px}.icon-button{width:38px;min-width:38px;min-height:38px;padding:8px;display:grid;place-items:center;background:#fff;color:var(--primary);border-color:var(--border)}.icon-button:hover:not(:disabled){background:#f3f4f6;border-color:#9ca3af}.icon-button svg{width:19px;height:19px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}.icon-button.is-loading svg{animation:sync-spin .8s linear infinite}@keyframes sync-spin{to{transform:rotate(360deg)}}

.workspace-grid{display:grid;grid-template-columns:minmax(0,1fr) minmax(360px,430px);gap:24px;align-items:start}.workspace-main,.workspace-side{min-width:0}.workspace-side{position:sticky;top:24px;max-height:calc(100dvh - 48px);overflow:auto}.workspace-side .panel{box-shadow:0 8px 24px rgb(31 41 55/10%)}.workspace-side table{font-size:.82rem}.workspace-side th,.workspace-side td{padding:9px 10px}.activity-list{display:flex;flex-direction:column;gap:10px}.activity-item{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:4px 14px;padding:13px;border:1px solid #e5e7eb;border-radius:8px;background:#fff}.activity-title{font-weight:700}.activity-code,.activity-detail{color:var(--muted);font-size:.8rem}.activity-value{grid-row:1/3;grid-column:2;align-self:center;color:var(--warning);font-size:1.05rem;font-weight:800;font-variant-numeric:tabular-nums}.side-empty{padding:28px 10px;text-align:center;color:var(--muted);font-size:.9rem}@media(max-width:1180px){.workspace-grid{grid-template-columns:minmax(0,1fr) 360px}}@media(max-width:980px){.workspace-grid{grid-template-columns:1fr}.workspace-side{position:static;max-height:none}}

/* Aprovechamiento de pantallas de escritorio */
@media(min-width:981px){.page{width:min(100% - 48px,1700px);padding-top:24px}.app-content .site-header{padding-left:max(24px,calc((100vw - var(--sidebar-width) - 1700px)/2));padding-right:max(24px,calc((100vw - var(--sidebar-width) - 1700px)/2))}.workspace-grid{grid-template-columns:minmax(560px,1.35fr) minmax(460px,1fr);gap:22px}.workspace-main .panel,.workspace-side .panel{padding:18px}.workspace-main .form-grid{gap:12px 14px}.workspace-main input,.workspace-main select{min-height:38px;padding:7px 10px}.workspace-main .form-actions{margin-top:14px}}
@media(min-width:1550px){.workspace-main .form-grid{grid-template-columns:repeat(4,minmax(0,1fr))}}
@media(min-width:981px) and (max-width:1250px){.workspace-grid{grid-template-columns:minmax(0,1fr) 400px}}

.product-editor .form-section{padding:14px 0;border-top:1px solid #e5e7eb}.product-editor .form-section:first-of-type{padding-top:0;border-top:0}.product-editor .form-section h3{margin:0 0 10px;font-size:.88rem;color:#4b5563}.product-editor .field-wide{grid-column:span 2}.form-actions-row{display:flex;gap:10px;align-items:center}.edit-status{margin-top:12px}.checkbox-label{display:inline-flex;align-items:center;gap:9px}.checkbox-label input{width:18px;min-height:18px}.list-filter{margin-bottom:12px}.list-filter label{position:absolute;width:1px;height:1px;overflow:hidden}.list-filter input{min-height:38px}.table-action{min-height:32px;padding:5px 10px;background:#eff6ff;color:#1d4ed8;border-color:#bfdbfe;font-size:.78rem}.table-action:hover{background:#dbeafe}@media(max-width:620px){.product-editor .field-wide{grid-column:span 1}}

/* Espacio de trabajo de productos */
.stock-indicator{display:inline-flex;align-items:center;justify-content:flex-end;gap:7px;min-width:64px;font-weight:750;font-variant-numeric:tabular-nums}.stock-indicator::before{width:9px;height:9px;flex:0 0 9px;border-radius:50%;content:"";box-shadow:0 0 0 3px currentColor inset}.stock-indicator.has-stock{color:var(--success)}.stock-indicator.no-stock{color:var(--danger)}.currency{white-space:nowrap;font-weight:650}.products-page .product-list-panel{display:flex;min-height:0;flex-direction:column}.products-page .product-list-panel .table-scroll{min-height:0;flex:1;overflow:auto}.products-page .product-list-panel thead{position:sticky;top:0;z-index:1}.products-page .field-help{display:block}
@media(min-width:981px){.products-page .page{padding-top:18px;padding-bottom:18px}.products-page .workspace-grid{grid-template-columns:minmax(470px,.82fr) minmax(680px,1.38fr);gap:18px}.products-page .workspace-main .product-editor,.products-page .workspace-side .product-list-panel{height:calc(100dvh - 122px);max-height:calc(100dvh - 122px);margin-bottom:0}.products-page .workspace-main .product-editor{position:sticky;top:18px;overflow:auto}.products-page .workspace-side{position:sticky;top:18px;max-height:none;overflow:visible}.products-page .workspace-main .form-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:9px 12px}.products-page .workspace-main .panel,.products-page .workspace-side .panel{padding:15px}.products-page .product-editor .form-section{padding:10px 0}.products-page .product-editor .panel-heading{margin-bottom:10px}.products-page .product-editor input,.products-page .product-editor select{min-height:34px;padding:5px 9px}.products-page .product-editor label{margin-bottom:4px;font-size:.79rem}.products-page .product-editor .form-actions{margin-top:10px}.products-page .product-editor button{min-height:36px;padding:7px 12px}}
@media(min-width:981px) and (max-width:1300px){.products-page .workspace-grid{grid-template-columns:minmax(430px,.9fr) minmax(560px,1.1fr)}}

/* Alto útil y margen inferior del dashboard */
.dashboard-page main.page>.message:empty{display:none}
@media(min-width:981px){.dashboard-page .page{padding-top:18px;padding-bottom:18px}.dashboard-page .workspace-grid{height:calc(100dvh - 146px);align-items:stretch}.dashboard-page .workspace-main{display:flex;min-height:0;flex-direction:column}.dashboard-page .workspace-main>.summary{flex:0 0 auto;margin-bottom:18px}.dashboard-page .workspace-main>.panel,.dashboard-page .workspace-side>.panel{display:flex;min-height:0;flex-direction:column;margin-bottom:0}.dashboard-page .workspace-main>.panel{flex:1}.dashboard-page .workspace-side{position:sticky;top:18px;display:flex;min-height:0;height:calc(100dvh - 146px);max-height:calc(100dvh - 146px);overflow:visible}.dashboard-page .workspace-side>.panel{flex:1;min-width:0;height:100%;overflow:hidden}.dashboard-page .workspace-side .panel-heading{flex-shrink:0}.dashboard-page .workspace-side .activity-item{flex-shrink:0}.dashboard-page .workspace-main>.panel .table-scroll{min-height:0;flex:1;overflow:auto}.dashboard-page .workspace-main>.panel thead{position:sticky;top:0;z-index:1}.dashboard-page .workspace-side .activity-list{min-height:0;flex:1;overflow:auto;padding-right:3px}}

/* Campos de precio, costo y valor monetario: usar .money-input y App.initMoneyInput. */
.money-input,.money-value,.currency{
    text-align:right;
    font-variant-numeric:tabular-nums;
    white-space:nowrap;
}
input.money-input{font-weight:650}
input.money-input::placeholder{color:var(--muted);font-weight:400}
.money-value{font-weight:650}

/* Producción requerida agrupada por proveedor principal. */
.dashboard-page .production-supplier{flex-shrink:0;min-width:0;border:1px solid #e5e7eb;border-radius:8px;background:#fff}
.dashboard-page .production-supplier>summary{display:grid;grid-template-columns:14px minmax(0,1fr) auto;align-items:center;gap:10px;min-height:54px;padding:13px;cursor:pointer;list-style:none}
.dashboard-page .production-supplier>summary::-webkit-details-marker{display:none}
.dashboard-page .production-supplier>summary::before{content:'›';color:var(--muted);font-size:1.4rem;line-height:1;transition:transform .15s}
.dashboard-page .production-supplier[open]>summary::before{transform:rotate(90deg)}
.dashboard-page .production-supplier>summary:hover{background:#f9fafb;border-radius:8px}
.dashboard-page .supplier-name{font-weight:700;overflow-wrap:anywhere}
.dashboard-page .supplier-total{color:var(--warning);font-size:1.05rem;font-variant-numeric:tabular-nums;white-space:nowrap}
.dashboard-page .supplier-products{display:flex;flex-direction:column;gap:8px;padding:0 10px 10px}
.dashboard-page .supplier-products .activity-item{padding:10px;background:#f9fafb}

.dashboard-page .production-supplier:not([open])>.supplier-products{display:none}

/* Preferencias visuales */
html[data-theme="dia"] .card,html[data-theme="dia"] .panel,html[data-theme="dia"] .login-card,html[data-theme="dia"] table,html[data-theme="dia"] input,html[data-theme="dia"] select,html[data-theme="dia"] .activity-item,html[data-theme="dia"] .production-supplier{background:#fffdf7;border-color:var(--border)}
html[data-theme="oscuro"] .card,html[data-theme="oscuro"] .panel,html[data-theme="oscuro"] .login-card,html[data-theme="oscuro"] table,html[data-theme="oscuro"] input,html[data-theme="oscuro"] select,html[data-theme="oscuro"] .activity-item,html[data-theme="oscuro"] .production-supplier,html[data-theme="oscuro"] .preferences-dialog{background:var(--surface);border-color:var(--border);color:var(--primary)}
html[data-theme="oscuro"] th{background:#374151}html[data-theme="oscuro"] td,html[data-theme="oscuro"] .table-scroll{border-color:var(--border)}html[data-theme="oscuro"] tbody tr:hover,html[data-theme="oscuro"] .production-supplier>summary:hover{background:#374151}html[data-theme="oscuro"] .needs-production,html[data-theme="oscuro"] .dashboard-page .supplier-products .activity-item{background:#2d251c}html[data-theme="oscuro"] .btn-secondary,html[data-theme="oscuro"] .icon-button{background:var(--surface);color:var(--primary);border-color:var(--border)}html[data-theme="oscuro"] .login-page{background:radial-gradient(circle at top,#26364b,var(--bg) 58%)}html[data-theme="oscuro"] .brand p{color:#d1d5db}
html[data-theme="oscuro"] .site-header{background:#0f172a;color:#fff}html[data-theme="oscuro"] .site-header .brand p{color:#d1d5db}
.preferences-button{display:flex;align-items:center;gap:13px;width:calc(100% - 24px);height:46px;margin:0 12px;padding:0 12px;border:0;border-radius:8px;background:transparent;color:#d1d5db;text-align:left}.preferences-button:hover{background:rgb(255 255 255/7%);color:#fff}.preferences-button .nav-icon svg{width:21px;height:21px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.preferences-dialog{width:min(92vw,430px);padding:0;border:1px solid var(--border);border-radius:10px;background:var(--surface);color:var(--primary);box-shadow:0 18px 55px rgb(0 0 0/25%)}.preferences-dialog::backdrop{background:rgb(17 24 39/52%)}.preferences-dialog form{padding:22px}.preferences-heading{display:flex;align-items:flex-start;justify-content:space-between;gap:18px;margin-bottom:18px}.preferences-heading h2{margin:0;font-size:1.1rem}.preferences-heading p{margin:4px 0 0;color:var(--muted);font-size:.85rem}.preferences-heading .icon-button{font-size:1.35rem;line-height:1;padding:5px}.preferences-dialog fieldset{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin:0 0 18px;padding:0;border:0}.preferences-dialog legend{grid-column:1/-1;margin-bottom:7px;font-size:.85rem;font-weight:700}.preferences-dialog fieldset label{display:flex;align-items:center;gap:7px;margin:0;padding:10px 8px;border:1px solid var(--border);border-radius:7px;cursor:pointer;font-size:.8rem}.preferences-dialog fieldset label:has(input:checked){border-color:#2563eb;background:rgb(37 99 235/10%)}.preferences-dialog fieldset input{width:auto;min-height:auto;margin:0}.preferences-actions{display:flex;justify-content:flex-end}.preferences-actions button{min-height:36px;padding:7px 14px}
@media(max-width:480px){.preferences-dialog fieldset{grid-template-columns:1fr}.preferences-dialog fieldset label{min-height:42px}}
.native-photo-actions{display:flex;align-items:center;flex-wrap:wrap;gap:8px;margin-top:8px}.native-photo-actions button{min-height:34px;padding:7px 10px;font-size:.8rem}.native-photo-actions .field-help{margin:0}
