:root {
  --blue: #2563eb;
  --green: #15803d;
  --amber: #b45309;
  --red: #b91c1c;
  --teal: #0f766e;
  --violet: #6d28d9;
  --ink: #172033;
  --muted: #64748b;
  --line: #d9e0ea;
  --panel: #ffffff;
  --soft: #f5f7fb;
  --blue-soft: #eff6ff;
  --green-soft: #f0fdf4;
  --amber-soft: #fffbeb;
  --red-soft: #fef2f2;
  --teal-soft: #f0fdfa;
  --violet-soft: #f5f3ff;
  --app-pad: 12px;
  --app-gap: 12px;
  --topbar-height: 66px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

html {
  height: 100%;
  touch-action: manipulation;
}

body {
  margin: 0;
  background: var(--soft);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
  overflow: hidden;
  overscroll-behavior: none;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
}

input {
  font-size: 16px;
  touch-action: manipulation;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.print-root {
  display: none;
}

.update-banner {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 16px;
  background: #111827;
  color: #fff;
}

.update-banner[hidden] {
  display: none;
}

.update-banner strong,
.update-banner span {
  color: #fff;
}

.update-banner button {
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: #fff;
  color: #111827;
  font-weight: 900;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
  min-height: var(--topbar-height);
  padding: 8px max(14px, env(safe-area-inset-right)) 8px max(14px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
  background: rgba(245, 247, 251, 0.94);
  backdrop-filter: blur(14px);
}

.brand,
.topbar-actions,
.session-pill,
.mini-stats,
.signature-head,
.table-head {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
}

.brand-logo {
  width: 88px;
  height: 46px;
  object-fit: contain;
}

.brand strong,
.brand small {
  display: block;
}

.brand small,
span,
small {
  color: var(--muted);
  font-weight: 800;
}

.topbar-actions {
  gap: 10px;
  justify-content: end;
}

.language-toggle {
  display: grid;
  grid-template-columns: repeat(2, minmax(92px, auto));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.language-toggle button {
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  font-weight: 900;
}

.language-toggle button.is-active {
  background: var(--blue);
  color: #fff;
}

.session-pill {
  min-height: 42px;
  gap: 8px;
  padding: 0 14px;
  border: 1px solid #86efac;
  border-radius: 8px;
  background: var(--green-soft);
  color: var(--green);
  font-weight: 900;
}

.session-pill span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: currentColor;
}

body.is-login .session-pill {
  display: none;
}

body.is-login .topbar {
  display: none;
}

.view-panel {
  display: none;
}

.view-panel.is-active {
  display: block;
}

.login-view.is-active {
  display: grid;
}

.login-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card,
.pin-card {
  display: grid;
  gap: 18px;
  padding: 28px;
}

.login-card {
  width: min(720px, 100%);
}

.pin-card {
  width: min(920px, 100%);
  gap: 14px;
  padding: 24px;
}

.login-card h1,
.pin-card h1 {
  margin: 0;
  font-size: 38px;
  line-height: 1;
}

.login-form {
  display: grid;
  gap: 16px;
}

.login-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 900;
}

.login-form input {
  min-height: 64px;
  width: 100%;
  padding: 0 16px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 22px;
  font-weight: 900;
}

.login-form input:focus {
  border-color: var(--blue);
  outline: 3px solid rgba(37, 99, 235, 0.18);
}

.login-form p {
  min-height: 22px;
  margin: 0;
  color: var(--red);
  font-weight: 900;
}

.login-form button {
  min-height: 64px;
  border: 0;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font: inherit;
  font-size: 22px;
  font-weight: 900;
}

.pin-card-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.pin-card-head > div {
  min-width: 0;
}

.pin-card-back {
  min-width: 116px;
  min-height: 52px;
  border: 0;
  border-radius: 8px;
  background: #e5e7eb;
  color: var(--ink);
  font: inherit;
  font-size: 18px;
  font-weight: 900;
}

.pin-display {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.pin-dot {
  width: 26px;
  height: 26px;
  border: 4px solid #0f766e;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 0 0 8px #f0fdfa;
}

.pin-dot.is-filled {
  background: #0f766e;
}

.pin-card p {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
  font-weight: 900;
  text-align: center;
}

.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.pin-key {
  min-height: clamp(74px, 12dvh, 118px);
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 52px;
  font-weight: 900;
  box-shadow: 0 2px 5px rgba(15, 23, 42, 0.08);
  touch-action: manipulation;
}

.pin-key:active {
  transform: translateY(1px);
}

.pin-key-clear {
  color: #0f766e;
  font-size: 32px;
}

.pin-key-delete {
  color: #0f766e;
  font-size: 44px;
}

.pin-card.is-busy .pin-key,
.pin-card.is-busy .pin-card-back {
  cursor: wait;
  opacity: 0.6;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.08);
}

.route-garland {
  --route-color: var(--violet);
  --route-bg: var(--violet-soft);
  --route-border: #ddd6fe;
}

.route-arlington {
  --route-color: var(--blue);
  --route-bg: var(--blue-soft);
  --route-border: #bfdbfe;
}

.route-carrollton {
  --route-color: var(--teal);
  --route-bg: var(--teal-soft);
  --route-border: #99f6e4;
}

.route-other {
  --route-color: var(--muted);
  --route-bg: #f8fafc;
  --route-border: var(--line);
}

.tone-default,
.tone-tofu {
  --tone: var(--green);
  --tone-bg: var(--green-soft);
  --tone-border: #bbf7d0;
}

.tone-bbq {
  --tone: var(--red);
  --tone-bg: var(--red-soft);
  --tone-border: #fecaca;
}

.tone-leaf {
  --tone: var(--teal);
  --tone-bg: var(--teal-soft);
  --tone-border: #99f6e4;
}

.tone-special {
  --tone: var(--amber);
  --tone-bg: var(--amber-soft);
  --tone-border: #fde68a;
}

.tone-holiday {
  --tone: var(--violet);
  --tone-bg: var(--violet-soft);
  --tone-border: #ddd6fe;
}

.tone-sea {
  --tone: #0369a1;
  --tone-bg: #f0f9ff;
  --tone-border: #bae6fd;
}

.tone-hue {
  --tone: #4338ca;
  --tone-bg: #eef2ff;
  --tone-border: #c7d2fe;
}

.driver-grid {
  display: grid;
  grid-template-columns: clamp(220px, 20vw, 260px) minmax(0, 1fr) clamp(248px, 26vw, 312px);
  gap: var(--app-gap);
  height: calc(100dvh - var(--topbar-height));
  min-height: 0;
  padding: var(--app-pad);
  overflow: hidden;
}

.invoice-history-panel,
.store-picker {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
}

.store-picker.is-attention {
  border-color: var(--blue);
  box-shadow:
    0 0 0 4px rgba(37, 99, 235, 0.16),
    0 14px 34px rgba(15, 23, 42, 0.08);
  animation: store-picker-attention 900ms ease-out;
}

.store-picker.is-attention .panel-head {
  background: var(--blue-soft);
}

@keyframes store-picker-attention {
  0% {
    box-shadow:
      0 0 0 0 rgba(37, 99, 235, 0.26),
      0 14px 34px rgba(15, 23, 42, 0.08);
  }

  45% {
    box-shadow:
      0 0 0 8px rgba(37, 99, 235, 0.18),
      0 14px 34px rgba(15, 23, 42, 0.08);
  }

  100% {
    box-shadow:
      0 0 0 4px rgba(37, 99, 235, 0.16),
      0 14px 34px rgba(15, 23, 42, 0.08);
  }
}

.panel-head {
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.panel-head span,
.panel-head strong {
  display: block;
}

.panel-head strong {
  margin-top: 4px;
  font-size: clamp(20px, 2.2vw, 28px);
}

.panel-head strong:first-child {
  margin-top: 0;
}

.store-list,
.item-grid,
.cart-list,
.review-lines {
  overflow: auto;
}

.create-invoice-wrap {
  padding: 10px;
  border-bottom: 1px solid var(--line);
}

.invoice-history-panel .create-invoice-button {
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--blue);
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font-size: 20px;
  font-weight: 900;
}

.store-list {
  display: grid;
  gap: 8px;
  align-content: start;
  padding: 6px 8px 8px;
}

.store-region {
  display: grid;
  gap: 4px;
}

.store-region-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 2px;
  color: var(--route-color);
  font-size: 14px;
  font-weight: 900;
  text-transform: uppercase;
}

.store-region-heading span {
  color: inherit;
}

.store-region-heading small {
  min-width: 28px;
  min-height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--route-bg);
  color: var(--route-color);
  font-size: 14px;
}

.store-region-list {
  display: grid;
  gap: 4px;
}

.store-option {
  display: flex;
  align-items: center;
  min-height: 52px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-left: 6px solid var(--route-border);
  border-radius: 8px;
  background: linear-gradient(90deg, var(--route-bg) 0, #fff 46%);
  color: var(--ink);
  text-align: left;
  font-weight: 900;
}

.store-option span {
  color: var(--ink);
  font-size: 22px;
  line-height: 1.08;
  overflow: visible;
  overflow-wrap: anywhere;
  white-space: normal;
}

.store-option.is-active {
  border-color: var(--route-color);
  background: var(--route-bg);
  box-shadow: inset 0 0 0 1px var(--route-color);
}

.order-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: var(--app-gap);
  min-width: 0;
  min-height: 0;
}

#driver-view.is-selecting-store .order-panel {
  grid-template-rows: auto minmax(0, 1fr);
}

#driver-view.is-selecting-store .store-card {
  display: none;
}

.flow-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 7px;
}

.flow-steps button {
  --step-color: var(--blue);
  --step-bg: var(--blue-soft);
  --step-border: #bfdbfe;
  min-height: 46px;
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--step-border);
  border-radius: 8px;
  background: var(--step-bg);
  color: var(--step-color);
  font-size: 15px;
  font-weight: 900;
}

.flow-steps button[data-step="items"] {
  --step-color: var(--amber);
  --step-bg: var(--amber-soft);
  --step-border: #fde68a;
}

.flow-steps button[data-step="review"] {
  --step-color: var(--green);
  --step-bg: var(--green-soft);
  --step-border: #bbf7d0;
}

.flow-steps span {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #fff;
  color: var(--step-color);
}

.flow-steps em {
  color: inherit;
  font-style: normal;
}

.flow-steps button.is-complete {
  border-color: var(--step-border);
  background: var(--step-bg);
  color: var(--step-color);
}

.flow-steps button.is-complete span {
  background: var(--step-color);
  color: #fff;
}

.flow-steps button.is-active {
  border-color: var(--step-color);
  background: var(--step-color);
  color: #fff;
}

.flow-steps button.is-active span {
  background: #fff;
  color: var(--step-color);
}

.flow-steps button:disabled {
  cursor: not-allowed;
  border-color: var(--line);
  background: #f8fafc;
  color: var(--muted);
  opacity: 0.72;
}

.flow-steps button:disabled span {
  background: #e2e8f0;
  color: var(--muted);
}

.store-picker[hidden],
.item-grid[hidden] {
  display: none;
}

.store-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  border-left: 6px solid var(--route-color, var(--line));
  background:
    linear-gradient(90deg, var(--route-bg, #fff) 0, #fff 60%),
    #fff;
  padding: 14px 16px;
}

.store-card-title {
  min-width: 0;
}

.route-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--route-color, var(--blue));
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

.store-card h1,
.review-top h1,
.admin-header h1 {
  margin: 4px 0 0;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.04;
}

.store-card h1 {
  margin-top: 6px;
  font-size: clamp(30px, 3.8vw, 42px);
}

#current-store-email {
  display: block;
  margin-top: 4px;
  color: #475569;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.change-store-button {
  min-height: 50px;
  padding: 0 14px;
  border: 1px solid var(--route-border, var(--line));
  border-radius: 8px;
  background: #fff;
  color: var(--route-color, var(--blue));
  font-weight: 900;
  white-space: nowrap;
}

.change-store-button[hidden] {
  display: none;
}

.review-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
}

.review-title-row h1 {
  margin: 0;
}

.review-title-row .good {
  max-width: min(360px, 100%);
  min-height: 34px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.good,
#signature-status {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  padding: 8px 10px;
  border-radius: 8px;
  background: #fef3c7;
  color: var(--amber);
  font-weight: 900;
}

.good,
#signature-status.is-good {
  background: #dcfce7;
  color: var(--green);
}

.admin-header button,
.table-head button {
  border: 0;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 900;
}

.item-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
  align-content: start;
  min-height: 0;
}

.item-card {
  position: relative;
  display: grid;
  grid-template-rows: auto auto;
  gap: 9px;
  min-height: 130px;
  padding: 14px 14px 14px 22px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(90deg, var(--tone-bg) 0, #fff 42%);
}

.item-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 8px;
  background: var(--tone);
}

.item-card.is-picked {
  border: 2px solid var(--tone);
  background: linear-gradient(90deg, var(--tone-bg) 0, #fff 72%);
  box-shadow: inset 0 0 0 1px var(--tone), 0 10px 18px rgba(15, 23, 42, 0.08);
}

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

.item-card-head > span {
  min-width: 0;
}

.item-card h2 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: clamp(22px, 2.4vw, 28px);
  line-height: 1;
}

.item-card small {
  color: #526071;
  font-size: 16px;
  font-weight: 900;
  white-space: nowrap;
}

.item-clear {
  min-height: 34px;
  padding: 0 9px;
  border: 1px solid var(--tone-border);
  border-radius: 8px;
  background: #fff;
  color: var(--tone);
  font-size: 13px;
  font-weight: 900;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.item-card.is-picked .item-clear {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}

.qty-row {
  display: grid;
  grid-template-columns: 64px minmax(82px, 1fr) 64px;
  gap: 9px;
  align-items: center;
}

.qty-row button {
  height: 58px;
  border: 0;
  border-radius: 8px;
  background: #e5e7eb;
  color: var(--ink);
  font-size: 38px;
  font-weight: 900;
}

.qty-row button[data-delta="1"] {
  background: var(--tone);
  color: #fff;
}

.qty-row button[data-delta="-1"] {
  background: #eef2f7;
  color: var(--ink);
}

.qty-row input {
  height: 58px;
  width: 100%;
  display: grid;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 40px;
  font-weight: 900;
  text-align: center;
  appearance: textfield;
}

.qty-row input:focus {
  border-color: var(--blue);
  outline: 3px solid rgba(37, 99, 235, 0.2);
}

.qty-row input::-webkit-inner-spin-button,
.qty-row input::-webkit-outer-spin-button {
  margin: 0;
  appearance: none;
}

.summary-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 10px;
  min-height: 0;
  padding: 12px;
}

.total {
  font-size: clamp(34px, 4vw, 44px);
  line-height: 1;
}

.mini-stats {
  gap: 8px;
}

.mini-stats div {
  flex: 1;
  min-height: 72px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  text-align: center;
}

.mini-stats b,
.mini-stats span {
  display: block;
}

.mini-stats b {
  font-size: 24px;
}

.cart-list {
  display: grid;
  gap: 8px;
  align-content: start;
  min-height: 0;
}

.cart-list p {
  margin: 0;
  padding: 22px 14px;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  font-weight: 900;
}

.cart-line,
.review-line {
  display: grid;
  gap: 10px;
  align-items: start;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.cart-line {
  border-color: var(--tone-border);
  border-left: 6px solid var(--tone);
  background: linear-gradient(90deg, var(--tone-bg) 0, #fff 68%);
}

.review-line {
  grid-template-columns: minmax(0, 1fr) 118px;
  align-items: center;
  border-color: var(--tone-border);
  border-left: 6px solid var(--tone);
  background: var(--tone-bg);
}

.review-line span {
  color: var(--ink);
  font-weight: 900;
}

.cart-line-main,
.review-line-main {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.cart-line-top,
.cart-line-detail,
.review-line-main span {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.cart-line-top {
  gap: 10px;
  justify-content: flex-start;
}

.cart-line-detail {
  justify-content: space-between;
}

.cart-line-top b,
.review-line-main b {
  min-width: 0;
  color: var(--ink);
  font-size: 17px;
  line-height: 1.15;
}

.cart-line-top em {
  min-width: 32px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--tone);
  color: #fff;
  font-size: 17px;
  font-style: normal;
  font-weight: 900;
  line-height: 1;
}

.cart-line-detail strong {
  flex: 0 0 auto;
  color: var(--ink);
  font-size: 19px;
  line-height: 1.15;
}

.review-line-main b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.review-line-main em {
  flex: 0 0 auto;
  min-width: 62px;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--tone);
  color: #fff;
  font-size: 14px;
  font-style: normal;
  font-weight: 900;
  line-height: 1;
  text-align: center;
}

.cart-line-detail small,
.review-line-main small {
  color: var(--muted);
  font-size: 14px;
  font-weight: 900;
}

.review-line strong {
  font-size: 18px;
  text-align: right;
}

.today-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  min-height: 0;
  overflow: hidden;
  padding: 12px;
}

.today-panel[hidden] {
  display: none;
}

#driver-view.is-editing-invoice .today-panel {
  background: #fbfdff;
}

.today-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.today-heading b {
  min-width: 32px;
  min-height: 32px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #eef2f7;
  color: var(--ink);
}

.today-invoices {
  display: grid;
  gap: 8px;
  align-content: start;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.today-invoices button {
  --status-color: var(--muted);
  --status-bg: #f8fafc;
  display: grid;
  gap: 8px;
  align-items: start;
  padding: 10px 9px;
  border: 1px solid var(--line);
  border-left: 6px solid var(--status-color);
  border-radius: 8px;
  background: linear-gradient(90deg, var(--status-bg) 0, #f8fafc 42%);
  color: var(--ink);
  text-align: left;
  min-width: 0;
}

.today-invoices button.status-sent,
.today-invoices button.status-finalized {
  --status-color: var(--green);
  --status-bg: var(--green-soft);
}

.today-invoices button.status-queued,
.today-invoices button.status-open {
  --status-color: #0369a1;
  --status-bg: #f0f9ff;
}

.today-invoices button.status-failed {
  --status-color: var(--red);
  --status-bg: var(--red-soft);
}

.today-invoices button.status-local {
  --status-color: var(--amber);
  --status-bg: var(--amber-soft);
}

.today-invoices span,
.today-invoices small {
  display: block;
}

.today-invoice-store,
.today-invoice-line {
  min-width: 0;
}

.today-invoices b {
  display: block;
  overflow: visible;
  color: var(--ink);
  font-size: 19px;
  line-height: 1.08;
  overflow-wrap: anywhere;
  white-space: normal;
}

.today-invoices .today-invoice-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 6px;
}

.today-invoices .today-invoice-line small {
  flex: 0 0 auto;
  color: #64748b;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1.1;
  overflow-wrap: normal;
  white-space: nowrap;
}

.today-invoices strong {
  flex: 0 0 auto;
  margin-left: auto;
  font-size: 15px;
  white-space: nowrap;
}

.today-invoices button > em {
  justify-self: start;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--status-bg);
  color: var(--status-color);
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
  text-transform: uppercase;
}

.today-invoices p {
  margin: 0;
  padding: 14px;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  font-weight: 900;
}

.primary-action,
.final-action {
  min-height: 64px;
  border: 0;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font-size: 22px;
  font-weight: 900;
}

.primary-action:not(:disabled) {
  background: var(--green);
}

.final-action {
  background: var(--green);
}

.final-action:disabled,
.primary-action:disabled {
  background: #94a3b8;
}

.review-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 0.76fr);
  grid-template-rows: auto minmax(0, 1fr);
  gap: var(--app-gap);
  height: calc(100dvh - var(--topbar-height));
  min-height: 0;
  padding: var(--app-pad);
  overflow: hidden;
}

.review-top {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 138px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border-left: 6px solid var(--route-color, var(--green));
  background: linear-gradient(90deg, var(--route-bg, #fff) 0, #fff 62%);
  padding: 10px 12px;
}

.review-top button,
.signature-head button {
  min-height: 48px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--ink);
  font-weight: 900;
}

.review-top .back-action {
  min-height: 46px;
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 16px;
}

.review-top .back-action:disabled {
  border-color: var(--line);
  background: #f8fafc;
  color: var(--muted);
  opacity: 1;
}

.review-summary {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
  min-height: 0;
  border-left: 6px solid var(--route-color, var(--green));
  padding: 14px;
}

.review-summary .store-line {
  display: none;
}

#review-view.is-finalized .review-summary {
  grid-template-rows: auto minmax(0, 1fr) auto;
  align-content: start;
}

.store-line h2 {
  margin: 0;
  font-size: clamp(22px, 2.7vw, 30px);
  line-height: 1.05;
}

#review-view.is-finalized .review-meta {
  display: none;
}

.review-total {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 14px;
  border: 1px solid #bfdbfe;
  border-left: 6px solid var(--blue);
  border-radius: 8px;
  background: #eff6ff;
  color: var(--ink);
}

.review-total span {
  color: #475569;
  font-weight: 900;
}

.review-total strong {
  color: var(--ink);
  font-size: clamp(34px, 4vw, 42px);
  line-height: 1;
}

.review-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.review-meta span {
  min-height: 42px;
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fafc;
  color: var(--muted);
  font-weight: 900;
}

.review-meta b {
  color: var(--ink);
}

.review-lines {
  display: grid;
  gap: 8px;
  align-content: start;
  min-height: 0;
}

.signature-panel {
  display: grid;
  grid-template-rows: auto minmax(200px, 1fr) auto auto auto;
  gap: 10px;
  min-height: 0;
  border-left: 6px solid var(--amber);
  background: linear-gradient(180deg, #fff 0, #fffbeb 100%);
  padding: 14px;
}

.signature-panel.is-signed,
.signature-panel.is-finalized {
  border-left-color: var(--green);
}

.signature-panel.is-finalized {
  grid-template-rows: auto auto;
  align-content: start;
  min-height: 0;
}

.signature-head {
  justify-content: space-between;
  gap: 12px;
}

.signature-head h2 {
  margin: 3px 0 0;
  font-size: 24px;
}

.signature-head small {
  display: block;
  margin-top: 4px;
}

#review-view.is-finalized .signature-head {
  display: none;
}

#signature-pad {
  width: 100%;
  height: 100%;
  min-height: 200px;
  border: 3px dashed #93b4dd;
  border-radius: 8px;
  background: linear-gradient(transparent 86%, rgba(37, 99, 235, 0.08)), #fff;
  touch-action: none;
}

#signature-pad.is-signed {
  border-color: var(--green);
  background: linear-gradient(transparent 86%, rgba(21, 128, 61, 0.08)), #fff;
}

#signature-pad[hidden] {
  display: none;
}

.finalized-panel {
  display: grid;
  gap: 8px;
  padding: 16px 18px;
  border: 1px solid #bbf7d0;
  border-left: 6px solid var(--green);
  border-radius: 8px;
  background: #f0fdf4;
}

.finalized-panel[hidden] {
  display: none;
}

.finalized-panel strong {
  color: var(--green);
  font-size: 26px;
  line-height: 1.15;
}

.finalized-status-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.finalized-status-chip {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

.finalized-status-chip.is-good {
  background: #dcfce7;
  color: var(--green);
}

.finalized-status-chip.is-warn {
  background: #fef3c7;
  color: var(--amber);
}

.finalized-status-chip.is-bad {
  background: #fee2e2;
  color: var(--red);
}

#finalized-detail {
  color: var(--ink);
  font-weight: 800;
  line-height: 1.25;
}

#review-view.is-finalized .final-action {
  min-height: 62px;
}

#final-message {
  margin: 0;
  color: var(--muted);
  font-weight: 900;
}

#final-message[hidden] {
  display: none;
}

.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.42);
}

.confirm-overlay[hidden] {
  display: none;
}

.confirm-dialog {
  width: min(460px, 100%);
  display: grid;
  gap: 14px;
  padding: 18px;
}

.confirm-dialog strong {
  color: var(--ink);
  font-size: 26px;
  line-height: 1.1;
}

.confirm-dialog p {
  margin: 0;
  color: #475569;
  font-weight: 800;
  line-height: 1.35;
}

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.confirm-actions button {
  min-height: 54px;
  border: 0;
  border-radius: 8px;
  font-weight: 900;
}

.confirm-cancel {
  background: #e2e8f0;
  color: var(--ink);
}

.confirm-accept {
  background: var(--blue);
  color: #fff;
}

.admin-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 16px;
  min-height: calc(100dvh - 81px);
  padding: 16px;
}

.admin-nav {
  display: grid;
  gap: 8px;
  align-content: start;
  padding: 16px;
}

.admin-nav strong {
  margin-bottom: 8px;
  font-size: 26px;
}

.admin-nav button {
  min-height: 46px;
  border: 1px solid transparent;
  border-left: 6px solid transparent;
  border-radius: 8px;
  background: #f8fafc;
  color: var(--ink);
  text-align: left;
  font-weight: 900;
}

.admin-nav button.is-active {
  border-color: #bfdbfe;
  border-left-color: var(--blue);
  background: var(--blue-soft);
  color: var(--blue);
}

.admin-main {
  display: grid;
  gap: 16px;
  align-content: start;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.admin-header button,
.table-head button {
  min-height: 46px;
  padding: 0 16px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric {
  --metric-color: var(--blue);
  --metric-bg: var(--blue-soft);
  min-height: 128px;
  border-left: 6px solid var(--metric-color);
  background: linear-gradient(180deg, var(--metric-bg) 0, #fff 72%);
  padding: 16px;
}

.metric-finalized {
  --metric-color: var(--green);
  --metric-bg: var(--green-soft);
}

.metric-email {
  --metric-color: var(--red);
  --metric-bg: var(--red-soft);
}

.metric-drafts {
  --metric-color: var(--amber);
  --metric-bg: var(--amber-soft);
}

.metric-total {
  --metric-color: var(--violet);
  --metric-bg: var(--violet-soft);
}

.metric span,
.metric strong {
  display: block;
}

.metric strong {
  color: var(--metric-color);
  margin-top: 18px;
  font-size: 38px;
}

.table-panel {
  padding: 16px;
}

.table-head {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

@media (max-width: 920px) {
  body {
    overflow: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  .update-banner {
    grid-template-columns: 1fr auto;
  }

  .update-banner span {
    grid-column: 1 / -1;
  }

  .topbar {
    grid-template-columns: 1fr;
  }

  .topbar-actions {
    width: 100%;
    justify-content: stretch;
  }

  .language-toggle {
    flex: 1;
    grid-template-columns: repeat(2, 1fr);
  }

  .session-pill {
    flex: 1;
    justify-self: stretch;
  }

  .driver-grid,
  .review-layout,
  .admin-layout {
    height: auto;
    min-height: auto;
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .store-card,
  .review-top {
    grid-template-columns: 1fr;
  }

  .change-store-button {
    width: 100%;
  }

  .item-grid,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .summary-panel,
  .signature-panel {
    min-height: 520px;
  }
}

@media (min-width: 700px) and (max-width: 920px) {
  .app-shell {
    min-height: 100dvh;
  }

  .topbar {
    grid-template-columns: minmax(0, auto) minmax(0, 1fr);
    gap: 12px;
  }

  .brand {
    min-width: 0;
  }

  .brand-logo {
    width: 80px;
  }

  .topbar-actions {
    width: auto;
    justify-content: end;
  }

  .language-toggle {
    flex: 0 0 auto;
    grid-template-columns: repeat(2, minmax(76px, auto));
  }

  .language-toggle button {
    padding: 0 10px;
    font-size: 14px;
  }

  .session-pill {
    flex: 0 0 auto;
    min-width: 0;
  }

  .driver-grid {
    grid-template-areas:
      "order"
      "summary"
      "history";
    grid-template-rows: minmax(0, 1fr) auto minmax(180px, 24dvh);
    gap: 10px;
    height: calc(100dvh - var(--topbar-height));
    min-height: 0;
    padding: 10px;
    overflow: hidden;
  }

  .invoice-history-panel {
    grid-area: history;
    min-height: 0;
    max-height: none;
  }

  .order-panel {
    grid-area: order;
    min-height: 0;
    overflow: hidden;
  }

  .summary-panel {
    grid-area: summary;
    grid-template-columns: auto auto minmax(0, 1fr) minmax(190px, 220px);
    grid-template-rows: auto;
    align-items: center;
    min-height: 0;
  }

  .summary-panel > span {
    grid-column: 1;
  }

  .summary-panel .total {
    grid-column: 2;
    font-size: clamp(30px, 5vw, 42px);
  }

  .summary-panel .cart-list {
    grid-column: 3;
    max-height: 124px;
    overflow: auto;
  }

  .summary-panel .primary-action {
    grid-column: 4;
    min-height: 58px;
  }

  .cart-list p {
    padding: 14px;
  }

  .cart-line {
    padding: 8px 10px;
  }

  .item-grid,
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .review-top {
    grid-template-columns: 150px minmax(0, 1fr) auto;
  }

  .signature-panel {
    min-height: 500px;
  }
}

@page mobile-invoice {
  size: 4in auto;
  margin: 0.08in 0.12in;
}

@page letter-invoice {
  size: letter;
  margin: 0.55in;
}

@media print {
  * {
    box-shadow: none !important;
  }

  body {
    background: #fff;
    color: #111827;
  }

  body[data-print-format="mobile"] {
    width: 4in;
  }

  .app-shell {
    display: none !important;
  }

  .print-root {
    display: block;
  }

  body[data-print-format="mobile"] .print-root {
    width: 4in;
  }

  .print-document {
    display: none;
    color: #111827;
    font-family: Arial, Helvetica, sans-serif;
  }

  body[data-print-format="mobile"] .print-mobile,
  body[data-print-format="letter"] .print-letter {
    display: block;
  }

  body[data-print-format="mobile"] .print-mobile {
    page: mobile-invoice;
    width: 3.76in;
    font-size: 12pt;
  }

  body[data-print-format="letter"] .print-letter {
    page: letter-invoice;
    width: 100%;
    font-size: 11pt;
  }

  .print-document header,
  .letter-header,
  .print-mobile-total,
  .letter-totals {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12pt;
  }

  .print-document header strong,
  .letter-header strong {
    display: block;
    font-size: 15pt;
    line-height: 1.1;
  }

  .print-document header span,
  .letter-header span {
    display: block;
    color: #374151;
    font-weight: 700;
  }

  .print-mobile-store {
    margin-top: 7pt;
    padding-top: 6pt;
    border-top: 2pt solid #111827;
  }

  .letter-store h1 {
    margin: 0;
    font-size: 22pt;
    line-height: 1.05;
  }

  .print-mobile-store h1 {
    margin: 0;
    font-size: 18pt;
    line-height: 1.05;
  }

  .print-mobile-store p,
  .letter-store p {
    margin: 3pt 0 0;
    color: #374151;
    font-weight: 700;
  }

  .print-document table {
    width: 100%;
    margin-top: 8pt;
    border-collapse: collapse;
  }

  .print-document th {
    padding: 0 0 5pt;
    border-bottom: 1.5pt solid #111827;
    color: #374151;
    font-size: 9pt;
    text-align: left;
    text-transform: uppercase;
  }

  .print-document td {
    padding: 5pt 0;
    border-bottom: 1pt solid #d1d5db;
    break-inside: avoid;
    vertical-align: top;
  }

  .print-document td:nth-child(n + 2),
  .print-document th:nth-child(n + 2) {
    text-align: right;
  }

  .print-mobile td b {
    display: block;
    font-size: 13pt;
    font-weight: 900;
    line-height: 1.1;
  }

  .print-mobile td:nth-child(2),
  .print-mobile td:nth-child(3) {
    color: #000;
    font-size: 14pt;
    font-weight: 900;
  }

  .print-mobile td small {
    display: block;
    margin-top: 2pt;
    color: #4b5563;
    font-size: 9pt;
    font-weight: 700;
  }

  .print-mobile-total {
    margin-top: 7pt;
    padding-top: 7pt;
    border-top: 2pt solid #111827;
  }

  .print-mobile-total span {
    font-size: 13pt;
    font-weight: 800;
  }

  .print-mobile-total strong {
    font-size: 22pt;
    font-weight: 900;
    line-height: 1;
  }

  .print-mobile-meta {
    display: grid;
    gap: 2pt;
    margin-top: 6pt;
    color: #374151;
    font-size: 9pt;
    font-weight: 700;
  }

  .print-signature,
  .letter-signature {
    margin-top: 7pt;
    padding-top: 6pt;
    border-top: 1.5pt solid #111827;
  }

  .print-signature span,
  .letter-signature span {
    display: block;
    color: #4b5563;
    font-size: 9pt;
    font-weight: 800;
    text-transform: uppercase;
  }

  .print-signature img {
    display: block;
    max-width: 100%;
    max-height: 0.7in;
    margin-top: 4pt;
    filter: grayscale(1) contrast(220%);
    image-rendering: crisp-edges;
  }

  .print-signature strong,
  .letter-signature strong {
    display: block;
    margin-top: 5pt;
    color: #111827;
    font-size: 10pt;
  }

  .letter-header {
    padding-bottom: 18pt;
    border-bottom: 2pt solid #111827;
  }

  .letter-header strong {
    font-size: 22pt;
  }

  .letter-store {
    margin-top: 22pt;
  }

  .letter-store span {
    display: block;
    color: #4b5563;
    font-size: 9pt;
    font-weight: 800;
    text-transform: uppercase;
  }

  .letter-store h1 {
    margin-top: 4pt;
    font-size: 18pt;
  }

  .letter-totals {
    margin-top: 16pt;
    padding-top: 12pt;
    border-top: 2pt solid #111827;
  }

  .letter-totals span {
    color: #374151;
    font-weight: 800;
  }

  .letter-totals strong {
    font-size: 22pt;
  }

  .letter-signature {
    margin-top: 26pt;
  }

  .letter-signature img {
    display: block;
    max-width: 3.4in;
    max-height: 1in;
    margin-top: 8pt;
    filter: grayscale(1) contrast(220%);
    image-rendering: crisp-edges;
  }
}
