/* CONTROL DE PRODUCTIVIDAD · interfaz técnica, legible y adaptable */
:root{--ui-font:"Segoe UI Variable","Segoe UI",system-ui,-apple-system,Arial,sans-serif;--ui-accent:#167b91;--ui-accent-strong:#0c6377;--ui-border:#d7e1e8;--ui-panel:rgba(255,255,255,.82);--ui-text:#203544;--ui-muted:#5c7180;--ui-bg:#e8eff3}
html,body{min-height:100%;font-family:var(--ui-font)!important;font-size:14px;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility}
body,button,input,select,textarea,table,dialog{font-family:var(--ui-font)!important}
body[data-theme="crystal"]{--ui-accent:#167b91;--ui-accent-strong:#0c6377;--ui-border:rgba(89,119,137,.20);--ui-panel:rgba(255,255,255,.82);--ui-text:#203544;--ui-muted:#5c7180;--ui-bg:#e8eff3;color:var(--ui-text);background:var(--ui-bg)}
body[data-theme="dark"]{--ui-accent:#63c6bd;--ui-accent-strong:#3ca79e;--ui-border:rgba(190,220,228,.16);--ui-panel:rgba(20,39,49,.92);--ui-text:#e8f1f3;--ui-muted:#adbec5;--ui-bg:#10212a;color:var(--ui-text);background:var(--ui-bg)}
body[data-theme="crystal"]::before{background:radial-gradient(ellipse at 8% 5%,rgba(91,168,180,.17),transparent 38%),radial-gradient(ellipse at 90% 10%,rgba(96,143,176,.13),transparent 42%),linear-gradient(135deg,#edf3f5 0%,#e6eef1 58%,#f1f3f2 100%)}
body[data-theme="dark"]::before{background:radial-gradient(ellipse at 8% 5%,rgba(45,124,136,.19),transparent 40%),radial-gradient(ellipse at 92% 10%,rgba(36,89,118,.2),transparent 45%),linear-gradient(135deg,#0d1c25 0%,#10232d 58%,#14262c 100%)}
/* Acceso */
.login-layout{position:relative;isolation:isolate;min-height:100vh;grid-template-columns:minmax(320px,.92fr) minmax(430px,1.08fr);align-items:stretch;gap:0;padding:clamp(20px,4vw,64px);background:transparent}
.login-layout::before{content:"";position:fixed;inset:0;z-index:-2;background:linear-gradient(135deg,#eaf1f4,#f5f7f8 55%,#e5edf0)}
body[data-theme="dark"] .login-layout::before{background:linear-gradient(135deg,#0c1a22,#132831 58%,#10212a)}
.brand{position:relative;min-height:min(720px,calc(100vh - 2*clamp(20px,4vw,64px)));overflow:hidden;border:1px solid rgba(255,255,255,.18);border-radius:22px 0 0 22px;padding:clamp(28px,5vw,64px);background:linear-gradient(145deg,#12344b 0%,#155878 58%,#167b91 100%);box-shadow:0 24px 70px rgba(23,55,72,.17)}
.brand::before{inset:-24%;opacity:.25;animation:brandFlow 42s ease-in-out infinite alternate}.brand::after{width:460px;height:460px;right:-240px;top:35%;opacity:.65;animation:brandGlow 34s ease-in-out infinite alternate}
.brand>img{position:relative;width:min(380px,100%);height:auto;object-fit:contain;align-self:flex-start;filter:drop-shadow(0 8px 20px rgba(0,0,0,.12))}
.brand-copy{position:relative;max-width:520px;margin:auto 0}.brand .eyebrow{color:#b7dce6;font-size:12px;letter-spacing:.16em}.brand h1{font-size:clamp(34px,4.3vw,60px);line-height:1.04;letter-spacing:-.045em;font-weight:650}.brand p:not(.eyebrow){max-width:430px;color:#d5e8ed;font-size:16px;line-height:1.7}.brand>small{position:relative;color:#c2dce2;font-size:12px}.login-status{display:inline-flex;align-items:center;gap:10px;margin-top:18px;padding:9px 13px;border:1px solid rgba(222,246,248,.2);border-radius:999px;background:rgba(7,35,49,.2);color:#d9edf0;font-size:12px}.login-status span{width:8px;height:8px;border-radius:50%;background:#8ce0c2;box-shadow:0 0 0 4px rgba(140,224,194,.13)}
.access{min-width:0;display:flex;align-items:center;justify-content:center;padding:clamp(20px,5vw,72px);background:rgba(255,255,255,.74);border:1px solid rgba(255,255,255,.88);border-left:0;border-radius:0 22px 22px 0;backdrop-filter:blur(18px);-webkit-backdrop-filter:blur(18px)}
body[data-theme="dark"] .access{background:rgba(14,31,39,.78);border-color:rgba(220,242,244,.1)}
.access form{width:min(100%,420px);padding:0;border:0;border-radius:0;background:transparent;box-shadow:none}
.login-badge{display:flex;align-items:center;gap:10px;margin-bottom:28px;color:#597583;font-size:11px;font-weight:700;letter-spacing:.12em}.login-badge img{width:34px;height:34px;object-fit:contain;border-radius:9px}.access h2{margin:0 0 7px;color:#1d3849;font-size:32px;font-weight:650;letter-spacing:-.035em}.access .muted{margin-bottom:28px;color:#617580;font-size:14px}
body[data-theme="dark"] .login-badge,body[data-theme="dark"] .access .muted{color:#a9bec5}body[data-theme="dark"] .access h2{color:#eef6f7}
.access label{gap:8px;margin:0 0 19px;color:#344f5e;font-size:13px;font-weight:600}.access input{height:48px;padding:0 14px;border:1px solid #cbd9df;border-radius:9px;background:rgba(255,255,255,.88);font-size:14px;color:#1d3441;transition:border-color .16s,box-shadow .16s}
body[data-theme="dark"] .access label{color:#d1e0e3}body[data-theme="dark"] .access input{color:#eef5f6;background:#162b34;border-color:#35505c}
.access input:focus{outline:0;border-color:#16869a;box-shadow:0 0 0 4px rgba(22,123,145,.14)}
.access #loginBtn{height:48px;margin-top:5px;border:0;border-radius:9px;background:linear-gradient(105deg,#126e86,#168a9a);box-shadow:0 8px 20px rgba(18,110,134,.19);font-size:14px;font-weight:650;letter-spacing:.01em}.access #loginBtn:hover{background:linear-gradient(105deg,#0d6178,#11798b);transform:translateY(-1px)}
.access #forgotPassword,.access #signupToggle{width:auto;display:block;margin:13px auto 0;padding:7px 10px;color:#246e83;font-size:13px}.access #forgotPassword:hover,.access #signupToggle:hover{background:rgba(36,110,131,.08)}body[data-theme="dark"] .access #forgotPassword,body[data-theme="dark"] .access #signupToggle{color:#8cd1d1}
#loginMessage{min-height:20px;margin-top:12px;color:#9b531c;font-size:13px}.login-footer{margin-top:32px;padding-top:15px;border-top:1px solid rgba(94,125,139,.2);color:#78909a;font-size:10px;font-weight:650;letter-spacing:.11em}.login-footer span{padding:0 6px;color:#188196}
body[data-theme="dark"] .login-footer{color:#95aeb6;border-color:rgba(194,222,228,.15)}
/* Barra superior por pestañas */
.app-header{position:relative;z-index:20;display:flex;align-items:center;justify-content:space-between;gap:22px;min-height:70px;height:auto;padding:10px clamp(16px,2.5vw,36px);border:0;border-bottom:1px solid rgba(255,255,255,.62);background:rgba(249,252,253,.82);box-shadow:0 4px 20px rgba(24,54,69,.06);backdrop-filter:blur(18px);-webkit-backdrop-filter:blur(18px)}
body[data-theme="dark"] .app-header{background:rgba(13,29,37,.9);border-color:rgba(211,235,239,.1);box-shadow:0 5px 22px rgba(0,0,0,.16)}
.identity{display:flex;align-items:center;gap:18px;min-width:0}.identity>img{display:block;width:min(200px,22vw);height:46px;object-fit:contain;object-position:left center}.product-name{display:flex;flex-direction:column;gap:4px;padding-left:18px;border-left:1px solid var(--ui-border);color:#203947;font-size:13px;font-weight:750;letter-spacing:.075em;white-space:nowrap}.product-name strong{font:inherit}.product-name small{color:#607986;font-size:10px;font-weight:600;letter-spacing:.12em}body[data-theme="dark"] .product-name{color:#eef6f7}body[data-theme="dark"] .product-name small{color:#a7c0c7}
.header-actions{display:flex;align-items:center;justify-content:flex-end;gap:9px;min-width:0}.account{margin:0 10px 0 0;text-align:right;color:var(--ui-text)}.account strong{font-size:13px}.account small{display:block;margin-top:3px;color:var(--ui-muted);font-size:11px}
.header-actions .header-button{min-height:36px;padding:7px 12px;border:1px solid var(--ui-border);border-radius:8px;background:rgba(255,255,255,.52);color:var(--ui-text);font-size:12px;font-weight:600;white-space:nowrap}.header-actions .header-button:hover{border-color:rgba(22,123,145,.45);background:rgba(255,255,255,.9)}body[data-theme="dark"] .header-actions .header-button{color:#dcebee;background:rgba(255,255,255,.045)}body[data-theme="dark"] .header-actions .header-button:hover{background:rgba(255,255,255,.09)}
.theme-switch{display:flex;gap:3px;padding:3px;border:1px solid var(--ui-border);border-radius:10px;background:rgba(119,150,165,.08)}.theme-switch .header-button{border-color:transparent!important;background:transparent!important}.theme-switch [aria-pressed="true"]{background:rgba(22,123,145,.13)!important;color:#0c6377!important;border-color:rgba(22,123,145,.2)!important}body[data-theme="dark"] .theme-switch [aria-pressed="true"]{background:rgba(99,198,189,.16)!important;color:#85ddd4!important;border-color:rgba(99,198,189,.22)!important}
.window-tabs{position:relative;z-index:10;display:flex;align-items:stretch;gap:12px;min-height:50px;padding:8px clamp(14px,2vw,28px) 0;overflow-x:auto;overflow-y:hidden;border-bottom:1px solid var(--ui-border);background:rgba(239,245,247,.82);scrollbar-width:thin;scrollbar-color:rgba(82,125,143,.3) transparent;backdrop-filter:blur(15px);-webkit-backdrop-filter:blur(15px)}body[data-theme="dark"] .window-tabs{background:rgba(15,34,43,.88);border-color:rgba(194,222,228,.12)}
.window-tab-group,.admin-tabs{display:flex;align-items:stretch;gap:5px;flex:0 0 auto}.admin-tabs{padding-left:13px;border-left:1px solid var(--ui-border)}.nav-group-label{align-self:center;padding:0 6px;color:var(--ui-muted);font-size:10px;font-weight:700;letter-spacing:.09em;text-transform:uppercase;white-space:nowrap}
.window-tabs button[data-view]{position:relative;display:inline-flex;align-items:center;justify-content:center;min-height:41px;min-width:max-content;margin:0;padding:0 16px;border:1px solid transparent;border-bottom-color:transparent;border-radius:9px 9px 0 0;background:transparent;color:#526b79;font-size:13px;font-weight:600;white-space:nowrap;transition:color .14s,background .14s,border-color .14s}
.window-tabs button[data-view]:hover{background:rgba(255,255,255,.58);color:#203e4d}.window-tabs button[data-view].selected{color:#0e6478;background:rgba(255,255,255,.88);border-color:var(--ui-border);border-bottom-color:rgba(255,255,255,.88);box-shadow:0 -2px 8px rgba(34,72,89,.04)}.window-tabs button[data-view].selected::after{position:absolute;right:12px;bottom:-1px;left:12px;height:3px;border-radius:3px 3px 0 0;background:#168397;content:""}body[data-theme="dark"] .window-tabs button[data-view]{color:#b7cbd0}body[data-theme="dark"] .window-tabs button[data-view]:hover{background:rgba(255,255,255,.07);color:#f1f7f8}body[data-theme="dark"] .window-tabs button[data-view].selected{color:#a9e4dd;background:rgba(24,52,63,.98);border-color:rgba(197,226,230,.13);border-bottom-color:rgba(24,52,63,.98)}body[data-theme="dark"] .window-tabs button[data-view].selected::after{background:#62c7bc}
.online-users{flex:0 0 auto;max-width:215px;margin:0 0 0 auto;padding:0 0 0 12px;border:0;border-left:1px solid var(--ui-border);color:var(--ui-muted);font-size:12px}.online-users details{position:relative}.online-users summary{padding:9px 6px;cursor:pointer;list-style:none;white-space:nowrap;font-weight:600}.online-users summary::before{display:inline-block;width:7px;height:7px;margin-right:8px;border-radius:50%;background:#40a477;content:""}.online-users-list{position:absolute;top:calc(100% + 10px);right:0;z-index:50;width:min(260px,80vw);max-height:260px;overflow:auto;padding:10px 14px;border:1px solid var(--ui-border);border-radius:11px;background:#fff;color:#263d49;box-shadow:0 16px 38px rgba(20,47,62,.16)}body[data-theme="dark"] .online-users-list{background:#142a34;color:#e6f0f2}.online-user{display:flex;align-items:center;gap:8px;padding:7px 0;border-bottom:1px solid var(--ui-border)}.online-user small{margin-left:auto;color:var(--ui-muted);font-size:11px}
/* Partidas del día en una banda compacta, no en un panel lateral */
.day-explorer{display:flex;align-items:center;gap:12px;min-height:46px;padding:5px clamp(16px,2vw,28px);border-bottom:1px solid var(--ui-border);background:rgba(245,249,250,.64)}body[data-theme="dark"] .day-explorer{background:rgba(17,39,49,.65)}.day-explorer .panel-caption{display:flex;align-items:center;gap:8px;flex:0 0 auto;padding:4px 0;border:0;background:transparent;color:#637985;font-size:10px;font-weight:750;letter-spacing:.1em}.day-explorer .panel-caption span{padding:2px 7px;border-radius:999px;background:rgba(22,123,145,.11);color:#126c7e;font-size:11px}body[data-theme="dark"] .day-explorer .panel-caption{color:#a9c0c6}body[data-theme="dark"] .day-explorer .panel-caption span{background:rgba(99,198,189,.13);color:#94ddd5}#dayNavigator{display:flex;align-items:center;gap:6px;min-width:0;overflow-x:auto;scrollbar-width:thin}#dayNavigator>p{margin:0;padding:4px 0;color:var(--ui-muted);font-size:12px}.navigator-item{display:flex;align-items:center;gap:8px;flex:0 0 auto;width:auto;max-width:280px;margin:0;padding:5px 10px;border:1px solid var(--ui-border);border-radius:7px;background:rgba(255,255,255,.56);text-align:left}.navigator-item strong{margin:0;color:var(--ui-accent-strong);font-size:11px}.navigator-item span{display:block;max-width:190px;overflow:hidden;color:var(--ui-muted);font-size:11px;text-overflow:ellipsis;white-space:nowrap}.navigator-item.active{border-color:rgba(22,123,145,.36);background:rgba(22,123,145,.08);box-shadow:inset 0 0 0 1px rgba(22,123,145,.08)}body[data-theme="dark"] .navigator-item{background:rgba(255,255,255,.04);color:#dcebee}body[data-theme="dark"] .navigator-item.active{background:rgba(99,198,189,.1);border-color:rgba(99,198,189,.28)}
/* Alineación, contraste y tamaño coherentes */
.workspace{display:block;min-height:0;background:transparent}#main{align-self:start;width:min(100% - 44px,1680px);max-width:1680px;margin:0 auto;padding:22px 0 38px;background:transparent;color:var(--ui-text)}.view{min-width:0}.page-title{align-items:center;min-height:112px;margin:0 0 18px;padding:21px 26px;border:1px solid var(--ui-border);border-radius:13px;background:rgba(250,253,254,.83);box-shadow:0 8px 24px rgba(25,57,72,.055)}body[data-theme="dark"] .page-title{background:rgba(22,43,53,.94);border-color:rgba(193,223,230,.15);box-shadow:0 8px 25px rgba(0,0,0,.12)}.page-title h1{color:#203b4b;font-size:clamp(23px,2.1vw,30px);font-weight:680;letter-spacing:-.035em;line-height:1.2}body[data-theme="dark"] .page-title h1{color:#eff7f8}.page-title .eyebrow{color:#397587;font-size:11px;letter-spacing:.12em}body[data-theme="dark"] .page-title .eyebrow{color:#81c9c9}.page-title .muted{color:#5c7480;font-size:13px}body[data-theme="dark"] .page-title .muted{color:#b5c8ce}.card{color:var(--ui-text);background:var(--ui-panel);border-color:var(--ui-border);box-shadow:0 5px 18px rgba(30,62,78,.045)}body[data-theme="dark"] .card,body[data-theme="dark"] .work-ribbon,body[data-theme="dark"] .work-sheet{color:var(--ui-text);background:var(--ui-panel);border-color:var(--ui-border)}.muted,.table-help,.group-caption{color:var(--ui-muted)}label{color:var(--ui-muted);font-size:13px}input,select,textarea{font-size:14px}button{font-size:13px}small{font-size:12px}.eyebrow{font-size:11px}
@media(max-width:900px){.login-layout{grid-template-columns:minmax(0,.8fr) minmax(380px,1.2fr);padding:20px}.brand{padding:30px}.access{padding:30px}.app-header{flex-wrap:wrap;gap:10px}.identity>img{width:160px}.product-name{font-size:11px}.header-actions{gap:6px}.account{display:none}}
@media(max-width:700px){.login-layout{display:flex;min-height:100vh;flex-direction:column;padding:13px}.brand{min-height:auto;flex:0 0 auto;gap:18px;border-radius:16px 16px 0 0;padding:22px 24px}.brand>img{width:min(260px,72vw)}.brand-copy{margin:0}.brand h1{font-size:32px}.brand p:not(.eyebrow){margin-bottom:7px;font-size:13px}.login-status{margin-top:5px}.brand>small{display:none}.access{flex:1;border-left:1px solid rgba(255,255,255,.8);border-top:0;border-radius:0 0 16px 16px;padding:26px 22px}.access form{width:min(100%,420px)}.login-badge{margin-bottom:18px}.access h2{font-size:27px}.access .muted{margin-bottom:20px}.window-tabs{gap:8px;min-height:46px;padding:6px 10px 0}.window-tab-group,.admin-tabs{gap:2px}.admin-tabs{padding-left:7px}.window-tabs button[data-view]{min-height:38px;padding:0 11px;font-size:12px}.nav-group-label{display:none}.online-users{margin-left:auto;padding-left:7px}.online-users summary{font-size:11px}.day-explorer{gap:8px;padding:5px 10px}.day-explorer .panel-caption{font-size:9px}#main{width:calc(100% - 24px);padding:15px 0 28px}.page-title{min-height:0;padding:17px 18px}.page-title h1{font-size:23px}}
@media(max-width:460px){.app-header{min-height:58px;padding:7px 10px}.identity{gap:8px}.identity>img{width:105px;height:32px}.product-name{padding-left:9px;font-size:9px;letter-spacing:.03em}.product-name small{font-size:8px;letter-spacing:.05em}.header-actions .header-button{min-height:32px;padding:5px 7px;font-size:11px}.theme-switch{gap:0;padding:2px}.theme-switch .header-button{padding:5px!important}.theme-label{display:none}.window-tabs button[data-view]{padding:0 9px;font-size:11px}.online-users{max-width:130px}.online-users summary{max-width:120px;overflow:hidden;text-overflow:ellipsis}#main{width:calc(100% - 18px);padding-top:10px}.day-explorer .panel-caption{max-width:115px;font-size:8px}.navigator-item{max-width:210px}.navigator-item span{max-width:130px}}
@media(prefers-reduced-motion:reduce){.brand::before,.brand::after{animation:none!important}*,*::before,*::after{scroll-behavior:auto!important;transition-duration:.01ms!important}}

/* Tema integral: los mismos tokens gobiernan el registro, administración,
   consulta, paneles, diálogos y tutorial. */
body[data-theme="crystal"]{
  color-scheme:light;
  --ui-bg:#eaf0f3;
  --ui-panel:rgba(255,255,255,.78);
  --ui-panel-solid:#fff;
  --ui-panel-soft:rgba(246,250,251,.86);
  --ui-panel-raised:rgba(255,255,255,.94);
  --ui-border:rgba(79,108,124,.2);
  --ui-text:#243844;
  --ui-muted:#5b707c;
  --ui-accent:#177c91;
  --ui-accent-strong:#105d70;
  --ui-accent-soft:rgba(23,124,145,.1);
  --ui-hover:rgba(32,103,128,.075);
  --ui-row:#fff;
  --ui-row-alt:#f5f8f9;
  --ui-control:rgba(255,255,255,.88);
  --ui-table-head:#eaf1f4;
  --ui-shadow:0 10px 28px rgba(32,64,78,.07);
  --ui-focus:rgba(23,124,145,.2);
  --ui-danger:#a94141;
  --ui-danger-soft:#fff0ef;
  --ui-success:#287859;
  --ui-success-soft:#e8f5ee;
  --ui-warning:#8b6723;
  --ui-warning-soft:#fff5df;
}
body[data-theme="dark"]{
  color-scheme:dark;
  --ui-bg:#101e26;
  --ui-panel:rgba(22,39,48,.82);
  --ui-panel-solid:#172a34;
  --ui-panel-soft:rgba(27,47,57,.9);
  --ui-panel-raised:rgba(31,52,62,.96);
  --ui-border:rgba(180,211,220,.17);
  --ui-text:#e6eff1;
  --ui-muted:#adbec4;
  --ui-accent:#73c9c1;
  --ui-accent-strong:#9ce1da;
  --ui-accent-soft:rgba(99,198,189,.13);
  --ui-hover:rgba(192,224,230,.075);
  --ui-row:rgba(20,39,48,.88);
  --ui-row-alt:rgba(29,49,59,.94);
  --ui-control:rgba(15,31,39,.92);
  --ui-table-head:rgba(36,59,69,.96);
  --ui-shadow:0 12px 32px rgba(0,0,0,.2);
  --ui-focus:rgba(99,198,189,.23);
  --ui-danger:#ffaaa1;
  --ui-danger-soft:rgba(141,55,51,.22);
  --ui-success:#91d6b2;
  --ui-success-soft:rgba(39,122,84,.2);
  --ui-warning:#f0cd82;
  --ui-warning-soft:rgba(137,100,35,.2);
}

body[data-theme]::before{pointer-events:none}
body[data-theme] #app,
body[data-theme] .workspace,
body[data-theme] #main,
body[data-theme] .view{color:var(--ui-text);background:transparent}
body[data-theme] #main :is(h1,h2,h3,h4,.card-title,.sheet-heading h3,.apu-editor-heading h2){color:var(--ui-text)}
body[data-theme] #main :is(p,small,.muted,.table-help,.group-caption,.sheet-heading small,.query-description,.team-help,.apu-overview,.apu-shared,.apu-table-help){color:var(--ui-muted)}
body[data-theme] #main :is(label,.eyebrow,.panel-caption,.ribbon-title span,.ribbon-secondary,.selection-bar,.sheet-context){color:var(--ui-muted)}
body[data-theme] #main a{color:var(--ui-accent-strong)}

/* Superficies translúcidas del producto. */
body[data-theme] :is(.card,.work-ribbon,.work-sheet,.page-title,.apu-library,.apu-editor,.ins-view .card,.ins-section,.ins-chart-card,.ins-machine-card){
  color:var(--ui-text)!important;
  background:var(--ui-panel)!important;
  border-color:var(--ui-border)!important;
  box-shadow:var(--ui-shadow);
  backdrop-filter:blur(12px);
  -webkit-backdrop-filter:blur(12px);
}
body[data-theme] .page-title{background:var(--ui-panel-raised)!important}
body[data-theme] :is(.ribbon-title,.ribbon-secondary,.selection-bar,.sheet-title,.sheet-context,.apu-library-head,.apu-library-filters,.apu-pagination,.apu-properties,.apu-editor-tools,.apu-publishbar,.complementary){
  color:var(--ui-text);
  background:var(--ui-panel-soft)!important;
  border-color:var(--ui-border)!important;
}
body[data-theme] :is(.command-group,.workspace-summary,.sheet-actions,.list-line,.asset-row,.team-row,.team-form){border-color:var(--ui-border)}
body[data-theme] :is(.sheet-code,.badge,.panel-caption span){color:var(--ui-accent-strong);background:var(--ui-accent-soft);border-color:var(--ui-border)}
body[data-theme] :is(.grid-tabs,.theme-switch){background:var(--ui-panel-soft);border-color:var(--ui-border)}
body[data-theme] .grid-tabs button{color:var(--ui-text);background:transparent}
body[data-theme] .grid-tabs button.active{color:var(--ui-accent-strong);background:var(--ui-accent-soft);box-shadow:inset 0 -2px var(--ui-accent)}
body[data-theme] :is(.command-group button,.sheet-actions button,.selection-bar button,.ribbon-secondary button,.team-form button,.team-row button,.asset-form button,.asset-row button,.apu-library button:not(.primary),.apu-editor button:not(.primary),.picker-body button:not(.primary),.dialog-actions button:not(.primary)){
  color:var(--ui-text);
  background:var(--ui-panel-raised);
  border-color:var(--ui-border);
}
body[data-theme] :is(.command-group button,.sheet-actions button,.selection-bar button,.ribbon-secondary button,.team-form button,.team-row button,.asset-form button,.asset-row button,.apu-library button:not(.primary),.apu-editor button:not(.primary),.picker-body button:not(.primary),.dialog-actions button:not(.primary)):hover{
  background:var(--ui-hover);
  border-color:var(--ui-accent);
}
body[data-theme] :is(button,.navigator-item,.picker-result,.apu-base-pick){transition:background-color .16s,border-color .16s,color .16s,box-shadow .16s}
body[data-theme] :is(.command-group button.primary,.savebar .primary,.guide-actions .primary,.ins-toolbar .primary,.ins-publish .primary,.apu-library .primary,.apu-editor .primary,.apu-publishbar .primary,.picker-body .primary,.dialog-actions .primary){color:#fff;background:#176f91;border-color:#176f91}
body[data-theme="dark"] :is(.command-group button.primary,.savebar .primary,.guide-actions .primary,.ins-toolbar .primary,.ins-publish .primary,.apu-library .primary,.apu-editor .primary,.apu-publishbar .primary,.picker-body .primary,.dialog-actions .primary){color:#082a31;background:#79d1c8;border-color:#79d1c8}

/* Controles, incluidos los campos de módulos antiguos y ventanas emergentes. */
body[data-theme] :is(input:not([type=checkbox]):not([type=radio]),select,textarea){
  color:var(--ui-text);
  background-color:var(--ui-control);
  border-color:var(--ui-border);
}
body[data-theme] :is(input,select,textarea)::placeholder{color:var(--ui-muted);opacity:.82}
body[data-theme] :is(input,select,textarea):focus{outline-color:var(--ui-focus);border-color:var(--ui-accent)}
body[data-theme] :is(input,select,textarea):disabled{color:var(--ui-muted);background:var(--ui-panel-soft);opacity:.72}
body[data-theme] select option{color:var(--ui-text);background:var(--ui-panel-solid)}
body[data-theme] .daily-table :is(input:not([type=checkbox]),select){background:transparent;color:var(--ui-text);border-color:transparent}
body[data-theme] .daily-table :is(input:not([type=checkbox]),select):focus{background:var(--ui-panel-raised);outline-color:var(--ui-accent)}
body[data-theme] .daily-table input[readonly]{background:var(--ui-panel-soft);color:var(--ui-muted)}
body[data-theme] .daily-table input[aria-invalid=true]{color:var(--ui-danger);background:var(--ui-danger-soft)}
body[data-theme] .ribbon-check input,.guide-checks input{accent-color:var(--ui-accent)}

/* Tablas: encabezados, celdas fijas, selección, hover y edición. */
body[data-theme] :is(.tablewrap,.grid-scroll,.apu-library-scroll,.apu-detail-scroll){scrollbar-color:var(--ui-border) transparent}
body[data-theme] :is(table:not(.daily-table),.daily-table,.apu-edit-table){color:var(--ui-text);background:transparent}
body[data-theme] :is(table:not(.daily-table) th,.daily-table th,.apu-edit-table th){color:var(--ui-text);background:var(--ui-table-head)!important;border-color:var(--ui-border)!important}
body[data-theme] :is(table:not(.daily-table) td,.daily-table td,.apu-edit-table td){color:var(--ui-text);background:var(--ui-row);border-color:var(--ui-border)!important}
body[data-theme] .daily-table tbody tr:nth-child(even) td{background:var(--ui-row-alt)}
body[data-theme] .daily-table :is(.row-control,.row-actions,.field-qty){background:var(--ui-panel-soft)}
body[data-theme] .daily-table tbody tr:hover td,
body[data-theme] .daily-table tbody tr:hover .row-control,
body[data-theme] .daily-table tbody tr:hover .row-actions,
body[data-theme] .daily-table tbody tr:hover .field-qty{background:var(--ui-hover)}
body[data-theme] .daily-table tbody tr.row-selected td,
body[data-theme] .daily-table tbody tr.row-selected .activity-col,
body[data-theme] .daily-table tbody tr.row-selected .row-control,
body[data-theme] .daily-table tbody tr.row-selected .row-actions,
body[data-theme] .daily-table tbody tr.row-selected .field-qty{background:var(--ui-accent-soft)}
body[data-theme] .daily-table td:focus-within{background:var(--ui-accent-soft)!important;box-shadow:inset 0 0 0 1px var(--ui-accent)!important}
body[data-theme] .daily-table .activity-col>span{color:var(--ui-text)}
body[data-theme] .daily-table .activity-col>small,
body[data-theme] .daily-table .row-actions button,
body[data-theme] .daily-table .unit-tag{color:var(--ui-muted)}
body[data-theme] .daily-table .row-actions button:hover{color:var(--ui-accent-strong);background:var(--ui-hover)}
body[data-theme] .daily-table .row-actions button.subtle-danger:hover{color:var(--ui-danger);background:var(--ui-danger-soft)}
body[data-theme] .apu-library td,.apu-edit-table td{background:var(--ui-row)}
body[data-theme] .apu-library-pick{color:var(--ui-text);background:transparent}
body[data-theme] .apu-library-pick:hover,body[data-theme] .picker-result:hover,body[data-theme] .apu-base-pick:hover{background:var(--ui-hover)}
body[data-theme] .apu-current{background:var(--ui-accent-soft);box-shadow:inset 3px 0 var(--ui-accent)}
body[data-theme] .apu-edit-table input{color:var(--ui-text);background:transparent}
body[data-theme] .apu-edit-table input:focus{background:var(--ui-accent-soft)}
body[data-theme] .empty-sheet{color:var(--ui-muted);background:var(--ui-panel-soft);border-color:var(--ui-border)}

/* Selector de partidas, edición de detalle y demás diálogos. */
body[data-theme] dialog,
body[data-theme] #rhTutorial,
body[data-theme] .guide-layout,
body[data-theme] .guide-peek{
  color:var(--ui-text);
  background:var(--ui-panel-raised);
  border-color:var(--ui-border);
  box-shadow:var(--ui-shadow);
  backdrop-filter:blur(16px);
  -webkit-backdrop-filter:blur(16px);
}
body[data-theme] dialog::backdrop{background:rgba(19,39,50,.42);backdrop-filter:blur(3px)}
body[data-theme] :is(.dialog-title,.dialog-actions,.picker-body,.picker-filters,.picker-result,.guide-topics){color:var(--ui-text);background:var(--ui-panel-soft);border-color:var(--ui-border)}
body[data-theme] .dialog-title{background:var(--ui-panel-raised);border-bottom:1px solid var(--ui-border)}
body[data-theme] .dialog-title h2{color:var(--ui-text)}
body[data-theme] .dialog-title small,body[data-theme] .dialog-title .icon-button{color:var(--ui-muted)}
body[data-theme] .dialog-title .icon-button{background:transparent}
body[data-theme] :is(.dialog-body,.picker-body){color:var(--ui-text);background:var(--ui-panel-raised)}
body[data-theme] .dialog-actions{border-top:1px solid var(--ui-border)}
body[data-theme] :is(.picker-filters summary,.picker-result small,.picker-result .picker-edt,.query-description){color:var(--ui-muted)}
body[data-theme] .picker-result{border-bottom-color:var(--ui-border)}
body[data-theme] :is(#recoverStatus,#passwordStatus){color:var(--ui-accent-strong)}
body[data-theme] .notification{color:var(--ui-text);background:var(--ui-panel-raised);border-color:var(--ui-border);border-left-color:var(--ui-accent);box-shadow:var(--ui-shadow);backdrop-filter:blur(14px)}
body[data-theme] .notification.error{color:var(--ui-danger);background:var(--ui-danger-soft);border-color:var(--ui-danger)}

/* Tutorial de la gota: colores de marca, superficies coherentes con el tema. */
body[data-theme] #rhTutorial{font-family:var(--ui-font)!important;border:1px solid var(--ui-border)}
body[data-theme] .guide-top{color:var(--ui-text);background:var(--ui-panel-raised);border-color:var(--ui-border);border-bottom-color:var(--ui-accent);backdrop-filter:blur(16px)}
body[data-theme] .guide-top h2,body[data-theme] .guide-top small,body[data-theme] .guide-top>button{color:var(--ui-text)}
body[data-theme] .guide-top>button{background:var(--ui-panel-soft);border-color:var(--ui-border)}
body[data-theme] .guide-layout{background:var(--ui-panel-raised);border-color:var(--ui-border)}
body[data-theme] .guide-topics{background:var(--ui-panel-soft);border-color:var(--ui-border)}
body[data-theme] .guide-topics button{color:var(--ui-text)}
body[data-theme] .guide-topics button:hover,body[data-theme] .guide-topics button[aria-current=step]{color:var(--ui-accent-strong);background:var(--ui-accent-soft);border-color:var(--ui-border)}
body[data-theme] :is(.guide-topics button small,.guide-topics>p,.guide-topics>small,.guide-progress,.guide-explain,.guide-tip p,.guide-practice>p,.guide-workbook>p,.guide-peek p){color:var(--ui-muted)}
body[data-theme] .guide-host{color:var(--ui-text);background:var(--ui-panel-soft);border-color:var(--ui-border)}
body[data-theme] .guide-host p,body[data-theme] #guideLesson h3,body[data-theme] .guide-peek strong{color:var(--ui-text)}
body[data-theme] :is(.guide-tip,.guide-mini span,.guide-practice,.guide-workbook,.guide-workbook>strong,.guide-quiz button){color:var(--ui-text);background:var(--ui-panel-soft);border-color:var(--ui-border)}
body[data-theme] .guide-workbook span{color:var(--ui-success);background:var(--ui-success-soft);border-color:var(--ui-border)}
body[data-theme] .guide-practice output{color:var(--ui-accent-strong);background:var(--ui-accent-soft)}
body[data-theme] .guide-progress,body[data-theme] .guide-actions{border-color:var(--ui-border)}
body[data-theme] .guide-drop-button{color:var(--ui-accent-strong)}
body[data-theme] .guide-drop-button:hover{background:var(--ui-accent-soft);border-color:var(--ui-border)}
body[data-theme] .guide-quiz p{color:var(--ui-accent-strong)}
body[data-theme] .guide-peek{background:var(--ui-panel-raised)}
body[data-theme] .guide-login{color:var(--ui-accent-strong)}

/* Usuarios en línea, avisos de estado y estados de APU. */
body[data-theme] .online-users-list{color:var(--ui-text);background:var(--ui-panel-raised);border-color:var(--ui-border);box-shadow:var(--ui-shadow);backdrop-filter:blur(14px)}
body[data-theme] .online-user{color:var(--ui-text);border-color:var(--ui-border)}
body[data-theme] .online-user small{color:var(--ui-muted)}
body[data-theme] .online-users summary{color:var(--ui-muted)}
body[data-theme] .apu-state{color:var(--ui-success);background:var(--ui-success-soft)}
body[data-theme] .apu-state.missing{color:var(--ui-warning);background:var(--ui-warning-soft)}
body[data-theme] .apu-state.review{color:var(--ui-danger);background:var(--ui-danger-soft)}
body[data-theme] .subtle-danger{color:var(--ui-danger)!important}
body[data-theme] .demo-banner{color:var(--ui-muted);background:var(--ui-panel-soft);border-color:var(--ui-border)}
body[data-theme] .demo-message{color:#fff;background:#183d51}

@media(max-width:760px){
  body[data-theme] .savebar{background:var(--ui-panel-raised);border-color:var(--ui-border)}
  body[data-theme] .apu-workspace{background:transparent}
}
@media(prefers-reduced-transparency:reduce){
  body[data-theme] :is(.card,.work-ribbon,.work-sheet,.page-title,.apu-library,.apu-editor,.online-users-list,dialog,#rhTutorial,.guide-layout,.guide-peek,.notification){backdrop-filter:none;-webkit-backdrop-filter:none}
  body[data-theme="crystal"] :is(.card,.work-ribbon,.work-sheet,.page-title,.apu-library,.apu-editor,dialog,#rhTutorial,.guide-layout,.guide-peek){background:#fff}
  body[data-theme="dark"] :is(.card,.work-ribbon,.work-sheet,.page-title,.apu-library,.apu-editor,dialog,#rhTutorial,.guide-layout,.guide-peek){background:#172a34}
}

/* Solo tema oscuro. La transparencia deja ver el fondo sin perder contraste. */
body[data-theme="dark"]{
  color-scheme:dark;
  --ui-bg:#101e26;
  --ui-panel:rgba(22,39,48,.86);
  --ui-panel-solid:#172a34;
  --ui-panel-soft:rgba(29,49,59,.92);
  --ui-panel-raised:rgba(31,52,62,.97);
  --ui-border:rgba(190,218,225,.2);
  --ui-text:#edf4f5;
  --ui-muted:#bed0d4;
  --ui-accent:#73d1c7;
  --ui-accent-strong:#a4e9e1;
  --ui-row:rgba(20,39,48,.92);
  --ui-row-alt:rgba(29,49,59,.96);
  --ui-control:rgba(12,27,35,.96);
  --ui-table-head:rgba(39,64,75,.98);
}
body[data-theme="dark"]::before{background:radial-gradient(ellipse at 10% 7%,rgba(40,128,137,.22),transparent 40%),radial-gradient(ellipse at 91% 13%,rgba(44,99,132,.24),transparent 44%),radial-gradient(ellipse at 64% 98%,rgba(110,84,49,.12),transparent 38%),linear-gradient(135deg,#0d1921 0%,#11242d 58%,#15262b 100%)}
body[data-theme="dark"] :is(.app-header,.window-tabs,.day-explorer){background-color:rgba(13,29,37,.88);border-color:var(--ui-border)}
body[data-theme="dark"] #main :is(.card,.page-title,.apu-library,.apu-editor,.work-ribbon,.work-sheet,.ins-section,.ins-chart-card,.ins-machine-card,.ins-view .card){color:var(--ui-text);background:var(--ui-panel);border-color:var(--ui-border);box-shadow:var(--ui-shadow);backdrop-filter:blur(14px);-webkit-backdrop-filter:blur(14px)}
body[data-theme="dark"] #main :is(h1,h2,h3,h4,.card-title,.sheet-heading h3,.apu-editor-heading h2,.ins-card-title h2,.ins-section-heading strong){color:#f0f7f8!important}
body[data-theme="dark"] #main :is(p,small,.muted,.table-help,.group-caption,.sheet-heading small,.query-description,.team-help,.apu-overview,.apu-shared,.apu-table-help,.ins-card-title small){color:var(--ui-muted)!important}
body[data-theme="dark"] #main :is(label,.eyebrow,.panel-caption,.ribbon-title span,.ribbon-secondary,.selection-bar,.sheet-context,.ins-section-heading small){color:#bed0d4!important}
body[data-theme="dark"] .apu-editor-heading{color:var(--ui-text)!important;background:linear-gradient(120deg,rgba(36,64,76,.98),rgba(24,47,57,.98))!important;border-top-color:var(--ui-accent)!important;border-bottom:1px solid var(--ui-border)}
body[data-theme="dark"] .apu-editor-heading .apu-section-code{color:var(--ui-accent)!important}
body[data-theme="dark"] .apu-editor-heading h2{color:#f2f8f9!important}
body[data-theme="dark"] .apu-editor-heading p{color:#c2d3d7!important}
body[data-theme="dark"] :is(.apu-library-head,.apu-library-filters,.apu-pagination,.apu-properties,.apu-editor-tools,.apu-publishbar,.ribbon-title,.ribbon-secondary,.selection-bar,.sheet-title,.sheet-context,.complementary){color:var(--ui-text);background:var(--ui-panel-soft)!important;border-color:var(--ui-border)!important}
body[data-theme="dark"] :is(.apu-library-head,.apu-library-filters,.apu-properties,.apu-editor-tools,.apu-publishbar) :is(h2,h3,strong,summary,label,span,small){color:var(--ui-text)}
body[data-theme="dark"] :is(.apu-properties summary,.apu-library-pick small,.apu-pagination span,.apu-editor-tools span,.apu-publishbar small,.apu-table-help){color:var(--ui-muted)!important}
body[data-theme="dark"] .apu-library-pick strong{color:var(--ui-text)!important}
body[data-theme="dark"] :is(.apu-edit-table td,.apu-library td){background:var(--ui-row)!important;color:var(--ui-text)!important}
body[data-theme="dark"] :is(.apu-edit-table tr:nth-child(even) td,.apu-library tbody tr:nth-child(even) td){background:var(--ui-row-alt)!important}
body[data-theme="dark"] :is(.apu-edit-table th,.apu-library th){background:var(--ui-table-head)!important;color:#dcebed!important;border-color:var(--ui-border)!important}
body[data-theme="dark"] .apu-editor-heading + .apu-shared{color:var(--ui-muted)!important;background:rgba(13,29,37,.42)}
body[data-theme="dark"] :is(.ins-kpis article,.ins-ratios article,.ins-production-donuts>.card){color:var(--ui-text);background:rgba(18,37,46,.78)!important;border-color:var(--ui-border)!important}
body[data-theme="dark"] :is(.ins-kpis article strong,.ins-ratios strong,.ins-view td strong){color:#f0f7f8!important}
body[data-theme="dark"] :is(.ins-kpis article small,.ins-kpis article span,.ins-ratios small,.ins-ratios span:not(.ins-ratio-mark),.ins-view td small){color:var(--ui-muted)!important}
body[data-theme="dark"] :is(.ins-view th,.ins-view td,.tablewrap th,.tablewrap td){border-color:var(--ui-border)!important}
body[data-theme="dark"] :is(.ins-view th,.tablewrap th){background:var(--ui-table-head)!important;color:#dcebed!important}
body[data-theme="dark"] :is(.ins-view td,.tablewrap td){background:rgba(18,37,46,.72);color:#d9e7e9!important}
body[data-theme="dark"] :is(.ins-chart-types,.ins-chart-types button.active){color:var(--ui-text);background:var(--ui-panel-soft);border-color:var(--ui-border)}
body[data-theme="dark"] :is(.ins-chart-types button,.ins-series-heading strong,.ins-series-heading small){color:#c1d3d7}
body[data-theme="dark"] :is(.ins-ring-legend button,.ins-ring-legend strong){color:#dcebed}
body[data-theme="dark"] :is(.ins-bars span,.ins-performance-note p,.ins-performance-meta){color:var(--ui-muted)}
body[data-theme="dark"] :is(.ins-bars strong,.ins-performance-note strong,.ins-performance-meta strong){color:var(--ui-text)}
body[data-theme="dark"] :is(.ins-empty,.ins-note,.ins-unit-bars,.ins-performance-note){color:var(--ui-muted);background:rgba(20,39,48,.82);border-color:var(--ui-border)}
body[data-theme="dark"] :is(.ins-ratio-mark,.ins-goal-number,.ins-goal-track,.ins-bar-track,.ins-meter){background-color:rgba(190,218,225,.12)}
body[data-theme="dark"] :is(dialog,#rhTutorial,.guide-layout,.guide-peek,.online-users-list,.notification){color:var(--ui-text);background:var(--ui-panel-raised);border-color:var(--ui-border);box-shadow:var(--ui-shadow);backdrop-filter:blur(16px);-webkit-backdrop-filter:blur(16px)}
body[data-theme="dark"] :is(.dialog-title,.dialog-body,.dialog-actions,.picker-body,.picker-filters,.guide-top,.guide-topics,.guide-host){color:var(--ui-text);background:var(--ui-panel-soft);border-color:var(--ui-border)}
body[data-theme="dark"] :is(.dialog-title h2,.dialog-title small,.dialog-body p,.guide-top h2,.guide-top small,.guide-topics button,.guide-host p){color:var(--ui-text)}
body[data-theme="dark"] :is(.dialog-body,.picker-body,.guide-layout,.guide-peek) :is(p,small,label){color:var(--ui-muted)}
body[data-theme="dark"] .demo-banner{color:#d9e7e9;background:rgba(20,39,48,.72);border-color:var(--ui-border)}
body[data-theme="dark"] .demo-title :is(h2,p,small){color:var(--ui-text)!important}
body[data-theme="dark"] .demo-title small,.demo-banner strong{color:var(--ui-accent)!important}
body[data-theme="dark"] :is(.notification.error,#recoverStatus,#passwordStatus){color:var(--ui-danger)}
body[data-theme="dark"] :is(button,input,select,textarea):focus-visible{outline:2px solid var(--ui-accent);outline-offset:2px}
body[data-theme="dark"] #main button:not(.primary):not(.text):not(.row-actions button){color:var(--ui-text);background:var(--ui-panel-raised);border-color:var(--ui-border)}
body[data-theme="dark"] #main button:not(.primary):not(.text):not(.row-actions button):hover{color:#f2f8f9;background:var(--ui-hover);border-color:var(--ui-accent)}
body[data-theme="dark"] #main button.text{color:var(--ui-accent-strong);background:transparent;border-color:transparent}
body[data-theme="dark"] #main .savebar{color:var(--ui-text);background:rgba(17,35,44,.94);border-color:var(--ui-border);box-shadow:var(--ui-shadow);backdrop-filter:blur(16px);-webkit-backdrop-filter:blur(16px)}
body[data-theme="dark"] #main .savebar>span{color:var(--ui-muted)}
body[data-theme="dark"] #main .daily-table .row-actions button{color:var(--ui-muted);background:transparent;border-color:transparent}
@media(prefers-reduced-transparency:reduce){body[data-theme="dark"] :is(.card,.page-title,.apu-library,.apu-editor,.work-ribbon,.work-sheet,.ins-section,.ins-chart-card,.ins-machine-card,.ins-view .card,dialog,#rhTutorial,.guide-layout,.guide-peek,.notification){background:#172a34!important;backdrop-filter:none;-webkit-backdrop-filter:none}}
