:root{--ink:#1d304d;--navy:#172b43;--muted:#6a7f9e;--line:#dae3ed;--paper:#fff;--amber:#835613;--red:#a0372f;font-family:Arial,Helvetica,sans-serif;color:var(--ink);background:#fcfdff;font-size:16px}
*{box-sizing:border-box}
body{margin:0}
button,input,select{font:inherit}
button,a,input,select,summary{touch-action:manipulation}
button{cursor:pointer;border:1px solid #a9bdd8;border-radius:5px;background:white;color:#0b2a50;padding:10px 15px;min-height:44px}
button:hover{background:#f1f6fb}
button:disabled{cursor:default;opacity:.45}
button:focus-visible,a:focus-visible,summary:focus-visible,input:focus-visible,select:focus-visible{outline:3px solid #52aeb6;outline-offset:3px}
a{color:inherit}
input,select{width:100%;min-width:0;min-height:46px;border:1px solid var(--line);border-radius:5px;padding:11px 12px;background:white;color:var(--ink);font-weight:400}
label{display:flex;flex-direction:column;gap:7px;font-size:.875rem;font-weight:600}
[hidden]{display:none!important}
.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0)}
h1{font-size:38px;letter-spacing:-.65px;font-weight:700;margin:0 0 10px;line-height:1.13;color:#071c38}
h2{font-size:23px;letter-spacing:-.3px;margin:0;font-weight:700;color:#071d3f}
h3{font-size:1.1rem}
.muted{color:var(--muted);font-size:.9rem;line-height:1.5;margin:0}
.eyebrow{font-size:.72rem;letter-spacing:.14em;font-weight:700;color:var(--muted);margin:0 0 10px}
.heading{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:start;gap:10px 24px;margin-bottom:28px}
.heading .muted{font-size:16px}
.notes-actions{display:flex;align-items:center;gap:10px}
.readonly{font-size:12px;border:1px solid var(--line);border-radius:30px;padding:7px 12px;color:var(--muted);white-space:nowrap}
.updated{grid-column:1/-1;justify-self:end;font-size:12px;color:var(--muted);line-height:1.6;text-align:right;margin:0}
.quiet{background:transparent}
.filters{padding:16px;background:white;border:1px solid var(--line);border-radius:7px}
.search-label input{font-size:1rem;padding:15px 16px}
.search-label>span{position:absolute;clip:rect(0,0,0,0)}
.filter-grid{display:grid;grid-template-columns:.8fr .9fr .9fr 1.3fr 1.3fr 1fr;gap:12px;margin-top:18px}
.filter-bottom{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-top:14px}
.checkbox{flex-direction:row;align-items:center;font-weight:400;color:var(--muted)}
.checkbox input{width:17px;height:17px;min-height:0;accent-color:#238a96;flex-shrink:0}
.filter-bottom button{padding:6px 10px;font-size:.875rem;border:0}
.metrics{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:18px;margin:24px 0}
.metric{background:white;border:1px solid var(--line);padding:18px;min-height:104px;border-radius:7px;display:flex;flex-direction:column;gap:8px}
.metric span{font-size:16px}
.metric strong{font-size:30px;font-weight:700;letter-spacing:-.3px;color:#061c3a;font-variant-numeric:tabular-nums}
.metric small{font-size:.8rem;color:var(--muted)}
#review{color:#b8730a}
.tabs{display:flex;flex-wrap:wrap;gap:4px;padding:3px;border:1px solid var(--line);border-radius:5px;background:#f5f7fa;margin-bottom:16px;width:fit-content;max-width:100%}
.tabs button{border:0;border-radius:4px;padding:10px 18px;min-height:40px;background:transparent;color:var(--muted)}
.tabs .active{background:#19314f;color:white;box-shadow:0 1px 3px #1d304d33}
.tabs button:hover{background:#e7edf4}
.tabs .active:hover{background:#24455b}
.panel{background:white;border:1px solid var(--line);border-radius:7px;overflow:hidden}
.panel-heading{display:flex;justify-content:space-between;align-items:center;gap:12px;padding:18px}
.table-scroll{overflow-x:auto;position:relative;width:100%}
table{width:100%;border-collapse:collapse;font-size:.875rem}
th{text-align:left;font-size:14px;color:var(--ink);background:#f2f5f8;font-weight:600;padding:13px 17px;white-space:nowrap}
td{padding:14px 17px;border-bottom:1px solid #e6ecf2;vertical-align:middle;line-height:1.45}
td small{display:block;color:var(--muted);margin-top:5px;font-size:.78rem}
tbody tr:nth-child(even){background:#f8fafc}
tbody tr:hover{background:#eaf5f7}
.product-name{font-weight:600;min-width:190px;max-width:360px;overflow-wrap:anywhere}
.numeric{text-align:right;font-variant-numeric:tabular-nums;white-space:nowrap}
.badge{display:inline-block;padding:4px 8px;border-radius:4px;font-size:.75rem;white-space:nowrap;background:#edf1f6;color:#64748b}
.badge.manual{background:#ddf2ed;color:#235e55}
.badge.sugestao{background:#f6ebd5;color:var(--amber)}
.badge.rever{background:#f5dfd8;color:#904d36}
.detail-button{font-size:.8rem;padding:6px 10px;white-space:nowrap}
.pagination{padding:17px 22px;display:flex;justify-content:space-between;align-items:center;font-size:.85rem;gap:8px}
.pagination button{font-size:.85rem}
.footnote{font-size:.78rem;color:var(--muted);line-height:1.6;padding:20px 0;max-width:1000px}
.group-list{padding:0 22px 20px}
.group-row{border-top:1px solid var(--line);padding:17px 0}
.group-row summary{cursor:pointer;list-style:none}
.group-line{display:flex;justify-content:space-between;align-items:center;gap:14px}
.group-line strong{font-size:.95rem}
.group-line span{font-size:.88rem;font-variant-numeric:tabular-nums;white-space:nowrap}
.group-note{font-size:.78rem;color:var(--muted);margin-top:8px}
.bar{width:100%;height:7px;border:0;margin:12px 0 3px;accent-color:#2ca4a0}
.subcategories{padding:10px 0 0 20px}
.subcategories p{display:flex;justify-content:space-between;gap:16px;font-size:.875rem;margin:12px 0}
.empty{text-align:center;padding:45px 15px;color:var(--muted)}
.empty>span{font-size:2.5rem;color:var(--navy)}
.notice{padding:12px 16px;border-radius:7px;background:#f7ebd1;color:#735727;font-size:.875rem;line-height:1.5}
.error{color:var(--red);font-size:.9rem;line-height:1.5}
.error:empty{display:none}
dialog{width:min(1080px,94vw);max-height:90vh;border:1px solid var(--line);border-radius:10px;padding:26px;background:white;color:var(--ink);box-shadow:0 20px 80px #112d4933}
dialog::backdrop{background:#12284070}
.dialog-heading{display:flex;justify-content:space-between;gap:15px;align-items:center;margin-bottom:20px}
#close-dialog{flex:none;white-space:nowrap}
.invoice-meta{display:flex;gap:20px;flex-wrap:wrap;margin-bottom:20px;color:var(--muted);font-size:.9rem}
.invoice-item{padding:16px 0;border-top:1px solid var(--line)}
.invoice-item h3{margin:0 0 12px;overflow-wrap:anywhere}
.item-values{display:grid;grid-template-columns:repeat(4,1fr);gap:12px;font-size:.85rem}
.item-values small{display:block;color:var(--muted);margin-bottom:4px}
#notes-view>.notice,#notes-view>.invoice-meta{margin:20px}
.item-price strong{display:block}
.item-price small{display:block;white-space:normal;font-size:11px;line-height:1.4}
.item-price .gross-price{color:var(--muted)}
.item-price .discount-price{color:#18757a}
.brand-icon{width:42px;height:42px;background:var(--navy);color:white;display:grid;place-items:center;border-radius:9px;font-size:1.5rem;font-weight:700}
.login-page{min-height:100vh;display:grid;place-items:center;padding:24px;background:radial-gradient(ellipse at 0 100%,#e2f2f5,transparent 65%),#fcfdff}
.login-card{background:white;padding:40px;width:min(440px,100%);border:1px solid var(--line);border-radius:10px;box-shadow:0 20px 70px #112d4914}
.login-card .brand-icon{margin-bottom:28px}
.login-card h1{font-size:2.2rem}
.login-card form{margin-top:25px;display:grid;gap:18px}
.primary{background:var(--navy);color:white;display:flex;justify-content:space-between;padding:14px}
.primary:hover{background:#24455b}
.login-foot{font-size:.8rem;color:var(--muted);margin:24px 0 0;text-align:center}
@media(max-width:1250px){
  h1{font-size:34px}
  .heading{gap:12px}
  .notes-actions{grid-column:1/-1}
  .updated{justify-self:start;text-align:left}
  .metric span{font-size:14px}
  .metric strong{font-size:27px}
}
@media(max-width:1100px){.filter-grid{grid-template-columns:repeat(3,minmax(0,1fr))}}
@media(max-width:760px){
  h1{font-size:27px}
  h2{font-size:20px}
  .heading{grid-template-columns:1fr;gap:14px;margin-bottom:22px}
  .heading .muted{font-size:13px}
  .notes-actions{flex-wrap:wrap;gap:8px}
  .notes-actions button{padding:8px 12px;font-size:14px}
  .readonly{border:0;padding:0;margin-right:auto}
  .updated{font-size:11px}
  .filters{padding:16px}
  .filter-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
  .filter-bottom{flex-wrap:wrap;align-items:flex-start}
  .checkbox{font-size:.8rem;line-height:1.4}
  .metrics{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;margin:18px 0}
  .metric{padding:14px;min-height:86px}
  .metric.principal{grid-column:1/-1}
  .metric strong{font-size:25px}
  .tabs{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));width:100%;gap:3px}
  .tabs button{padding:10px 8px;font-size:14px;min-height:44px}
  .panel-heading{padding:16px;align-items:flex-start;flex-direction:column}
  .group-list{padding:0 16px 14px}
  .pagination{padding:12px 8px}
  .pagination button{padding:8px}
  .item-values{grid-template-columns:repeat(2,minmax(0,1fr))}
  dialog{padding:18px}
  .login-card{padding:28px}
  .login-card h1{font-size:2rem}
}
@media(max-width:640px){
  #notes-view th:first-child,#notes-view td:first-child{width:calc(100vw - 168px);min-width:calc(100vw - 168px);max-width:calc(100vw - 168px);padding:13px 12px;white-space:normal;overflow-wrap:anywhere}
  #notes-view .product-name{min-width:0;max-width:none}
  #notes-view th:nth-child(2),#notes-view td:nth-child(2){width:112px;min-width:112px;max-width:112px;padding:13px 12px}
  #notes-view td:nth-child(2){font-weight:600}
}
@media(prefers-reduced-motion:reduce){*{animation:none!important;transition:none!important}}
@media(max-width:360px){.notes-actions .readonly{width:100%;margin:0}}
.panel-heading .sort-label{flex-direction:row;align-items:center;gap:10px;font-weight:400;color:var(--muted);white-space:nowrap}
.panel-heading .sort-label select{width:auto;min-height:40px;padding:8px 10px}
.price-notice{margin:0 18px 16px}
.best-vendor{color:#18757a!important}
.change.up{color:#b0412f}.change.down{color:#18757a}.change.flat{color:var(--muted)}
.price-chart{width:100%;height:auto;display:block;margin:6px 0 10px}
.chart-grid{stroke:#e3e9f0;stroke-width:1}
.chart-axis{font-family:Arial,Helvetica,sans-serif;font-size:13px;fill:#6a7f9e}
.chart-line{fill:none;stroke:#b7c4d3;stroke-width:1.5}
.chart-dot{stroke:white;stroke-width:2}
.price-legend{display:flex;flex-wrap:wrap;gap:8px 20px;font-size:.85rem;margin:0 0 18px;color:var(--ink)}
.vendor-dot{display:inline-block;vertical-align:baseline;flex:none}
#price-body table td,#price-body table th{padding:10px 12px}
@media(max-width:760px){.panel-heading .sort-label{width:100%}.panel-heading .sort-label select{flex:1}.price-notice{margin:0 16px 14px}}
.product-cell{display:flex;align-items:flex-start;gap:12px}
.product-text{min-width:0}
.product-thumb{flex:none;width:44px;height:44px;border-radius:8px;background:#eef2f6;border:1px solid var(--line);display:grid;place-items:center;overflow:hidden;color:var(--muted);font-weight:700;font-size:1.05rem}
.product-thumb img{width:100%;height:100%;object-fit:contain;background:white}
.product-thumb.large{width:96px;height:96px;border-radius:10px;font-size:2rem}
.price-header{display:flex;gap:16px;align-items:center;margin-bottom:14px}
.price-header p{margin:0 0 4px}
.catalog-name{color:#18757a!important}
.catalog-source{font-size:.78rem}
@media(max-width:640px){.product-thumb{width:36px;height:36px}.product-cell{gap:9px}}

.each-price{color:var(--ink)!important;font-weight:600}
.price-notice summary{cursor:pointer;font-weight:600}
.price-notice p{margin:8px 0 0}
/* Celular: cada linha vira um cartão, sem rolagem lateral */
@media(max-width:640px){
  .card-table,.card-table tbody,.card-table tr,.card-table td{display:block;width:auto}
  .card-table thead{display:none}
  .table-scroll:has(.card-table){overflow:visible}
  .card-table tr{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px 14px;padding:14px 16px;border-bottom:1px solid var(--line)}
  .card-table tbody tr:nth-child(even){background:transparent}
  .card-table td{padding:0;border:0;min-width:0;text-align:left;white-space:normal;overflow-wrap:anywhere}
  .card-table td.numeric{text-align:left}
  .card-table td[data-label]::before{content:attr(data-label);display:block;font-size:.72rem;color:var(--muted);margin-bottom:2px}
  .card-table .product-col,.card-table .detail-col,.card-table .note-name-col{grid-column:1/-1}
  .card-table .product-name{min-width:0;max-width:none}
  .card-table .detail-col .detail-button{width:100%}
  .card-table td small{margin-top:2px}
  #price-body .card-table td{padding:0}
  .price-notice{margin:0 12px 12px}
}
.chart-axis-big{font-size:28px}

/* Topo compacto: busca + botão Filtros, etiquetas, totais em faixa */
.heading{margin-bottom:16px;align-items:center}
.heading h1{font-size:30px;margin:0}
.filters{padding:12px}
.search-row{display:flex;gap:10px;align-items:stretch}
.search-row .search-label{flex:1;min-width:0}
.filter-toggle{display:inline-flex;align-items:center;gap:8px;flex:none;font-weight:600;min-height:52px}
.filter-toggle.open{background:#eef4f9}
.filter-count{display:inline-grid;place-items:center;min-width:22px;height:22px;padding:0 6px;border-radius:11px;background:#238a96;color:white;font-size:.75rem}
.active-filters{display:flex;flex-wrap:wrap;gap:8px;margin-top:10px}
.filter-chip{display:inline-flex;align-items:center;gap:8px;min-height:32px;padding:4px 10px;border-radius:16px;font-size:.82rem;border-color:#bcd3df;background:#eef7f8;color:#1d4e5a}
.chip-x{font-size:1rem;line-height:1;opacity:.7}
#filter-panel .filter-grid{margin-top:14px}
.compact-notice{padding:8px 12px;font-size:.8rem;margin:12px 0 0}
.filters+.error+.compact-notice+.tabs,.filters+.error+.compact-notice[hidden]+.tabs{margin-top:14px}
.tabs{margin:14px 0 12px}
.compact-metrics{grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;margin:0 0 12px}
.compact-metrics .metric{min-height:0;padding:10px 14px;gap:2px;display:grid;grid-template-columns:1fr;border-radius:6px}
.compact-metrics .metric span{font-size:.78rem;color:var(--muted)}
.compact-metrics .metric strong{font-size:20px}
.compact-metrics .metric small{font-size:.72rem}
@media(max-width:760px){
  .heading{grid-template-columns:1fr auto;margin-bottom:12px}
  .heading h1{font-size:22px}
  .notes-actions{grid-column:auto}
  .notes-actions .readonly{display:none}
  .filter-toggle{min-height:46px;padding:8px 12px}
  .tabs{display:flex;flex-wrap:nowrap;overflow-x:auto;width:100%;scrollbar-width:none}
  .tabs::-webkit-scrollbar{display:none}
  .tabs button{flex:none;white-space:nowrap;padding:8px 14px;min-height:40px}
  .compact-metrics{grid-template-columns:repeat(3,minmax(0,1fr));gap:6px}
  .compact-metrics .metric.principal{grid-column:auto}
  .compact-metrics .metric{padding:8px 10px}
  .compact-metrics .metric strong{font-size:16px}
  .compact-metrics .metric span{font-size:.7rem}
  .compact-metrics .metric small{display:none}
}
@media(max-width:760px){
  .heading{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:6px 10px}
  .heading>div:first-child{flex:1 1 100%;order:-1}
  .heading .updated{order:-1;margin:0}
  .notes-actions button{padding:6px 12px;min-height:38px}
  .compact-notice{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .panel-heading{padding:14px 16px 6px}
}
.search-shortcut{position:fixed;right:20px;bottom:20px;z-index:20;width:54px;height:54px;border-radius:50%;padding:0;display:grid;place-items:center;background:var(--navy);color:white;border:0;box-shadow:0 6px 20px #0f233c55}
.search-shortcut:hover{background:#24455b}
.total-spent{color:#18757a}
@media(max-width:760px){.search-shortcut{right:14px;bottom:14px;width:50px;height:50px}}
