* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; background: #f5f6f8; color: #333; }
main { padding: 12px 16px; }
.hidden { display: none !important; }
.muted { color: #999; }
.error { color: #d33; }
b { font-weight: 600; }

.topnav { background: #2c3e50; color: #fff; padding: 0 16px; display: flex; align-items: center; gap: 4px; }
.topnav .brand { font-weight: 700; padding: 14px 20px 14px 0; }
.topnav a { color: #cfd8e3; text-decoration: none; padding: 14px 14px; }
.topnav a:hover { color: #fff; background: #34495e; }
.topnav .spacer { flex: 1; }
.topnav .acct { color: #9fb3c8; padding: 0 10px; font-size: 14px; }

.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.auth-card { background: #fff; border-radius: 12px; padding: 32px 36px; width: 380px; box-shadow: 0 2px 12px rgba(0,0,0,.12); }
.auth-card h2 { margin-top: 0; }
.auth-card form { display: flex; flex-direction: column; gap: 12px; }
.auth-card label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.auth-card button { padding: 10px; font-size: 15px; }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.auth-tabs button { flex: 1; }
.flash-box { margin-bottom: 12px; }
.flash { background: #fdf3e0; border: 1px solid #f0c36d; color: #8a5a00; border-radius: 8px; padding: 8px 14px; margin-bottom: 6px; }
.perm-group { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; margin: 8px 0; }
.perm-group label, .perm-cell label { display: inline-flex; align-items: center; gap: 3px; font-size: 13px; white-space: nowrap; }
.perm-cell { max-width: 320px; }
.perm-cell label { margin-right: 10px; }

button { cursor: pointer; border: 1px solid #ccc; background: #fff; border-radius: 6px; padding: 6px 14px; font-size: 14px; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: #e67e22; border-color: #e67e22; color: #fff; font-weight: 600; }
button.active { background: #2c3e50; color: #fff; border-color: #2c3e50; }
input, select { padding: 6px 8px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px; }

/* 收银台 */
.pos-top { display: flex; align-items: center; gap: 16px; margin-bottom: 10px; }
.mode-tabs button { padding: 8px 22px; font-size: 15px; }
.pos-layout { display: flex; gap: 14px; }
.pos-left { flex: 1; min-width: 0; }
.pos-right { width: 340px; background: #fff; border-radius: 10px; padding: 12px; box-shadow: 0 1px 4px rgba(0,0,0,.08); display: flex; flex-direction: column; }
.pos-toolbar { display: flex; gap: 10px; margin-bottom: 10px; align-items: center; flex-wrap: wrap; }
#cat-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
#search { flex: 1; min-width: 160px; }
#product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.product-card { background: #fff; border-radius: 10px; padding: 12px; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.08); transition: transform .05s; }
.product-card:hover { transform: translateY(-2px); }
.product-card.nostock { opacity: .5; }
.pname { font-weight: 600; margin-bottom: 4px; }
.pprice { color: #e67e22; font-weight: 700; }
.pstock { color: #999; font-size: 12px; margin-top: 4px; }

.member-box { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.member-box input { width: 130px; }
#member-info { width: 100%; font-size: 13px; color: #27ae60; }
#cart-list { flex: 1; min-height: 120px; max-height: 320px; overflow-y: auto; border-top: 1px dashed #ddd; border-bottom: 1px dashed #ddd; padding: 6px 0; }
.cart-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.cname { flex: 1; }
.cqty button { padding: 0 8px; }
.csub { width: 72px; text-align: right; }
.cdel { border: none; color: #d33; font-size: 16px; background: none; }
.cart-summary { padding: 10px 0; display: flex; flex-direction: column; gap: 6px; }
.cart-summary input { width: 70px; }
.final-line { font-size: 18px; font-weight: 700; color: #e67e22; }
.cart-actions { display: flex; gap: 8px; }
.cart-actions .primary { flex: 1; padding: 10px; font-size: 16px; }

/* 桌台 */
#tables-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.table-card { border-radius: 10px; padding: 22px; text-align: center; cursor: pointer; color: #fff; }
.table-card.free { background: #27ae60; }
.table-card.busy { background: #e74c3c; }
.table-card .tname { font-size: 20px; font-weight: 700; margin-bottom: 6px; }

/* 弹层 */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 10; }
.modal-body { background: #fff; border-radius: 12px; padding: 24px; min-width: 340px; max-width: 520px; }
#pay-methods { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0; }
#pay-methods button { padding: 12px 20px; font-size: 15px; }

#toast { position: fixed; top: 60px; left: 50%; transform: translateX(-50%); padding: 10px 24px; border-radius: 8px; color: #fff; z-index: 20; }
#toast.toast-ok { background: #27ae60; }
#toast.toast-err { background: #e74c3c; }

/* 管理页 / 报表 */
.card { background: #fff; border-radius: 10px; padding: 16px; margin-bottom: 14px; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
table.list { width: 100%; border-collapse: collapse; background: #fff; }
table.list th, table.list td { border: 1px solid #e3e6ea; padding: 8px 10px; font-size: 14px; text-align: left; }
table.list th { background: #f0f2f5; }
table.list input, table.list select { width: 100%; padding: 4px 6px; }
.low-stock { color: #d33; font-weight: 700; }
.stat-cards { display: flex; gap: 14px; margin-bottom: 14px; }
.stat-card { flex: 1; background: #fff; border-radius: 10px; padding: 18px; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.stat-card .num { font-size: 26px; font-weight: 700; color: #e67e22; }
.stat-card .label { color: #888; margin-top: 4px; }
form.inline { display: inline; }
.toolbar-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.status-done { color: #27ae60; }
.status-void { color: #999; text-decoration: line-through; }
.status-pending { color: #e67e22; }
.status-refund { color: #8e44ad; }
.stat-card .num.refund { color: #8e44ad; }
.gift-tag { background: #8e44ad; color: #fff; border-radius: 4px; padding: 0 5px; font-size: 12px; margin-left: 4px; }
.btn-link { color: #2c3e50; text-decoration: underline; margin-right: 8px; }
.btn-primary-link { background: #e67e22; border: 1px solid #e67e22; border-radius: 6px; color: #fff; display: inline-block; font-weight: 600; padding: 7px 16px; text-decoration: none; }
.btn-primary-link:hover { background: #d96f16; border-color: #d96f16; }
.cart-row .cgift { border: none; background: none; color: #bbb; font-size: 13px; padding: 0 4px; }
.cart-row .cgift.on { color: #8e44ad; font-weight: 700; }
.cart-row .cgift-name { color: #8e44ad; font-size: 12px; }
.report-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.report-tabs a { padding: 8px 18px; border-radius: 8px; background: #fff; border: 1px solid #ddd; color: #333; text-decoration: none; }
.report-tabs a.active { background: #2c3e50; color: #fff; border-color: #2c3e50; }
.opt-group { margin-bottom: 12px; }
.opt-group b { display: block; margin-bottom: 6px; }
.opt-group label { display: inline-block; margin-right: 14px; padding: 6px 10px; border: 1px solid #ddd; border-radius: 6px; cursor: pointer; }

/* 小鱼 AI 助手 */
.xiaoyu-fab { position: fixed; right: 24px; bottom: 24px; width: 60px; height: 60px; border-radius: 50%; background: #e67e22; border: none; color: #fff; font-size: 17px; font-weight: 700; box-shadow: 0 3px 12px rgba(0,0,0,.25); z-index: 30; }
.xiaoyu-panel { position: fixed; right: 24px; bottom: 24px; width: 340px; height: 460px; background: #fff; border-radius: 12px; box-shadow: 0 6px 24px rgba(0,0,0,.25); display: flex; flex-direction: column; z-index: 30; overflow: hidden; }
.xiaoyu-head { display: flex; justify-content: space-between; align-items: center; background: #2c3e50; color: #fff; padding: 10px 14px; }
.xiaoyu-close { background: none; border: none; color: #fff; font-size: 18px; padding: 0 4px; }
.xiaoyu-msgs { flex: 1; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.xy-msg { max-width: 85%; padding: 8px 12px; border-radius: 10px; font-size: 14px; line-height: 1.5; white-space: pre-wrap; }
.xy-user { align-self: flex-end; background: #e67e22; color: #fff; }
.xy-bot { align-self: flex-start; background: #f0f2f5; color: #333; }
.xiaoyu-quick { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px 0; }
.xiaoyu-quick button { font-size: 12px; padding: 4px 10px; border-radius: 12px; }
.xiaoyu-input { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid #eee; }
.xiaoyu-input input { flex: 1; }

/* 数据补录 */
.cal-grid td.cal-cell { vertical-align: top; width: 14%; padding: 8px; }
.cal-grid td.cal-empty { background: #f7f8fa; }
.cal-grid th.wkend { color: #e67e22; }
.cal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.cal-auto { font-size: 12px; color: #999; }
.cal-amount { width: 90%; box-sizing: border-box; }
.cal-opts { display: flex; gap: 6px; align-items: center; margin-top: 4px; }
.cal-opts select { font-size: 12px; max-width: 110px; }
.cal-opts label { font-size: 12px; color: #666; }
.cal-closed { background: #f0f2f5; }
.ok-zero { color: #27ae60; font-weight: 700; }
.diff-bad { color: #d33; font-weight: 700; }
.license-warn { background: #fdf3e0; border: 1px solid #f0c36d; color: #8a5a00; border-radius: 8px; padding: 8px 14px; margin-bottom: 10px; }
.license-warn a { color: #b3541e; font-weight: 600; }
.license-expired { color: #d33; font-weight: 700; }
.license-form input { padding: 8px 10px; font-size: 15px; letter-spacing: 1px; width: 240px; }
.report-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.report-head h2 { margin-top: 0; }
