@font-face {
  font-family: "Archivo Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  font-stretch: 62% 125%;
  src: url(/fonts/archivo-latin-standard-normal.woff2) format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Archivo Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  font-stretch: 62% 125%;
  src: url(/fonts/archivo-latin-ext-standard-normal.woff2) format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --chalk: #edf0f3;      /* tailor's chalk: the work surface */
  --paper: #ffffff;
  --ink: #15202e;
  --slate: #566373;
  --line: #d3d9e0;
  --tape: #f4c430;       /* measuring-tape yellow: selection and the header strip */
  --pin: #b92d24;        /* pin-cushion red: destructive actions */
  --green: #1e6b52;      /* paid */
  --kb-h: 0px;
  --touch: 52px;
  --radius: 10px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  padding-bottom: var(--kb-h);
  background: var(--chalk);
  color: var(--ink);
  font: 400 17px/1.4 "Archivo Variable", "Segoe UI", system-ui, sans-serif;
  touch-action: manipulation;
}
h1, h2, h3 { margin: 0; font-stretch: 112%; font-weight: 700; line-height: 1.15; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; margin-top: 1.25rem; }
p { margin: 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.25rem 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }

/* The measuring tape: the one decorative element, under the header and on sign-in. */
.tape {
  height: 16px;
  background-color: var(--tape);
  background-image:
    linear-gradient(90deg, var(--ink) 0 2px, transparent 2px),
    linear-gradient(90deg, var(--ink) 0 1px, transparent 1px);
  background-size: 60px 16px, 12px 7px;
  background-repeat: repeat-x;
  background-position: 0 0, 0 100%;
}

/* --- controls --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--touch); padding: 0 1.1rem;
  border: 2px solid var(--ink); border-radius: var(--radius);
  background: var(--paper); color: var(--ink);
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-secondary { background: var(--paper); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--slate); font-weight: 500; }
.btn-ghost { border-color: rgba(255, 255, 255, 0.35); background: transparent; color: #fff; font-weight: 500; min-height: 44px; }
.btn-danger { background: var(--pin); border-color: var(--pin); color: #fff; }
.btn-danger-quiet { border-color: transparent; background: transparent; color: var(--pin); }
.btn-block { width: 100%; }
.btn-big { min-height: 64px; font-size: 1.1rem; white-space: normal; }
.btn-row { display: flex; gap: 0.6rem; flex-wrap: wrap; }

.field { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }
.field-label { font-size: 0.9rem; font-weight: 600; color: var(--slate); }
.field-hint { font-size: 0.88rem; color: var(--slate); }
.input {
  width: 100%; min-height: var(--touch); padding: 0 0.85rem;
  border: 2px solid var(--line); border-radius: var(--radius);
  background: var(--paper); color: var(--ink); font: inherit; font-size: 1.1rem;
}
textarea.input { padding: 0.7rem 0.85rem; resize: vertical; }
.input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px var(--tape); }
.check { width: 26px; height: 26px; accent-color: var(--ink); }
.check-label { display: inline-flex; align-items: center; gap: 0.5rem; white-space: nowrap; }
.stack { display: flex; flex-direction: column; gap: 0.85rem; }
.row-form { display: flex; gap: 0.6rem; align-items: flex-end; }
.row-form > .field, .row-form > .input { flex: 1; }
.row-form.narrow { max-width: 30rem; margin: 1rem 0 0; }
.grow { flex: 1; min-width: 0; }
.form-error { color: var(--pin); font-weight: 600; min-height: 1.4em; }
.empty { color: var(--slate); padding: 1.25rem 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* --- sign in --- */
.login { min-height: calc(100vh - var(--kb-h)); display: flex; flex-direction: column; }
.login-card {
  width: min(26rem, calc(100% - 2rem)); margin: clamp(1.5rem, 8vh, 6rem) auto 2rem;
  display: flex; flex-direction: column; gap: 1rem;
  background: var(--paper); border: 2px solid var(--ink); border-radius: 14px; padding: 2rem 1.75rem 1.25rem;
}
.brand { font-stretch: 125%; font-weight: 800; letter-spacing: -0.01em; font-size: 1.45rem; }
.brand-big { font-size: 2.6rem; }
.login-sub { color: var(--slate); margin-top: -0.6rem; }

/* --- shell --- */
.top { background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 5; }
.top-row { display: flex; align-items: center; gap: 1.25rem; padding: 0.55rem 1.1rem; flex-wrap: wrap; }
.tabs { display: flex; gap: 0.35rem; flex: 1; }
.tab { border-color: transparent; background: transparent; color: #cfd6de; min-height: 44px; }
.tab-on { background: var(--tape); color: var(--ink); }
.top-right { display: flex; gap: 0.5rem; }
.top :focus-visible { outline-color: var(--tape); }
.view { padding: 1.1rem; max-width: 1500px; margin: 0 auto; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 1.1rem; min-width: 0; }
.panel > h2, .panel-head { margin-bottom: 0.9rem; }
.panel-head { display: flex; align-items: center; justify-content: space-between; }

/* --- new ticket --- */
.view-counter { display: grid; grid-template-columns: minmax(270px, 320px) minmax(0, 1fr) minmax(320px, 400px); gap: 1.1rem; align-items: start; }
.cust-status { margin: 0.7rem 0 0.9rem; padding: 0.6rem 0.8rem; border-radius: var(--radius); background: var(--chalk); color: var(--slate); font-size: 0.95rem; }
.cust-status.is-found { background: #e3f1ea; color: var(--green); font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip { border-color: var(--line); border-radius: 999px; font-weight: 500; }
.chip-on { background: var(--tape); border-color: var(--ink); font-weight: 700; }
.jobs { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0.6rem; margin: 1rem 0; }
.job {
  display: flex; flex-direction: column; justify-content: space-between; gap: 0.5rem; text-align: left;
  min-height: 84px; padding: 0.7rem 0.8rem; border: 2px solid var(--line); border-radius: var(--radius);
  background: var(--paper); color: var(--ink); font: inherit; cursor: pointer;
}
.job:active { background: var(--tape); border-color: var(--ink); }
.job-name { font-weight: 600; line-height: 1.2; }
.job-price { font-variant-numeric: tabular-nums; color: var(--slate); }
.custom-form { display: grid; grid-template-columns: minmax(0, 1fr) 7.5rem auto; gap: 0.6rem; align-items: end; border-top: 1px solid var(--line); padding-top: 1rem; }

.lines { min-height: 5rem; }
.line { display: grid; grid-template-columns: minmax(0, 1fr) auto 5rem; gap: 0.2rem 0.6rem; align-items: center; padding: 0.55rem 0; border-bottom: 1px dashed var(--line); }
.line-job { font-weight: 600; overflow-wrap: anywhere; }
.line-price { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.qty { display: inline-flex; align-items: center; gap: 0.35rem; }
.qty-n { min-width: 1.6rem; text-align: center; font-variant-numeric: tabular-nums; }
.btn-step { min-height: 44px; width: 44px; padding: 0; font-size: 1.3rem; }
.btn-remove { grid-column: 1 / -1; justify-self: start; min-height: 36px; padding: 0; font-size: 0.9rem; text-decoration: underline; }
.totals { margin: 0.9rem 0; display: flex; flex-direction: column; gap: 0.5rem; }
.total-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; font-variant-numeric: tabular-nums; }
.total-row .input { width: 8.5rem; text-align: right; }
.total-due { border-top: 2px solid var(--ink); padding-top: 0.6rem; font-size: 1.35rem; font-weight: 700; }
.panel-ticket > .field { margin-bottom: 0.9rem; }
.panel-ticket > .field-hint { margin-top: 0.5rem; min-height: 1.3em; color: var(--pin); }

/* --- tickets --- */
.ticket-tools { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.segmented { display: inline-flex; border: 2px solid var(--ink); border-radius: var(--radius); overflow: hidden; }
.seg { border: 0; border-radius: 0; min-height: 48px; font-weight: 500; }
.seg-on { background: var(--tape); font-weight: 700; }
.trow {
  display: grid; grid-template-columns: 5.5rem minmax(0, 1.6fr) minmax(0, 1.2fr) 6rem 6rem 8.5rem; gap: 0.75rem; align-items: center;
  width: 100%; min-height: 64px; padding: 0.5rem 0.75rem; text-align: left;
  border: 0; border-bottom: 1px solid var(--line); background: transparent; color: inherit; font: inherit; cursor: pointer;
}
.trow:active { background: var(--chalk); }
.thead { min-height: 0; cursor: default; font-size: 0.88rem; font-weight: 600; color: var(--slate); }
.thead span:nth-child(4), .thead span:nth-child(5) { text-align: right; }
.t-num { font-size: 1.3rem; font-weight: 800; font-stretch: 112%; font-variant-numeric: tabular-nums; }
.t-cust { display: flex; flex-direction: column; min-width: 0; }
.t-cust small { color: var(--slate); }
.badge { display: inline-block; padding: 0.2rem 0.6rem; border-radius: 999px; font-size: 0.88rem; font-weight: 600; border: 1.5px solid currentColor; }
.badge-open { color: var(--ink); background: var(--tape); border-color: var(--ink); }
.badge-paid { color: var(--green); }
.badge-void { color: var(--slate); }

/* --- dialogs --- */
.overlay { position: fixed; inset: 0; z-index: 20; background: rgba(21, 32, 46, 0.55); display: flex; align-items: center; justify-content: center; padding: 1rem 1rem calc(1rem + var(--kb-h)); overflow: auto; }
.kb-open .overlay { align-items: flex-start; }
.dialog { background: var(--paper); border-radius: 14px; width: min(30rem, 100%); max-height: 100%; display: flex; flex-direction: column; margin: auto; }
.dialog-wide { width: min(52rem, 100%); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 0.6rem 0.6rem 0.6rem 1.25rem; border-bottom: 1px solid var(--line); }
.dialog-body { padding: 1.25rem; overflow: auto; }
.ticket-dialog { display: flex; gap: 1.5rem; flex-wrap: wrap; align-items: flex-start; }
.paper { background: var(--chalk); padding: 0.9rem; border-radius: var(--radius); max-width: 100%; overflow: auto; }
.paper .receipt { box-shadow: 0 1px 0 var(--line), 0 6px 14px rgba(21, 32, 46, 0.12); }
.ticket-actions { flex: 1; min-width: 15rem; display: flex; flex-direction: column; gap: 0.9rem; }
.close-box { border: 2px solid var(--ink); border-radius: var(--radius); padding: 1rem; display: flex; flex-direction: column; gap: 0.75rem; }
.close-box h3 { margin: 0; }
.pay-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.pay { min-height: 72px; font-size: 1.2rem; }
.pay-on { background: var(--tape); box-shadow: inset 0 0 0 2px var(--ink); }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 0.4rem 1rem; margin: 0; }
.facts dt { color: var(--slate); }
.facts dd { margin: 0; font-weight: 600; }

/* --- manage --- */
.view-manage .segmented { margin-bottom: 1.1rem; }
.edit-list { display: flex; flex-direction: column; margin-top: 0.75rem; }
.edit-row { display: grid; grid-template-columns: minmax(0, 1fr) 8rem auto auto; gap: 0.6rem; align-items: end; padding: 0.5rem 0; border-bottom: 1px solid var(--line); }
.edit-new { border: 0; margin-top: 0.75rem; }
.staff-row { grid-template-columns: 11rem minmax(0, 1fr) 8.5rem auto minmax(0, 1fr) auto; align-items: center; }
.staff-row + .staff-row { margin-top: 0; }
.staff-user { display: flex; flex-direction: column; min-width: 0; }
.staff-user small { color: var(--slate); font-size: 0.82rem; }
.view-manage .edit-new:has(.field:nth-child(4)) { grid-template-columns: repeat(4, minmax(0, 1fr)) auto; align-items: start; }
.view-manage .edit-new:has(.field:nth-child(4)) .btn { margin-top: 1.55rem; }

/* --- toasts --- */
#toasts { position: fixed; z-index: 40; bottom: calc(1rem + var(--kb-h)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column-reverse; gap: 0.5rem; align-items: center; width: min(32rem, calc(100% - 2rem)); pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 0.8rem 1.1rem; border-radius: var(--radius); font-weight: 600; border-left: 8px solid var(--tape); }
.toast-error { border-left-color: var(--pin); }

/* --- on-screen keyboard --- */
.kb { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--ink); padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.kb-inner { max-width: 980px; margin: 0 auto; display: flex; flex-direction: column; gap: 6px; }
.kb-num .kb-inner { max-width: 420px; }
.kb-row { display: flex; gap: 6px; }
.kb-key {
  flex: 1 1 0; min-width: 0; height: 54px; padding: 0;
  border: 0; border-radius: 8px; background: #f7f8fa; color: var(--ink);
  font: 600 1.3rem/1 "Archivo Variable", system-ui, sans-serif; cursor: pointer;
}
.kb-num .kb-key { height: 60px; font-size: 1.5rem; }
.kb-key:active { background: var(--tape); }
.kb-blank { background: transparent; }
.kb-special { background: #3a495b; color: #fff; font-size: 1rem; flex-grow: 1.5; }
.kb-space { flex-grow: 5; background: #f7f8fa; color: var(--slate); }
.kb-enter { background: var(--tape); color: var(--ink); flex-grow: 2; }
.kb-on { background: #fff; color: var(--ink); }
.kb-caps { box-shadow: inset 0 -5px 0 var(--tape); }

/* --- smaller screens --- */
@media (max-width: 1180px) {
  .view-counter { grid-template-columns: minmax(0, 1fr) minmax(320px, 400px); }
  .panel-customer { grid-column: 1; }
  .panel-catalog { grid-column: 1; }
  .panel-ticket { grid-column: 2; grid-row: 1 / span 2; }
  .staff-row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  body { font-size: 16px; }
  .view { padding: 0.7rem; }
  .view-counter { grid-template-columns: minmax(0, 1fr); }
  .panel-ticket { grid-column: 1; grid-row: auto; }
  .custom-form { grid-template-columns: minmax(0, 1fr) 6.5rem; }
  .custom-form .btn { grid-column: 1 / -1; }
  .trow { grid-template-columns: 4rem minmax(0, 1fr) auto; }
  .trow > :nth-child(3), .trow > :nth-child(4), .trow > :nth-child(5) { display: none; }
  .edit-row, .staff-row, .view-manage .edit-new:has(.field:nth-child(4)) { grid-template-columns: 1fr; }
  .view-manage .edit-new:has(.field:nth-child(4)) .btn { margin-top: 0; }
  .kb-key { height: 46px; font-size: 1.1rem; }
  .kb-row, .kb-inner { gap: 4px; }
  .tabs { order: 3; flex-basis: 100%; }
  .top-right { margin-left: auto; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
