/* ==========================================================================
   点单系统中控台 · 基础样式
   ========================================================================== */

:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --text: #0f172a;
  --text-soft: #475569;
  --text-faint: #94a3b8;

  --brand: #2563eb;
  --brand-soft: #eff6ff;
  --brand-strong: #1d4ed8;

  --success: #15803d;
  --success-soft: #f0fdf4;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --danger: #dc2626;
  --danger-soft: #fef2f2;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgb(15 23 42 / 6%), 0 8px 24px -12px rgb(15 23 42 / 12%);

  --topbar-h: 56px;
  --sidebar-w: 208px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

code {
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
}

.num {
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ---------- 顶栏 ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  height: var(--topbar-h);
  padding: 0 20px;
  background: #0f172a;
  color: #e2e8f0;
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.topbar__logo {
  font-size: 18px;
}

.topbar__spacer {
  flex: 1;
}

.operator {
  display: flex;
  align-items: center;
  gap: 8px;
}

.operator__label {
  font-size: 12px;
  color: #94a3b8;
}

.operator__select {
  appearance: none;
  padding: 6px 28px 6px 10px;
  border: 1px solid #334155;
  border-radius: var(--radius-sm);
  background: #1e293b
    url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8.5 1.5 4h9z'/%3E%3C/svg%3E")
    no-repeat right 9px center;
  color: #e2e8f0;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.operator__select:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

/* ---------- 骨架 ---------- */

.shell {
  display: flex;
  align-items: flex-start;
  min-height: calc(100vh - var(--topbar-h));
}

.sidebar {
  position: sticky;
  top: var(--topbar-h);
  flex: 0 0 var(--sidebar-w);
  width: var(--sidebar-w);
  height: calc(100vh - var(--topbar-h));
  padding: 16px 12px;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.sidebar__group + .sidebar__group {
  margin-top: 18px;
}

.sidebar__group-label {
  margin: 0 0 6px 10px;
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.sidebar__link {
  display: block;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  font-size: 13.5px;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.sidebar__link:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.sidebar__link.is-active {
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-weight: 600;
}

.content {
  flex: 1;
  min-width: 0;
  max-width: 1180px;
  padding: 24px 28px 64px;
}

/* ---------- 页头 ---------- */

.page-head {
  margin-bottom: 20px;
}

.page-head__title {
  margin: 0;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.page-head__sub {
  margin: 4px 0 0;
  color: var(--text-soft);
  font-size: 13px;
}

/* ---------- 面板 ---------- */

.panel {
  margin-bottom: 20px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel--muted {
  background: var(--surface-muted);
  box-shadow: none;
}

.panel__title {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 650;
}

.panel__hint {
  margin: 0 0 12px;
  color: var(--text-soft);
  font-size: 13px;
}

.panel__hint:last-child {
  margin-bottom: 0;
}

/* ---------- 统计 ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin: 12px 0 0;
}

.stats__item {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
}

.stats__item dt {
  color: var(--text-faint);
  font-size: 12px;
}

.stats__item dd {
  margin: 2px 0 0;
  font-size: 16px;
  font-weight: 600;
}

/* ---------- 表格 ---------- */

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.table th,
.table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.nowrap {
  white-space: nowrap;
}

.table thead th {
  border-bottom: 1px solid var(--border-strong);
  color: var(--text-faint);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover {
  background: var(--surface-muted);
}

.table .num {
  text-align: right;
}

.table th.num {
  text-align: right;
}

/* ---------- 徽标 ---------- */

.badge {
  display: inline-block;
  padding: 1px 9px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1.7;
  white-space: nowrap;
}

.badge--brand {
  border-color: #bfdbfe;
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.badge--success {
  border-color: #bbf7d0;
  background: var(--success-soft);
  color: var(--success);
}

.badge--warn {
  border-color: #fde68a;
  background: var(--warn-soft);
  color: var(--warn);
}

.badge--danger {
  border-color: #fecaca;
  background: var(--danger-soft);
  color: var(--danger);
}

/* ---------- 提示条 ---------- */

.alert {
  margin: 0 0 12px;
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  font-size: 13.5px;
}

.alert:last-child {
  margin-bottom: 0;
}

.alert--error {
  border-color: #fecaca;
  background: var(--danger-soft);
  color: var(--danger);
}

.alert--warn {
  border-color: #fde68a;
  background: var(--warn-soft);
  color: var(--warn);
}

.alert--success {
  border-color: #bbf7d0;
  background: var(--success-soft);
  color: var(--success);
}

/* ---------- 按钮 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  padding: 7px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}

.btn:hover {
  background: var(--surface-muted);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

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

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

.btn--danger:hover {
  filter: brightness(0.94);
}

.btn--sm {
  padding: 4px 10px;
  font-size: 12.5px;
}

/* ---------- 表单 ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.field__label {
  color: var(--text-soft);
  font-size: 12.5px;
}

.field__input,
.field__select,
.field__textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
}

.field__input:focus-visible,
.field__select:focus-visible,
.field__textarea:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: -1px;
  border-color: var(--brand);
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.form-row .field {
  flex: 1 1 180px;
  margin-bottom: 0;
}

/* ---------- 栅格 ---------- */

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

.empty {
  padding: 32px 16px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-faint);
  text-align: center;
  font-size: 13.5px;
}

/* ==========================================================================
   基础数据维护（菜品 / 套餐）
   ========================================================================== */

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

.panel__head .panel__title {
  margin: 0;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 13px;
}

.tab:hover {
  border-color: var(--brand);
  color: var(--brand-strong);
}

.tab.is-active {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-weight: 600;
}

.tab__count {
  color: var(--text-faint);
  font-size: 12px;
}

.tab.is-active .tab__count {
  color: var(--brand-strong);
}

/* 表单里的错误提示：没有内容时不占位 */
.form-error:empty {
  display: none;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.link {
  color: var(--brand-strong);
  font-weight: 550;
}

.link:hover {
  text-decoration: underline;
}

.right {
  text-align: right;
}

.muted {
  color: var(--text-faint);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.thumb {
  display: flex;
  align-items: center;
  gap: 14px;
}

.thumb {
  flex-wrap: wrap;
}

.thumb > .stack {
  flex: 1 1 220px;
  min-width: 0;
}

.thumb input[type="file"] {
  width: 100%;
  min-width: 0;
  font-size: 12px;
}

.thumb__img {
  flex: none;
  width: 96px;
  height: 96px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--surface-muted);
}

.thumb__empty {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 96px;
  height: 96px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-faint);
  font-size: 12px;
  background: var(--surface-muted);
}

/* 表格单元格里的行内小表单 */
.inline-form {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.table td .inline-form + .inline-form {
  margin-left: 6px;
}

.danger-zone {
  border-color: #fecaca;
}

.subpanel {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
}

.subpanel + .subpanel {
  margin-top: 12px;
}

.subpanel__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.subpanel__title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

/* 头部的左侧分组：标题、徽标、编号挨在一起，右侧备注靠最右。 */
.subpanel__lead {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
}

.subpanel__meta {
  margin-left: auto;
}

/* ---------------------------------------------------------------- 桌台总览 */

.board {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.area__head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
}

.area__title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.area__count {
  font-size: 12px;
  color: var(--text-faint);
}

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

.tcard {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
}

.tcard--idle {
  border-left-color: var(--success);
}

.tcard--occupied {
  border-left-color: var(--brand);
  background: var(--brand-soft);
}

.tcard--awaiting_clear {
  border-left-color: var(--warn);
}

.tcard--disabled {
  border-left-color: var(--border-strong);
  background: var(--surface-muted);
  opacity: 0.7;
}

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

.tcard__name {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.tcard__seats {
  margin: 0;
  font-size: 12px;
  color: var(--text-faint);
}

.tcard__facts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin: 0;
  font-size: 12px;
}

.tcard__facts div {
  display: flex;
  gap: 4px;
}

.tcard__facts dt {
  color: var(--text-faint);
}

.tcard__facts dd {
  margin: 0;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
}

.tcard__form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-top: auto;
}

.tcard__guest {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  font-size: 12px;
  color: var(--text-faint);
}

.tcard__guest .field__input {
  padding: 5px 8px;
}

.tcard .form-error {
  flex-basis: 100%;
}

.field__input--num {
  width: 84px;
}

/* ------------------------------------------------------------ 点单 */

.order {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 16px;
  align-items: start;
}

.order__menu,
.order__side {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.order__side {
  position: sticky;
  top: 16px;
}

@media (max-width: 1180px) {
  .order {
    grid-template-columns: minmax(0, 1fr);
  }

  .order__side {
    position: static;
  }
}

.panel--accent {
  border-left: 3px solid var(--brand);
}

.picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 8px;
}

.pick {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  font: inherit;
  text-align: left;
  color: var(--text);
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 120ms, box-shadow 120ms;
}

.pick:hover {
  border-color: var(--brand);
  box-shadow: 0 1px 6px rgb(37 99 235 / 12%);
}

.pick--out {
  opacity: 0.55;
}

.pick__name {
  font-weight: 600;
}

.pick__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.pick__price {
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
}

.choice {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 4px 0;
  cursor: pointer;
}

.choice input {
  flex: none;
}

.choice__price {
  margin-left: auto;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
}

.cartlist,
.orderlist {
  margin: 0;
  padding: 0;
  list-style: none;
}

.cartline {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.cartline:last-child {
  border-bottom: 0;
}

.cartline--bad {
  background: #fff7f7;
  margin: 0 -12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
}

.cartline__top,
.orderline__top {
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.cartline__title,
.orderline__title {
  font-weight: 600;
}

.cartline__amount,
.orderline__amount {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

.cartline__details,
.orderline__extra,
.orderline__note {
  margin: 2px 0 0;
  color: var(--text-soft);
  font-size: 12px;
}

.cartline__problem {
  margin: 4px 0 0;
  color: var(--danger);
  font-size: 12px;
}

.cartline__ops {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-top: 8px;
}

.cartfoot {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 12px 0;
  margin-top: 4px;
  border-top: 2px solid var(--border-strong);
  font-weight: 600;
}

.cartfoot__amount {
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.form-actions--split {
  justify-content: space-between;
}

.round + .round {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border-strong);
}

.round__head {
  display: flex;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 4px;
  color: var(--text-soft);
  font-size: 12px;
}

.round__no {
  font-weight: 600;
  color: var(--brand);
}

.round__who {
  margin-left: auto;
}

.orderline {
  padding: 6px 0;
}

.orderline--refunded .orderline__title {
  text-decoration: line-through;
  color: var(--text-faint);
}

.orderline__qty {
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
}

.orderline__refund {
  margin: 2px 0 0;
  color: var(--danger);
  font-size: 12px;
}

.totals {
  margin: 12px 0 0;
  padding-top: 12px;
  border-top: 2px solid var(--border-strong);
}

.totals > div {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
}

.totals dt {
  color: var(--text-soft);
}

.totals dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.totals__pay {
  margin-top: 4px;
  font-size: 16px;
  font-weight: 600;
}

.tcard__actions {
  margin: 8px 0 0;
}

.ticket {
  margin: 0;
  padding: 16px;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre;
  background: #fbfbf8;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

/* ---------------------------------------------------------------- 退菜 */

/* 行内退菜：平时收成一行小字，点开才占地方。 */
.refundbox {
  margin-top: 6px;
}

.refundbox > summary {
  cursor: pointer;
  font-size: 12px;
  list-style: none;
}

.refundbox > summary::-webkit-details-marker {
  display: none;
}

.refundbox > summary::before {
  content: "▸ ";
  color: var(--text-faint);
}

.refundbox[open] > summary::before {
  content: "▾ ";
}

.refundform {
  margin-top: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
}

.refundform .field__input,
.refundform .field__select {
  padding: 5px 8px;
  font-size: 13px;
}

.refundform .form-row {
  gap: 8px;
}

.refundform .form-actions {
  margin-top: 8px;
  padding-top: 0;
  border-top: none;
}

/* 表格里并排的两个按钮 */
.ops {
  display: inline-flex;
  gap: 6px;
  justify-content: flex-end;
}

/* 账单与结账（P5） */
.stat-em {
  color: var(--brand);
  font-weight: 700;
}

.payrow .field {
  flex: 1 1 200px;
}

.payline {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 14px;
}

.payline:last-child {
  border-bottom: none;
}

.payline .num {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

/* 账单明细紧跟在统计条之后时，给一点分界 */
.panel > .stats + .round {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}

/* 收款表单固定几行，标签只在第一行出现，所以留出等高的空行 */
.payrow .field__label {
  display: block;
  min-height: 1.1rem;
}
