:root {
  color-scheme: light;
  --ink: #122023;
  --muted: #667579;
  --line: #d9e1df;
  --surface: #ffffff;
  --wash: #f2f6f5;
  --accent: #ffb000;
  --accent-strong: #d89a00;
  --accent-soft: #fff1cc;
  --on-accent: #171713;
  --on-accent-soft: #5b4100;
  --teal: #0f4c64;
  --cool-accent: #1477a5;
  --amber: #ffb000;
  --green: #28785f;
  --shadow: 0 10px 30px rgba(18, 32, 35, 0.09);
}

body[data-palette="highContrast"] {
  --accent: #ffd54a;
  --accent-strong: #d5a400;
  --accent-soft: #fff4c7;
  --teal: #092f40;
  --cool-accent: #1677a3;
}

body[data-palette="workshop"] {
  --accent: #f2b705;
  --accent-strong: #be8f00;
  --accent-soft: #fff1bd;
  --teal: #184e3d;
  --cool-accent: #2a7f62;
}

body[data-palette="office"] {
  --accent: #f5bd3c;
  --accent-strong: #c68e13;
  --accent-soft: #fff0c8;
  --teal: #263b7a;
  --cool-accent: #3b62b4;
}

body[data-theme="dark"] {
  color-scheme: dark;
  --ink: #edf5f4;
  --muted: #aabbbb;
  --line: #33484b;
  --surface: #122023;
  --wash: #081315;
  --accent-soft: color-mix(in srgb, var(--accent) 28%, #171713);
  --on-accent-soft: #ffe3a4;
  --shadow: 0 14px 34px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: var(--wash);
}

button, input, select, textarea {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

input, select, textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface);
  color: var(--ink);
}

textarea {
  min-height: 92px;
  resize: vertical;
}

label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 650;
}

.unit-input {
  position: relative;
  display: block;
}

.unit-input input {
  padding-right: 76px;
}

.unit-input span {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
  pointer-events: none;
}

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 84px 14px 92px;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: linear-gradient(135deg, var(--wash), color-mix(in srgb, var(--teal) 14%, var(--wash)));
}

.login-panel {
  width: min(440px, 100%);
  display: grid;
  gap: 16px;
  padding: 28px;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-emblem {
  width: 94px;
  height: 94px;
  object-fit: contain;
}

.login-lettering {
  width: min(100%, 330px);
  height: auto;
  object-fit: contain;
}

.brand-kicker, .eyebrow {
  margin: 0;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.7rem, 2.2vw, 2.35rem); letter-spacing: 0; }
h2 { font-size: 1.08rem; letter-spacing: 0; }
h3 { font-size: 1rem; letter-spacing: 0; }

.topbar {
  position: fixed;
  z-index: 20;
  top: 0;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: auto 1fr auto auto auto auto;
  gap: 8px;
  align-items: center;
  padding: max(10px, env(safe-area-inset-top)) 12px 10px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand, .account-button {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  background: transparent;
  color: var(--teal);
  font-weight: 800;
}

.brand-emblem {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  font-size: 0.75rem;
}

.top-search input {
  min-height: 42px;
}

.icon-button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--teal) 12%, var(--surface));
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 900;
}

.scan-hot {
  background: var(--teal);
  color: #fff;
}

.account-button {
  width: 44px;
  height: 44px;
  min-width: 44px;
  padding: 0;
  justify-content: center;
  background: var(--accent-soft);
  color: var(--on-accent-soft);
  overflow: hidden;
}

.account-button img,
.account-menu-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.account-button span {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
}

.account-menu {
  position: fixed;
  top: calc(max(10px, env(safe-area-inset-top)) + 58px);
  right: 12px;
  z-index: 40;
  width: min(320px, calc(100vw - 24px));
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.account-menu-head {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.account-menu-head p {
  margin: 2px 0 8px;
  word-break: break-word;
}

.account-menu-avatar {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  overflow: hidden;
  background: var(--accent-soft);
  color: var(--on-accent-soft);
  font-weight: 900;
}

.account-upload {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--teal) 8%, var(--surface));
  color: var(--teal);
  font-weight: 800;
  cursor: pointer;
}

.account-upload input {
  display: none;
}

.account-appearance {
  display: grid;
  gap: 10px;
  padding: 12px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}

.account-appearance > strong {
  font-size: 0.9rem;
}

.account-appearance label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.account-appearance select {
  min-height: 42px;
  font-size: 0.92rem;
}

.theme-quick-buttons {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.theme-quick-buttons button {
  min-height: 42px;
  padding: 8px;
  background: var(--surface);
  color: var(--teal);
  border: 1px solid var(--line);
  font-weight: 850;
}

.theme-quick-buttons button.active {
  background: var(--teal);
  color: white;
  border-color: var(--teal);
}

.wide-button {
  width: 100%;
}

.page-title {
  display: flex;
  gap: 14px;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 18px;
}

.title-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.primary {
  padding: 0 16px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 800;
}

.primary:hover { background: var(--accent-strong); }

.secondary {
  padding: 0 16px;
  background: color-mix(in srgb, var(--teal) 12%, var(--surface));
  color: var(--teal);
  font-weight: 800;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.stat {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.stat strong {
  display: block;
  font-size: 1.75rem;
  letter-spacing: 0;
}

.stat span {
  color: var(--muted);
  font-size: 0.88rem;
}

.action-strip, .filters {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.action-strip {
  grid-template-columns: 1fr auto;
}

.action-strip button {
  padding: 0 14px;
  background: var(--teal);
  color: #fff;
  font-weight: 800;
}

.split-layout {
  display: grid;
  gap: 14px;
}

.split-layout > section, .split-layout > aside, .form-grid, .customer-list, .tabs, .tab-panel, .chart-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.split-layout > section, .split-layout > aside, .chart-section {
  padding: 14px;
}

.chart-section {
  margin-bottom: 14px;
}

.section-head {
  display: flex;
  gap: 10px;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-head h2 {
  margin-bottom: 0;
}

.location-chart {
  display: grid;
  gap: 10px;
}

.chart-row {
  display: grid;
  grid-template-columns: minmax(118px, 190px) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.chart-label {
  font-weight: 800;
}

.chart-track {
  height: 16px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--teal) 14%, var(--surface));
}

.chart-bar {
  height: 100%;
  min-width: 8px;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--cool-accent), var(--accent));
}

.chart-value {
  min-width: 28px;
  text-align: right;
  font-weight: 850;
}

.item-list, .customer-list, .activity-list, .note-list, .charge-list {
  display: grid;
  gap: 10px;
}

.item-list-visual {
  gap: 12px;
}

.item-card, .customer-card, .activity-card, .note-card, .charge-card, .photo-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.item-card {
  display: grid;
  gap: 8px;
  text-align: left;
}

.item-card.visual {
  grid-template-columns: 92px minmax(0, 1fr);
  align-items: stretch;
}

.item-photo-slot {
  min-height: 112px;
  overflow: hidden;
  border-radius: 6px;
  background: color-mix(in srgb, var(--teal) 12%, var(--surface));
}

.item-photo-slot img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.item-photo-placeholder {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  padding: 8px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
  text-align: center;
}

.item-card-body {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.item-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.item-meta-line {
  color: var(--muted);
  font-size: 0.86rem;
}

.directory-filters {
  display: grid;
  gap: 8px;
  padding: 14px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.reference {
  color: var(--teal);
  font-weight: 850;
}

.chip-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 3px 9px;
  background: color-mix(in srgb, var(--teal) 12%, var(--surface));
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 800;
}

.chip.warn { background: var(--accent-soft); color: var(--on-accent-soft); }
.chip.good { background: color-mix(in srgb, var(--green) 20%, var(--surface)); color: var(--green); }
.chip.danger { background: color-mix(in srgb, #b8262f 18%, var(--surface)); color: #b8262f; }

.form-grid {
  display: grid;
  gap: 14px;
  padding: 14px;
  margin-bottom: 14px;
}

.field-with-action {
  display: grid;
  gap: 8px;
}

.field-with-action button {
  width: 100%;
}

.form-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.form-actions button {
  flex: 1 1 170px;
}

.admin-panel {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  margin-bottom: 14px;
}

.admin-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.admin-tab {
  min-height: 44px;
  padding: 0 10px;
  background: color-mix(in srgb, var(--teal) 10%, var(--surface));
  color: var(--teal);
  font-size: 0.82rem;
  font-weight: 850;
}

.admin-tab.active {
  background: var(--teal);
  color: #fff;
}

.billing-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.billing-tab {
  min-height: 44px;
  padding: 0 10px;
  background: color-mix(in srgb, var(--teal) 10%, var(--surface));
  color: var(--teal);
  font-size: 0.82rem;
  font-weight: 850;
}

.billing-tab.active {
  background: var(--teal);
  color: #fff;
}

.settings-block {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.settings-grid {
  display: grid;
  gap: 10px;
}

.admin-panel .form-grid {
  padding: 0;
  border: 0;
  background: transparent;
}

.wide {
  grid-column: 1 / -1;
}

.check-row {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 46px;
  padding: 10px 0;
}

.check-row input {
  width: auto;
}

button.danger {
  border-color: color-mix(in srgb, #b8262f 48%, var(--line));
  color: #b8262f;
}

.compact-button {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 0.82rem;
}

.queue-summary {
  display: grid;
  gap: 8px;
}

.queue-summary-row {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) minmax(90px, auto) auto;
  gap: 8px;
  align-items: center;
  min-height: 42px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--wash) 52%, var(--surface));
}

.pending-upload-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 84%, var(--wash));
}

.billing-item-fields {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 86%, var(--wash));
}

.billing-grid {
  display: grid;
  gap: 12px;
}

.handling-tally {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 84%, var(--wash));
}

.compact-head {
  margin-bottom: 0;
}

.handling-grid {
  display: grid;
  gap: 8px;
}

.handling-grid label {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 44px;
}

.handling-grid.checkbox-grid label {
  grid-template-columns: auto 1fr;
  justify-content: start;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.stepper {
  display: grid;
  grid-template-columns: 42px 58px 42px;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.stepper button {
  min-height: 42px;
  border: 0;
  border-radius: 0;
  background: color-mix(in srgb, var(--amber) 55%, var(--surface));
  color: #1d1707;
  font-size: 1.2rem;
  font-weight: 900;
}

.stepper input {
  min-height: 42px;
  border: 0;
  border-inline: 1px solid var(--line);
  border-radius: 0;
  text-align: center;
  font-weight: 850;
}

.upload-actions {
  display: grid;
  gap: 8px;
}

.upload-button {
  min-height: 48px;
  display: grid;
  place-items: center;
  border: 1px dashed #9fb0ad;
  border-radius: 8px;
  background: var(--surface);
  color: var(--teal);
  font-weight: 850;
  cursor: pointer;
}

.upload-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.pending-upload-list {
  display: grid;
  gap: 8px;
}

.pending-upload-item {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.pending-upload-thumb {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 6px;
  background: color-mix(in srgb, var(--teal) 12%, var(--surface));
  color: var(--teal);
  font-size: 0.72rem;
  font-weight: 850;
}

.pending-upload-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pending-upload-item button {
  width: 42px;
  height: 42px;
  min-height: 42px;
  background: color-mix(in srgb, #b8262f 18%, var(--surface));
  color: #7a1219;
  font-weight: 900;
}

.form-grid.compact {
  border: 0;
  padding: 0;
}

.wide { grid-column: 1 / -1; }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checkbox-label input {
  width: 20px;
  min-height: 20px;
}

.print-after-save {
  min-height: 52px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--on-accent-soft);
}

.tabs {
  display: flex;
  gap: 6px;
  padding: 6px;
  overflow-x: auto;
}

.tab {
  flex: 1;
  min-width: 90px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.tab.active {
  background: var(--teal);
  color: #fff;
}

.tab-panel {
  margin-top: 10px;
  padding: 14px;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.photo-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 6px;
  background: #eef3f1;
}

.label-preview {
  width: min(100%, 440px);
  min-height: 250px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 128px;
  gap: 16px;
  align-items: center;
  padding: 18px;
  border: 4px solid #d71920;
  border-radius: 4px;
  background: var(--surface);
  margin-bottom: 12px;
}

.label-preview h2 {
  color: #d71920;
  font-size: 1.35rem;
  white-space: nowrap;
}

.label-preview p {
  margin-bottom: 7px;
  font-size: 0.98rem;
}

.fake-qr {
  width: 118px;
  height: 118px;
  background:
    linear-gradient(90deg, #111 12px, transparent 12px 20px, #111 20px 28px, transparent 28px),
    linear-gradient(#111 12px, transparent 12px 20px, #111 20px 28px, transparent 28px);
  background-size: 32px 32px;
  border: 8px solid #fff;
  box-shadow: inset 0 0 0 8px #111;
}

.real-qr {
  width: 128px;
  height: 128px;
  display: block;
  image-rendering: pixelated;
}

.print-frame {
  position: fixed;
  right: 0;
  bottom: 0;
  width: 0;
  height: 0;
  border: 0;
  opacity: 0;
}

.export-grid {
  display: grid;
  gap: 10px;
}

.export-grid a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--teal);
  font-weight: 800;
  text-decoration: none;
}

.button-link {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  text-decoration: none;
}

.billing-dashboard-lists {
  display: grid;
  gap: 14px;
}

.bulk-customer-list {
  display: grid;
  gap: 8px;
  max-height: 420px;
  overflow: auto;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 92%, var(--background));
}

.bulk-customer-toolbar {
  display: grid;
  gap: 10px;
  align-items: end;
  margin: 12px 0;
}

.bulk-customer-toolbar .chip {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.bulk-customer-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.bulk-billing-result {
  margin-top: 12px;
}

.bulk-billing-result table {
  width: 100%;
  border-collapse: collapse;
}

.bulk-billing-result th,
.bulk-billing-result td {
  padding: 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.billing-customer-button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
}

.previous-review-card {
  display: grid;
  gap: 10px;
}

.user-role-card {
  display: grid;
  gap: 10px;
  align-items: center;
}

.compact-check {
  min-height: 42px;
}

.billing-movement {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.handling-summary-grid {
  display: grid;
  gap: 10px;
  margin: 12px 0 14px;
}

.handling-summary-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.handling-summary-card h3 {
  margin-bottom: 8px;
}

.handling-pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.billing-movement-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--wash) 48%, var(--surface));
}

.billing-movement-card h3 {
  margin-bottom: 6px;
}

.billing-movement-card p {
  margin-bottom: 0;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.billing-table {
  width: 100%;
  min-width: 1520px;
  border-collapse: collapse;
  background: var(--surface);
}

.customer-table {
  width: 100%;
  min-width: 880px;
  border-collapse: collapse;
  background: var(--surface);
}

.billing-table th,
.billing-table td,
.customer-table th,
.customer-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 0.84rem;
}

.billing-table th,
.customer-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: color-mix(in srgb, var(--teal) 10%, var(--surface));
  color: var(--teal);
  font-weight: 850;
}

.billing-table tr.billing-row-active td {
  background: color-mix(in srgb, #1f8f63 8%, var(--surface));
}

.billing-table tr.billing-row-inactive td {
  background: color-mix(in srgb, #7a8794 10%, var(--surface));
}

.billing-table tr.billing-row-active:hover td,
.billing-table tr.billing-row-inactive:hover td {
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
}

.customer-row {
  cursor: pointer;
}

.customer-row:hover,
.customer-row:focus {
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  outline: none;
}

.customer-detail-head {
  margin-bottom: 12px;
}

.customer-detail-head h2 {
  margin-top: 10px;
}

.billing-table select,
.billing-table input {
  min-width: 160px;
  min-height: 38px;
}

.billing-table .money-input {
  min-width: 96px;
  width: 96px;
}

.billing-table .billing-final-week {
  min-width: 108px;
  margin: 0;
}

.billing-table .billing-final-week input {
  min-width: auto;
  min-height: auto;
}

.warning-text {
  display: block;
  margin-top: 4px;
  color: var(--danger);
  font-weight: 800;
}

.bottom-nav {
  position: fixed;
  z-index: 20;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  padding: 8px 8px max(8px, env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  border-top: 1px solid var(--line);
}

.bottom-nav button {
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.bottom-nav button.active {
  background: color-mix(in srgb, var(--teal) 12%, var(--surface));
  color: var(--teal);
}

.scanner-dialog, .inline-dialog {
  width: min(640px, calc(100vw - 20px));
  border: 0;
  border-radius: 8px;
  padding: 0;
}

.scanner-dialog {
  background: #091719;
  color: #fff;
}

.scanner-dialog::backdrop, .inline-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.inline-dialog {
  background: var(--surface);
}

.dialog-panel {
  display: grid;
  gap: 14px;
  padding: 0 14px 14px;
}

.inline-dialog .scanner-head {
  margin: 0 -14px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
}

.settings-fieldset {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.settings-fieldset legend {
  padding: 0 6px;
  color: var(--muted);
  font-weight: 800;
}

.palette-option {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 10px;
  align-items: center;
  min-height: 46px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 88%, var(--wash));
  cursor: pointer;
}

.palette-option input {
  width: 20px;
  min-height: 20px;
}

.swatches {
  display: inline-flex;
  gap: 4px;
}

.swatches i {
  width: 22px;
  height: 22px;
  display: block;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 999px;
}

.scanner-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
}

.scanner-head h2 { margin: 0; }

#scannerVideo {
  display: block;
  width: 100%;
  height: min(68vh, 560px);
  min-height: 340px;
  object-fit: cover;
  background: #000;
}

.scanner-message, .manual-scan {
  padding: 12px;
}

.manual-scan {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.manual-scan button {
  padding: 0 14px;
  background: var(--amber);
  color: #1d1707;
  font-weight: 800;
}

.toast {
  position: fixed;
  z-index: 50;
  left: 14px;
  right: 14px;
  bottom: 82px;
  max-width: 560px;
  margin: 0 auto;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow);
}

.small-muted, .muted {
  color: var(--muted);
  font-size: 0.88rem;
}

[hidden] { display: none !important; }

@media (max-width: 640px) {
  .brand span:last-child { display: none; }
  .topbar { grid-template-columns: auto 1fr auto auto auto auto; padding-left: 8px; padding-right: 8px; }
  main { padding-left: 10px; padding-right: 10px; }
  .bottom-nav button[data-view="billing"],
  .bottom-nav button[data-view="admin"] {
    display: none;
  }
  .page-title { align-items: stretch; flex-direction: column; }
  .title-actions { justify-content: stretch; }
  .title-actions button { flex: 1; }
  .action-strip, .manual-scan { grid-template-columns: 1fr; }
  .chart-row {
    grid-template-columns: 1fr auto;
  }
  .chart-track {
    grid-column: 1 / -1;
    grid-row: 2;
  }
  .item-card.visual {
    grid-template-columns: 84px minmax(0, 1fr);
  }
  .item-photo-slot {
    min-height: 104px;
  }
  .phone-action-dialog .dialog-panel {
    width: min(100%, 420px);
  }
  .handling-grid label {
    grid-template-columns: 1fr;
  }
}

body.phone-app-mode .phone-app-hidden,
body.phone-app-mode #settingsButton,
body.phone-app-mode #billingView,
body.phone-app-mode #adminView,
body.phone-app-mode .bottom-nav button[data-view="billing"],
body.phone-app-mode .bottom-nav button[data-view="admin"] {
  display: none !important;
}

body.phone-app-mode .topbar {
  grid-template-columns: auto 1fr auto auto;
  gap: 10px;
  padding: max(12px, env(safe-area-inset-top)) 12px 12px;
}

body.phone-app-mode .bottom-nav {
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 10px 10px max(12px, env(safe-area-inset-bottom));
}

body.phone-app-mode .bottom-nav button[data-view="customers"] {
  display: block;
}

body.phone-app-mode .bottom-nav button[data-view="dashboard"],
body.phone-app-mode .bottom-nav button[data-view="items"],
body.phone-app-mode .bottom-nav button[data-view="customers"],
body.phone-app-mode .bottom-nav button[data-view="itemEditor"] {
  min-height: 74px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--teal) 10%, var(--surface));
  color: var(--teal);
  font-size: 1.08rem;
  line-height: 1.12;
  font-weight: 900;
}

body.phone-app-mode .bottom-nav button.active {
  background: var(--teal);
  color: #fff;
}

body.phone-app-mode {
  font-size: 19px;
}

body.phone-app-mode main {
  max-width: none;
  padding: 104px 12px 122px;
}

body.phone-app-mode .top-search {
  display: none;
}

body.phone-app-mode .brand {
  gap: 10px;
}

body.phone-app-mode .brand span:last-child {
  display: inline;
  font-size: 1.15rem;
}

body.phone-app-mode .brand-emblem {
  width: 58px;
  height: 58px;
}

body.phone-app-mode .icon-button,
body.phone-app-mode .account-button {
  width: 56px;
  height: 56px;
  min-width: 56px;
  font-size: 1rem;
}

body.phone-app-mode h1 {
  font-size: 2.35rem;
  line-height: 1.05;
}

body.phone-app-mode h2 {
  font-size: 1.5rem;
}

body.phone-app-mode h3 {
  font-size: 1.22rem;
}

body.phone-app-mode .page-title {
  align-items: stretch;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 18px;
}

body.phone-app-mode #dashboardView .dashboard-action-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  width: 100%;
}

body.phone-app-mode #dashboardView .dashboard-action-buttons button {
  aspect-ratio: 1 / 1;
  min-height: 0;
  padding: 14px;
  font-size: 1.42rem;
  line-height: 1.08;
  font-weight: 950;
  white-space: normal;
}

body.phone-app-mode button,
body.phone-app-mode .button-link {
  min-height: 60px;
  font-size: 1.08rem;
}

body.phone-app-mode input,
body.phone-app-mode select,
body.phone-app-mode textarea {
  min-height: 60px;
  padding: 15px;
  font-size: 1.08rem;
}

body.phone-app-mode label {
  gap: 9px;
  font-size: 1.08rem;
}

body.phone-app-mode .stats-grid {
  gap: 14px;
  margin-bottom: 18px;
}

body.phone-app-mode .stat {
  min-height: 118px;
  padding: 22px 18px;
}

body.phone-app-mode .stat strong {
  font-size: 2.75rem;
  line-height: 1;
}

body.phone-app-mode .stat span {
  font-size: 1.08rem;
  font-weight: 750;
}

body.phone-app-mode .action-strip {
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

body.phone-app-mode .chart-section,
body.phone-app-mode .split-layout > section,
body.phone-app-mode .form-grid,
body.phone-app-mode .tab-panel,
body.phone-app-mode .customer-list,
body.phone-app-mode .directory-filters,
body.phone-app-mode .admin-panel {
  padding: 20px;
}

body.phone-app-mode #dashboardView .split-layout {
  display: block;
}

body.phone-app-mode #dashboardView .split-layout > section {
  width: 100%;
  min-height: 340px;
}

body.phone-app-mode #dashboardView .split-layout > section h2 {
  margin-bottom: 14px;
}

body.phone-app-mode .chart-row {
  gap: 12px;
  font-size: 1rem;
}

body.phone-app-mode .chart-track {
  height: 22px;
}

body.phone-app-mode .item-list,
body.phone-app-mode .customer-list,
body.phone-app-mode .activity-list,
body.phone-app-mode .note-list,
body.phone-app-mode .charge-list {
  gap: 14px;
}

body.phone-app-mode .item-card,
body.phone-app-mode .customer-card,
body.phone-app-mode .activity-card,
body.phone-app-mode .note-card,
body.phone-app-mode .charge-card,
body.phone-app-mode .photo-card {
  padding: 18px;
}

body.phone-app-mode .item-card.visual {
  grid-template-columns: 128px minmax(0, 1fr);
  min-height: 168px;
  gap: 14px;
}

body.phone-app-mode .item-photo-slot {
  min-height: 150px;
}

body.phone-app-mode .reference {
  font-size: 1.18rem;
}

body.phone-app-mode .item-card-body {
  gap: 10px;
}

body.phone-app-mode .item-meta-line {
  font-size: 1.02rem;
}

body.phone-app-mode .chip {
  min-height: 38px;
  padding: 6px 12px;
  font-size: 0.98rem;
}

body.phone-app-mode .small-muted,
body.phone-app-mode .muted {
  font-size: 1.06rem;
}

body.phone-app-mode .scanner-dialog,
body.phone-app-mode .inline-dialog {
  width: min(100vw - 16px, 560px);
}

body.phone-app-mode .dialog-panel {
  gap: 16px;
  padding: 0 16px 16px;
}

body.phone-app-mode .toast {
  bottom: 100px;
  padding: 16px;
  font-size: 1rem;
}

@media (min-width: 720px) {
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .directory-filters { grid-template-columns: 1.4fr repeat(5, minmax(130px, 1fr)); }
  .stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .split-layout { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .billing-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .billing-dashboard-lists { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .handling-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .handling-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .billing-movement { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .previous-review-card { grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; }
  .user-role-card { grid-template-columns: minmax(0, 1fr) 190px auto; }
  .admin-tabs { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .billing-tabs { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .bulk-customer-toolbar { grid-template-columns: minmax(260px, 1fr) 220px auto; }
  .bulk-customer-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .settings-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .upload-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .export-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

body.phone-app-mode {
  width: 100%;
  overflow-x: hidden;
  font-size: 20px;
  -webkit-text-size-adjust: 100%;
}

body.phone-app-mode main {
  width: 100%;
  overflow-x: hidden;
  padding: 104px 10px 126px;
}

body.phone-app-mode .brand span:last-child {
  font-size: 1.2rem;
}

body.phone-app-mode .brand-emblem {
  width: 58px;
  height: 58px;
}

body.phone-app-mode .icon-button,
body.phone-app-mode .account-button {
  width: 58px;
  height: 58px;
  min-width: 58px;
  font-size: 1.05rem;
}

body.phone-app-mode h1 {
  font-size: 2.35rem;
}

body.phone-app-mode h2 {
  font-size: 1.55rem;
}

body.phone-app-mode .eyebrow {
  font-size: 0.95rem;
}

body.phone-app-mode #dashboardView .dashboard-action-buttons {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 16px;
}

body.phone-app-mode #dashboardView .dashboard-action-buttons button {
  min-height: 0;
  aspect-ratio: 1 / 1;
  font-size: 1.45rem;
}

body.phone-app-mode .stats-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 16px;
}

body.phone-app-mode .stat {
  min-height: 124px;
  padding: 20px 18px;
}

body.phone-app-mode .stat strong {
  font-size: 2.75rem;
}

body.phone-app-mode .stat span {
  font-size: 1.08rem;
}

body.phone-app-mode input,
body.phone-app-mode select,
body.phone-app-mode textarea,
body.phone-app-mode button,
body.phone-app-mode .button-link {
  min-height: 62px;
  font-size: 1.1rem;
}

body.phone-app-mode label {
  font-size: 1.08rem;
}

body.phone-app-mode #dashboardView .split-layout {
  display: block !important;
}

body.phone-app-mode #dashboardView .split-layout > section {
  width: 100%;
  min-height: 360px;
}

body.phone-app-mode #dashboardView .split-layout > aside {
  display: none !important;
}

body.phone-app-mode .chart-section,
body.phone-app-mode .split-layout > section,
body.phone-app-mode .form-grid,
body.phone-app-mode .tab-panel,
body.phone-app-mode .customer-list,
body.phone-app-mode .directory-filters,
body.phone-app-mode .admin-panel {
  padding: 18px;
}

body.phone-app-mode .chart-row,
body.phone-app-mode .chart-label,
body.phone-app-mode .chart-value {
  font-size: 1.05rem;
}

body.phone-app-mode .chart-track {
  height: 22px;
}

body.phone-app-mode .item-card,
body.phone-app-mode .customer-card,
body.phone-app-mode .activity-card,
body.phone-app-mode .note-card,
body.phone-app-mode .charge-card,
body.phone-app-mode .photo-card {
  padding: 18px;
}

body.phone-app-mode .item-card.visual {
  grid-template-columns: 1fr;
  min-height: 0;
  gap: 16px;
}

body.phone-app-mode .item-photo-slot {
  min-height: 190px;
  max-height: 240px;
}

body.phone-app-mode .reference {
  font-size: 1.28rem;
}

body.phone-app-mode .item-card-body,
body.phone-app-mode .item-card header {
  gap: 12px;
  min-width: 0;
}

body.phone-app-mode .item-card header {
  align-items: flex-start;
  flex-wrap: wrap;
}

body.phone-app-mode .item-card header .chip {
  margin-left: 0;
}

body.phone-app-mode .item-meta-line,
body.phone-app-mode .small-muted,
body.phone-app-mode .muted {
  font-size: 1.08rem;
}

body.phone-app-mode .item-card strong,
body.phone-app-mode .item-card p,
body.phone-app-mode .item-meta-line {
  overflow-wrap: anywhere;
}

body.phone-app-mode .chip {
  min-height: 38px;
  padding: 6px 12px;
  font-size: 0.98rem;
}

body.phone-app-mode .bottom-nav {
  overflow: hidden;
  padding: 10px 8px max(12px, env(safe-area-inset-bottom));
}

body.phone-app-mode .bottom-nav button[data-view="dashboard"],
body.phone-app-mode .bottom-nav button[data-view="items"],
body.phone-app-mode .bottom-nav button[data-view="customers"],
body.phone-app-mode .bottom-nav button[data-view="itemEditor"] {
  min-width: 0;
  min-height: 76px;
  padding: 8px 5px;
  font-size: 1.05rem;
}
