:root{
 --red:#b5121b;--red2:#8e0d14;--ink:#23262b;--muted:#747982;--line:#e7e9ed;--bg:#f3f4f6;--white:#fff;--soft:#fff3f3;--good:#1f8a4c;--warning:#b26a00;
 --shadow:0 18px 45px rgba(31,35,41,.12);--radius:20px;--header:74px;
}
*{box-sizing:border-box}html,body{margin:0;height:100%;font-family:Inter,ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Arial,sans-serif;color:var(--ink);background:var(--bg)}
button,input,select,textarea{font:inherit}button{cursor:pointer}.muted{color:var(--muted)}
.login-body{overflow:hidden;background:linear-gradient(145deg,#f6f6f7 0,#eceeef 100%)}
.login-shell{height:100dvh;display:grid;grid-template-columns:1.15fr .85fr;max-width:1180px;margin:auto;padding:30px;gap:30px;align-items:stretch}
.brand-panel{border-radius:30px;background:linear-gradient(145deg,var(--red),var(--red2));color:#fff;display:flex;align-items:center;justify-content:center;gap:34px;padding:50px;box-shadow:var(--shadow)}
.brand-panel p{max-width:420px;line-height:1.5;opacity:.9}.brand-title{font-weight:900;font-size:56px;letter-spacing:-2px}.brand-subtitle{font-size:18px;letter-spacing:8px;font-weight:800;opacity:.92}
.brand-mark{width:72px;height:72px;color:var(--red);display:grid;place-items:center}.brand-mark svg{width:100%;height:100%}.brand-mark-xl{width:150px;height:150px;color:#fff}.brand-mark-sm{width:45px;height:45px}.login-card{align-self:center;background:#fff;border-radius:30px;padding:42px;box-shadow:var(--shadow);max-width:470px;width:100%;justify-self:center}.login-card h1{margin:0 0 8px;font-size:34px}.login-card label{display:block;font-weight:700;font-size:13px;margin:18px 0 7px}.login-card input{width:100%;height:50px;border:1px solid var(--line);border-radius:14px;padding:0 14px;outline:none}.login-card input:focus{border-color:var(--red);box-shadow:0 0 0 3px rgba(181,18,27,.08)}.login-foot{margin-top:22px;color:var(--muted);font-size:12px;text-align:center}.mobile-brand{display:none;align-items:center;gap:10px;color:var(--red);margin-bottom:20px}.mobile-brand .brand-mark{width:42px;height:42px}
.btn{border:0;border-radius:12px;height:44px;padding:0 16px;font-weight:800;display:inline-flex;align-items:center;justify-content:center;gap:8px;transition:.16s}.btn-primary{background:var(--red);color:#fff}.btn-primary:hover{background:var(--red2);transform:translateY(-1px)}.btn-outline{background:#fff;color:var(--red);border:1px solid rgba(181,18,27,.25)}.btn-danger{background:#fff0f0;color:#a40d14}.btn-block{width:100%;margin-top:22px}.btn-sm{height:34px;padding:0 11px;border-radius:9px;font-size:12px}.form-msg{min-height:22px;margin-top:12px;font-size:13px;text-align:center}.form-msg.loading{color:var(--muted)}.form-msg.error{color:var(--red)}
.app-body{overflow:hidden;background:linear-gradient(180deg,#f7f7f8,#eef0f2)}.app-header{height:var(--header);background:#fff;border-bottom:1px solid var(--line);display:flex;align-items:center;justify-content:space-between;padding:0 24px;position:relative;z-index:10}.app-brand{display:flex;align-items:center;gap:12px}.app-brand-button{border:0;background:transparent;padding:0;color:inherit;font:inherit;text-align:left;cursor:pointer;border-radius:12px}.app-brand-button:focus-visible{outline:3px solid rgba(181,18,27,.2);outline-offset:4px}.app-brand strong{font-size:22px;display:block;line-height:1}.app-brand span{font-size:10px;letter-spacing:4px;font-weight:900;color:var(--red)}.header-right{display:flex;align-items:center;gap:10px}.home-btn{height:40px;border:1px solid #ead7d9;background:#fff5f5;color:var(--red);border-radius:12px;padding:0 13px;display:flex;align-items:center;gap:7px;font-weight:900;font-size:12px;cursor:pointer}.home-btn:hover{background:#ffecef;border-color:#e4bcc0}.home-btn i{font-size:13px}.user-pill{display:grid;grid-template-columns:auto 1fr;column-gap:9px;align-items:center;background:#f5f6f7;border-radius:14px;padding:7px 12px}.user-pill i{grid-row:1/3;color:var(--red)}.user-pill span{font-size:12px;font-weight:800}.user-pill small{color:var(--muted);font-size:10px}.icon-btn,.back-btn,.modal-x{border:0;background:#f4f5f6;width:40px;height:40px;border-radius:12px;color:var(--ink);display:grid;place-items:center}.icon-btn:hover,.back-btn:hover{background:#eee}.dashboard-main{height:calc(100dvh - var(--header));display:grid;grid-template-rows:auto 1fr auto;padding:22px 24px 14px;overflow:hidden;max-width:1400px;margin:auto}.dashboard-copy h1{margin:0;font-size:27px}.dashboard-copy p{margin:4px 0 0;color:var(--muted);font-size:13px}.menu-grid{align-self:center;display:grid;grid-template-columns:repeat(4,minmax(140px,1fr));gap:16px;max-width:1050px;width:100%;margin:0 auto}.menu-card{min-height:145px;border:1px solid #eceef1;border-radius:22px;background:#fff;box-shadow:0 9px 24px rgba(38,42,47,.07);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:14px;color:var(--ink);font-weight:900;font-size:15px;transition:.18s}.menu-card i{font-size:34px;color:var(--red)}.menu-card:hover{transform:translateY(-4px);box-shadow:0 15px 35px rgba(38,42,47,.12);border-color:rgba(181,18,27,.18)}.dash-foot{display:flex;justify-content:space-between;color:#8a8f97;font-size:11px;padding-top:10px}
.module-screen{position:fixed;z-index:20;inset:var(--header) 0 0;background:var(--bg);padding:18px 22px 18px;display:none;grid-template-rows:auto auto minmax(0,1fr);gap:12px;overflow:hidden}.module-screen.open{display:grid}.module-head{display:flex;align-items:center;justify-content:space-between}.module-head>div:first-child{display:flex;align-items:center;gap:10px}.module-head h2{margin:0;font-size:24px}.head-actions{display:flex;gap:8px}.module-toolbar,.filters-row{display:flex;align-items:center;gap:9px;min-width:0}.search-box{height:42px;flex:1;min-width:180px;max-width:430px;background:#fff;border:1px solid var(--line);border-radius:12px;display:flex;align-items:center;padding:0 12px;gap:9px}.search-box i{color:#9ca1a8}.search-box input{border:0;outline:0;width:100%;background:transparent}.module-toolbar select,.filters-row select,.filters-row input{height:42px;border:1px solid var(--line);background:#fff;border-radius:12px;padding:0 12px;outline:0;min-width:135px}.summary-chip{background:#fff;border:1px solid var(--line);height:42px;border-radius:12px;padding:0 13px;display:flex;align-items:center;gap:5px;font-size:12px;white-space:nowrap}.summary-chip strong{font-size:13px}.danger-lite{background:#fff7f7;border-color:#f2d8da;color:#8d1117}.table-wrap{min-height:0;overflow:auto;background:#fff;border:1px solid var(--line);border-radius:16px}.table-wrap table{width:100%;border-collapse:collapse;min-width:780px}.table-wrap th{position:sticky;top:0;background:#f7f8f9;z-index:1;text-align:left;font-size:11px;text-transform:uppercase;letter-spacing:.04em;color:#727780;padding:12px;border-bottom:1px solid var(--line)}.table-wrap td{padding:11px 12px;border-bottom:1px solid #eff0f2;font-size:13px;vertical-align:middle}.table-wrap tr:hover td{background:#fcfcfd}.actions{display:flex;justify-content:flex-end;gap:5px}.row-btn{width:34px;height:34px;border:0;border-radius:9px;background:#f3f4f5;color:#444}.row-btn:hover{background:#e8eaed}.row-btn.red{color:var(--red);background:#fff2f2}.badge{display:inline-flex;height:26px;padding:0 9px;border-radius:999px;align-items:center;font-size:11px;font-weight:800}.badge.active{background:#eaf7ef;color:#1c7b43}.badge.inactive{background:#f0f1f2;color:#777}.badge.mat{background:#eef3ff;color:#3456a4}.badge.mdo{background:#f5efff;color:#6e3ca5}.badge.gas{background:#fff3df;color:#9a5d00}.progress{height:8px;background:#eceef0;border-radius:99px;overflow:hidden;width:130px}.progress>span{display:block;height:100%;background:var(--red);border-radius:99px}.report-total{position:absolute;right:22px;top:76px;background:#fff;border:1px solid var(--line);border-radius:12px;padding:10px 13px;font-size:12px}.report-total strong{color:var(--red);font-size:15px}
.modal{position:fixed;z-index:60;inset:0;background:rgba(17,20,24,.5);backdrop-filter:blur(4px);display:none;align-items:center;justify-content:center;padding:16px}.modal.open{display:flex}.modal-card{width:min(760px,100%);max-height:calc(100dvh - 32px);background:#fff;border-radius:22px;box-shadow:0 30px 70px rgba(0,0,0,.23);display:grid;grid-template-rows:auto minmax(0,1fr);overflow:hidden}.modal-card.wide{width:min(1040px,100%)}.modal-head{height:62px;padding:0 18px;border-bottom:1px solid var(--line);display:flex;align-items:center;justify-content:space-between}.modal-head h3{margin:0;font-size:19px}.modal-x{font-size:25px}.modal-body{padding:16px 18px;overflow:auto}.form-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:13px}.form-grid .full{grid-column:1/-1}.field label{font-size:11px;font-weight:800;color:#666c75;display:block;margin-bottom:6px;text-transform:uppercase}.field input,.field select,.field textarea{width:100%;height:44px;border:1px solid var(--line);border-radius:11px;padding:0 12px;outline:0;background:#fff}.field textarea{min-height:78px;padding:10px 12px;resize:vertical}.field input:focus,.field select:focus,.field textarea:focus{border-color:var(--red);box-shadow:0 0 0 3px rgba(181,18,27,.07)}.form-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:18px}.switch-row{display:flex;align-items:center;gap:10px}.switch{width:48px;height:27px;border-radius:99px;background:#cfd3d7;position:relative;border:0}.switch span{position:absolute;width:21px;height:21px;left:3px;top:3px;background:#fff;border-radius:50%;transition:.15s}.switch.on{background:var(--red)}.switch.on span{left:24px}.hint{font-size:11px;color:var(--muted);margin-top:5px}.lookup-status{min-height:19px;font-size:12px;color:var(--muted);display:flex;align-items:center;gap:7px}.spinner{width:14px;height:14px;border:2px solid #ddd;border-top-color:var(--red);border-radius:50%;animation:spin .7s linear infinite}@keyframes spin{to{transform:rotate(360deg)}}.invoice-items{margin-top:14px;border:1px solid var(--line);border-radius:14px;overflow:hidden}.invoice-items-head{display:flex;align-items:center;justify-content:space-between;padding:10px 12px;background:#f8f9fa}.mini-table{width:100%;border-collapse:collapse}.mini-table th,.mini-table td{padding:9px 10px;border-top:1px solid var(--line);font-size:12px;text-align:left}.invoice-total{font-size:17px;font-weight:900;color:var(--red)}.autocomplete{position:relative}.autocomplete-list{position:absolute;z-index:80;left:0;right:0;top:calc(100% + 4px);background:#fff;border:1px solid var(--line);border-radius:11px;box-shadow:0 12px 30px rgba(0,0,0,.12);max-height:190px;overflow:auto;display:none}.autocomplete-list.open{display:block}.autocomplete-item{padding:10px 11px;border-bottom:1px solid #f1f2f3;cursor:pointer;font-size:12px}.autocomplete-item:hover{background:#fff5f5}.autocomplete-item small{display:block;color:var(--muted);margin-top:2px}
.toast{position:fixed;z-index:100;left:50%;bottom:24px;transform:translate(-50%,20px);background:#24282e;color:#fff;border-radius:12px;padding:11px 15px;font-size:13px;opacity:0;pointer-events:none;transition:.2s}.toast.show{opacity:1;transform:translate(-50%,0)}.toast.error{background:var(--red)}
.charts-filters{padding-right:0}.charts-filters{padding-right:0}.charts-grid{min-height:0;display:grid;grid-template-columns:repeat(6,1fr);grid-template-rows:1fr 1fr;gap:12px;overflow:hidden}.chart-card{min-height:0;background:#fff;border:1px solid var(--line);border-radius:16px;padding:12px;display:grid;grid-template-rows:auto minmax(0,1fr)}.chart-card h3{font-size:12px;margin:0 0 7px;color:#555b63}.chart-card canvas{max-width:100%;max-height:100%}.chart-card[data-chart-card="budget"]{grid-column:1/3;grid-row:1}.chart-card[data-chart-card="daily"]{grid-column:3/5;grid-row:1}.chart-card[data-chart-card="expenses"]{grid-column:5/7;grid-row:1}.chart-card[data-chart-card="materials"]{grid-column:1/4;grid-row:2}.chart-card[data-chart-card="labor"]{grid-column:4/7;grid-row:2}#chartMobileSelect{display:none}
.roles-layout{display:grid;grid-template-columns:220px 1fr;gap:14px;min-height:360px}.roles-list{border:1px solid var(--line);border-radius:13px;overflow:auto}.role-item{padding:11px;border-bottom:1px solid var(--line);cursor:pointer}.role-item.active{background:#fff2f2;color:var(--red);font-weight:800}.permission-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:8px}.perm-check{border:1px solid var(--line);border-radius:10px;padding:10px;display:flex;gap:8px;align-items:center;font-size:12px}
.empty{padding:28px!important;text-align:center;color:#969aa1!important}
@media(max-width:900px){
 .login-shell{grid-template-columns:1fr;padding:16px}.brand-panel{display:none}.mobile-brand{display:flex}.login-card{padding:28px}.menu-grid{grid-template-columns:repeat(4,1fr);gap:10px}.menu-card{min-height:120px}.module-toolbar{flex-wrap:wrap}.summary-chip{display:none}.charts-grid{grid-template-columns:1fr}.chart-card{display:none!important}.chart-card.mobile-active{display:grid!important;grid-column:1!important;grid-row:1!important}.charts-grid{grid-template-rows:1fr}.charts-filters #chartMobileSelect{display:block}.report-total{display:none}
}
@media(max-width:640px){
 :root{--header:62px}.app-header{padding:0 12px}.header-right{gap:6px}.home-btn{height:38px;padding:0 9px;font-size:11px;gap:5px}.app-brand{gap:8px}.app-brand strong{font-size:17px}.app-brand span{font-size:8px;letter-spacing:3px}.brand-mark-sm{width:38px;height:38px}.user-pill{padding:6px 8px}.user-pill small{display:none}.user-pill span{max-width:86px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dashboard-main{padding:12px 12px 8px}.dashboard-copy h1{font-size:21px}.dashboard-copy p{font-size:11px}.menu-grid{grid-template-columns:repeat(2,1fr);grid-template-rows:repeat(4,1fr);height:calc(100% - 10px);gap:8px;margin-top:8px}.menu-card{min-height:0;border-radius:17px;gap:7px;font-size:13px}.menu-card i{font-size:27px}.dash-foot{display:none}.module-screen{padding:10px;gap:8px}.module-head h2{font-size:18px}.module-head .btn{height:38px;padding:0 10px;font-size:12px}.module-toolbar,.filters-row{overflow-x:auto;flex-wrap:nowrap;padding-bottom:2px}.search-box{min-width:210px;height:39px}.module-toolbar select,.filters-row select,.filters-row input{height:39px;min-width:130px}.table-wrap{border-radius:12px}.table-wrap th{padding:10px;font-size:10px}.table-wrap td{padding:9px 10px;font-size:12px}.modal{padding:8px}.modal-card{max-height:calc(100dvh - 16px);border-radius:16px}.modal-head{height:54px}.modal-body{padding:12px}.form-grid{grid-template-columns:1fr;gap:10px}.form-grid .full{grid-column:1}.roles-layout{grid-template-columns:1fr;min-height:0}.roles-list{max-height:130px}.permission-grid{grid-template-columns:1fr}.head-actions .btn{padding:0 9px}.head-actions .btn i{margin:0}.head-actions .btn{font-size:0}.head-actions .btn i{font-size:14px}.login-card{max-width:100%}
}
@media(max-height:650px) and (orientation:landscape){.dashboard-copy{display:none}.menu-grid{grid-template-columns:repeat(4,1fr);grid-template-rows:repeat(2,1fr);height:calc(100% - 10px)}.menu-card{min-height:0}.dashboard-main{padding-top:10px}}

/* V1.3 - vista de factura e historial de precios */
.row-btn.view{background:#eef3ff;color:#3456a4}.row-btn.history{background:#fff4e8;color:#9a5d00}
.invoice-paper{background:#fff;border:1px solid #dfe2e6;border-radius:16px;overflow:hidden;box-shadow:0 10px 28px rgba(26,30,35,.06)}
.invoice-letterhead{display:flex;justify-content:space-between;align-items:center;padding:18px 20px;border-bottom:3px solid var(--red);background:linear-gradient(135deg,#fff 0%,#fff 62%,#fff5f5 100%)}
.invoice-letter-logo{display:flex;align-items:center;gap:10px;color:var(--red)}.invoice-letter-logo svg{width:48px;height:48px}.invoice-letter-logo>div{display:flex;flex-direction:column;line-height:1}.invoice-letter-logo strong{font-size:24px;letter-spacing:-.5px}.invoice-letter-logo span{font-size:9px;letter-spacing:4px;margin-top:5px;color:#545961;font-weight:900}
.invoice-doc-title{text-align:right;display:flex;flex-direction:column;gap:3px}.invoice-doc-title strong{font-size:16px;color:#33383f}.invoice-doc-title span{font-size:10px;color:var(--muted);text-transform:uppercase;letter-spacing:.08em}
.invoice-meta{display:grid;grid-template-columns:1.5fr 1fr;gap:18px;padding:16px 20px;background:#fafbfc;border-bottom:1px solid var(--line)}.invoice-meta>div{display:flex;flex-direction:column;gap:4px}.invoice-meta small,.invoice-paper-foot small,.current-price small{text-transform:uppercase;letter-spacing:.07em;color:#8a8f97;font-size:9px;font-weight:900}.invoice-meta strong{font-size:14px}.invoice-meta span{font-size:11px;color:#666c75}
.invoice-paper-items{overflow:auto}.invoice-paper-items table{width:100%;border-collapse:collapse;min-width:720px}.invoice-paper-items th{background:#f3f4f6;color:#686e76;font-size:9px;text-transform:uppercase;letter-spacing:.05em;text-align:left;padding:10px 12px}.invoice-paper-items td{border-top:1px solid #eceef1;padding:11px 12px;font-size:11px}.obra-chip{display:inline-flex;gap:5px;align-items:center;background:#f4f5f6;border-radius:8px;padding:5px 7px;font-weight:800;color:#4d535b}
.invoice-paper-foot{display:flex;justify-content:space-between;gap:20px;padding:15px 20px;border-top:1px solid var(--line);align-items:flex-end}.invoice-paper-foot>div:first-child{display:flex;flex-direction:column;gap:4px;max-width:65%;font-size:11px;color:#666}.invoice-grand-total{text-align:right;display:flex;flex-direction:column}.invoice-grand-total strong{font-size:24px;color:var(--red)}
.price-history-head{display:flex;align-items:center;justify-content:space-between;gap:15px;border:1px solid var(--line);border-radius:14px;padding:13px 15px;background:#fafbfc}.price-history-head>div:first-child{min-width:0}.price-history-head h4{margin:5px 0 0;font-size:17px}.price-type{display:inline-block}.current-price{display:flex;flex-direction:column;text-align:right;white-space:nowrap}.current-price strong{font-size:21px;color:var(--red);margin-top:3px}.price-chart-box{height:250px;margin-top:12px;border:1px solid var(--line);border-radius:14px;padding:12px;background:#fff}.history-table-wrap{margin-top:12px;max-height:230px;overflow:auto;border:1px solid var(--line);border-radius:14px}.history-table-wrap .mini-table th{position:sticky;top:0;background:#f7f8f9;z-index:1}.history-origin{display:inline-flex;padding:4px 7px;border-radius:999px;background:#eef0f2;font-size:9px;font-weight:900}.history-origin.factura{background:#eef3ff;color:#3456a4}.history-origin.manual{background:#fff3df;color:#9a5d00}.history-origin.alta,.history-origin.inicial{background:#eaf7ef;color:#1c7b43}.item-price-tools{display:flex;align-items:center}
@media(max-width:640px){.invoice-letterhead{padding:13px}.invoice-letter-logo svg{width:38px;height:38px}.invoice-letter-logo strong{font-size:19px}.invoice-letter-logo span{font-size:7px;letter-spacing:3px}.invoice-doc-title strong{font-size:12px}.invoice-meta{grid-template-columns:1fr 1fr;padding:12px;gap:10px}.invoice-paper-foot{padding:12px}.invoice-grand-total strong{font-size:19px}.price-history-head{align-items:flex-start}.price-chart-box{height:220px}.history-table-wrap{max-height:190px}.form-actions{flex-wrap:wrap}}


/* V1.3.3 - pantallas sin scroll horizontal + flujo rápido de factura */
html,body,.app-body,.module-screen{overflow-x:hidden}
#module-facturas .table-wrap{overflow-x:hidden}
#module-facturas .table-wrap table{min-width:0;table-layout:fixed}
#module-facturas .invoice-col-date{width:92px}
#module-facturas .invoice-col-provider{width:auto;overflow-wrap:anywhere}
#module-facturas .invoice-col-ruc{width:112px}
#module-facturas .invoice-col-number{width:142px}
#module-facturas .invoice-col-count{width:64px;text-align:center}
#module-facturas .invoice-col-total{width:128px;white-space:nowrap}
#module-facturas .invoice-col-actions{width:120px}
.invoice-mobile-meta{display:none;margin-top:4px;font-size:10px;color:var(--muted);line-height:1.25}
.invoice-paper-items{overflow-x:hidden}
.invoice-paper-items table{min-width:0;table-layout:fixed}
.invoice-paper-items th:nth-child(1){width:72px}.invoice-paper-items th:nth-child(2){width:24%}.invoice-paper-items th:nth-child(3){width:27%}.invoice-paper-items th:nth-child(4){width:64px}.invoice-paper-items th:nth-child(5){width:118px}.invoice-paper-items th:nth-child(6){width:120px}
.invoice-paper-items td{overflow-wrap:anywhere}
.invoice-items{overflow-x:hidden}
.invoice-items .mini-table{table-layout:fixed}
.invoice-items .mini-table th,.invoice-items .mini-table td{overflow-wrap:anywhere}
.item-desc-first{order:-1}

@media(max-width:900px){
 #module-facturas .invoice-col-ruc,#module-facturas .invoice-col-count{display:none}
 #module-facturas .invoice-col-date{width:86px}
 #module-facturas .invoice-col-number{width:125px}
 #module-facturas .invoice-col-total{width:112px}
 #module-facturas .invoice-col-actions{width:112px}
}
@media(max-width:640px){
 .module-screen{overflow:hidden}
 #module-facturas .module-toolbar{overflow:hidden}
 #module-facturas .search-box{min-width:0;max-width:none;width:100%}
 #module-facturas .table-wrap{overflow-y:auto;overflow-x:hidden}
 #module-facturas .table-wrap table{width:100%;min-width:0;table-layout:fixed}
 #module-facturas .table-wrap th:nth-child(3),#module-facturas .table-wrap td:nth-child(3),
 #module-facturas .table-wrap th:nth-child(4),#module-facturas .table-wrap td:nth-child(4),
 #module-facturas .table-wrap th:nth-child(5),#module-facturas .table-wrap td:nth-child(5){display:none}
 #module-facturas .invoice-col-date{width:62px;font-size:10px;padding-left:7px;padding-right:5px}
 #module-facturas .invoice-col-provider{width:auto;padding-left:5px;padding-right:5px}
 #module-facturas .invoice-col-provider strong{display:block;font-size:11px;line-height:1.15;white-space:normal;overflow-wrap:anywhere}
 #module-facturas .invoice-desktop-detail{display:none}
 #module-facturas .invoice-mobile-meta{display:block}
 #module-facturas .invoice-col-total{width:74px;font-size:10px;padding-left:4px;padding-right:4px;white-space:normal;text-align:right}
 #module-facturas .invoice-col-actions{width:82px;padding-left:3px;padding-right:3px}
 #module-facturas .actions{gap:2px;justify-content:center}
 #module-facturas .row-btn{width:25px;height:31px;border-radius:7px;font-size:10px}
 #module-facturas .table-wrap th{padding-left:5px;padding-right:5px;font-size:8px;letter-spacing:0}

 .invoice-paper-items table,.invoice-paper-items thead,.invoice-paper-items tbody,.invoice-paper-items tr,.invoice-paper-items th,.invoice-paper-items td{display:block;width:100%!important;min-width:0!important}
 .invoice-paper-items thead{display:none}
 .invoice-paper-items tbody{padding:8px;display:grid;gap:8px}
 .invoice-paper-items tr{border:1px solid var(--line);border-radius:11px;padding:8px;background:#fff}
 .invoice-paper-items td{border:0;padding:4px 2px;font-size:11px;display:flex;align-items:flex-start;justify-content:space-between;gap:12px;text-align:right;overflow-wrap:anywhere}
 .invoice-paper-items td::before{content:attr(data-label);font-size:9px;text-transform:uppercase;letter-spacing:.04em;color:#848991;font-weight:900;text-align:left;flex:0 0 36%}
 .invoice-paper-items td>*{max-width:62%}
 .invoice-paper-items .obra-chip{white-space:normal;justify-content:flex-end}

 .invoice-items .mini-table,.invoice-items .mini-table thead,.invoice-items .mini-table tbody,.invoice-items .mini-table tr,.invoice-items .mini-table th,.invoice-items .mini-table td{display:block;width:100%;min-width:0}
 .invoice-items .mini-table thead{display:none}
 .invoice-items .mini-table tbody{padding:7px;display:grid;gap:7px}
 .invoice-items .mini-table tr{border:1px solid var(--line);border-radius:10px;padding:7px}
 .invoice-items .mini-table td{border:0;padding:4px 2px;display:flex;justify-content:space-between;gap:10px;text-align:right}
 .invoice-items .mini-table td::before{content:attr(data-label);font-size:9px;text-transform:uppercase;color:#858a92;font-weight:900;text-align:left}
 .invoice-items .mini-table td .actions{margin-left:auto}
 .invoice-items-head{gap:8px;align-items:center}
 .invoice-items-head>div{min-width:0}
 .invoice-items-head .btn{white-space:nowrap;padding:0 9px}
 .item-form-grid .item-desc-first{grid-column:1}
}


/* V1.3.4 - modales apilados seguros */
.sub-modal{z-index:85;background:rgba(17,20,24,.58)}
.sub-modal .modal-card{box-shadow:0 36px 90px rgba(0,0,0,.32)}
.modal-x.is-hidden{display:none!important}
#subModal .modal-body{overscroll-behavior:contain}
@media(max-width:640px){
 #subModal{padding:8px}
 #subModal .modal-card{max-height:calc(100dvh - 16px)}
}


/* V1.3.5 - resumen diario + navegación segura entre modales */
.dashboard-copy{display:flex;align-items:center;justify-content:space-between;gap:16px;min-width:0}
.today-loaded-card{border:1px solid #ead7d9;background:#fff;border-radius:16px;min-width:250px;height:58px;padding:0 13px;display:flex;align-items:center;gap:10px;color:var(--ink);box-shadow:0 7px 20px rgba(38,42,47,.05)}
.today-loaded-card>i:first-child{width:34px;height:34px;border-radius:10px;background:#fff1f2;color:var(--red);display:grid;place-items:center;flex:0 0 auto}
.today-loaded-card>i:last-child{color:#a6aab0;font-size:11px;margin-left:auto}
.today-loaded-card span{display:grid;grid-template-columns:auto auto;align-items:end;column-gap:8px;min-width:0;text-align:left}
.today-loaded-card small{grid-column:1/-1;color:#777d85;font-size:9px;font-weight:900;text-transform:uppercase;letter-spacing:.04em}
.today-loaded-card strong{font-size:15px;color:var(--red);white-space:nowrap}
.today-loaded-card em{font-style:normal;color:#90959d;font-size:9px;white-space:nowrap}
.today-loaded-card:hover{border-color:#deb9bd;background:#fffafa}
.today-detail-head{display:flex;justify-content:space-between;align-items:center;gap:12px;background:#fff5f5;border:1px solid #f0dadd;border-radius:14px;padding:12px 14px}
.today-detail-head>div{display:flex;flex-direction:column}.today-detail-head small{font-size:9px;text-transform:uppercase;font-weight:900;color:#7c8289;letter-spacing:.05em}.today-detail-head strong{font-size:24px;color:var(--red);margin-top:2px}.today-detail-head>span{font-size:11px;font-weight:800;color:#6e747c}
.today-detail-list{margin-top:10px;border:1px solid var(--line);border-radius:14px;overflow:auto;max-height:55dvh}
.today-detail-row{display:grid;grid-template-columns:54px minmax(0,1fr) minmax(150px,.65fr);gap:12px;align-items:center;padding:11px 12px;border-bottom:1px solid #eef0f2}
.today-detail-row:last-child{border-bottom:0}.today-time{font-size:12px;font-weight:900;color:var(--red)}
.today-desc{display:flex;flex-direction:column;gap:3px;min-width:0}.today-desc strong{font-size:12px;overflow-wrap:anywhere}.today-desc span,.today-desc small{font-size:10px;color:var(--muted)}
.today-work{display:flex;flex-direction:column;align-items:flex-end;gap:4px;text-align:right;min-width:0}.today-work span{font-size:10px;color:#5d636b;font-weight:800;overflow-wrap:anywhere}.today-work strong{font-size:12px;color:var(--red)}
@media(max-width:640px){
 .dashboard-copy{gap:8px}
 .dashboard-copy p{display:none}
 .today-loaded-card{min-width:165px;height:48px;padding:0 8px;gap:7px;border-radius:13px}
 .today-loaded-card>i:first-child{width:30px;height:30px}
 .today-loaded-card span{display:block}
 .today-loaded-card small{display:block;font-size:7px}
 .today-loaded-card strong{display:block;font-size:12px}
 .today-loaded-card em{display:none}
 .today-loaded-card>i:last-child{display:none}
 .today-detail-list{max-height:58dvh}
 .today-detail-row{grid-template-columns:42px minmax(0,1fr);gap:8px;padding:9px}
 .today-work{grid-column:2;align-items:flex-start;text-align:left;border-top:1px dashed #eceef0;padding-top:6px}
}

/* V1.3.6 - cero scroll horizontal en módulos + total gastado hoy destacado */
.dashboard-copy-total{display:block;width:100%;}
.today-loaded-card-primary{
  width:100%;min-width:0;height:68px;padding:0 18px;border:0;
  background:linear-gradient(135deg,var(--red),var(--red2));color:#fff;
  box-shadow:0 10px 26px rgba(181,18,27,.22);
}
.today-loaded-card-primary:hover{background:linear-gradient(135deg,#c51620,var(--red2));border:0;}
.today-loaded-card-primary>i:first-child{width:40px;height:40px;background:rgba(255,255,255,.16);color:#fff;}
.today-loaded-card-primary>i:last-child{color:rgba(255,255,255,.78);font-size:13px;}
.today-loaded-card-primary span{grid-template-columns:auto auto;column-gap:10px;}
.today-loaded-card-primary small{color:rgba(255,255,255,.82);}
.today-loaded-card-primary strong{color:#fff;font-size:20px;}
.today-loaded-card-primary em{color:rgba(255,255,255,.78);font-size:10px;}

/* Ninguna pantalla funcional debe generar desplazamiento horizontal. */
.module-screen,.module-toolbar,.filters-row,.table-wrap,.charts-grid,.chart-card{min-width:0;max-width:100%;}
.module-screen{overflow-x:hidden;}
.module-screen .table-wrap{overflow-x:hidden;overflow-y:auto;}
#module-categorias .table-wrap table,
#module-materiales .table-wrap table,
#module-mano_obra .table-wrap table,
#module-reportes .table-wrap table,
#module-usuarios .table-wrap table{
  width:100%;min-width:0;table-layout:fixed;
}
#module-categorias td,#module-categorias th,
#module-materiales td,#module-materiales th,
#module-mano_obra td,#module-mano_obra th,
#module-reportes td,#module-reportes th,
#module-usuarios td,#module-usuarios th{
  overflow-wrap:anywhere;word-break:normal;min-width:0;
}
#module-categorias th:last-child{width:142px;}
#module-materiales th:last-child,#module-mano_obra th:last-child{width:178px;}
#module-usuarios th:last-child{width:135px;}
#module-reportes th:nth-child(1){width:88px;}
#module-reportes th:nth-child(3){width:74px;}
#module-reportes th:nth-child(6){width:72px;}
#module-reportes th:nth-child(7),#module-reportes th:nth-child(8){width:115px;}
#module-graficos .charts-grid{overflow:hidden;}
#module-graficos .chart-card{overflow:hidden;}
#module-graficos canvas{width:100%!important;max-width:100%!important;}

@media(max-width:640px){
  .today-loaded-card-primary{height:58px;padding:0 12px;min-width:0;border-radius:14px;}
  .today-loaded-card-primary>i:first-child{width:34px;height:34px;}
  .today-loaded-card-primary span{display:grid;grid-template-columns:1fr auto;align-items:end;width:100%;}
  .today-loaded-card-primary small{display:block;grid-column:1/-1;font-size:8px;}
  .today-loaded-card-primary strong{display:block;font-size:16px;}
  .today-loaded-card-primary em{display:block;font-size:9px;}
  .today-loaded-card-primary>i:last-child{display:block;}

  /* Filtros y buscadores se reacomodan; nunca deslizan lateralmente. */
  .module-toolbar,.filters-row{overflow-x:hidden!important;overflow-y:visible;flex-wrap:wrap;padding-bottom:0;}
  .module-toolbar .search-box{flex:1 1 100%;width:100%;max-width:none;min-width:0;}
  .module-toolbar select{flex:1 1 100%;width:100%;min-width:0!important;}
  .filters-row{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));width:100%;}
  .filters-row>*{width:100%;min-width:0!important;max-width:100%;}
  #module-reportes #btnApplyReport{grid-column:1/-1;}
  #module-graficos #chartMobileSelect{display:block;grid-column:1/-1;}
  #module-graficos #btnApplyCharts{grid-column:1/-1;}

  /* Categorías en tarjetas responsivas. */
  #module-categorias .table-wrap table,#module-categorias .table-wrap thead,#module-categorias .table-wrap tbody,#module-categorias .table-wrap tr,#module-categorias .table-wrap th,#module-categorias .table-wrap td,
  #module-materiales .table-wrap table,#module-materiales .table-wrap thead,#module-materiales .table-wrap tbody,#module-materiales .table-wrap tr,#module-materiales .table-wrap th,#module-materiales .table-wrap td,
  #module-mano_obra .table-wrap table,#module-mano_obra .table-wrap thead,#module-mano_obra .table-wrap tbody,#module-mano_obra .table-wrap tr,#module-mano_obra .table-wrap th,#module-mano_obra .table-wrap td,
  #module-reportes .table-wrap table,#module-reportes .table-wrap thead,#module-reportes .table-wrap tbody,#module-reportes .table-wrap tr,#module-reportes .table-wrap th,#module-reportes .table-wrap td,
  #module-usuarios .table-wrap table,#module-usuarios .table-wrap thead,#module-usuarios .table-wrap tbody,#module-usuarios .table-wrap tr,#module-usuarios .table-wrap th,#module-usuarios .table-wrap td{
    display:block;width:100%!important;min-width:0!important;
  }
  #module-categorias .table-wrap thead,#module-materiales .table-wrap thead,#module-mano_obra .table-wrap thead,#module-reportes .table-wrap thead,#module-usuarios .table-wrap thead{display:none;}
  #module-categorias .table-wrap tbody,#module-materiales .table-wrap tbody,#module-mano_obra .table-wrap tbody,#module-reportes .table-wrap tbody,#module-usuarios .table-wrap tbody{padding:7px;display:grid;gap:8px;}
  #module-categorias .table-wrap tr,#module-materiales .table-wrap tr,#module-mano_obra .table-wrap tr,#module-reportes .table-wrap tr,#module-usuarios .table-wrap tr{border:1px solid var(--line);border-radius:11px;padding:8px;background:#fff;}
  #module-categorias .table-wrap td,#module-materiales .table-wrap td,#module-mano_obra .table-wrap td,#module-reportes .table-wrap td,#module-usuarios .table-wrap td{
    border:0;padding:4px 2px;display:flex;align-items:flex-start;justify-content:space-between;gap:10px;text-align:right;font-size:11px;
  }
  #module-categorias .table-wrap td::before,#module-materiales .table-wrap td::before,#module-mano_obra .table-wrap td::before,#module-reportes .table-wrap td::before,#module-usuarios .table-wrap td::before{
    flex:0 0 34%;font-size:8px;text-transform:uppercase;letter-spacing:.04em;color:#858a92;font-weight:900;text-align:left;
  }
  #module-categorias td:nth-child(1)::before{content:'Categoría'}#module-categorias td:nth-child(2)::before{content:'Tipo'}#module-categorias td:nth-child(3)::before{content:'Estado'}#module-categorias td:nth-child(4)::before{content:'Acciones'}
  #module-materiales td:nth-child(1)::before{content:'Material'}#module-materiales td:nth-child(2)::before{content:'Categoría'}#module-materiales td:nth-child(3)::before{content:'Unidad'}#module-materiales td:nth-child(4)::before{content:'Precio ref.'}#module-materiales td:nth-child(5)::before{content:'Estado'}#module-materiales td:nth-child(6)::before{content:'Acciones'}
  #module-mano_obra td:nth-child(1)::before{content:'Descripción'}#module-mano_obra td:nth-child(2)::before{content:'Categoría'}#module-mano_obra td:nth-child(3)::before{content:'Unidad'}#module-mano_obra td:nth-child(4)::before{content:'Precio ref.'}#module-mano_obra td:nth-child(5)::before{content:'Estado'}#module-mano_obra td:nth-child(6)::before{content:'Acciones'}
  #module-reportes td:nth-child(1)::before{content:'Fecha'}#module-reportes td:nth-child(2)::before{content:'Obra'}#module-reportes td:nth-child(3)::before{content:'Tipo'}#module-reportes td:nth-child(4)::before{content:'Descripción'}#module-reportes td:nth-child(5)::before{content:'Proveedor'}#module-reportes td:nth-child(6)::before{content:'Cantidad'}#module-reportes td:nth-child(7)::before{content:'P. unit.'}#module-reportes td:nth-child(8)::before{content:'Subtotal'}
  #module-usuarios td:nth-child(1)::before{content:'Nombre'}#module-usuarios td:nth-child(2)::before{content:'Usuario'}#module-usuarios td:nth-child(3)::before{content:'Email'}#module-usuarios td:nth-child(4)::before{content:'Rol'}#module-usuarios td:nth-child(5)::before{content:'Estado'}#module-usuarios td:nth-child(6)::before{content:'Acciones'}
  #module-categorias .table-wrap td.empty::before,#module-materiales .table-wrap td.empty::before,#module-mano_obra .table-wrap td.empty::before,#module-reportes .table-wrap td.empty::before,#module-usuarios .table-wrap td.empty::before{display:none;content:none;}
  #module-categorias .table-wrap td.empty,#module-materiales .table-wrap td.empty,#module-mano_obra .table-wrap td.empty,#module-reportes .table-wrap td.empty,#module-usuarios .table-wrap td.empty{display:block;text-align:center;padding:18px 8px;}
  #module-categorias .actions,#module-materiales .actions,#module-mano_obra .actions,#module-usuarios .actions{margin-left:auto;flex-wrap:wrap;}
  #module-materiales .row-btn,#module-mano_obra .row-btn,#module-usuarios .row-btn,#module-categorias .row-btn{width:32px;height:32px;}

  /* Gráficos: un gráfico por vez y filtros en el ancho disponible. */
  #module-graficos .charts-grid{width:100%;min-width:0;}
  #module-graficos .chart-card{width:100%;min-width:0;}
}


/* V1.4.0 - captura de factura por foto / OCR */
.scan-start,.scan-review{display:grid;gap:12px;min-width:0}.scan-camera{border:2px dashed #d9dde2;border-radius:16px;padding:22px;text-align:center;background:#fafbfc;display:grid;justify-items:center;gap:8px}.scan-camera>i{font-size:34px;color:var(--red)}.scan-camera strong{font-size:16px}.scan-camera p{margin:0;color:var(--muted);font-size:12px;max-width:520px}.scan-pick{position:relative;overflow:hidden}.scan-pick input{position:absolute;inset:0;opacity:0;cursor:pointer}.scan-stage{min-width:0}.scan-tips{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:7px}.scan-tips span{background:#f4f5f6;border:1px solid var(--line);border-radius:10px;padding:8px;font-size:10px;font-weight:800;text-align:center}.scan-tips i{color:#18864b;margin-right:4px}.scan-working{display:grid;grid-template-columns:minmax(120px,220px) 1fr;gap:14px;align-items:center;border:1px solid var(--line);border-radius:14px;padding:10px}.scan-working img{width:100%;max-height:210px;object-fit:contain;border-radius:10px;background:#f0f1f2}.scan-working>div{display:grid;gap:8px}.scan-working strong{font-size:13px}.scan-working small{font-size:10px;color:var(--muted)}.scan-progress{height:9px;border-radius:99px;background:#eceef0;overflow:hidden}.scan-progress span{display:block;height:100%;width:0;background:var(--red);transition:width .15s ease}.scan-error{padding:18px;border:1px solid #efb8bc;background:#fff5f6;border-radius:12px;display:grid;gap:5px;text-align:center;color:#8d1118}.scan-error i{font-size:25px}.scan-review-top{display:grid;grid-template-columns:minmax(170px,260px) 1fr;gap:12px;min-width:0}.scan-review-top>img{width:100%;height:100%;max-height:260px;object-fit:contain;border-radius:12px;background:#f2f3f4;border:1px solid var(--line)}.scan-header-form{min-width:0}.scan-detected-note{margin-top:8px;padding:8px 10px;border-radius:9px;background:#f5f6f7;color:#555d66;font-size:10px}.scan-items-title{display:flex;justify-content:space-between;align-items:end;gap:10px;border-top:1px solid var(--line);padding-top:11px}.scan-items-title>div{display:grid;gap:2px}.scan-items-title small,.scan-items-title span{font-size:9px;color:var(--muted)}.scan-items-title>div:last-child{text-align:right}.scan-items-title>div:last-child strong{color:var(--red);font-size:16px}.scan-items,#scanItems{display:grid;gap:9px}.scan-item{border:1px solid var(--line);border-radius:12px;padding:9px;background:#fff;min-width:0}.scan-item-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:7px}.scan-item-head strong{font-size:11px;color:#555d66}.scan-grid{display:grid;grid-template-columns:minmax(0,2.3fr) minmax(0,1.25fr) minmax(0,.9fr) minmax(80px,.55fr) minmax(110px,.8fr) minmax(110px,.75fr);gap:7px;align-items:end;min-width:0}.scan-grid .field{min-width:0}.scan-grid label{font-size:8px}.scan-sub strong{height:38px;display:flex;align-items:center;justify-content:flex-end;padding:0 8px;border-radius:8px;background:#f6f7f8;color:var(--red);font-size:11px;white-space:nowrap}.scan-actions{position:sticky;bottom:-1px;background:#fff;padding-top:9px;border-top:1px solid var(--line);z-index:2}
@media(max-width:800px){.scan-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.scan-desc{grid-column:1/-1}.scan-sub strong{justify-content:flex-start}.scan-review-top{grid-template-columns:130px 1fr}.scan-tips{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:560px){.scan-review-top{grid-template-columns:1fr}.scan-review-top>img{max-height:150px}.scan-grid{grid-template-columns:1fr 1fr}.scan-desc,.scan-grid .field:nth-child(2){grid-column:1/-1}.scan-working{grid-template-columns:90px 1fr}.scan-working img{max-height:130px}.scan-items-title{align-items:center}.scan-actions{display:grid;grid-template-columns:1fr 1fr}.scan-actions #scanLoad{grid-column:1/-1;grid-row:1}.scan-camera{padding:16px 10px}.scan-tips{grid-template-columns:1fr 1fr}}

/* V1.5.0 - pagos, proveedores, factura fiscal/OCR y foto original */
.badge.pending{background:#fff4df;color:#986000;border:1px solid #f0d5a2}.text-good{color:var(--good)!important}.text-red{color:var(--red)!important}.good-lite{background:#eef9f2!important;color:#17753f!important;border-color:#cae9d7!important}
.today-cards-grid{display:grid!important;grid-template-columns:1fr 1fr;gap:10px;width:100%;}
.today-paid-card{width:100%;min-width:0;height:68px;padding:0 18px;border:0;background:linear-gradient(135deg,#18834a,#116c3c);color:#fff;box-shadow:0 10px 26px rgba(24,131,74,.20)}
.today-paid-card:hover{background:linear-gradient(135deg,#1b9454,#116c3c);border:0}.today-paid-card>i:first-child{width:40px;height:40px;background:rgba(255,255,255,.16);color:#fff}.today-paid-card>i:last-child{color:rgba(255,255,255,.78);font-size:13px}.today-paid-card small{color:rgba(255,255,255,.82)}.today-paid-card strong{color:#fff;font-size:20px}.today-paid-card em{color:rgba(255,255,255,.78);font-size:10px}.paid-head{background:#effaf4;border-color:#ccebd9}.paid-head strong,.paid-time,.paid-amount{color:var(--good)!important}

.invoice-meta-rich{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}.invoice-meta-rich>div{min-width:0}.cdc-text{overflow-wrap:anywhere;font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:9px!important}.invoice-taxes{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:7px;padding:10px 0;border-top:1px solid var(--line);border-bottom:1px solid var(--line);margin-top:8px}.invoice-taxes span{display:grid;gap:2px;background:#f7f8f9;border-radius:8px;padding:7px;font-size:9px;color:var(--muted)}.invoice-taxes strong{font-size:11px;color:var(--ink)}.invoice-payments{display:grid;gap:4px;margin-top:10px;padding-top:8px;border-top:1px dashed var(--line);font-size:10px}.invoice-photo-view{display:grid;gap:8px;justify-items:center}.invoice-photo-view img{max-width:100%;max-height:70dvh;object-fit:contain;border-radius:12px;border:1px solid var(--line);background:#f5f6f7}.invoice-status-strip{display:flex;gap:7px;align-items:center;flex-wrap:wrap;margin:10px 0;padding:8px;background:#f6f7f8;border-radius:10px;font-size:10px}.check-line{display:flex!important;align-items:center;gap:8px;height:38px}.check-line input{width:18px;height:18px}.row-btn.photo{color:#5d4aa8;background:#f1effc}

.payment-tabs{display:grid;grid-template-columns:1fr 1fr;gap:6px;background:#f1f2f4;border-radius:12px;padding:5px}.pay-tab{border:0;border-radius:9px;background:transparent;height:38px;font-weight:900;color:#6d737b}.pay-tab.active{background:#fff;color:var(--red);box-shadow:0 3px 12px rgba(0,0,0,.06)}.payment-summary{display:flex;align-items:center;gap:10px;margin-top:10px;padding:10px 12px;border:1px solid var(--line);border-radius:12px}.payment-summary span{font-size:10px;color:var(--muted);font-weight:800}.payment-summary strong{font-size:18px;color:var(--red);margin-left:auto}.payment-summary em{font-style:normal;font-size:9px;color:var(--muted)}.payment-list{margin-top:9px;display:grid;gap:7px;max-height:56dvh;overflow-y:auto;overflow-x:hidden}.payment-row{display:grid;grid-template-columns:minmax(0,1fr) 130px auto;gap:10px;align-items:center;border:1px solid var(--line);border-radius:12px;padding:9px 10px}.payment-main{display:grid;gap:2px;min-width:0}.payment-main strong{font-size:12px;overflow-wrap:anywhere}.payment-main span,.payment-main small{font-size:9px;color:var(--muted)}.payment-balance{display:grid;gap:2px;text-align:right}.payment-balance small{font-size:8px;color:var(--muted);text-transform:uppercase;font-weight:900}.payment-balance strong{font-size:12px;color:var(--red)}.pay-target{display:grid;gap:3px;padding:10px;background:#f7f8f9;border-radius:12px;margin-bottom:10px}.pay-target small{font-size:8px;color:var(--muted);text-transform:uppercase;font-weight:900}.pay-target strong{font-size:14px}.pay-target span{font-size:11px;color:var(--red);font-weight:900}

#module-proveedores .table-wrap{overflow-x:hidden}#module-proveedores .table-wrap table{width:100%;min-width:0;table-layout:fixed}#module-proveedores th:last-child{width:125px}#module-proveedores td,#module-proveedores th{overflow-wrap:anywhere;min-width:0}.supplier-history-head{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:10px;border:1px solid var(--line);border-radius:12px}.supplier-history-head>div{display:grid;gap:2px}.supplier-history-head small{font-size:8px;color:var(--muted);font-weight:900;text-transform:uppercase}.supplier-history-head strong{font-size:14px}.supplier-history-head>span{font-size:10px;color:var(--muted)}.supplier-history-list{display:grid;gap:7px;margin-top:9px;max-height:58dvh;overflow-y:auto;overflow-x:hidden}.supplier-move{display:grid;grid-template-columns:minmax(0,1fr) 150px 38px;gap:8px;align-items:center;border:1px solid var(--line);border-left:4px solid var(--red);border-radius:10px;padding:8px}.supplier-move.credit{border-left-color:var(--good)}.supplier-move>div{display:grid;gap:2px;min-width:0}.supplier-move>div:nth-child(2){text-align:right}.supplier-move span,.supplier-move small{font-size:9px;color:var(--muted)}.supplier-move strong{font-size:11px}.supplier-move.credit>div:nth-child(2)>strong{color:var(--good)}.supplier-move.debit>div:nth-child(2)>strong{color:var(--red)}

.scan-header-grid{grid-template-columns:repeat(3,minmax(0,1fr))}.scan-header-grid .full{grid-column:1/-1}.scan-header-grid textarea{resize:vertical;min-height:46px}.scan-detected-note strong{color:var(--ink)}

#module-reportes td::before{content:attr(data-label)!important}

@media(max-width:900px){.invoice-taxes{grid-template-columns:repeat(3,minmax(0,1fr))}.scan-header-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:640px){
 .today-cards-grid{grid-template-columns:1fr 1fr;gap:6px}.today-paid-card,.today-loaded-card-primary{height:58px;padding:0 8px;border-radius:13px}.today-paid-card>i:first-child,.today-loaded-card-primary>i:first-child{width:30px;height:30px}.today-paid-card span,.today-loaded-card-primary span{display:block!important}.today-paid-card small,.today-loaded-card-primary small{display:block;font-size:7px}.today-paid-card strong,.today-loaded-card-primary strong{display:block;font-size:12px}.today-paid-card em,.today-loaded-card-primary em,.today-paid-card>i:last-child,.today-loaded-card-primary>i:last-child{display:none}
 .menu-grid{grid-template-rows:repeat(5,1fr)}
 .invoice-meta-rich{grid-template-columns:1fr}.invoice-taxes{grid-template-columns:repeat(2,minmax(0,1fr))}.invoice-photo-view img{max-height:65dvh}
 .payment-row{grid-template-columns:minmax(0,1fr) auto;gap:6px}.payment-balance{grid-column:1;text-align:left}.payment-row>.actions{grid-column:2;grid-row:1/3;display:grid;align-content:center}.payment-summary{flex-wrap:wrap}.payment-summary strong{margin-left:0;width:100%}
 #module-proveedores .table-wrap table,#module-proveedores .table-wrap thead,#module-proveedores .table-wrap tbody,#module-proveedores .table-wrap tr,#module-proveedores .table-wrap th,#module-proveedores .table-wrap td{display:block;width:100%!important;min-width:0!important}#module-proveedores .table-wrap thead{display:none}#module-proveedores .table-wrap tbody{padding:7px;display:grid;gap:8px}#module-proveedores .table-wrap tr{border:1px solid var(--line);border-radius:11px;padding:8px;background:#fff}#module-proveedores .table-wrap td{border:0;padding:4px 2px;display:flex;align-items:flex-start;justify-content:space-between;gap:10px;text-align:right;font-size:11px}#module-proveedores .table-wrap td::before{content:attr(data-label);flex:0 0 34%;font-size:8px;text-transform:uppercase;letter-spacing:.04em;color:#858a92;font-weight:900;text-align:left}#module-proveedores .table-wrap td.empty::before{display:none}#module-proveedores .table-wrap td.empty{display:block;text-align:center;padding:18px 8px}
 .supplier-move{grid-template-columns:minmax(0,1fr) 105px 34px}.scan-header-grid{grid-template-columns:1fr 1fr}
}
@media(max-width:420px){.scan-header-grid{grid-template-columns:1fr}.scan-header-grid .full{grid-column:1}.today-cards-grid{gap:5px}.today-paid-card>i:first-child,.today-loaded-card-primary>i:first-child{display:none}.today-paid-card,.today-loaded-card-primary{padding:0 9px}.supplier-move{grid-template-columns:minmax(0,1fr) 92px}.supplier-move>.row-btn{display:none}}

/* V1.6.0 - Gastos, cabecera compacta de factura e informe PDF por obra */
.row-btn.pdf{background:#fff0f1;color:#b5121b}.row-btn.pdf:hover{background:#f9dfe2}
#module-gastos .table-wrap table{width:100%;min-width:0;table-layout:fixed}
#module-gastos td,#module-gastos th{overflow-wrap:anywhere;min-width:0}
#module-gastos th:last-child{width:178px}

.invoice-header-grid{grid-template-columns:repeat(4,minmax(0,1fr));gap:10px 11px}
.invoice-header-grid .full{grid-column:1/-1}.invoice-header-grid .span-2{grid-column:span 2}.invoice-header-grid .span-3{grid-column:span 3}
.invoice-ruc-field{grid-column:span 1}.invoice-provider-field{grid-column:span 3}
.invoice-tax-line{display:flex;align-items:center;gap:18px;min-height:28px;padding:5px 10px;border-radius:10px;background:#f7f8f9;border:1px solid #eceef1;color:#686d74;font-size:10px}
.invoice-tax-line strong{color:#2f3338}.total-field input[readonly]{background:#fff1f2;color:var(--red);font-weight:900;border-color:#e7bfc2}
.electronic-grid{display:grid;grid-template-columns:1fr 1fr;gap:10px}.electronic-extras{padding:9px;border:1px dashed #e2c7ca;border-radius:11px;background:#fffafa}
.compact-status{min-height:12px;height:12px;font-size:9px;margin-top:2px}.compact-status .spinner{width:10px;height:10px}
.invoice-save-hint{margin:7px 0 0}.invoice-compact-form .form-actions{margin-top:10px}

@media(min-width:761px){
 #mainModal .modal-card.invoice-compact{width:min(1120px,calc(100vw - 28px));max-height:calc(100dvh - 24px)}
 #mainModal .modal-card.invoice-compact .modal-head{height:54px}
 #mainModal .modal-card.invoice-compact .modal-body{overflow:hidden;padding:11px 16px 12px}
 #mainModal .modal-card.invoice-compact .field label{font-size:9px;margin-bottom:4px}
 #mainModal .modal-card.invoice-compact .field input,#mainModal .modal-card.invoice-compact .field select{height:36px;border-radius:9px;padding:0 10px;font-size:12px}
 #mainModal .modal-card.invoice-compact .form-grid{gap:7px 10px}
 #mainModal .modal-card.invoice-compact .form-actions{margin-top:9px}
 #mainModal .modal-card.invoice-compact .btn{height:38px}
}

/* Contenedores Highcharts usados solo durante la generación del PDF. */
.obra-pdf-charts-stage{position:fixed;left:-12000px;top:0;width:1100px;background:#fff;z-index:1;pointer-events:none}
.obra-pdf-charts-stage>div{width:520px;height:310px;display:inline-block;vertical-align:top;background:#fff}
.obra-pdf-charts-stage>#pdfChartDaily{display:block;width:1060px;height:330px;margin-top:10px}

@media(max-width:760px){
 .invoice-header-grid{grid-template-columns:1fr 1fr}
 .invoice-header-grid .span-2,.invoice-header-grid .span-3,.invoice-ruc-field,.invoice-provider-field{grid-column:1/-1}
 .invoice-tax-line{display:grid;grid-template-columns:1fr;gap:3px}
 .electronic-grid{grid-template-columns:1fr}
 #module-gastos .table-wrap table,#module-gastos .table-wrap thead,#module-gastos .table-wrap tbody,#module-gastos .table-wrap tr,#module-gastos .table-wrap th,#module-gastos .table-wrap td{display:block;width:100%!important;min-width:0!important}
 #module-gastos .table-wrap thead{display:none}
 #module-gastos .table-wrap tbody{padding:7px;display:grid;gap:8px}
 #module-gastos .table-wrap tr{border:1px solid var(--line);border-radius:11px;padding:8px;background:#fff}
 #module-gastos .table-wrap td{border:0;padding:4px 2px;display:flex;align-items:flex-start;justify-content:space-between;gap:10px;text-align:right;font-size:11px}
 #module-gastos .table-wrap td::before{flex:0 0 34%;font-size:8px;text-transform:uppercase;letter-spacing:.04em;color:#858a92;font-weight:900;text-align:left}
 #module-gastos td:nth-child(1)::before{content:'Gasto'}#module-gastos td:nth-child(2)::before{content:'Categoría'}#module-gastos td:nth-child(3)::before{content:'Unidad'}#module-gastos td:nth-child(4)::before{content:'Precio ref.'}#module-gastos td:nth-child(5)::before{content:'Estado'}#module-gastos td:nth-child(6)::before{content:'Acciones'}
 #module-gastos .table-wrap td.empty::before{display:none;content:none}
}
@media(max-width:640px){
 .dashboard-main{overflow:hidden}.menu-grid{grid-template-rows:none!important;grid-auto-rows:minmax(78px,1fr);height:auto!important;max-height:100%;overflow-y:auto;padding-right:2px;align-self:stretch}
 .menu-card{min-height:78px}
}
.invoice-provider-row{display:grid;grid-template-columns:minmax(180px,1fr) minmax(0,3fr);gap:10px}
@media(max-width:760px){.invoice-provider-row{grid-template-columns:1fr}}
