:root {
  color-scheme: light;
  --bg: #f6f7f3;
  --panel: #ffffff;
  --panel-soft: #eef3ef;
  --ink: #17201b;
  --muted: #66736b;
  --line: #dce4dc;
  --brand: #0f8b6f;
  --brand-strong: #09604e;
  --accent: #d8892f;
  --danger: #c33d3d;
  --warn: #c77c11;
  --ok: #2d7d46;
  --shadow: 0 18px 50px rgba(30, 45, 37, 0.1);
  --receipt-80mm-width: 430px;
  --label-40mm-width: 260px;
  --label-40mm-height: 195px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

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

button {
  border: 0;
  cursor: pointer;
}

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

.app-shell {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  background: #11231d;
  color: #f7fbf7;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 0;
  overflow-y: auto;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 8px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand strong {
  font-size: 21px;
}

.brand span {
  color: #b9c9c1;
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav button {
  width: 100%;
  text-align: left;
  border-radius: 8px;
  padding: 12px 12px;
  color: #d9e5df;
  background: transparent;
}

.nav button.active,
.nav button:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.nav-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.nav-arrow {
  color: #b9c9c1;
  font-size: 18px;
  line-height: 1;
}

.nav-main.active .nav-arrow,
.nav-main:hover .nav-arrow {
  color: #fff;
}

.nav-sub {
  display: grid;
  gap: 4px;
  margin: -2px 0 4px 14px;
  padding-left: 10px;
  border-left: 1px solid rgba(255, 255, 255, 0.16);
}

.nav-sub button {
  min-height: 34px;
  padding: 8px 10px;
  font-size: 13px;
  color: #b9c9c1;
}

.nav-sub button.active,
.nav-sub button:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 10px;
}

.sidebar-account-card {
  display: grid;
  gap: 6px;
  padding: 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-account-card span {
  color: #b9c9c1;
  font-size: 12px;
}

.sidebar-account-card strong {
  color: #fff;
}

.sidebar-account-card .ghost-btn {
  width: 100%;
  min-height: 34px;
  background: rgba(255, 255, 255, 0.08);
  color: #eaf5ef;
  border-color: rgba(255, 255, 255, 0.12);
}

.lang-toggle,
.plain-btn,
.primary-btn,
.danger-btn,
.ghost-btn {
  border-radius: 8px;
  min-height: 38px;
  padding: 9px 12px;
  border: 1px solid transparent;
}

.lang-toggle {
  background: #e4efe9;
  color: #10251e;
}

.main {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  height: 100vh;
  overflow: hidden;
}

.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h1 {
  font-size: 22px;
  margin: 0;
}

.topbar p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.content {
  padding: 24px 28px 32px;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

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

.login-card h1 {
  margin: 0;
  font-size: 24px;
}

.login-hint {
  display: grid;
  gap: 4px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.kpi span {
  color: var(--muted);
  font-size: 13px;
}

.kpi strong {
  display: block;
  font-size: 26px;
  margin-top: 6px;
}

.section,
.cart,
.modal-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.section {
  padding: 18px;
  min-width: 0;
}

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

.section-head h2 {
  margin: 0;
  font-size: 18px;
}

.section-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.categories {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.chip {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 8px 12px;
}

.chip.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.product-card {
  min-height: 134px;
  border: 1px solid var(--line);
  background: #fbfcfa;
  border-radius: 8px;
  padding: 14px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.product-card:hover {
  border-color: var(--brand);
}

.product-card strong {
  font-size: 17px;
}

.product-card span,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.price {
  margin-top: auto;
  color: var(--brand-strong);
  font-weight: 700;
}

.order-entry {
  min-width: 230px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fbfcfa;
  color: var(--ink);
  text-align: left;
}

.order-entry:hover {
  border-color: var(--brand);
  background: #eef7f3;
}

.order-entry span {
  display: grid;
  gap: 2px;
}

.order-entry strong {
  font-size: 15px;
}

.order-entry small {
  color: var(--muted);
}

.order-entry b {
  color: var(--brand-strong);
  white-space: nowrap;
}

.cart {
  position: sticky;
  top: 96px;
  padding: 16px;
}

.cart-layer {
  position: relative;
  top: auto;
  width: min(430px, 100%);
  max-height: 92vh;
  overflow: auto;
  padding: 16px;
}

.cart-layer .cart-list {
  max-height: 42vh;
}

.clear-order-btn {
  width: 100%;
}

.cart-list {
  display: grid;
  gap: 10px;
  max-height: 41vh;
  overflow: auto;
  padding-right: 4px;
}

.cart-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  background: #fbfcfa;
}

.cart-row,
.total-row,
.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.cart-meta {
  color: var(--muted);
  font-size: 12px;
  margin: 5px 0 8px;
}

.qty {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px;
}

.qty button {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--panel-soft);
}

.cart-totals {
  border-top: 1px solid var(--line);
  margin-top: 14px;
  padding-top: 14px;
  display: grid;
  gap: 9px;
}

.service-type-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.service-type-toggle button {
  min-height: 38px;
  border-radius: 6px;
  background: var(--panel-soft);
  color: var(--ink);
  font-weight: 700;
}

.service-type-toggle button.active {
  background: var(--brand);
  color: #fff;
}

.order-print-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 5px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  color: var(--muted);
  font-size: 13px;
}

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

.order-print-card strong {
  color: var(--ink);
  font-size: 14px;
}

.order-print-card button {
  margin-top: 6px;
  width: 100%;
}

.order-warning {
  color: var(--danger);
  font-size: 13px;
}

.work-order-board {
  overflow: hidden;
}

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

.work-order-column {
  min-height: 230px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.work-order-column-head,
.work-order-head,
.work-order-meta,
.work-order-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.work-order-column-head strong {
  font-size: 15px;
}

.work-order-column-head span {
  min-width: 28px;
  min-height: 24px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  color: var(--brand-strong);
  font-weight: 700;
}

.work-order-column small {
  display: block;
  color: var(--muted);
  margin: 5px 0 10px;
}

.work-order-list {
  display: grid;
  gap: 10px;
  max-height: 420px;
  overflow: auto;
  padding-right: 2px;
}

.work-order-card {
  display: grid;
  gap: 9px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.work-order-head span,
.work-order-meta {
  color: var(--muted);
  font-size: 12px;
}

.work-order-items {
  display: grid;
  gap: 4px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.35;
}

.work-order-actions {
  align-items: stretch;
}

.work-order-actions button {
  flex: 1;
  min-height: 34px;
  padding: 7px 8px;
  font-size: 13px;
}

.total-row.big {
  font-size: 20px;
  font-weight: 800;
}

.primary-btn {
  background: var(--brand);
  color: #fff;
}

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

.plain-btn {
  background: var(--panel-soft);
  color: var(--ink);
}

.danger-btn {
  background: #f8e7e7;
  color: var(--danger);
}

.ghost-btn {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}

.button-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.checkout-grid,
.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: var(--muted);
  font-size: 13px;
}

.field input,
.field select,
.field textarea {
  min-height: 39px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
  width: 100%;
}

.field textarea {
  min-height: 72px;
  resize: vertical;
}

.field textarea.template-textarea {
  min-height: 560px;
  font-family: Consolas, "Courier New", monospace;
  line-height: 1.45;
}

.template-edit-panel,
.template-preview-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.template-edit-panel {
  align-items: start;
  justify-items: center;
  background: #fff;
}

.field textarea.template-receipt-editor {
  width: min(var(--receipt-80mm-width), 100%);
  border-color: var(--line);
  background: #fff;
  color: #111;
  font-size: 13px;
  line-height: 1.48;
  padding: 18px 14px;
  white-space: pre;
  box-shadow: 0 10px 26px rgba(30, 45, 37, 0.08);
}

.receipt-paper-editor {
  width: min(var(--receipt-80mm-width), 100%);
  min-height: 620px;
  padding: 20px 3ch 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 10px 26px rgba(30, 45, 37, 0.08);
  color: #111;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.5;
  box-sizing: border-box;
}

.receipt-paper-editor input,
.receipt-paper-editor textarea {
  min-height: 24px;
  border: 0;
  border-radius: 0;
  padding: 0 2px;
  background: transparent;
  color: #111;
  font-family: inherit;
  font-size: inherit;
}

.receipt-paper-editor textarea {
  resize: vertical;
  overflow: auto;
}

.receipt-paper-editor input:focus,
.receipt-paper-editor textarea:focus {
  outline: 1px solid var(--brand);
  background: #f4fbf8;
}

.receipt-center-input,
.receipt-center-textarea,
.receipt-center-line {
  width: 100%;
  text-align: center;
}

.receipt-center-textarea {
  line-height: 1.5;
}

.receipt-title-input {
  font-weight: 700;
}

.receipt-left-line,
.receipt-left-input,
.receipt-left-textarea {
  width: 100%;
  text-align: left;
}

.receipt-left-textarea {
  line-height: 1.5;
}

.receipt-empty-line {
  min-height: 1.5em;
}

.receipt-separator {
  height: 1.5em;
  overflow: hidden;
}

.receipt-separator::before {
  content: "------------------------------------------------";
}

.receipt-space {
  height: 26px;
}

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

.receipt-total {
  grid-template-columns: 56px minmax(0, 1fr) 74px auto;
  font-weight: 700;
}

.receipt-total span:first-child {
  grid-column: 1 / 3;
}

.receipt-total span:last-child {
  grid-column: 3;
  text-align: right;
}

.receipt-tax-edit {
  grid-template-columns: 56px minmax(0, 1fr) 74px auto;
}

.receipt-tax-rate,
.receipt-tax-name {
  text-align: left;
}

.receipt-amount {
  text-align: right;
}

.receipt-item-row,
.receipt-tax-display {
  grid-template-columns: 56px minmax(0, 1fr) 74px auto;
}

.receipt-item-row span:first-child,
.receipt-tax-display span:first-child {
  grid-column: 1 / 3;
  text-align: left;
}

.receipt-item-row span:last-child,
.receipt-tax-display span:last-child {
  grid-column: 3;
  text-align: right;
}

.receipt-modifier-line {
  padding-left: 2ch;
}

.receipt-tax-remove {
  min-height: 24px;
  padding: 1px 6px;
  border-radius: 6px;
  background: #f8e7e7;
  color: var(--danger);
  font-size: 12px;
}

.receipt-add-tax {
  width: 100%;
  margin-top: 8px;
}

.receipt-paper-preview {
  box-shadow: none;
}

.field textarea.label-paper-editor,
.label-paper-editor {
  width: min(var(--label-40mm-width), 100%);
  height: var(--label-40mm-height);
  min-height: var(--label-40mm-height);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 4ch;
  background: #fff;
  color: #111;
  font-family: Consolas, "Courier New", monospace;
  font-size: 15px;
  line-height: 1.35;
  text-align: center;
  white-space: pre-wrap;
  overflow: auto;
  resize: none;
  box-shadow: 0 10px 26px rgba(30, 45, 37, 0.08);
}

.field textarea.label-paper-editor:focus {
  outline: 1px solid var(--brand);
  background: #f8fcfa;
}

.label-paper-preview {
  margin: 0;
  box-shadow: none;
}

.template-preview-panel {
  background: #fff;
}

.template-preview {
  min-height: 520px;
  width: min(var(--receipt-80mm-width), 100%);
  margin: 0;
  padding: 14px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  color: var(--ink);
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  box-shadow: 0 10px 26px rgba(30, 45, 37, 0.08);
}

.template-action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.template-entry {
  min-height: 96px;
  width: 100%;
  padding: 18px;
  border: 1px solid #b8d8c8;
  border-radius: 8px;
  background: #e8f5ee;
  color: var(--brand-strong);
  text-align: left;
  display: grid;
  gap: 8px;
  align-content: center;
}

.template-entry:hover {
  border-color: var(--brand);
  background: #dff1e9;
}

.template-entry strong {
  color: var(--ink);
  font-size: 20px;
}

.template-entry span {
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 1080px) {
  .template-editor-grid {
    grid-template-columns: 1fr;
  }

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

.stack {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.table-wrap {
  overflow: auto;
  min-width: 0;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  background: #fff;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  background: #f3f6f1;
}

tr:last-child td {
  border-bottom: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  min-height: 24px;
  padding: 3px 9px;
  font-size: 12px;
  background: var(--panel-soft);
  color: var(--muted);
}

.badge.ok {
  background: #e8f5eb;
  color: var(--ok);
}

.badge.warn {
  background: #fff3dd;
  color: var(--warn);
}

.badge.danger {
  background: #fae6e6;
  color: var(--danger);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 18, 14, 0.42);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
}

.modal-card {
  width: min(740px, 100%);
  max-height: 92vh;
  overflow: auto;
  padding: 18px;
}

.product-admin-modal {
  width: min(820px, calc(100vw - 48px));
  overflow-x: hidden;
}

.simple-addon-table {
  overflow-x: hidden;
}

.simple-addon-table table {
  min-width: 0;
  table-layout: fixed;
}

.simple-addon-table th:nth-child(1),
.simple-addon-table th:nth-child(2) {
  width: 32%;
}

.simple-addon-table th:nth-child(3) {
  width: 22%;
}

.simple-addon-table th:nth-child(4) {
  width: 14%;
}

.simple-addon-table input {
  width: 100%;
  min-width: 0;
}

.simple-addon-table .danger-btn {
  width: 100%;
  padding-inline: 8px;
}

.recipe-modal-card {
  width: min(1120px, calc(100vw - 48px));
}

.recipe-modal-card table {
  min-width: 900px;
}

.recipe-modal-card input {
  width: 100%;
  min-width: 0;
}

.recipe-addon-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  display: grid;
  gap: 10px;
}

.recipe-addon-card h3 {
  margin: 0;
  font-size: 15px;
}

.recipe-search-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.recipe-search-bar .plain-btn {
  min-height: 42px;
  white-space: nowrap;
}

.option-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.option {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 10px;
  text-align: left;
}

.option.active {
  border-color: var(--brand);
  background: #eaf6f1;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: 360px;
  padding: 13px 15px;
  border-radius: 8px;
  background: #10231d;
  color: #fff;
  box-shadow: var(--shadow);
  z-index: 80;
}

.empty {
  padding: 32px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

@media (max-width: 1080px) {
  body {
    height: auto;
    min-height: 100vh;
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    flex-direction: row;
    align-items: center;
    overflow: auto;
    padding: 12px;
  }

  .main {
    height: auto;
    overflow: visible;
  }

  .content {
    overflow: visible;
  }

  .brand {
    min-width: 160px;
    border-bottom: 0;
    padding: 0;
  }

  .nav {
    display: flex;
    min-width: max-content;
  }

  .sidebar-footer {
    margin-top: 0;
    min-width: 100px;
  }

  .work-order-columns,
  .checkout-grid,
  .two-col {
    grid-template-columns: 1fr;
  }

  .cart {
    position: static;
  }

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

@media (max-width: 620px) {
  .topbar {
    height: auto;
    align-items: flex-start;
    flex-direction: column;
    padding: 16px;
    gap: 10px;
  }

  .content {
    padding: 16px;
  }

  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .order-entry {
    width: 100%;
  }

  .kpi-grid,
  .product-grid {
    grid-template-columns: 1fr;
  }
}
