/* ══════════════════════════════════════════════════
   THE COUNTER — the instore account (17-counter.js)
   Everything here is under html.role-counter, so the
   owner and staff app is untouched. Built for an iPad
   or phone on the counter: calm and uncluttered, big
   targets, 17px type (an iPad zooms the page on
   anything under 16px), the total always in sight,
   and — with the keyboard up — the room given to the
   box being typed in.
   ══════════════════════════════════════════════════ */

/* ── The rail: every page, but no back-office buttons ── */
html.role-counter .admin-only { display: none !important; }

/* ── Invoices page ── */
html.role-counter .ctr-new { height: 50px; padding: 0 26px; font-size: 15px; }
html.role-counter [data-invfilter="nofloor"],
html.role-counter #pane-invoice .toolbar-sep { display: none; }

/* revenue behind an eye */
.stat-rev .stat-key { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.eye-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; margin: -10px -10px -10px 0; border: none; border-radius: 50%;
  background: none; color: var(--muted); cursor: pointer; touch-action: manipulation;
}
.eye-btn svg { width: 19px; height: 19px; }
.eye-btn:hover { background: var(--card-2); color: var(--text); }
.eye-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.stat-rev.masked .stat-val { color: var(--faint); letter-spacing: .06em; }
@media (hover: none) { .eye-btn { width: 44px; height: 44px; margin: -14px -14px -14px 0; } }

/* touch targets on the list */
@media (hover: none), (any-pointer: coarse) {
  html.role-counter .btn.sm { height: 44px; padding: 0 16px; font-size: 13.5px; }
  html.role-counter .chip { height: 44px; padding: 0 18px; font-size: 14px; }
}

/* ══ The invoice form: full screen, nothing to tap away by accident ══ */
html.role-counter #invoice-modal { padding: 0; align-items: stretch; justify-content: stretch; }
html.role-counter body:has(#invoice-modal.open) { overflow: hidden; }
html.role-counter #invoice-modal .modal {
  width: 100% !important;   /* the modal carries an inline 760px for everyone else */
  max-width: none; height: 100%; max-height: none; border-radius: 0;
  display: flex; flex-direction: column; overflow: hidden;
}
/* a toast never covers the Save button */
html.role-counter body:has(#invoice-modal.open) .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }

/* ── Title bar: ✕ · title · PDF · Email, one slim row ── */
html.role-counter #invoice-modal .modal-head {
  flex: none; border-bottom: 1px solid var(--line-soft);
  padding: max(8px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 8px max(14px, env(safe-area-inset-left));
}
html.role-counter #invoice-modal .ctr-head > div { align-items: center !important; flex-wrap: nowrap !important; gap: 10px !important; }
html.role-counter #invoice-modal .ctr-head > div > div:not(.inv-head-acts) { flex: 1; min-width: 0; }
html.role-counter #invoice-modal .modal-title { font-size: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
html.role-counter #invoice-modal .modal-msg { display: none; }
html.role-counter #invoice-modal .inv-head-acts { display: flex; gap: 8px; flex: none; width: auto !important; flex-wrap: nowrap; }
html.role-counter #invoice-modal .inv-head-acts .btn { height: 42px; padding: 0 14px; flex: none !important; }
.ctr-close { width: 44px !important; height: 44px !important; flex: none; border-color: transparent !important; color: var(--muted); }
.ctr-close svg { width: 20px; height: 20px; }

/* ── The page: plain white, sections split by a hairline, no boxes in boxes ── */
html.role-counter #invoice-modal .modal-body {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain; touch-action: pan-y;
  padding: 14px max(20px, env(safe-area-inset-right)) 40px max(20px, env(safe-area-inset-left));
}
html.role-counter #invoice-modal .ctr-form { max-width: 980px; margin: 0 auto; gap: 0; }
.ctr-sec { padding: 16px 0 18px; border-top: 1px solid var(--line-soft); }
.ctr-sec:first-child { border-top: none; padding-top: 4px; }
.ctr-h { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--faint); font-weight: 600; margin-bottom: 10px; }
.ctr-grid { display: grid; gap: 12px; align-items: start; }
.ctr-cust-grid { grid-template-columns: 1.3fr 1fr 1.3fr; }
.ctr-pay-grid  { grid-template-columns: 1fr 1fr 1fr; align-items: end; }
.ctr-when-grid { grid-template-columns: 1.2fr 1fr 1fr; }
.ctr-more-grid { grid-template-columns: 1fr 1fr 1fr; }
.ctr-more-grid > :nth-child(4), .ctr-more-grid > :nth-child(5) { grid-column: 1 / -1; }

/* every box: 17px, one height */
html.role-counter #invoice-modal .field,
html.role-counter #invoice-modal .cloth-row input { font-size: 17px !important; height: 50px; }
html.role-counter #invoice-modal input[type=date].field { min-height: 50px; }
html.role-counter #invoice-modal .field-label { font-size: 10.5px; letter-spacing: .12em; margin-bottom: 6px; color: var(--faint); }

/* ── Items ── */
html.role-counter #invoice-modal .ctr-items > div > .field-label:first-child { display: none; }
html.role-counter #invoice-modal .ctr-items .search-wrap { margin-bottom: 10px !important; }
html.role-counter #invoice-modal .ctr-items .search-wrap .field { height: 52px; padding-left: 42px; background: var(--card-2); }
html.role-counter #invoice-modal .ctr-items .search-wrap .field:focus { background: var(--card); }
html.role-counter #invoice-modal .picker-list { max-height: 50vh; }
html.role-counter #invoice-modal .picker-row { padding: 12px 14px; }
html.role-counter #invoice-modal .picker-name { font-size: 16px; }
html.role-counter #invoice-modal .price-cells { gap: 8px; }
html.role-counter #invoice-modal .pcell { min-height: 50px; min-width: 92px; padding: 6px 13px; font-size: 15.5px; touch-action: manipulation; }
html.role-counter #invoice-modal .pcell em { font-size: 10px; }

/* a line: what it is on top, the numbers in one row, the cloth under */
.ctr-line { padding: 10px 12px 12px !important; margin-bottom: 10px !important; border-radius: var(--r-md) !important; }
.ctr-line-top { display: flex; gap: 8px; align-items: center; }
.ctr-line-desc {
  flex: 1; min-width: 0; height: 46px; padding: 0 12px; border: 1px solid transparent; border-radius: var(--r-sm);
  background: var(--card-2); font: inherit; font-size: 16.5px !important; font-weight: 500; color: var(--text);
  outline: none; -webkit-appearance: none;
}
.ctr-line-desc:focus { border-color: var(--gold); background: var(--card); box-shadow: 0 0 0 3px rgba(168,132,47,.13); }
.ctr-line-x { width: 42px !important; height: 42px !important; flex: none; }
.ctr-line-nums { display: grid; grid-template-columns: minmax(0, 1fr) auto 150px 120px; gap: 10px; align-items: center; margin-top: 10px; }
.ctr-line-tag { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctr-unit {
  display: flex; align-items: center; gap: 4px; height: 46px; padding-left: 11px;
  border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--card); margin: 0;
}
.ctr-unit > span { font-size: 13px; color: var(--faint); }
html.role-counter #invoice-modal .ctr-unit input {
  flex: 1; min-width: 0; height: 44px !important; padding: 0 11px 0 4px !important; text-align: right;
  border: none !important; box-shadow: none !important; background: transparent;
}
.ctr-unit:focus-within { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(168,132,47,.13); }
.ctr-line-amt { text-align: right; font-variant-numeric: tabular-nums; font-size: 16px; font-weight: 600; white-space: nowrap; }

/* quantity: − 1 + */
.qty-step { display: flex; align-items: stretch; gap: 5px; }
.qty-step .field { flex: 1; min-width: 0; text-align: center !important; padding: 0 2px; }
.ctr-line .qty-step { width: 148px; }
html.role-counter #invoice-modal .ctr-line .qty-step .field { height: 46px !important; }
.qty-btn {
  flex: none; width: 44px; height: 46px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--card); font-size: 21px; line-height: 1; color: var(--text); cursor: pointer;
  touch-action: manipulation;
}
.qty-btn:active { background: var(--gold-soft); border-color: var(--gold); }

/* the cloth: garment · fabric · lining in one row */
.ctr-parts .inv-part {
  display: grid; grid-template-columns: 96px minmax(0, 1fr) minmax(0, 1fr); gap: 10px; align-items: center;
  border-top: 1px dashed var(--line) !important; margin-top: 10px !important; padding-top: 10px !important;
}
.ctr-parts .inv-part > .cloth-name { margin: 0 !important; font-size: 11px; }
.ctr-parts .cloth-row { margin: 0; min-width: 0; }
.ctr-parts .cloth-row input { min-width: 0; width: 100%; }
.ctr-parts .cloth-row label { display: none; }
html.role-counter #invoice-modal .ctr-parts .cloth-row input { height: 46px; }

.ctr-addline { display: inline-flex; align-items: center; min-height: 44px; font-size: 14px; padding: 0 2px; }

/* the workshop: a tick box, not a black button */
html.role-counter #invoice-modal .ctr-workshop {
  background: none !important; border: none !important; padding: 2px 0 0 !important;
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px;
}
html.role-counter #invoice-modal .ctr-workshop > .field-label { display: none; }
html.role-counter #invoice-modal .ctr-workshop .chips { margin: 0 !important; }
html.role-counter #invoice-modal #inv-makeorder {
  height: 44px; padding: 0 14px 0 11px; display: inline-flex; align-items: center; gap: 10px;
  background: var(--card); color: var(--text); border-color: var(--line); font-size: 14px;
}
html.role-counter #invoice-modal #inv-makeorder::before {
  content: ''; flex: none; width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid var(--faint);
}
html.role-counter #invoice-modal #inv-makeorder.on::before {
  border-color: var(--ink); background: var(--ink) center / 13px no-repeat
    url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E");
}
html.role-counter #invoice-modal .ctr-workshop .inline-note { flex: 1 1 260px; font-size: 12px; }

/* ── Payment ── */
.ctr-paidfull-cell { display: flex; }
.ctr-paidfull {
  width: 100%; height: 50px; font-size: 15.5px; font-weight: 600;
  border-color: var(--st-store-ln); color: var(--st-store); background: var(--card);
}
.ctr-paidfull:hover, .ctr-paidfull:active { background: var(--st-store-bg); border-color: var(--st-store); color: var(--st-store); }

/* ── Handled by, and one-tap dates ── */
html.role-counter #inv-staff-chips .chip { height: 50px; min-width: 100px; font-size: 15.5px; }
.ctr-datechips { display: flex; gap: 6px; margin-top: 7px; flex-wrap: wrap; }
.ctr-datechips .chip { height: 40px !important; padding: 0 12px !important; font-size: 13px !important; color: var(--muted); }

/* ── Folded away ── */
.ctr-more { border-top: 1px solid var(--line-soft); padding: 0; }
.ctr-more > summary {
  list-style: none; cursor: pointer; min-height: 56px; display: flex; align-items: center; gap: 12px;
  font-size: 14px; font-weight: 500; touch-action: manipulation;
}
.ctr-more > summary::-webkit-details-marker { display: none; }
.ctr-more > summary::before {
  content: '+'; width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--line);
  display: inline-flex; align-items: center; justify-content: center; color: var(--muted); flex: none;
}
.ctr-more[open] > summary::before { content: '−'; }
.ctr-more > summary span { font-size: 12.5px; color: var(--faint); font-weight: 400; }
.ctr-more[open] { padding-bottom: 18px; }
.ctr-more .ctr-delete { margin-top: 16px; height: 46px; }

/* the footer carries the total; no second breakdown at the bottom */
html.role-counter #invoice-modal .ctr-totals { display: none; }

/* ── Footer: the total, Save & new, Save — one row ── */
html.role-counter #invoice-modal .modal-foot {
  flex: none; position: static; align-items: center; gap: 10px;
  padding: 10px max(16px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  border-top: 1px solid var(--line); box-shadow: 0 -4px 14px rgba(22,21,15,.04);
}
html.role-counter #invoice-modal .modal-foot > span[style*="flex:1"],
html.role-counter #invoice-modal .ctr-cancel { display: none; }
html.role-counter #invoice-modal .modal-foot .btn { height: 48px; font-size: 15px; padding: 0 20px; flex: none !important; min-width: 0 !important; }
.ctr-sum { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 4px 10px; flex-wrap: wrap; }
.ctr-sum-k { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--faint); }
.ctr-sum-v { font-family: var(--font-display); font-size: 26px; line-height: 1; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ctr-sum-bal { font-size: 13.5px; color: var(--danger); font-weight: 600; white-space: nowrap; }
.ctr-sum-tag { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; font-weight: 600;
               padding: 4px 10px; border-radius: 20px; }
.ctr-sum-tag.ok { color: var(--st-store); background: var(--st-store-bg); border: 1px solid var(--st-store-ln); }

/* ══ Keyboard up: the title bar steps aside, the footer shrinks to the
   total and Save, and the price results become part of the page's own
   scroll instead of a box inside it ══ */
html.role-counter #invoice-modal.kb .modal-head { display: none; }
html.role-counter #invoice-modal.kb .modal-body { padding-top: 8px; padding-bottom: 20px; }
html.role-counter #invoice-modal.kb .ctr-again { display: none; }
html.role-counter #invoice-modal.kb .modal-foot { padding-top: 6px; padding-bottom: 6px; box-shadow: none; }
html.role-counter #invoice-modal.kb .modal-foot .btn { height: 42px; }
html.role-counter #invoice-modal.kb .ctr-sum-v { font-size: 21px; }
html.role-counter #invoice-modal.kb .picker-list { max-height: none; }
html.role-counter body:has(#invoice-modal.kb) .toast { bottom: calc(64px + env(safe-area-inset-bottom)); }
/* iOS draws its keyboard toolbar see-through: under it, the form's own
   paper — not a strip of the page behind */
html.role-counter #invoice-modal.kb::after {
  content: ''; position: absolute; left: 0; right: 0; top: 100%; height: 100vh; background: var(--card);
}

/* ── iPad portrait ── */
@media (max-width: 900px) {
  .ctr-cust-grid { grid-template-columns: 1fr 1fr; }
  .ctr-cust-grid > :nth-child(3) { grid-column: 1 / -1; }
  .ctr-pay-grid { grid-template-columns: 1fr 1fr; }
  .ctr-pay-grid > .ctr-paidfull-cell { grid-column: 1 / -1; }
  .ctr-when-grid { grid-template-columns: 1fr 1fr; }
  .ctr-when-grid > :first-child { grid-column: 1 / -1; }
  .ctr-more-grid { grid-template-columns: 1fr 1fr; }
  .ctr-more-grid > :nth-child(3) { grid-column: 1 / -1; }
}
/* ── Phones ── */
@media (max-width: 620px) {
  html.role-counter #invoice-modal .modal-head { padding-left: 8px; padding-right: 10px; }
  html.role-counter #invoice-modal .modal-title { font-size: 17px; }
  html.role-counter #invoice-modal .inv-head-acts .btn { padding: 0 11px; }
  html.role-counter #invoice-modal .inv-head-acts .btn svg { display: none; }
  html.role-counter #invoice-modal .modal-body { padding: 10px 14px 28px; }
  .ctr-sec { padding: 14px 0 16px; }
  .ctr-cust-grid, .ctr-pay-grid, .ctr-when-grid, .ctr-more-grid { grid-template-columns: 1fr; gap: 10px; }
  .ctr-cust-grid > *, .ctr-pay-grid > *, .ctr-more-grid > * { grid-column: auto !important; }
  .ctr-pay-grid { grid-template-columns: 1fr 1fr; }
  .ctr-pay-grid > .ctr-paidfull-cell { grid-column: 1 / -1 !important; }
  .ctr-when-grid { grid-template-columns: 1fr 1fr; }
  .ctr-when-grid > :first-child { grid-column: 1 / -1 !important; }
  .ctr-line-nums { grid-template-columns: auto minmax(0, 1fr) auto; }
  .ctr-line-nums > .ctr-line-tag { grid-column: 1 / -1; }
  .ctr-line .qty-step { width: 132px; }
  .qty-btn { width: 40px; }
  .ctr-parts .inv-part { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
  .ctr-parts .inv-part > .cloth-name { grid-column: 1 / -1; }
  html.role-counter #invoice-modal .modal-foot { gap: 8px; }
  html.role-counter #invoice-modal .ctr-sum-k { display: none; }
  html.role-counter #invoice-modal .ctr-sum-v { font-size: 22px; }
  html.role-counter #invoice-modal .modal-foot .btn { padding: 0 14px; font-size: 14.5px; }
}
