:root {
  --primary: #409eff;
  --primary-hover: #66b1ff;
  --primary-light: #ecf5ff;
  --bg: #f0f2f5;
  --panel: #fff;
  --ink: #303133;
  --regular: #606266;
  --muted: #909399;
  --line: #dcdfe6;
  --line-light: #ebeef5;
  --sidebar: #304156;
  --sidebar-active: #263445;
  --success: #67c23a;
  --warning: #e6a23c;
  --danger: #f56c6c;
  --info: #909399;
  --shadow: 0 2px 12px rgba(0, 0, 0, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; color: var(--ink); background: var(--bg); font-size: 14px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 6px; color: var(--muted); font-size: 12px; font-weight: 400; letter-spacing: 0; }

.login-view { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #f2f6fc; }
.login-view::before { content: ""; position: fixed; inset: 0 0 auto; height: 4px; background: var(--primary); }
.login-panel { width: min(420px, 100%); padding: 40px; border: 1px solid var(--line-light); border-radius: 6px; background: #fff; box-shadow: 0 8px 30px rgba(48, 65, 86, .12); }
.login-panel h1 { margin: 8px 0; color: var(--ink); font-size: 26px; font-weight: 500; }
.brand-mark { width: 52px; height: 52px; display: grid; place-items: center; margin-bottom: 22px; border-radius: 6px; color: #fff; background: var(--primary); font-size: 22px; font-weight: 600; }
.brand-mark.small { width: 38px; height: 38px; margin: 0; border-radius: 4px; font-size: 17px; }
.stack-form { display: grid; gap: 18px; margin-top: 30px; }
.stack-form label, .form-grid label { display: grid; gap: 8px; color: var(--regular); font-size: 14px; font-weight: 400; }
input, select, textarea { min-width: 0; padding: 10px 12px; color: var(--ink); border: 1px solid var(--line); border-radius: 4px; background: #fff; outline: none; transition: border-color .2s, box-shadow .2s; }
input::placeholder, textarea::placeholder { color: #c0c4cc; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(64, 158, 255, .12); }
.primary, .secondary { min-height: 40px; padding: 9px 16px; border: 1px solid transparent; border-radius: 4px; font-weight: 400; transition: color .2s, border-color .2s, background .2s; }
.primary { color: #fff; border-color: var(--primary); background: var(--primary); }
.primary:hover { border-color: var(--primary-hover); background: var(--primary-hover); }
.primary.wide { width: 100%; min-height: 42px; }
.secondary { color: var(--regular); border-color: var(--line); background: #fff; }
.secondary:hover { color: var(--primary); border-color: #c6e2ff; background: var(--primary-light); }
.form-error { min-height: 18px; margin: 0; color: var(--danger); font-size: 13px; }

.admin-shell { min-height: 100vh; }
.sidebar { position: fixed; z-index: 20; inset: 0 auto 0 0; width: 220px; display: flex; flex-direction: column; color: #bfcbd9; background: var(--sidebar); box-shadow: 2px 0 6px rgba(0, 21, 41, .12); }
.sidebar-brand { height: 64px; display: flex; align-items: center; gap: 12px; padding: 0 20px; color: #fff; background: #2b3a4d; }
.sidebar-brand strong, .sidebar-brand span { display: block; }
.sidebar-brand strong { color: #fff; font-size: 16px; font-weight: 500; }
.sidebar-brand span { margin-top: 3px; color: #a6b2c0; font-size: 12px; }
.sidebar nav { display: grid; padding-top: 10px; }
.nav-item { width: 100%; height: 50px; display: flex; align-items: center; gap: 12px; padding: 0 20px; color: #bfcbd9; border: 0; border-radius: 0; background: transparent; text-align: left; font-weight: 400; }
.nav-item span { width: 20px; color: #a6b2c0; text-align: center; font-size: 17px; }
.nav-item:hover { color: #fff; background: #263445; }
.nav-item.active { color: #409eff; background: var(--sidebar-active); }
.nav-item.active span { color: #409eff; }
.sidebar-foot { margin-top: auto; padding: 18px 20px; border-top: 1px solid rgba(255, 255, 255, .08); color: #a6b2c0; font-size: 12px; }
.online-dot { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--success); }
.text-button { padding: 0; color: #bfcbd9; border: 0; background: none; font-size: 12px; }
.text-button:hover { color: #fff; }
.sidebar-account-actions { margin-top: 12px; display: flex; justify-content: space-between; gap: 12px; }

.main-area { min-height: 100vh; margin-left: 220px; }
.topbar { position: sticky; z-index: 10; top: 0; height: 64px; padding: 0 24px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line-light); background: #fff; box-shadow: 0 1px 4px rgba(0, 21, 41, .08); }
.topbar h2 { margin: 0; font-size: 20px; font-weight: 500; }
.topbar-actions, .action-row { display: flex; align-items: center; gap: 10px; }
.store-picker { height: 40px; display: flex; align-items: center; gap: 8px; padding-left: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; background: #fff; font-size: 12px; }
.store-picker select { min-width: 170px; padding: 8px 28px 8px 4px; border: 0; background: transparent; box-shadow: none; color: var(--ink); }
.icon-button { width: 40px; height: 40px; display: grid; place-items: center; color: var(--regular); border: 1px solid var(--line); border-radius: 4px; background: #fff; font-size: 18px; }
.icon-button:hover { color: var(--primary); border-color: #c6e2ff; background: var(--primary-light); }
.avatar { width: 36px; height: 36px; display: grid; place-items: center; color: #fff; border-radius: 50%; background: var(--primary); font-size: 13px; }
.content { padding: 24px; }
.page { display: none; }
.page.active { display: block; animation: appear .18s ease; }
@keyframes appear { from { opacity: .35; } }

.hero-card { min-height: 124px; padding: 26px 28px; display: flex; align-items: center; justify-content: space-between; border: 1px solid #d9ecff; border-left: 4px solid var(--primary); border-radius: 4px; background: linear-gradient(90deg, #ecf5ff 0%, #fff 75%); }
.hero-card h3 { margin: 0 0 8px; color: var(--ink); font-size: 24px; font-weight: 500; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin: 18px 0; }
.stat-card { min-height: 120px; padding: 20px; display: flex; align-items: center; gap: 16px; border: 1px solid var(--line-light); border-radius: 4px; background: var(--panel); box-shadow: 0 1px 3px rgba(0, 0, 0, .03); }
.stat-card p { margin: 0 0 8px; color: var(--muted); font-size: 13px; }
.stat-card strong { display: block; margin-bottom: 5px; color: var(--ink); font-size: 24px; font-weight: 600; }
.stat-card small { color: #c0c4cc; }
.stat-icon { flex: 0 0 auto; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 4px; font-size: 14px; font-weight: 600; }
.stat-icon.gold { color: #e6a23c; background: #fdf6ec; }
.stat-icon.blue { color: #409eff; background: #ecf5ff; }
.stat-icon.orange { color: #f56c6c; background: #fef0f0; }
.stat-icon.mint { color: #67c23a; background: #f0f9eb; }

.panel { padding: 20px; border: 1px solid var(--line-light); border-radius: 4px; background: var(--panel); }
.panel.flush { padding: 0; overflow: hidden; }
.panel-head, .section-actions, .filterbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.panel-head { margin-bottom: 16px; }
.panel-head h3 { margin: 0; font-size: 18px; font-weight: 500; }
.section-actions, .filterbar { margin-bottom: 18px; }
.link-button { padding: 0; color: var(--primary); border: 0; background: none; }
.link-button:hover { color: var(--primary-hover); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: #fff; font-size: 14px; }
th { padding: 12px 14px; color: var(--muted); border-bottom: 1px solid var(--line-light); background: #f5f7fa; text-align: left; font-size: 13px; font-weight: 500; }
td { padding: 14px; border-bottom: 1px solid var(--line-light); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f5f7fa; }
.order-number { color: var(--regular); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 500; }
.badge { display: inline-block; padding: 4px 8px; color: var(--info); border: 1px solid #d3d4d6; border-radius: 4px; background: #f4f4f5; font-size: 12px; line-height: 1; white-space: nowrap; }
.badge.paid, .badge.accepted { color: #409eff; border-color: #b3d8ff; background: #ecf5ff; }
.badge.preparing { color: #e6a23c; border-color: #f5dab1; background: #fdf6ec; }
.badge.ready { color: #7b61d1; border-color: #d8cef4; background: #f4f0ff; }
.badge.completed { color: #67c23a; border-color: #c2e7b0; background: #f0f9eb; }
.badge.cancelled, .badge.refunded { color: #909399; border-color: #d3d4d6; background: #f4f4f5; }
.empty-state { padding: 48px 20px; color: var(--muted); text-align: center; }

.store-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.store-card { min-height: 220px; padding: 20px; display: flex; flex-direction: column; border: 1px solid var(--line-light); border-radius: 4px; background: #fff; transition: border-color .2s, box-shadow .2s; }
.store-card:hover { border-color: #c6e2ff; box-shadow: var(--shadow); }
.store-card.off { opacity: .7; }
.store-card-head { display: flex; justify-content: space-between; gap: 12px; }
.store-card h3 { margin: 16px 0; font-size: 18px; font-weight: 500; }
.store-meta { display: grid; gap: 10px; color: var(--regular); font-size: 13px; line-height: 1.5; }
.store-card-actions { margin-top: auto; padding-top: 18px; display: flex; gap: 8px; }
.mini-button { padding: 6px 11px; color: var(--primary); border: 1px solid #b3d8ff; border-radius: 4px; background: var(--primary-light); font-size: 12px; }
.mini-button:hover { color: #fff; border-color: var(--primary); background: var(--primary); }
.mini-button.danger { color: var(--danger); border-color: #fbc4c4; background: #fef0f0; }
.mini-button.danger:hover { color: #fff; border-color: var(--danger); background: var(--danger); }

.segmented { display: inline-flex; gap: 0; overflow-x: auto; border: 1px solid var(--line); border-radius: 4px; background: #fff; }
.segmented button { padding: 9px 15px; color: var(--regular); border: 0; border-right: 1px solid var(--line); background: #fff; white-space: nowrap; font-size: 13px; }
.segmented button:last-child { border-right: 0; }
.segmented button:hover { color: var(--primary); }
.segmented button.active { color: #fff; background: var(--primary); }
.chips { display: flex; gap: 8px; margin-bottom: 16px; overflow-x: auto; }
.chip { padding: 7px 13px; color: var(--regular); border: 1px solid var(--line); border-radius: 4px; background: #fff; white-space: nowrap; font-size: 13px; }
.chip:hover, .chip.active { color: var(--primary); border-color: #b3d8ff; background: var(--primary-light); }
.dish-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.dish-card { min-height: 148px; display: grid; grid-template-columns: 112px 1fr; overflow: hidden; border: 1px solid var(--line-light); border-radius: 4px; background: #fff; transition: border-color .2s, box-shadow .2s; }
.dish-card:hover { border-color: #c6e2ff; box-shadow: var(--shadow); }
.dish-image { min-height: 148px; display: grid; place-items: center; overflow: hidden; color: #a0cfff; background: #ecf5ff; font-size: 30px; }
.dish-image img { width: 100%; height: 100%; object-fit: cover; }
.dish-info { min-width: 0; padding: 16px; display: flex; flex-direction: column; }
.dish-info h3 { margin: 0 0 7px; overflow: hidden; color: var(--ink); font-size: 16px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.dish-info p { height: 36px; margin: 0; overflow: hidden; color: var(--muted); font-size: 12px; line-height: 1.5; }
.dish-bottom { margin-top: auto; display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }
.price { color: #f56c6c; font-size: 18px; font-weight: 600; }
.dish-tags { min-height: 21px; display: flex; gap: 5px; margin-bottom: 7px; }
.dish-tags .badge { padding: 3px 6px; }

.filterbar { align-items: flex-start; }
.search-box { width: 300px; height: 40px; display: flex; align-items: center; gap: 7px; padding-left: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; background: #fff; }
.search-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(64, 158, 255, .12); }
.search-box input { width: 100%; padding: 9px 12px 9px 0; border: 0; box-shadow: none; }
.modal-backdrop { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(0, 0, 0, .45); }
.modal-card { width: min(620px, 100%); max-height: calc(100vh - 40px); padding: 0 20px 20px; overflow-y: auto; border-radius: 4px; background: #fff; box-shadow: 0 2px 12px rgba(0, 0, 0, .2); }
.modal-head { min-height: 62px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line-light); }
.modal-head h3 { margin: 0; font-size: 18px; font-weight: 500; }
.modal-head .eyebrow { display: none; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 20px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-grid textarea { min-height: 86px; resize: vertical; }
.check-row { display: flex !important; grid-template-columns: none !important; align-items: center; gap: 8px !important; padding-top: 24px; }
.check-row input { width: 16px; height: 16px; min-width: auto; padding: 0; accent-color: var(--primary); }
.modal-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 10px; padding-top: 8px; }
.image-upload-row { display: flex; align-items: center; gap: 10px; }
.image-upload-row input { flex: 1; }
.category-list { display: grid; gap: 8px; margin: 18px 0; }
.category-row { padding: 11px 12px; display: flex; align-items: center; justify-content: space-between; border: 1px solid var(--line-light); border-radius: 4px; }
.category-row strong { margin-left: 8px; font-weight: 500; }
.order-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 18px 0; }
.detail-cell { padding: 13px; border: 1px solid var(--line-light); border-radius: 4px; background: #f5f7fa; }
.detail-cell span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 12px; }
.detail-items { margin: 16px 0; }
.detail-item { padding: 11px 0; display: flex; justify-content: space-between; border-bottom: 1px solid var(--line-light); font-size: 13px; }
.status-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.toast { position: fixed; z-index: 200; left: 50%; bottom: 34px; transform: translateX(-50%); padding: 11px 18px; color: #fff; border-radius: 4px; background: #303133; box-shadow: var(--shadow); font-size: 13px; }
.mobile-only { display: none; }

@media (max-width: 1120px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .store-grid, .dish-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 760px) {
  .sidebar { transform: translateX(-100%); transition: transform .22s; }
  .sidebar.open { transform: translateX(0); box-shadow: 12px 0 30px rgba(0, 0, 0, .25); }
  .main-area { margin-left: 0; }
  .mobile-only { display: grid; }
  .topbar { min-height: 64px; height: auto; padding: 10px 14px; gap: 10px; }
  .topbar > div:first-of-type { display: none; }
  .topbar-actions { min-width: 0; flex: 1; justify-content: flex-end; }
  .store-picker { min-width: 0; flex: 1; }
  .store-picker span, .avatar { display: none; }
  .store-picker select { width: 100%; min-width: 0; }
  .content { padding: 16px 12px 36px; }
  .hero-card { min-height: 118px; padding: 22px 20px; }
  .hero-card h3 { font-size: 21px; }
  .hero-card .primary { display: none; }
  .stats-grid { gap: 10px; }
  .stat-card { min-height: 106px; padding: 14px; gap: 10px; }
  .stat-card strong { font-size: 20px; }
  .stat-icon { width: 36px; height: 36px; }
  .store-grid, .dish-grid { grid-template-columns: 1fr; }
  .section-actions, .filterbar { align-items: stretch; flex-direction: column; }
  .section-actions .primary, .section-actions .secondary { flex: 1; }
  .search-box, .order-tabs { width: 100%; }
  .table-wrap table { min-width: 650px; }
  .table-wrap { scrollbar-width: thin; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2, .modal-actions { grid-column: 1; }
  .modal-card { padding: 0 16px 16px; }
  .login-panel { padding: 32px 24px; }
}
