/* Same design language as quintoset-corporate (type, mono labels, hairlines, 2px buttons),
   built on its light "paper" palette instead of the black canvas. */
:root{
  --paper:#ececea;
  --card:#f5f5f3;
  --paper-ink:#141416;
  --paper-mute:#5d5e63;
  --paper-line:rgba(20,20,22,.14);
  --line-strong:rgba(20,20,22,.32);
  --err:#a3261f;
  --f-display:"Archivo","Helvetica Neue",Arial,sans-serif;
  --f-body:"Hanken Grotesk","Segoe UI",system-ui,sans-serif;
  --f-mono:"Martian Mono",ui-monospace,"SFMono-Regular",Menlo,monospace;
  --gut-l:max(20px, env(safe-area-inset-left,0px));
  --gut-r:max(20px, env(safe-area-inset-right,0px));
  /* Label size. Change it here AND in the @page rule at the bottom to match your label roll. */
  --label-w:60mm;
  --label-h:40mm;
  color-scheme:light;
}
*{box-sizing:border-box}
[hidden]{display:none!important}
/* Keeps the scrollbar's room on every page, so the header does not shift between a long page and a short one */
html{scrollbar-gutter:stable}
body{margin:0;background:var(--paper);color:var(--paper-ink);font-family:var(--f-body);font-size:16px;line-height:1.6;-webkit-font-smoothing:antialiased}
h1,h2{font-family:var(--f-display);font-stretch:125%;font-weight:300;margin:0;text-wrap:balance;letter-spacing:-.025em}
h1{font-size:clamp(30px,4.4vw,48px);line-height:1.08}
h2{font-size:clamp(20px,2.4vw,26px);line-height:1.2}
p{margin:0}
/* Page column: 88% of the window, so it never touches the edges on a big screen. Never under 1120px,
   the product table needs that much, and never over 1600px. Header and both pages share it. */
.wrap{max-width:max(1120px,min(88vw,1600px));margin:0 auto;padding-left:var(--gut-l);padding-right:var(--gut-r)}
.narrow{max-width:520px;margin-inline:auto}
.eyebrow{font-family:var(--f-mono);font-size:10.5px;letter-spacing:.1em;text-transform:uppercase;color:var(--paper-mute)}
.mute{color:var(--paper-mute);font-size:15px}
.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}
:focus-visible{outline:1.5px solid var(--paper-ink);outline-offset:3px;border-radius:2px}

/* Buttons */
/* Two fast taps on a button are two taps, not the phone's double-tap zoom. Pinch zoom still works. */
button{touch-action:manipulation}
.btn{display:inline-flex;align-items:center;justify-content:center;gap:12px;font-family:var(--f-body);font-weight:600;font-size:14.5px;letter-spacing:.01em;text-decoration:none;padding:15px 22px;border-radius:2px;border:1px solid transparent;cursor:pointer;white-space:nowrap;transition:background .25s,color .25s,border-color .25s}
.btn .arr{transition:transform .25s}
.btn:hover .arr{transform:translateX(4px)}
.btn-solid{background:var(--paper-ink);color:var(--paper)}
.btn-solid:hover{background:#2e2e33}
.btn-ghost{border-color:var(--line-strong);color:var(--paper-ink);background:transparent}
.btn-ghost:hover{border-color:var(--paper-ink)}
.btn-danger{background:var(--err);color:#fff}
.btn-danger:hover{background:#871f19}
.btn-sm{padding:9px 14px;font-size:13px}
.btn:disabled{opacity:.5;cursor:progress}

/* Nav */
.nav{position:sticky;top:0;z-index:50;padding-top:env(safe-area-inset-top,0px);background:rgba(236,236,234,.88);backdrop-filter:saturate(140%) blur(14px);-webkit-backdrop-filter:saturate(140%) blur(14px);border-bottom:1px solid var(--paper-line)}
.nav-in{display:flex;align-items:center;justify-content:space-between;gap:24px;height:64px}
.brand{display:flex;align-items:center;gap:12px;text-decoration:none;color:inherit;font-family:var(--f-display);font-stretch:125%;font-size:17px;letter-spacing:-.01em}
.nav-links{display:flex;gap:28px}
.nav-links a,.nav-links button{text-decoration:none;font-size:14px;color:var(--paper-mute);padding:10px 0;position:relative;transition:color .2s}
/* Sair is a button, it does something instead of going somewhere. It looks like the links. */
.nav-links button{background:none;border:0;font-family:inherit;cursor:pointer}
.nav-links a:hover,.nav-links a[aria-current],.nav-links button:hover{color:var(--paper-ink)}
.nav-links a::after,.nav-links button::after{content:"";position:absolute;left:0;right:100%;bottom:4px;height:1px;background:var(--paper-ink);transition:right .3s}
.nav-links a:hover::after,.nav-links a[aria-current]::after,.nav-links button:hover::after{right:0}

/* Page */
main{padding-block:clamp(32px,6vw,72px) 96px}
.head{display:grid;gap:14px;margin-bottom:clamp(24px,4vw,40px)}
/* Top aligned, so a title next to a button starts at the same height as a title alone */
.head-row{display:flex;flex-wrap:wrap;align-items:start;justify-content:space-between;gap:16px 24px}
/* Phone: the title and its button share one line, with a shorter button ("+ Adicionar").
   The title box is as tall as that button on every page, so the titles of both tabs stay at the same height. */
@media (max-width:560px){
  h1{display:flex;align-items:center;min-height:38px}
  .head-row{flex-wrap:nowrap;align-items:center}
  #add{padding:9px 14px;font-size:13px}
  #add .wide{display:none}
}
/* The scan screen keeps its title where the other pages have it, and its content in a column under it */
#baixa>.stack{max-width:520px}
.stack{display:grid;gap:18px}
.row{display:flex;gap:12px;align-items:end}
.row .field{flex:1}
.card{border:1px solid var(--paper-line);background:var(--card);padding:clamp(20px,3vw,32px)}

/* Forms */
.field{display:grid;gap:8px;min-width:0}
label,.facts dt,.stats dt{font-family:var(--f-mono);font-size:10.5px;letter-spacing:.14em;text-transform:uppercase;color:var(--paper-mute)}
/* 16px keeps iOS from zooming the page when a field gets focus */
input,select{font:inherit;font-size:16px;color:var(--paper-ink);background:transparent;border:0;border-bottom:1px solid var(--line-strong);padding:10px 0;border-radius:0;width:100%;transition:border-color .2s,box-shadow .2s}
input:focus,select:focus{outline:none;border-color:var(--paper-ink);box-shadow:0 1px 0 var(--paper-ink)}
select{appearance:none;-webkit-appearance:none;padding-right:24px;cursor:pointer;background-image:linear-gradient(45deg,transparent 50%,var(--paper-mute) 50%),linear-gradient(135deg,var(--paper-mute) 50%,transparent 50%);background-position:calc(100% - 10px) 52%,calc(100% - 5px) 52%;background-size:5px 5px;background-repeat:no-repeat}
input::placeholder{color:var(--line-strong)}
input[type=number]{appearance:textfield;-moz-appearance:textfield}
input[type=number]::-webkit-inner-spin-button{-webkit-appearance:none}
.product-form{display:grid;grid-template-columns:1fr 1fr;gap:22px 24px}
.product-form .full{grid-column:1/-1}

.status{margin-top:16px;font-size:14.5px}
.status:empty{display:none}
.status.err{color:var(--err)}
.empty{margin-top:24px;color:var(--paper-mute);font-size:15px}

/* Stock numbers above the list: one box with a hairline between the cells. The money cell is wider,
   its number is the long one. On a phone it takes the whole first line and the other three share the second. */
.stats{display:grid;grid-template-columns:1.6fr 1fr 1fr 1fr;margin:0 0 20px;border:1px solid var(--paper-line);background:var(--card)}
.stats div{min-width:0;padding:16px 20px}
.stats div+div{border-left:1px solid var(--paper-line)}
.stats dd{margin:6px 0 0;font-family:var(--f-display);font-stretch:125%;font-weight:300;font-size:clamp(20px,2.4vw,28px);line-height:1.15;letter-spacing:-.02em;font-variant-numeric:tabular-nums;white-space:nowrap}
.stats .note{margin-top:4px;font-family:var(--f-body);font-stretch:normal;font-weight:400;font-size:13px;letter-spacing:0;color:var(--paper-mute)}
.stats .note:empty{display:none}
@media (max-width:560px){
  .stats{grid-template-columns:repeat(3,1fr)}
  .stats div{padding:12px 14px}
  .stats div:first-child{grid-column:1/-1;border-bottom:1px solid var(--paper-line)}
  .stats div:nth-child(2){border-left:0}
  .stats div:first-child dd:not(.note){font-size:26px}
}

/* Product list */
/* The row above the list. Empty on a big screen with one page, and then it takes no room. */
.tools{display:flex;align-items:center;gap:12px}
.tools .pager{margin:0 0 0 auto}
#filters-toggle{display:none}
.table{margin-top:12px;border:1px solid var(--paper-line);background:var(--card);overflow-x:auto}
table{width:100%;border-collapse:collapse}
th,td{text-align:left;padding:14px 8px;border-bottom:1px solid var(--paper-line);vertical-align:middle;font-size:15px}
/* Only while it is a table. On a small screen the cells of a row are a card, and this rule would
   also take the bottom line off the chips (td.tag) of the last product. */
@media (min-width:1141px){tbody tr:last-child td{border-bottom:0}}
th{font-family:var(--f-mono);font-weight:400;font-size:10.5px;letter-spacing:.14em;text-transform:uppercase;color:var(--paper-mute);vertical-align:bottom}
/* Column filters. width:100% lets a filter take the width of its column instead of setting it. */
th label{display:block}
th input,th select{font-family:var(--f-body);font-size:14px;letter-spacing:0;text-transform:none;padding:6px 0;min-width:56px;text-overflow:ellipsis}
th select{padding-right:18px;background-position:calc(100% - 7px) 52%,calc(100% - 2px) 52%}
/* A filter in use gets a dark line, and drops its arrow so the picked value has the whole column width */
th .on{border-color:var(--paper-ink);box-shadow:0 1px 0 var(--paper-ink)}
th select.on{background-image:none;padding-right:0}
/* A column with no filter: its name stays on the line of the other names, not down with the filters */
th:not(:has(*)){vertical-align:top}
td.sku{font-family:var(--f-mono);font-size:12.5px;letter-spacing:.06em;color:var(--paper-mute);white-space:nowrap}
/* A field the product does not have */
td:empty::after,.facts dd:empty::after{content:"–";color:var(--line-strong)}
.num{text-align:right;font-variant-numeric:tabular-nums}
td.num{white-space:nowrap}
.neg{color:var(--err)}
th:last-child,td:last-child{text-align:right;width:1%;white-space:nowrap}
.more{font-size:18px;line-height:1;padding:8px 12px}
.pager{display:flex;align-items:center;justify-content:flex-end;gap:8px;margin-top:16px}
.pager .mute{margin-right:8px;font-variant-numeric:tabular-nums;white-space:nowrap}
.pager .btn:disabled{cursor:default}

/* A product's fields as chips, in the panels that show one product (stock update, delete, scan).
   The small-screen cards give td.tag the same look, keep the two in step. */
.tags{display:flex;flex-wrap:wrap;gap:6px 8px;margin:10px 0 8px}
.tags:empty{display:none}
.chip{padding:2px 8px;border:1px solid var(--paper-line);border-radius:2px;font-size:13px}
/* Numbers of one product in the stock dialog, one per line: the name on the left, the number on the right */
.facts{display:grid;gap:6px;margin:14px 0 0}
.stack>.facts{margin:0}
.facts div{display:flex;justify-content:space-between;align-items:baseline;gap:16px}
.facts dd{margin:0;font-variant-numeric:tabular-nums}
#new-total,#after-total{font-weight:600}

/* Row menu */
.menu{position:fixed;inset:auto;margin:0;min-width:168px;padding:6px;border:1px solid var(--line-strong);border-radius:2px;background:var(--card);color:inherit;box-shadow:0 10px 30px rgba(9,9,10,.14)}
.menu button{display:block;width:100%;padding:11px 12px;border:0;border-radius:2px;background:transparent;color:inherit;font:inherit;font-size:14.5px;text-align:left;cursor:pointer}
.menu button:hover,.menu button:focus-visible{background:var(--paper)}
.menu .danger{color:var(--err)}

/* Toast: what the last action did, at the bottom of the screen for a few seconds. Same ink as the
   solid buttons. Taps go through it, so it never blocks what is under it. */
.toast{position:fixed;inset:auto 0 max(20px,env(safe-area-inset-bottom,0px)) 0;margin:0 auto;width:fit-content;max-width:min(440px,calc(100vw - 40px));padding:14px 18px;border:0;border-radius:2px;background:var(--paper-ink);color:var(--paper);font-size:14px;line-height:1.45;box-shadow:0 10px 30px rgba(9,9,10,.25);pointer-events:none}
.toast:popover-open{animation:toast-in .2s ease-out}
.toast strong,.toast span{display:block}
.toast strong{font-weight:600}
@keyframes toast-in{from{opacity:0;transform:translateY(8px)}}
/* "bottom" alone is not safe on a phone. In Chrome on iPhone the page goes on under the browser's
   bottom bar, and the bar covered the last lines of the toast. 100svh is the height of the part of
   the screen that is still free with every browser bar showing, so the toast is measured from the
   top instead: its top edge goes to that line and translate lifts it by its own height. On a
   computer this is the same place as before. A browser without svh keeps the rule above. */
@supports (top:100svh){
  .toast{top:calc(100svh - max(20px,env(safe-area-inset-bottom,0px)));bottom:auto;translate:0 -100%}
}
/* Small screens. With its twelve columns the table needs about 1030px, and up to 1060px when a total
   runs to six figures. The page column gives it 1078px from a 1140px window up, so under that every
   product is a card and nothing scrolls sideways. Same HTML, only the display changes:
     line 1  name, and the ⋯ button
     line 2  code, and the stock
     line 3  unit price, and the total
     line 4  the other fields as chips, the empty ones left out
   tr::before and tr::after are the line breaks after lines 1 and 2. */
@media (max-width:1140px){
  #filters-toggle{display:inline-flex}
  /* Arrows only, so Filtros, the count and both page buttons fit on one line of a phone */
  .pager .btn span{display:none}
  .table{overflow-x:visible}
  .table:not(.filters-open):has(tbody:empty){display:none}
  table,tbody,tr,th,td{display:block}

  /* Filters: closed until the Filtros button opens them, then two per line */
  thead{display:none}
  .filters-open thead{display:block}
  thead tr{display:grid;grid-template-columns:1fr 1fr;gap:16px;padding:16px 14px;border-bottom:1px solid var(--paper-line)}
  th{padding:0;border:0;min-width:0}
  th.num{text-align:left}
  th:not(:has(*)){display:none}
  th:last-child{grid-column:1/-1;width:auto}
  th:last-child .btn{width:100%}
  /* 16px again, see the note on iOS zoom above */
  th input,th select{font-size:16px}

  tbody tr{display:flex;flex-wrap:wrap;align-items:center;gap:6px 8px;padding:12px 14px;border-bottom:1px solid var(--paper-line)}
  tbody tr:last-child{border-bottom:0}
  tbody tr::before,tbody tr::after{content:"";flex-basis:100%}
  tbody tr::before{order:1}
  tbody tr::after{order:3}
  td{padding:0;border:0}
  td:empty{display:none}
  td[data-field=name]{order:0;flex:1;font-size:16px;font-weight:600}
  td:last-child{order:0;width:auto}
  td.sku{order:2;flex:1}
  td.num{order:2;white-space:normal}
  td.num::before{content:"Estoque";margin-right:8px;font-family:var(--f-mono);font-size:10.5px;letter-spacing:.14em;text-transform:uppercase;color:var(--paper-mute)}
  /* Half the card each (the gap is 8px), so together they fill line 3 and the chips start line 4.
     A product without a price has both cells empty, and then there is no line 3. */
  td[data-field=price],td[data-field=total]{order:4;flex:0 0 calc(50% - 4px)}
  td[data-field=price]{text-align:left}
  /* On this line each name sits above its number: "Preço unitário" beside the number does not fit in half a card */
  td[data-field=price]::before,td[data-field=total]::before{display:block;margin:0}
  td[data-field=price]::before{content:"Preço unitário"}
  td[data-field=total]::before{content:"Total"}
  td.tag{order:5;padding:2px 8px;border:1px solid var(--paper-line);border-radius:2px;font-size:13px}
}

/* Scan */
.cam{position:relative;aspect-ratio:3/2;border:1px dashed var(--line-strong);background:var(--card);display:grid;place-items:center;overflow:hidden}
.cam.on{border-style:solid;background:#000}
.cam video{position:absolute;inset:0;width:100%;height:100%;object-fit:cover}
.cam.on::after{content:"";position:absolute;left:8%;right:8%;top:50%;height:1px;background:rgba(255,255,255,.85)}
.stepper{display:grid;grid-template-columns:56px 1fr 56px;border:1px solid var(--line-strong);border-radius:2px}
.stepper button{height:56px;border:0;background:transparent;color:inherit;font-size:24px;cursor:pointer}
.stepper input{border:0;border-inline:1px solid var(--paper-line);padding:0;text-align:center;font-family:var(--f-mono);font-size:20px;box-shadow:none}

/* Label */
dialog{border:1px solid var(--paper-line);border-radius:2px;background:var(--paper);color:inherit;padding:clamp(20px,4vw,32px);max-width:calc(100vw - 40px)}
dialog::backdrop{background:rgba(9,9,10,.5)}
#estoque,#excluir,#acima{width:420px}
/* Wider, the label is drawn as wide as this dialog lets it (showLabel in app.js) */
#etiqueta{width:480px}
/* show() in app.js puts the focus on the dialog itself. That needs no ring, the dialog just opened. */
dialog:focus{outline:none}

/* Drawer: a native dialog docked to the right edge, full width on a phone */
.drawer{position:fixed;inset:0 0 0 auto;margin:0;width:min(480px,100vw);max-width:none;height:100dvh;max-height:none;border:0;border-left:1px solid var(--paper-line);padding:max(24px,env(safe-area-inset-top,0px)) var(--gut-r) max(32px,env(safe-area-inset-bottom,0px)) 24px;overflow-y:auto}
.drawer[open]{animation:drawer-in .28s cubic-bezier(.2,.7,.2,1)}
@keyframes drawer-in{from{transform:translateX(100%)}}
@media (prefers-reduced-motion:reduce){.drawer[open],.toast:popover-open{animation:none}}
.drawer-head{display:flex;align-items:start;justify-content:space-between;gap:16px;margin-bottom:28px}
.drawer-head>div{display:grid;gap:10px}
.close{width:44px;height:44px;border:1px solid var(--line-strong);border-radius:2px;background:transparent;color:inherit;font-size:22px;line-height:1;cursor:pointer;transition:border-color .25s}
.close:hover{border-color:var(--paper-ink)}

/* Label */
/* Every size inside the label is a share of its height (--u is 1% of it), so a different label
   roll only needs the two numbers at the top of this file and the @page rule below: the text
   and the bars grow or shrink with it. Black only, a label printer has no grey. */
.label{--u:calc(var(--label-h) / 100);width:var(--label-w);height:var(--label-h);margin:20px auto;padding:calc(6 * var(--u)) calc(8 * var(--u));border:1px solid var(--paper-line);background:#fff;color:#000;display:flex;flex-direction:column;gap:calc(4 * var(--u));overflow:hidden}
.label-name{flex:none;font-size:calc(13 * var(--u));font-weight:600;line-height:1.1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
/* The other fields in two columns, one value per cell, never broken in the middle */
.label-details{flex:none;display:grid;grid-template-columns:1fr 1fr;gap:0 calc(6 * var(--u));font-size:calc(8.5 * var(--u));line-height:1.15}
.label-details:empty{display:none}
.label .chip{padding:0;border:0;font-size:inherit;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
/* A little more air above the bars than between the other blocks */
.label svg{flex:1;min-height:0;width:100%;margin-top:calc(1 * var(--u))}
.label-sku{flex:none;font-family:var(--f-mono);font-size:calc(8.5 * var(--u));line-height:1;letter-spacing:.2em;text-align:center}

/* Printing sends only the label, on a page the size of one label. */
@page{size:60mm 40mm;margin:0}
@media print{
  body{background:#fff}
  body>:not(#etiqueta),#etiqueta>:not(.label){display:none}
  /* max-height and overflow undo the browser's modal defaults, which clip the label and add a scrollbar */
  #etiqueta{position:absolute;inset:0 auto auto 0;width:auto;margin:0;padding:0;border:0;max-width:none;max-height:none;overflow:visible;background:#fff}
  #etiqueta::backdrop{display:none}
  /* zoom:1 undoes the on-screen enlargement, paper gets the real size */
  .label{margin:0;border:0;zoom:1!important}
}
