[data-theme="light"] { color-scheme: light; }

:root, [data-theme="light"] {
  --violet: #2d2c71;
  --purple: #9a29e2;
  --lavender: #ddacdd;
  --bg: #F7F5FA;
  --card: #ffffff;
  --hover: #F0EDF7;
  --text: #2C2C2A;
  --muted: #888780;
  --text2: #5F5E5A;
  --line: rgba(45, 44, 113, .10);
  --line2: rgba(45, 44, 113, .20);
  --danger: #b3261e;
  --ok: #1b7f4b;
  --warn: #9a5b00;
  --ok-bg: rgba(61, 214, 140, .16);
  --warn-bg: rgba(240, 164, 41, .18);
  --bad-bg: rgba(240, 96, 96, .16);
  --accent-soft: rgba(154, 41, 226, .10);
  --shadow: 0 4px 8px rgba(45, 44, 113, .08), 0 2px 4px rgba(45, 44, 113, .04);
  --grad: linear-gradient(135deg, #2d2c71 0%, #9A29E2 100%);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0E0B1A;
  --card: #160F2A;
  --hover: #2A1F45;
  --text: #F0EEFF;
  --muted: #9B8EC4;
  --text2: #C5BBE0;
  --line: rgba(154, 41, 226, .15);
  --line2: rgba(154, 41, 226, .30);
  --lavender: #DDACDD;
  --danger: #ff8f8f;
  --ok: #6fd6a0;
  --warn: #f2c26b;
  --accent-soft: rgba(154, 41, 226, .20);
  --shadow: none;
  --grad: linear-gradient(135deg, #7A6FE8 0%, #C25CF5 100%);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "DM Sans", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px 24px;
}

.brand {
  font-weight: 700;
  font-size: 22px;
  color: var(--violet);
}

[data-theme="dark"] .brand { color: var(--lavender); }

.brand span { color: var(--purple); }

.login-card h1 { margin: 8px 0 20px; font-size: 18px; font-weight: 500; color: var(--muted); }

label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }

input, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line2);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  font: inherit;
}

input:focus, select:focus, button:focus-visible {
  outline: 2px solid var(--purple);
  outline-offset: 1px;
}

button {
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  border-radius: 999px;
  border: 1px solid transparent;
  background: linear-gradient(135deg, #fcea10 0%, #f47920 100%);
  color: #2d2c71;
  padding: 0 18px;
  min-height: 40px;
  box-shadow: 0 10px 26px -12px rgba(244, 121, 32, .85);
  transition: all .15s ease;
}

button:hover { transform: translateY(-1px); }
button:disabled { opacity: .5; cursor: not-allowed; transform: none; }

button.secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--line2);
  box-shadow: none;
  font-weight: 500;
}

.login-card button { width: 100%; margin-top: 18px; }

.error { color: var(--danger); font-size: 14px; margin-top: 12px; }

body { background: var(--bg); }

.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }

aside.side {
  background: var(--card);
  border-right: 1px solid var(--line);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

aside.side .brand { padding: 4px 10px 14px; }

nav.tabs { display: flex; flex-direction: column; gap: 4px; }

nav.tabs button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--text2);
  border: none;
  box-shadow: none;
  border-radius: 999px;
  padding: 0 14px;
  min-height: 40px;
  font-weight: 500;
  white-space: nowrap;
}

nav.tabs button:hover { background: var(--hover); color: var(--purple); transform: none; }

nav.tabs button[aria-selected="true"] {
  background: var(--grad);
  color: #fff;
  box-shadow: 0 8px 18px -10px rgba(154, 41, 226, .9);
}

nav.tabs .ico { width: 20px; height: 20px; flex: none; font-size: 20px; display: inline-flex; align-items: center; justify-content: center; }
nav.tabs img.ico { object-fit: contain; }
[data-theme="dark"] nav.tabs img.ico { filter: invert(.85); }
nav.tabs button[aria-selected="true"] img.ico { filter: invert(1) brightness(2); }

.side-spacer { flex: 1; }

.side-foot { border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.side-foot .biz { font-size: 13px; font-weight: 500; }
.side-foot .who { font-size: 12px; color: var(--muted); word-break: break-all; }
.side-foot .row { display: flex; gap: 6px; flex-wrap: wrap; }
.side-foot button { min-height: 32px; padding: 0 12px; font-size: 13px; }

.content { min-width: 0; }
h1.page-title { font-size: 22px; font-weight: 500; margin: 0; }

@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  aside.side { position: static; height: auto; flex-direction: row; align-items: center; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--line); padding: 8px; }
  aside.side .brand, .side-spacer, .side-foot .biz, .side-foot .who { display: none; }
  nav.tabs { flex-direction: row; }
  nav.tabs button span.lbl { display: none; }
  .side-foot { border: none; padding: 0; flex-direction: row; flex-wrap: wrap; margin-left: auto; min-width: 0; }
  /* menu row wraps instead of scrolling; the three buttons stay on one line (they used to stack into a tall column) */
  aside.side { flex-wrap: wrap; overflow-x: visible; gap: 6px 8px; }
  .side-foot .row { flex-wrap: nowrap; }
  .side-foot button { white-space: nowrap; }
}

/* menu on top by choice (wide, tall screens): the same row narrow screens use, with the labels and the brand kept.
   Narrow and short screens always use their own top row, so the choice button is hidden there. */
@media (min-width: 801px) and (min-height: 451px) {
  .app.nav-top { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .app.nav-top aside.side { position: sticky; z-index: 20; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; overflow: visible; border-right: none; border-bottom: 1px solid var(--line); padding: 8px 16px; gap: 6px 12px; }
  .app.nav-top aside.side .brand { padding: 0 8px 0 0; }
  .app.nav-top nav.tabs { flex-direction: row; flex-wrap: wrap; }
  .app.nav-top nav.tabs button { width: auto; }
  .app.nav-top .side-spacer, .app.nav-top .side-foot .biz, .app.nav-top .side-foot .who { display: none; }
  .app.nav-top .side-foot { border: none; padding: 0; flex-direction: row; flex-wrap: wrap; align-items: center; margin-left: auto; }
  .app.nav-top .side-foot .row { flex-wrap: nowrap; }
  .app.nav-top .side-foot button { white-space: nowrap; }
}
@media (max-width: 800px), (max-height: 450px) { .nav-layout-btn { display: none; } }
.nav-layout-btn { padding: 0 10px; min-width: 36px; }
.nav-layout-btn .ti { font-size: 18px; line-height: 1; }

main { padding: 16px; max-width: 1500px; margin: 0 auto; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar input { max-width: 260px; }
.toolbar select { max-width: 200px; }
.count { color: var(--muted); font-size: 14px; align-self: center; }

.table-wrap {
  overflow-x: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 500; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--hover); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  background: var(--hover);
  color: var(--text2);
}

.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--danger); }
.badge.info { background: var(--accent-soft); color: var(--purple); }

.empty { padding: 32px 16px; text-align: center; color: var(--muted); }

.late { color: var(--danger); font-weight: 700; }

@media (max-width: 600px) {
  main { padding: 12px; }
}

button.small { padding: 0 12px; min-height: 30px; font-size: 13px; }

dialog.modal {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: var(--text);
  width: min(460px, calc(100vw - 32px));
  padding: 20px 22px;
}

dialog.modal::backdrop { background: rgba(31, 29, 58, 0.45); }
dialog.modal h2 { margin: 0 0 4px; font-size: 18px; }
dialog.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 4px; }

.notice {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--violet);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
}

.row-actions { display: flex; gap: 6px; }
button.link { background: transparent; border: none; box-shadow: none; color: var(--purple); padding: 10px 4px; margin-right: auto; text-decoration: underline; font-weight: 500; }

.card-print {
  width: 85.6mm; max-width: 100%; aspect-ratio: 85.6 / 54;
  margin-top: 12px; padding: 14px 16px; border-radius: 10px;
  background: #fff; color: #2d2c71; border: 1px solid var(--line);
  display: flex; flex-direction: column; justify-content: space-between;
}
.card-brand { font-weight: 700; font-size: 16px; color: #2d2c71; }
.card-brand span { color: #9a29e2; }
.card-body { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.card-label { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: #6b6a84; margin-top: 6px; }
.card-name { font-size: 16px; font-weight: 700; }
.card-number { font-size: 15px; font-weight: 500; font-variant-numeric: tabular-nums; }

#print-area { display: none; }

.label-sheet { box-sizing: border-box; padding: 1.2mm 1.5mm; display: flex; flex-direction: column; justify-content: space-between;
  overflow: hidden; background: #fff; color: #000; font-family: "DM Sans", Arial, sans-serif; }
.label-sku { font-size: 8pt; font-weight: 700; line-height: 1.1; }
.label-desc { font-size: 7pt; line-height: 1.1; max-height: 2.3em; overflow: hidden; }
.label-detail { font-size: 6pt; line-height: 1.1; color: #333; }
.label-bottom { display: flex; align-items: flex-end; justify-content: space-between; gap: 2mm; }
.label-code { display: flex; align-items: flex-end; gap: 1.5mm; min-width: 0; }
.label-code .barcode { max-width: 30mm; height: 8mm; }
.label-price { font-size: 11pt; font-weight: 700; white-space: nowrap; }

.ticket-sheet { width: 72mm; margin: 0 auto; padding: 4mm 0; background: #fff; color: #000; font-family: "DM Sans", Arial, sans-serif; font-size: 9pt; }
.tk-title { text-align: center; font-weight: 700; font-size: 12pt; margin-bottom: 2mm; }
.tk-center { text-align: center; line-height: 1.35; }
.tk-small { font-size: 8pt; }
.tk-row { display: flex; justify-content: space-between; gap: 3mm; line-height: 1.4; }
.tk-strong { font-weight: 700; }
.tk-sub { font-size: 8pt; padding-left: 3mm; }
.ticket-sheet hr { border: none; border-top: 1px dashed #000; margin: 2mm 0; }
.ticket-sheet .barcode { max-width: 60mm; height: 12mm; }

@media print {
  html, body { background: #fff !important; }
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block; }
}

form.settings { max-width: 520px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px 22px; }
form.settings h2 { margin: 0 0 8px; font-size: 18px; }
form.settings .actions.left { margin-top: 18px; }
select:disabled, input:disabled { opacity: .7; }
h2.section { margin: 18px 0 0; font-size: 16px; }
.settings.device { max-width: 520px; margin-top: 16px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px 22px; }
.settings.device h2 { margin: 0 0 6px; font-size: 18px; }
.settings.device button { margin-top: 12px; }
.login-card button.link { width: auto; margin-top: 12px; }

.sticky-act { position: sticky; right: 0; background: var(--card); box-shadow: -8px 0 8px -8px rgba(45, 44, 113, .25); }
button.secondary:hover { border-color: var(--purple); color: var(--purple); }


/* ---- inventory: cards, groups, chips */
.bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.bar input.scan { max-width: 280px; border-radius: 999px; padding-left: 16px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0 14px; min-height: 32px;
  border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); color: var(--text);
  font-size: 13px; font-weight: 500; box-shadow: none;
}
.chip:hover { border-color: var(--purple); color: var(--purple); transform: none; }
.chip .n { font-size: 12px; opacity: .75; }
.chip.sel { background: var(--grad); color: #fff; border-color: transparent; box-shadow: 0 8px 18px -10px rgba(154, 41, 226, .9); }

.seg { display: inline-flex; border: 1px solid var(--line2); border-radius: 999px; overflow: hidden; margin-left: auto; }
.seg-b { display: inline-flex; align-items: center; gap: 6px; border-radius: 0; border: none; box-shadow: none;
  background: transparent; color: var(--text2); min-height: 34px; padding: 0 14px; font-size: 13px; font-weight: 500; }
.seg-b:hover { transform: none; color: var(--purple); }
.seg-b.on { background: var(--grad); color: #fff; }

select.tool-sel { width: auto; border-radius: 999px; padding: 6px 14px; font-size: 13px; font-weight: 500; color: var(--text2); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }

.igrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.igrid.small { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.item-card { overflow: hidden; display: flex; flex-direction: column; transition: all .15s ease; }
.item-card:hover { border-color: var(--purple); transform: translateY(-2px); }
.item-card .ph { aspect-ratio: 4 / 3; display: grid; place-items: center; font-size: 38px; color: rgba(255, 255, 255, .92); }
.igrid.small .item-card .ph { aspect-ratio: 1 / 1; font-size: 30px; }
.item-card .cb { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.item-card .ct { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.item-card .ct b { font-weight: 500; font-size: 13px; }
.item-card .pr { font-weight: 500; font-variant-numeric: tabular-nums; font-size: 13px; }
.item-card .cd { color: var(--text2); font-size: 13px; }
.row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.card-foot { justify-content: space-between; margin-top: auto; }

.grp { margin-bottom: 18px; }
.gh { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; cursor: pointer; }
.gh h2 { font-size: 15px; font-weight: 500; margin: 0; }
.gh .cnt { color: var(--muted); font-size: 13px; }
.gh i { color: var(--muted); }
.gh button.link { margin-left: auto; padding: 0; }
button.link.small { min-height: 0; font-size: 13px; }
.more-row { display: flex; justify-content: center; margin: 14px 0; }

.oc { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 500;
  background: color-mix(in srgb, var(--c) 18%, transparent); color: color-mix(in srgb, var(--c) 62%, #000); }
[data-theme="dark"] .oc { background: color-mix(in srgb, var(--c) 28%, transparent); color: color-mix(in srgb, var(--c) 55%, #fff); }
.oc-gray { --c: #9AA5BF; } .oc-violet { --c: #9A29E2; } .oc-pink { --c: #E27BA5; } .oc-red { --c: #E24B4A; }
.oc-orange { --c: #F0A429; } .oc-yellow { --c: #E3B21A; } .oc-green { --c: #3DAA6A; } .oc-teal { --c: #1D9E75; }
.oc-blue { --c: #378ADD; } .oc-brown { --c: #9A6B3F; }

.view-chips { margin-top: -4px; }
.chip .n-alert { background: var(--bad-bg); color: var(--danger); padding: 0 7px; border-radius: 999px; opacity: 1; font-weight: 700; }
.chip.sel .n-alert { background: rgba(255, 255, 255, .25); color: #fff; }
.nav-badge { margin-left: auto; background: var(--bad-bg); color: var(--danger); font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px; }
nav.tabs button[aria-selected="true"] .nav-badge { background: rgba(255, 255, 255, .25); color: #fff; }

.label-sheet { break-after: page; page-break-after: always; }
.label-sheet:last-child { break-after: auto; page-break-after: auto; }
.ph-wrap { position: relative; }
.item-card input.pick { position: absolute; left: 8px; top: 8px; width: 20px; height: 20px; padding: 0; accent-color: #9A29E2; cursor: pointer; opacity: .0; transition: opacity .15s ease; }
.item-card:hover input.pick, .item-card input.pick:checked, .item-card input.pick:focus-visible { opacity: 1; }
.sel-box { display: inline-flex; align-items: center; gap: 8px; }
td input[type=checkbox] { width: 18px; height: 18px; padding: 0; accent-color: #9A29E2; }

/* ---- settings: chip lists */
.chip-card { padding: 16px 18px; max-width: 640px; margin-bottom: 12px; }
.chip-card h2 { font-size: 16px; font-weight: 500; margin: 0; }
.chip-list { margin-top: 8px; }
.li { border-top: 1px solid var(--line); padding: 8px 0; }
.li-main { display: flex; align-items: center; gap: 10px; }
.li .ord { display: inline-flex; gap: 2px; }
.li .nm { flex: 1; }
.li.off .nm { opacity: .5; text-decoration: line-through; }
button.icon-b { min-height: 28px; width: 28px; padding: 0; border-radius: 50%; background: transparent; color: var(--text2); box-shadow: none; border: none; font-weight: 500; }
button.icon-b:hover { background: var(--hover); color: var(--purple); transform: none; }
button.icon-b:disabled { opacity: .25; }
button.dot-b { min-height: 0; width: 18px; height: 18px; padding: 0; border-radius: 50%; border: 2px solid transparent; box-shadow: none; }
button.dot-b.cur { border-color: var(--text); }
button.dot-b:hover { transform: scale(1.15); }
.palette { display: flex; gap: 8px; margin: 10px 0 2px 70px; flex-wrap: wrap; }
.palette button.dot-b { width: 24px; height: 24px; }
input.sw { appearance: none; -webkit-appearance: none; width: 36px; height: 20px; padding: 0; border-radius: 999px; background: var(--line2); position: relative; cursor: pointer; border: none; flex: none; }
input.sw::after { content: ""; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .15s ease; }
input.sw:checked { background: var(--grad); }
input.sw:checked::after { left: 18px; }
input.sw:disabled { opacity: .5; cursor: not-allowed; }
.add-row { display: flex; gap: 8px; margin-top: 12px; align-items: center; }
.add-row input { max-width: 260px; border-radius: 999px; padding-left: 16px; }

/* ---- alignment: one header row per screen, main action at the right; section bars the same way */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; min-height: 44px; margin-bottom: 14px; }
.page-action { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; }
.section-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; margin: 22px 0 10px; }
.section-bar:first-of-type { margin-top: 0; }
.section-bar h2.section { margin: 0; font-size: 16px; font-weight: 500; display: flex; align-items: baseline; gap: 8px; }
.sec-count { color: var(--muted); font-size: 13px; font-weight: 400; }
.toolbar { align-items: center; }
.bar { align-items: center; }
.table-wrap { margin-bottom: 4px; }

/* ---- avatars, team cards, size switch, user chip */
body { zoom: var(--ui-zoom, 1); }
.avatar { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 32px; height: 32px; font-size: 12px; font-weight: 700; }
.avatar.square { border-radius: 8px; }
.avatar.round { border-radius: 50%; }
.who2 { display: inline-flex; align-items: center; gap: 10px; }
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; margin-bottom: 8px; }
.team-card { display: flex; align-items: center; gap: 12px; padding: 12px 14px; flex-wrap: wrap; }
.team-card.off { opacity: .6; }
.team-card .avatar { width: 40px; height: 40px; font-size: 14px; }
.tc-main { flex: 1; min-width: 150px; display: flex; flex-direction: column; gap: 4px; }
.tc-name { font-weight: 500; }
.tc-code { color: var(--muted); font-size: 12px; }
.team-card .row-actions { width: 100%; justify-content: flex-end; }
.seg-left { margin-left: 0; }
.size-seg { margin-left: 0; align-self: flex-start; }
.size-seg .seg-b { min-height: 28px; padding: 0 10px; font-size: 12px; }
.user-chip { display: inline-flex; align-items: center; gap: 8px; color: var(--text2); font-size: 13px; }
@media (max-width: 800px) { .user-chip .uc-name { display: none; } }

@media print { body { zoom: 1 !important; } }
dialog.modal.wide { width: min(940px, calc(100vw - 32px)); }
.item-card { cursor: pointer; }
.item-card .ph.has-img { padding: 0; position: relative; overflow: hidden; background: var(--hover); }
.item-card .ph.has-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph-count { position: absolute; right: 8px; bottom: 8px; background: rgba(0, 0, 0, .5); color: #fff; font-size: 11px; padding: 2px 8px; border-radius: 999px; }
.big-photo { position: relative; aspect-ratio: 4 / 3; border-radius: 12px; overflow: hidden; background: var(--hover); display: grid; place-items: center; }
.big-photo img { width: 100%; height: 100%; object-fit: contain; background: #000; }
.big-photo.empty-photo { color: var(--muted); font-size: 14px; gap: 6px; align-content: center; justify-items: center; }
.big-photo.empty-photo i { font-size: 44px; }
.bp-badge { position: absolute; left: 10px; top: 10px; background: rgba(255, 255, 255, .92); color: #2d2c71; font-size: 12px; font-weight: 500; padding: 3px 10px; border-radius: 999px; }
.bp-count { position: absolute; right: 10px; top: 10px; background: rgba(0, 0, 0, .5); color: #fff; font-size: 12px; padding: 3px 10px; border-radius: 999px; }
.thumbs { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-top: 10px; }
button.thumb { aspect-ratio: 1 / 1; padding: 0; border-radius: 10px; border: 2px solid transparent; overflow: hidden; background: var(--hover); box-shadow: none; min-height: 0; }
button.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
button.thumb.sel { border-color: var(--purple); }
button.thumb:hover { transform: none; border-color: var(--purple); }
button.thumb.add { border: 1.5px dashed var(--line2); background: transparent; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; font-weight: 500; }
button.thumb.add i { font-size: 20px; }
input.file-in { display: none; }
.photo-tools { margin-top: 10px; }
button.danger { color: var(--danger); border-color: var(--danger); }
.dc { padding: 16px 18px; }
.dc h2 { font-size: 18px; font-weight: 500; margin: 0 0 2px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px; margin-top: 14px; font-size: 13px; align-items: center; }
.kv .k { color: var(--muted); }
.actions.left { justify-content: flex-start; }
.det { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 20px; align-items: start; margin-top: 8px; }
@media (max-width: 760px) { .det { grid-template-columns: 1fr; } }
.page-head h1.page-title { flex: 1; }

/* ---- receipt printer panel */
.printer-card { margin-top: 16px; max-width: 760px; }
.direct-row { display: flex; align-items: center; gap: 10px; margin: 14px 0 6px; font-size: 14px; }
.dev-row { border-top: 1px solid var(--line); padding: 12px 0; }
.dev-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.dev-addr input[type=text] { width: 190px; }
.dev-addr input.port-in { width: 90px; }
.small-empty { padding: 12px 0; text-align: left; }
.big-code { font-size: 32px; font-weight: 700; letter-spacing: .12em; text-align: center; margin: 14px 0; color: var(--violet); }
[data-theme="dark"] .big-code { color: var(--lavender); }
pre.cmd { background: var(--hover); border-radius: 10px; padding: 10px 12px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; margin: 8px 0; }

.test-label svg { display: block; }
.test-label-btn { margin-top: 14px; }

/* camera scan */
.scan-dialog { width: min(92vw, 420px); }
.scan-video { width: 100%; aspect-ratio: 4 / 3; background: #000; border-radius: 12px; object-fit: cover; }
.scan-btn { display: inline-flex; align-items: center; gap: 6px; }

/* Flag Tag preview and print pages */
.flag-preview { width: min(94vw, 560px); }
.flag-strip { display: flex; flex-wrap: wrap; gap: 14px; margin: 8px 0; }
.flag-one { text-align: center; }
.flag-canvas { width: 110px; height: auto; border: 1px solid var(--line, #ccd); border-radius: 6px; background: #fff; }
.flag-pages { display: block; }
.flag-page { display: block; width: 27.86mm; height: 50.8mm; page-break-after: always; }

.dev-label-head { display: flex; align-items: center; gap: 10px; margin-top: 12px; }

/* ---- one pill with counts (same idea as Timesheet): one shape, one selected segment */
.pill { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 3px; box-shadow: var(--shadow); max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.pill::-webkit-scrollbar { display: none; }
.pill button { flex: none; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; background: transparent; color: var(--text2); border: none; box-shadow: none; padding: 6px 14px; min-height: 0; font-weight: 500; border-radius: 999px; }
.pill button:hover { transform: none; color: var(--purple); }
.pill button.sel { background: var(--grad); color: #fff; box-shadow: 0 8px 18px -10px rgba(154, 41, 226, .9); }
.pill .n { font-size: 12px; opacity: .75; }
.pill .n.late { color: var(--danger); font-weight: 700; opacity: 1; }
.pill button.sel .n.late { color: #ffd0cc; }
.pill-wrap { position: relative; align-items: center; }
.pill-more.sel { border-color: var(--purple); color: var(--purple); }
.pill-menu { position: absolute; top: 100%; left: 0; z-index: 30; margin-top: 6px; background: var(--card); border: 1px solid var(--line2); border-radius: 12px; box-shadow: 0 12px 30px rgba(45, 44, 113, .18); padding: 6px; display: flex; flex-direction: column; gap: 4px; min-width: 190px; }
.pill-menu button { justify-content: space-between; display: flex; text-align: left; }
.pill-menu button.sel { border-color: var(--purple); color: var(--purple); }

/* ---- Repairs board */
.rp-bar { gap: 10px; }
.rp-bar input.scan { max-width: 280px; flex: 1; min-width: 140px; }
.rp-colpick { display: none; margin-bottom: 10px; }
.rp-board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: start; }
.rp-col { background: rgba(45, 44, 113, .04); border-radius: 14px; padding: 10px; min-width: 0; }
[data-theme="dark"] .rp-col { background: rgba(154, 41, 226, .07); }
.rp-col h3 { font-size: 13px; font-weight: 700; display: flex; align-items: center; gap: 8px; margin: 2px 4px 10px; }
.rp-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.rp-cnt { margin-left: auto; font-weight: 500; color: var(--muted); }
.rp-cards { display: flex; flex-direction: column; gap: 10px; max-height: calc(100vh - 250px); overflow-y: auto; }
.rp-job { padding: 12px; display: flex; flex-direction: column; gap: 8px; cursor: pointer; }
.rp-job:hover, .rp-job:focus-visible { border-color: var(--purple); outline: none; }
.rp-job.late { border-color: rgba(179, 38, 30, .45); }
.rp-row1 { display: flex; align-items: center; gap: 10px; }
.rp-who { min-width: 0; }
.rp-no { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.rp-nm { font-weight: 500; line-height: 1.25; }
.rp-desc { font-size: 13px; color: var(--text2); }
.rp-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.rp-tag { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 2px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--purple); font-weight: 500; }
.rp-tag.warn { background: var(--warn-bg); color: var(--warn); }
.rp-tag.place { background: transparent; border: 1px solid var(--line2); color: var(--text2); }
.rp-tag.place b { background: var(--violet); color: #fff; border-radius: 5px; padding: 0 5px; font-size: 11px; }
[data-theme="dark"] .rp-tag.place b { background: var(--purple); }
.rp-foot { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.rp-r { margin-left: auto; }
.rp-late { color: var(--danger); font-weight: 700; }

/* ---- one job */
dialog.rp-modal { width: min(960px, calc(100vw - 24px)); }
.rp-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.rp-head h2 { margin: 0; flex: 1; }
.rp-steps { display: grid; grid-template-columns: repeat(5, 1fr); padding: 14px 4px 8px; }
.rp-step { position: relative; text-align: center; font-size: 12px; color: var(--muted); padding: 0 2px; }
.rp-step b { display: block; color: var(--text); font-weight: 500; }
.rp-c { width: 30px; height: 30px; border-radius: 50%; margin: 0 auto 6px; display: grid; place-items: center; background: var(--hover); border: 2px solid var(--line2); color: var(--muted); font-weight: 700; position: relative; z-index: 1; }
.rp-step::before { content: ""; position: absolute; top: 14px; left: -50%; width: 100%; height: 2px; background: var(--line2); }
.rp-step:first-child::before { display: none; }
.rp-step.done .rp-c { background: var(--grad); border-color: transparent; color: #fff; }
.rp-step.done::before, .rp-step.cur::before { background: var(--purple); }
.rp-step.cur .rp-c { border-color: var(--purple); color: var(--purple); background: var(--card); box-shadow: 0 0 0 4px var(--accent-soft); }
.rp-split { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 18px; margin-top: 10px; }
.rp-split .kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; }
.rp-split .kv .k { color: var(--muted); }
.rp-act { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.rp-actrow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.rp-actrow .k { color: var(--muted); min-width: 52px; }
.rp-actrow select, .rp-actrow input[type=text] { width: auto; min-width: 150px; }
.rp-trailbox h4 { margin: 0 0 8px; font-size: 13px; }
.rp-trail { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.rp-trail li { display: grid; grid-template-columns: 18px 1fr; gap: 10px; font-size: 13px; }
.rp-trail li i { color: var(--purple); margin-top: 2px; }
a.link-a { color: var(--purple); cursor: pointer; }

/* ---- receive for repair */
.rp-f { margin-top: 12px; }
.rp-f label { display: block; font-size: 12px; color: var(--text2); margin-bottom: 4px; }
.rp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.rp-opts { display: flex; gap: 8px; flex-wrap: wrap; }
.rp-opt { background: var(--card); color: var(--text); border: 1px solid var(--line2); box-shadow: none; font-weight: 500; font-size: 13px; padding: 5px 13px; min-height: 0; }
.rp-opt:hover { transform: none; border-color: var(--purple); color: var(--purple); }
.rp-opt.sel { background: var(--accent-soft); border-color: var(--purple); color: var(--purple); font-weight: 700; }
.rp-opt b { background: var(--violet); color: #fff; border-radius: 5px; padding: 0 5px; font-size: 11px; margin-right: 5px; }
.rp-terms { margin-top: 14px; }
.rp-terms h4 { margin: 0 0 6px; font-size: 14px; }
.rp-termtext { background: var(--hover); border-radius: 10px; padding: 10px 12px; font-size: 13px; color: var(--text2); white-space: pre-wrap; max-height: 220px; overflow: auto; }
.rp-check { display: flex; gap: 10px; align-items: flex-start; margin-top: 10px; font-size: 14px; }
.rp-check input { width: 18px; height: 18px; margin-top: 3px; }
.seg.seg-left { margin-left: 0; }

/* ---- the three tickets on the receipt paper */
.rpt { width: 72mm; padding: 4mm 3mm; font-size: 11px; line-height: 1.35; color: #000; background: #fff; page-break-after: always; break-after: page; font-family: "DM Sans", system-ui, sans-serif; }
.rpt:last-child { page-break-after: auto; break-after: auto; }
.rpt-type { display: flex; justify-content: space-between; font-weight: 700; letter-spacing: .05em; border-bottom: 2px solid #000; padding-bottom: 3px; margin-bottom: 4px; font-size: 11px; }
.rpt-shop { font-size: 11px; color: #333; }
.rpt-big { font-size: 22px; font-weight: 700; letter-spacing: .02em; }
.rpt-small { font-size: 9.5px; color: #333; }
.rpt-center { text-align: center; }
.rpt hr { border: 0; border-top: 1px dashed #777; margin: 5px 0; }
.rpt-row { display: flex; gap: 6px; padding: 1px 0; }
.rpt-k { color: #444; width: 36%; flex: none; }
.rpt-v { flex: 1; }
.rpt-box { border: 2px solid #000; padding: 3px 6px; text-align: center; font-weight: 700; margin: 5px 0; }
.rpt-sig { margin-top: 16px; border-top: 1px solid #000; padding-top: 2px; font-size: 9.5px; color: #333; }
.rpt-qr { display: flex; justify-content: center; margin: 6px 0 2px; }

@media (max-width: 700px) {
  .rp-colpick { display: inline-flex; }
  .rp-board { display: block; overflow: visible; }
  .rp-col { display: none; margin-bottom: 12px; }
  .rp-col.show { display: block; }
  .rp-cards { max-height: none; }
  .rp-split { grid-template-columns: 1fr; }
  .rp-split .kv { grid-template-columns: 110px 1fr; }
  .rp-grid { grid-template-columns: 1fr; }
  .rp-steps { padding: 12px 0 6px; }
  .rp-step { font-size: 10px; }
  .rp-step .hint { display: none; }
}

/* text areas look like the other fields */
textarea { font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line2); border-radius: 10px; padding: 8px 12px; width: 100%; min-height: 72px; resize: vertical; }
textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--purple); }

/* narrow screens: the menu row keeps its own height, the page takes the rest (it used to stretch into a blank band) */
@media (max-width: 800px) { .app { grid-template-rows: auto 1fr; } }

/* the three tickets as a preview before printing */
.rp-preview > div { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-start; margin-top: 12px; }
.rp-preview .rpt { flex: none; border: 1px solid var(--line2); border-radius: 6px; box-shadow: var(--shadow); page-break-after: auto; break-after: auto; }

/* a gradient is drawn from the border edge, so a transparent border never shows the other end of it as a coloured strip
   (same fix as Timesheet: background-origin: border-box) */
button, .chip.sel, .seg-b.on, input.sw:checked, .pill button.sel, .rp-step.done .rp-c, nav.tabs button[aria-selected="true"] { background-origin: border-box; }

.rp-scanno { font-size: 34px; font-weight: 700; letter-spacing: .02em; margin: 6px 0 2px; color: var(--violet); }
[data-theme="dark"] .rp-scanno { color: var(--lavender); }

/* the name behind the round avatar shows in our own bubble, never the browser's grey tooltip */
.user-chip[data-name] { position: relative; outline: none; }
.user-chip[data-name]:hover::after, .user-chip[data-name]:focus-visible::after {
  content: attr(data-name); position: absolute; top: calc(100% + 6px); right: 0; z-index: 40; white-space: nowrap;
  background: var(--violet); color: #fff; padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 500; box-shadow: var(--shadow);
}
[data-theme="dark"] .user-chip[data-name]:hover::after, [data-theme="dark"] .user-chip[data-name]:focus-visible::after { background: var(--purple); }

/* short screens (iPhone Duo outer display in landscape is 368px tall): one thin menu row, one thin header, toolbars on one line */
@media (max-height: 450px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  aside.side { position: static; height: auto; flex-direction: row; align-items: center; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--line); padding: 4px 8px; gap: 8px; }
  aside.side .brand, .side-spacer, .side-foot .biz, .side-foot .who { display: none; }
  nav.tabs { flex-direction: row; flex: none; }
  nav.tabs button { padding: 4px 10px; min-height: 34px; }
  nav.tabs button span.lbl { display: none; }
  .side-foot { border: none; padding: 0; flex-direction: row; flex: none; }
  aside.side { flex-wrap: nowrap; overflow-x: auto; gap: 8px; }
  .side-foot { flex-wrap: nowrap; margin-left: 0; }
  .side-foot .row { flex-wrap: nowrap; }
  .side-foot button { min-height: 30px; white-space: nowrap; }
  main { padding: 8px 12px; }
  .page-head { min-height: 34px; margin-bottom: 6px; }
  h1.page-title { font-size: 17px; }
  .user-chip .uc-name { display: none; }
  .bar, .chips { flex-wrap: nowrap; overflow-x: auto; margin-bottom: 6px; scrollbar-width: none; }
  .bar::-webkit-scrollbar, .chips::-webkit-scrollbar { display: none; }
  .rp-colpick { margin-bottom: 6px; }
  .rp-cards { max-height: none; }
  dialog.modal { padding: 12px 14px; }
  dialog.modal .actions { margin-top: 10px; }
  .hint { margin-top: 2px; }
}

/* a button waiting for its second tap */
button.armed, button.secondary.armed { background: var(--danger); color: #fff; border-color: transparent; box-shadow: none; }
[data-theme="dark"] button.armed, [data-theme="dark"] button.secondary.armed { color: #1b1030; }

/* ---- the header stays in place and table header rows freeze (Timesheet does the same; --nav-h is the height of a menu on top) ---- */
table { font-size: 14px; }
td, th { padding: 8px 9px; }
td.ell, th.ell { max-width: 130px; overflow: hidden; text-overflow: ellipsis; }
.row-actions { gap: 4px; flex-wrap: nowrap; white-space: nowrap; }
td .row-actions button { min-height: 28px; padding: 0 8px; font-size: 13px; }
/* a low-priority column goes away when the table has less room than it needs; the buttons are never pushed off */
.table-wrap { container: tw / inline-size; }
@container tw (max-width: 1260px) { th.lo, td.lo { display: none; } }

@media (min-height: 560px) {
  .page-top { position: sticky; top: var(--nav-h, 0px); z-index: 15; background: var(--bg); margin: -16px -16px 0; padding: 16px 16px 2px; }
  .table-wrap { overflow: auto; max-height: calc(100vh - var(--nav-h, 0px) - 210px); }
  thead th { position: sticky; top: 0; z-index: 2; background: var(--card); }
  thead th.sticky-act { z-index: 3; }
}
@media (min-height: 560px) and (max-width: 600px) {
  .page-top { margin: -12px -12px 0; padding: 12px 12px 2px; }
}
/* narrow table areas (iPad with the menu on the left): the buttons stack in two lines and long text gives way first */
@container tw (max-width: 900px) {
  td .row-actions { flex-wrap: wrap; max-width: 170px; }
  td.ell, th.ell { max-width: 100px; }
  th.lo2, td.lo2 { display: none; }
}
/* phones: one line of buttons at the end of the row (four buttons would cover most of a 390px screen if they stayed pinned) */
@container tw (max-width: 600px) {
  td .row-actions { flex-wrap: nowrap; max-width: none; }
  td.sticky-act { position: static; box-shadow: none; background: transparent; }
  th.sticky-act { right: auto; }
}

/* ---- Settings: hex map, rail, chips (same structure as Kai's Turns Settings; the pictures are stand-ins until Geo's set arrives) ---- */
.set-map {
  --stm-link: rgba(95, 70, 200, .55); --stm-dot: #7a3fe0; --stm-glow: rgba(110, 80, 240, .55);
  position: relative; width: 100%; border-radius: 26px; overflow: hidden;
  background: radial-gradient(circle at 50% 50%, rgba(122, 63, 224, .12) 0, rgba(122, 63, 224, 0) 55%), radial-gradient(circle at 15% 85%, rgba(224, 82, 159, .08) 0, rgba(224, 82, 159, 0) 38%), #F3EEFA;
}
[data-theme="dark"] .set-map {
  --stm-link: rgba(190, 150, 255, .6); --stm-dot: #d3b8ff; --stm-glow: rgba(150, 90, 255, .65);
  background: radial-gradient(circle at 50% 50%, rgba(80, 60, 200, .28) 0, rgba(80, 60, 200, 0) 58%), radial-gradient(circle at 15% 85%, rgba(200, 70, 170, .18) 0, rgba(200, 70, 170, 0) 40%), #150F2B;
}
.set-map.is-rail { border-radius: 18px; }
.set-links { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.set-links path { fill: none; stroke: var(--stm-link); stroke-width: 1.6; }
.set-links circle { fill: none; stroke: var(--stm-dot); stroke-width: 1.5; opacity: .7; }
button.set-n {
  position: absolute; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 2px; width: max-content;
  background: none; border: 0; box-shadow: none; padding: 0; min-width: 44px; min-height: 44px; color: var(--text); font-weight: 700;
}
button.set-n:hover { transform: translate(-50%, -50%); }
.set-n svg.hex { display: block; overflow: visible; filter: drop-shadow(0 10px 18px var(--stm-glow)); }
.set-n .l { font-size: 13px; text-shadow: 0 0 8px var(--bg), 0 0 8px var(--bg); }
.set-n.hub svg.hex { width: 126px; height: 126px; }
.set-n.cat svg.hex { width: 108px; height: 108px; }
.is-rail .set-n.hub svg.hex { width: 84px; height: 84px; }
.is-rail .set-n.cat svg.hex { width: 74px; height: 74px; }
.is-rail .set-n .l { font-size: 11.5px; }
.set-n svg.hex .ring { opacity: 0; }
.set-n.on svg.hex .ring { opacity: 1; }
.set-n.on .l { color: var(--purple); }

.set-split { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 16px; align-items: start; }
.set-right { min-width: 0; }
.set-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
@media (min-width: 761px) { .page-top .set-chips { margin-left: 226px; } }
.set-chips .chip { display: inline-flex; align-items: center; gap: 4px; }
.set-cat { font-size: 14px; font-weight: 700; color: var(--purple); margin-right: 2px; }
.set-panel { min-width: 0; }
/* one sunny (yellow-orange) button per screen: Settings has none in the header, so its Save and Add buttons are violet, like Kai's small buttons */
.set-panel button:not([class]), .set-panel button[type="submit"]:not(.secondary) {
  background: var(--grad); color: #fff; background-origin: border-box; box-shadow: 0 8px 18px -10px rgba(154, 41, 226, .8);
}
.set-panel button:not([class]):disabled, .set-panel button[type="submit"]:disabled { box-shadow: none; }
@media (min-height: 560px) and (min-width: 761px) {
  /* the rail stays in view; the setting scrolls with the page under the locked header */
  .set-rail { position: sticky; top: calc(var(--nav-h, 0px) + 130px); }
}
@media (max-width: 760px) {
  .set-split { grid-template-columns: minmax(0, 1fr); }
  .set-rail { display: none; }
  .set-n.cat svg.hex { width: 84px; height: 84px; }
  .set-n.hub svg.hex { width: 98px; height: 98px; }
}

/* import customers */
dialog.modal.wide { width: min(760px, calc(100vw - 32px)); }
.imp-scroll { max-height: 320px; overflow: auto; margin: 8px 0; border: 1px solid var(--line); border-radius: 10px; }
table.imp-table { width: 100%; font-size: 13px; }
table.imp-table tr.bad td { background: var(--red-soft, #fdecec); }
.imp-recent h3 { margin: 14px 0 4px; font-size: 14px; }
.imp-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; padding: 3px 0; }

/* live camera for photos */
.shot-strip { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.shot { position: relative; width: 64px; height: 64px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); }
.shot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.shot-rm { position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; min-height: 0; padding: 0; border-radius: 50%; line-height: 1; font-size: 14px; background: rgba(0,0,0,.6); color: #fff; border: 0; box-shadow: none; }

/* purchase order lines: the description takes the free width, the numbers stay narrow */
.po-lines .add-row { flex-wrap: wrap; margin-top: 8px; }
.po-lines .add-row input:first-child { flex: 1 1 220px; max-width: none; }
.po-lines .add-row input { max-width: none; }

/* Orders as cards (same look as the Inventory cards), and the order window with notes and steps */
.ogrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.ord-card .ph { position: relative; }
.ord-card .ph.has-img { padding: 0; overflow: hidden; background: var(--hover); }
.ord-card .ph.has-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ord-st { position: absolute; left: 8px; top: 8px; font-size: 12px; font-weight: 500; padding: 2px 10px; border-radius: 999px; background: rgba(255, 255, 255, .92); color: var(--muted); }
.ord-st-open { color: var(--purple); }
.ord-st-ready { color: var(--ok); }
.ord-more { position: absolute; right: 8px; top: 8px; font-size: 12px; font-weight: 500; padding: 2px 10px; border-radius: 999px; background: rgba(0, 0, 0, .55); color: #fff; }
.ord-num { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ord-cust { font-weight: 500; }
.ord-card .ct { align-items: baseline; }
.ord-card .pr { font-size: 15px; }
.ord-desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.oc-chip { font-size: 12px; font-weight: 500; padding: 2px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--purple); }
.oc-chip.step { background: var(--warn-bg); color: var(--warn); }
.due-d { font-size: 12px; color: var(--text2); }
.due-d.late { color: var(--danger); font-weight: 500; }
.bal { font-size: 13px; font-weight: 500; }
.bal.due { color: var(--danger); }
.bal.ok { color: var(--ok); }
.ord-note { font-size: 12px; color: var(--text2); background: var(--hover); border-radius: 8px; padding: 4px 8px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ord-card .row { flex-wrap: wrap; }
.ord-card .sp { flex: 1; }
.ord-foot { margin-top: auto; padding-top: 6px; }
.ord-foot .row-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.ord-foot .row-actions button { width: 100%; justify-content: center; }
.ord-bar { align-items: center; }
.ord-bar .seg { margin-left: 0; }
.ord-bar .chips { margin-bottom: 0; }
.ord-bar input[type=search] { flex: 1 1 200px; max-width: 280px; }
.ord-items { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; }
.ord-item { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.ord-due { align-items: center; margin-bottom: 6px; }
.ord-due input { max-width: 180px; }
/* order window: lines, cost and notes on the left, step / dates / seller / money on the right; one column on a phone */
.ord-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 20px; align-items: start; margin-top: 6px; }
.ord-main h3.section:first-child, .ord-side h3.section:first-child { margin-top: 0; }
.ord-side { display: flex; flex-direction: column; gap: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.ord-side .ord-steps { gap: 6px; }
.ord-field { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.ord-field > select, .ord-field input { max-width: 100%; }
.ord-sum { border-top: 1px solid var(--line); padding-top: 10px; }
.sum-h { font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.sum-row { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; font-size: 14px; }
.sum-big { font-weight: 600; font-size: 16px; border-top: 1px solid var(--line); margin-top: 4px; padding-top: 8px; }
@media (max-width: 760px) { .ord-grid { grid-template-columns: minmax(0, 1fr); } .ord-side { order: -1; } }
.ord-steps { gap: 8px; margin-bottom: 6px; }
.ord-log { display: flex; flex-direction: column; gap: 8px; max-height: 260px; overflow-y: auto; margin-bottom: 10px; }
.ord-line { background: var(--hover); border-radius: 10px; padding: 8px 12px; font-size: 14px; }
.ord-line.stepline { background: var(--warn-bg); }
.ord-who { font-size: 12px; color: var(--muted); margin-bottom: 2px; }

/* The New (+) button and its ticket-style chooser: same look as Kai's "Who's here?" ticket in Kệ Timesheet */
.new-btn { display: inline-flex; align-items: center; gap: 6px; order: 99; }
.new-btn .ti { font-size: 18px; }
@media (max-width: 480px) { .new-btn .lbl { display: none; } }
dialog.modal.new-modal { background: transparent; border: 0; box-shadow: none; padding: 0; width: min(440px, calc(100vw - 32px)); overflow: visible; }
.new-ticket { border-radius: 18px; }
.new-head { background: linear-gradient(135deg, #2d2c71 0%, #9A29E2 100%); color: #fff; padding: 14px 20px 18px; border-radius: 18px 18px 0 0; }
.new-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.new-lbl { font-family: 'DM Mono', ui-monospace, Menlo, monospace; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; opacity: .8; }
.new-x { background: rgba(255, 255, 255, .14); border: 0; color: #fff; width: 30px; height: 30px; min-height: 0; padding: 0; border-radius: 50%; cursor: pointer; font-size: 17px; display: grid; place-items: center; box-shadow: none; }
.new-x:hover { background: rgba(255, 255, 255, .26); transform: none; }
.new-title { margin-top: 10px; font-size: 20px; font-weight: 700; }
.new-perf { position: relative; height: 22px; margin: -1px 0;
  background:
    radial-gradient(circle at 0 50%, transparent 11px, var(--card) 11.5px) left / 51% 100% no-repeat,
    radial-gradient(circle at 100% 50%, transparent 11px, var(--card) 11.5px) right / 51% 100% no-repeat; }
.new-perf::before { content: ''; position: absolute; left: 18px; right: 18px; top: 50%; border-top: 2px dashed var(--line2); }
.new-body { background: var(--card); border-radius: 0 0 18px 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 6px 18px 18px; }
.new-type { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; width: 100%; text-align: left; padding: 14px; border: 1.5px solid var(--line2); border-radius: 14px; background: var(--card); color: var(--text); box-shadow: none; min-height: 0; }
.new-type:hover { border-color: var(--purple); background: var(--accent-soft); transform: none; }
.new-type:last-child:nth-child(odd) { grid-column: 1 / -1; }
.new-ic { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: var(--accent-soft); color: var(--purple); font-size: 22px; }
.new-type:hover .new-ic { background: var(--purple); color: #fff; }
.new-tx { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.new-tx b { font-size: 15px; font-weight: 500; }
.new-tx small { font-size: 12px; color: var(--muted); }
@media (max-width: 480px) { .scan-btn .lbl { display: none; } }
.page-action button { white-space: nowrap; }

.new-ic img { width: 32px; height: 32px; display: block; }
.new-type:hover .new-ic img { filter: invert(1) brightness(2); }
[data-theme="dark"] .new-ic img { filter: invert(.85); }

/* menu footer: icon and name in the left menu; icon only when the menu is on top or the screen is narrow (the name is the tooltip) */
.foot-btn { display: inline-flex; align-items: center; gap: 6px; }
.foot-btn img.ico, .foot-btn i.ti { width: 18px; height: 18px; font-size: 18px; display: block; object-fit: contain; }
[data-theme="dark"] .foot-btn img.ico { filter: invert(.85); }
.app.nav-top .foot-btn .lbl { display: none; }
.app.nav-top .foot-btn, .app.nav-top .nav-layout-btn { padding: 0 10px; }
@media (max-width: 800px), (max-height: 450px) { .foot-btn .lbl { display: none; } .foot-btn { padding: 0 10px; } }
.size-seg .seg-b { padding: 0 9px; }
.size-seg .seg-b span { line-height: 1; font-weight: 500; }
/* a menu on top that is not wide enough for every name: only the open tab keeps its name (the others show the icon and a tooltip) */
@media (min-width: 801px) and (max-width: 1279px) {
  .app.nav-top nav.tabs button:not([aria-selected="true"]) span.lbl { display: none; }
  .app.nav-top nav.tabs button:not([aria-selected="true"]) { padding: 0 12px; }
}

/* bigger icons in the menu row, and an instant name tooltip where the name is not written (icon-only menu, footer buttons) */
nav.tabs .ico { width: 24px; height: 24px; font-size: 24px; }
.foot-btn img.ico, .foot-btn i.ti { width: 22px; height: 22px; font-size: 22px; }
.nav-layout-btn i.ti { font-size: 22px; }
.size-seg .seg-b { min-height: 36px; padding: 0 9px; }
.size-seg .seg-b span { line-height: 1; }
@media (max-width: 800px), (max-height: 450px) {
  nav.tabs button { min-height: 46px; padding: 0 12px; }
  nav.tabs { gap: 2px; }
  nav.tabs .ico { width: 28px; height: 28px; font-size: 28px; }
  .foot-btn, .nav-layout-btn { min-height: 42px; min-width: 42px; padding: 0 8px; justify-content: center; }
}
.app.nav-top .foot-btn, .app.nav-top .nav-layout-btn { min-height: 40px; min-width: 40px; padding: 0 8px; justify-content: center; }
.app.nav-top nav.tabs button { min-height: 46px; }
@media (min-width: 801px) and (max-width: 1279px) { .app.nav-top nav.tabs button:not([aria-selected="true"]) .ico { width: 26px; height: 26px; font-size: 26px; } .app.nav-top nav.tabs button:not([aria-selected="true"]) { padding: 0 9px; } .app.nav-top aside.side { gap: 6px 8px; } }
[data-tip] { position: relative; }
@media (max-width: 800px), (max-height: 450px) {
  nav.tabs button[data-tip]:hover::after, nav.tabs button[data-tip]:focus-visible::after { content: attr(data-tip); position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%); white-space: nowrap; background: var(--violet); color: #fff; padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 500; box-shadow: var(--shadow); z-index: 60; pointer-events: none; }
  .side-foot [data-tip]:hover::after, .side-foot [data-tip]:focus-visible::after { content: attr(data-tip); position: absolute; top: calc(100% + 8px); right: 0; white-space: nowrap; background: var(--violet); color: #fff; padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 500; box-shadow: var(--shadow); z-index: 60; pointer-events: none; }
}
@media (min-width: 801px) and (min-height: 451px) {
  .app.nav-top .side-foot [data-tip]:hover::after, .app.nav-top .side-foot [data-tip]:focus-visible::after { content: attr(data-tip); position: absolute; top: calc(100% + 8px); right: 0; white-space: nowrap; background: var(--violet); color: #fff; padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 500; box-shadow: var(--shadow); z-index: 60; pointer-events: none; }
  .app:not(.nav-top) .side-foot .nav-layout-btn[data-tip]:hover::after, .app:not(.nav-top) .side-foot .size-seg [data-tip]:hover::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 8px); left: 0; white-space: nowrap; background: var(--violet); color: #fff; padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 500; box-shadow: var(--shadow); z-index: 60; pointer-events: none; }
}
@media (min-width: 801px) and (max-width: 1279px) and (min-height: 451px) {
  .app.nav-top nav.tabs button:not([aria-selected="true"])[data-tip]:hover::after, .app.nav-top nav.tabs button:not([aria-selected="true"])[data-tip]:focus-visible::after { content: attr(data-tip); position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%); white-space: nowrap; background: var(--violet); color: #fff; padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 500; box-shadow: var(--shadow); z-index: 60; pointer-events: none; }
}
[data-theme="dark"] [data-tip]:hover::after { background: var(--purple); }

/* phone: the title and the user chip share the first row, the page buttons get their own row (New and Scan first); the six menu icons fit */
@media (max-width: 480px) {
  .page-head { gap: 6px 8px; }
  .page-head h1.page-title { flex: 1 1 auto; }
  .page-action { order: 5; flex: 1 1 100%; justify-content: flex-start; }
  .page-action .new-btn { order: -1; }
  nav.tabs button { padding: 0 8px; }
  nav.tabs .ico { width: 26px; height: 26px; font-size: 26px; }
}

/* the shop's own logo in the menu, and its settings panel */
.brand.has-logo { padding-top: 2px; padding-bottom: 2px; }
.brand-logo { display: block; max-height: 38px; max-width: 170px; object-fit: contain; }
[data-theme="dark"] .brand-logo { background: #fff; padding: 4px 8px; border-radius: 10px; }
.logo-panel { margin-top: 26px; max-width: 520px; }
.logo-preview { display: flex; align-items: center; min-height: 84px; padding: 12px 16px; margin: 10px 0; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.logo-preview img { max-height: 64px; max-width: 100%; object-fit: contain; display: block; }
.logo-panel .row { display: flex; gap: 8px; flex-wrap: wrap; }

/* Geo's picture on a Settings hexagon: a normal image laid over the hexagon (Safari cannot show an SVG file inside an SVG image) */
.hex-box { position: relative; display: block; }
.hex-glyph { position: absolute; left: 22%; top: 22%; width: 56%; height: 56%; pointer-events: none; display: block; }

/* Memo */
.sub-h { margin: 14px 0 6px; font-size: 14px; color: var(--text2); font-weight: 600; }
.pre-wrap { white-space: pre-wrap; }
.tk-sign { margin-top: 8mm; border-top: 1px solid #000; padding-top: 1mm; font-size: 8pt; }
.set-card { margin: 0 0 18px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--card, transparent); }
.set-card .row { margin-top: 8px; }
