:root {
  --bg: #f5f6f3;
  --surface: #ffffff;
  --surface-muted: #eef2eb;
  --text: #20231f;
  --muted: #687066;
  --line: #dfe5da;
  --accent: #16784f;
  --accent-dark: #0e5f3c;
  --warning: #b75f14;
  --info: #315f9b;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-width: 320px;
  color: var(--text);
  background: var(--bg);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
}

body.modal-open {
  overflow: hidden;
}

button,
input,
select {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--text);
  background: var(--surface);
  font: inherit;
}

button {
  cursor: pointer;
}

button:hover {
  border-color: #b8c7b4;
}

.hidden {
  display: none !important;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: #fbfcfa;
  padding: 22px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 26px;
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  object-fit: cover;
  box-shadow: 0 1px 3px rgba(32, 35, 31, 0.14);
}

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

.brand small {
  margin-top: 3px;
  color: var(--muted);
}

.nav {
  display: grid;
  align-content: start;
  gap: 6px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 14px;
}

.nav button {
  justify-content: flex-start;
  width: 100%;
  border: 0;
  text-align: left;
  color: var(--muted);
  background: transparent;
  font-family: inherit;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.2;
}

.nav button.active,
.nav button:hover {
  color: var(--accent-dark);
  background: var(--surface-muted);
}

.sidebar-account {
  display: grid;
  position: relative;
  grid-template-columns: 42px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 10px 12px;
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.sidebar-account strong {
  overflow: hidden;
  color: #687066;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-account img {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-muted);
  box-shadow: 0 1px 3px rgba(32, 35, 31, 0.1);
}

.account-menu-button {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  color: var(--muted);
  font-size: 20px;
  font-weight: 900;
  background: transparent;
}

.account-menu-button:hover {
  color: var(--text);
  background: var(--surface-muted);
}

.account-menu {
  position: absolute;
  right: 0;
  bottom: 56px;
  z-index: 5;
  display: grid;
  width: 168px;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  background: var(--surface);
  box-shadow: 0 16px 34px rgba(32, 35, 31, 0.16);
}

.account-menu button {
  width: 100%;
  border: 0;
  text-align: left;
  font-weight: 700;
  background: transparent;
}

.account-menu button:hover {
  background: var(--surface-muted);
}

.content {
  min-width: 0;
  padding: 26px;
}

.login-body {
  width: 100vw;
  min-height: 100vh;
  overflow: hidden;
  background: #fbfcfa;
}

.login-page {
  display: grid;
  width: 100vw;
  height: 100vh;
  place-items: center;
  padding: 32px;
  overflow: auto;
}

.login-panel {
  display: grid;
  min-height: calc(100vh - 52px);
  place-items: center;
}

.login-card {
  display: grid;
  width: min(420px, 100%);
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  background: var(--surface);
}

.standalone-login-card {
  width: min(560px, calc(100vw - 64px));
  max-width: 560px;
  gap: 12px;
  border-radius: 12px;
  padding: 32px 38px;
}

.login-logo {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  object-fit: cover;
}

.standalone-login-card .login-logo {
  justify-self: center;
  width: 64px;
  height: 64px;
  border-radius: 12px;
}

.login-card h1,
.login-card p {
  margin: 0;
}

.standalone-login-card h1 {
  text-align: center;
  margin-top: 10px;
  font-size: 34px;
  line-height: 1.1;
}

.standalone-login-card p {
  color: #697168;
  font-size: 17px;
  font-weight: 800;
}

.login-card p,
.login-card small,
.muted {
  color: var(--muted);
}

.login-card label,
.form-grid label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
}

.standalone-login-card label {
  gap: 7px;
  color: #697168;
  font-size: 17px;
  font-weight: 800;
}

.standalone-login-card input {
  height: 46px;
  border-radius: 8px;
  padding: 0 16px;
  font-size: 17px;
}

.login-submit {
  height: 46px;
  border-radius: 8px;
  font-size: 18px;
  font-weight: 900;
}

.standalone-login-card small {
  color: #697168;
  font-size: 14px;
  line-height: 1.35;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

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

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
}

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

.toolbar select {
  min-width: 180px;
}

.primary-button {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

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

.metrics article,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.metrics article {
  min-height: 108px;
  padding: 18px;
}

.metrics span {
  display: block;
  color: var(--muted);
  font-size: 14px;
}

.metrics strong {
  display: block;
  margin-top: 10px;
  font-size: 28px;
}

.view-root {
  display: grid;
  gap: 18px;
}

.split-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(360px, 1.1fr);
  gap: 18px;
}

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

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

.panel-header h2 {
  margin: 0;
  font-size: 18px;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

td.actions {
  white-space: nowrap;
}

td.actions button {
  margin: 0 6px 6px 0;
}

.assisted-order-panel {
  padding: 18px;
}

.assisted-layout {
  display: grid;
  grid-template-columns: minmax(520px, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

.assisted-menu {
  min-width: 0;
}

.assisted-category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.assisted-category-tabs button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  color: var(--muted);
  background: #fff;
}

.assisted-category-tabs button.active {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

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

.assisted-dish-card {
  display: grid;
  grid-template-columns: 82px 1fr;
  gap: 12px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.assisted-dish-card img,
.assisted-dish-placeholder {
  width: 82px;
  height: 82px;
  border-radius: 8px;
  object-fit: cover;
  background: #f4f4f0;
}

.assisted-dish-placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
}

.assisted-dish-body {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.assisted-dish-body strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.assisted-dish-body span {
  color: var(--danger);
  font-weight: 800;
}

.assisted-stepper {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.assisted-stepper button {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0;
  color: var(--accent);
  background: #fff;
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
}

.assisted-stepper em {
  min-width: 24px;
  color: var(--text);
  font-style: normal;
  font-weight: 800;
  text-align: center;
}

.assisted-cart {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fff;
}

.assisted-cart h3 {
  margin: 0;
  font-size: 18px;
}

.assisted-cart label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.assisted-cart input,
.assisted-cart select,
.assisted-cart textarea {
  width: 100%;
}

.assisted-mode {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.assisted-mode label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #fbfbf8;
}

.assisted-mode input {
  width: auto;
  margin-right: 6px;
}

.assisted-cart-list {
  display: grid;
  gap: 10px;
  max-height: 260px;
  overflow: auto;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.assisted-cart-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.assisted-cart-item strong,
.assisted-cart-item span {
  display: block;
}

.assisted-cart-item span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.assisted-stepper.compact button {
  width: 28px;
  height: 28px;
}

.assisted-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.assisted-total strong {
  color: var(--danger);
  font-size: 22px;
}

.assisted-submit {
  width: 100%;
  min-height: 44px;
  border-radius: 999px;
}

.assisted-empty {
  grid-column: 1 / -1;
}

.rank-list,
.order-list {
  display: grid;
  gap: 10px;
}

.rank-item,
.order-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
}

.rank-index {
  display: inline-grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 6px;
  color: #fff;
  background: var(--info);
  font-size: 13px;
  font-weight: 700;
}

.item-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.item-title strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border-radius: 999px;
  padding: 3px 9px;
  color: var(--warning);
  background: #fff4e8;
  font-size: 12px;
  white-space: nowrap;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 14px;
}

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

th {
  color: var(--muted);
  font-weight: 600;
  background: #fafbf9;
}

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

.empty {
  height: 96px;
  color: var(--muted);
  text-align: center;
}

.form-panel {
  max-width: 920px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.form-grid .wide {
  grid-column: span 2;
}

.miniapp-config-list {
  display: grid;
  gap: 14px;
  margin-bottom: 16px;
}

.miniapp-config-item {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(0, 1fr);
  align-items: center;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fbfcfa;
}

.miniapp-config-item h3 {
  margin: 0 0 6px;
  font-size: 16px;
}

.miniapp-config-item p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.miniapp-config-control {
  display: grid;
  grid-template-columns: auto minmax(220px, 1fr);
  align-items: center;
  gap: 12px;
}

.miniapp-config-control input[type="file"] {
  height: auto;
  padding: 9px 12px;
}

.upload-control {
  display: grid;
  gap: 6px;
}

.upload-control small {
  color: var(--muted);
  font-size: 12px;
}

.miniapp-config-control > input:not([type="file"]) {
  width: 100%;
}

.miniapp-config-control.single-control {
  grid-template-columns: repeat(3, minmax(180px, 1fr));
}

.miniapp-config-control.single-control label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.miniapp-config-control.single-control input,
.miniapp-config-control.single-control select {
  width: 100%;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.miniapp-copy-control {
  grid-template-columns: 1fr;
}

.miniapp-banner-upload-list {
  grid-template-columns: 1fr;
}

.miniapp-banner-upload {
  display: grid;
  grid-template-columns: auto minmax(220px, 1fr);
  align-items: center;
  gap: 12px;
}

.hero-preview,
.hero-placeholder {
  width: 150px;
  height: 112px;
  border-radius: 8px;
  object-fit: cover;
}

.entry-sort-list {
  display: grid;
  grid-column: 1 / -1;
  gap: 8px;
}

.entry-sort-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--surface);
}

.entry-check {
  display: inline-flex;
  min-width: 140px;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 700;
}

.entry-check input {
  width: 16px;
  height: 16px;
  padding: 0;
}

.entry-sort-actions {
  display: inline-flex;
  gap: 6px;
}

.entry-sort-actions button {
  height: 30px;
  padding: 0 10px;
  font-size: 13px;
}

.banner-preview,
.banner-placeholder {
  width: 128px;
  height: 64px;
  border-radius: 8px;
}

.image-placeholder {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 50%;
  color: var(--muted);
  background: var(--surface);
  font-size: 12px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 10;
  max-width: 360px;
  border-radius: 8px;
  padding: 12px 14px;
  color: #fff;
  background: #26332c;
  box-shadow: 0 10px 24px rgba(32, 35, 31, 0.18);
}

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

.modal-card {
  width: min(560px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(32, 35, 31, 0.22);
}

.confirm-card {
  max-width: 460px;
}

.confirm-message {
  margin: 18px 0 22px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
}

.modal-header,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-header h2 {
  margin: 0;
  font-size: 20px;
}

.icon-button {
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}

.modal-fields {
  display: grid;
  gap: 14px;
  margin: 18px 0 20px;
}

.modal-fields label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.modal-fields input,
.modal-fields select,
.modal-fields textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  background: #fff;
  font: inherit;
}

.modal-fields input,
.modal-fields select {
  height: 42px;
  padding: 0 12px;
}

.modal-fields textarea {
  min-height: 86px;
  resize: vertical;
  padding: 10px 12px;
}

.modal-fields input[type="file"] {
  height: auto;
  padding: 10px 12px;
}

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

.input-action-row button {
  height: 42px;
  white-space: nowrap;
}

.modal-fields small {
  color: var(--muted);
  font-weight: 500;
}

.field-example {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 12px;
  color: #3d453b;
  background: #f7f9f5;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.55;
  white-space: pre-wrap;
  user-select: text;
}

.upload-preview {
  width: 54px;
  height: 54px;
  border: 1px solid var(--line);
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-muted);
}

.table-image {
  display: block;
  width: 58px;
  height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface-muted);
}

.modal-fields input:focus,
.modal-fields select:focus,
.modal-fields textarea:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(31, 132, 86, 0.12);
}

.modal-fields .check-field {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 10px;
  color: var(--text);
}

.modal-fields .check-field input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.modal-actions {
  justify-content: flex-end;
}

.danger-button {
  border-color: var(--danger);
  color: #fff;
  background: var(--danger);
}

.danger-button:hover {
  background: #8f1d14;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: grid;
    position: static;
    height: auto;
    gap: 14px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    overflow: visible;
    padding-bottom: 0;
  }

  .sidebar-account {
    margin-top: 0;
  }

  .metrics,
  .split-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-grid .wide {
    grid-column: auto;
  }

  .miniapp-config-item,
  .miniapp-config-control,
  .miniapp-config-control.single-control {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .content {
    padding: 18px;
  }

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

  .toolbar {
    justify-content: flex-start;
  }

  .toolbar select,
  .toolbar button {
    width: 100%;
  }

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

  .standalone-login-card {
    padding: 32px 22px;
  }

  .standalone-login-card .login-logo {
    width: 82px;
    height: 82px;
  }

  .standalone-login-card h1 {
    font-size: 40px;
  }

  .standalone-login-card p,
  .standalone-login-card label,
  .login-submit {
    font-size: 20px;
  }

  .standalone-login-card input,
  .login-submit {
    height: 56px;
  }

  .standalone-login-card small {
    font-size: 16px;
  }
}
