/* ============ 基础 ============ */
:root{
  --bg:#f6f4f1;
  --card:#ffffff;
  --ink:#2b2723;
  --ink-2:#6f675f;
  --ink-3:#a89f96;
  --line:#ece7e1;
  --brand:#b8412f;
  --brand-soft:#fdf1ee;
  --green:#1f7a4d;
  --green-soft:#e8f5ee;
  --green-line:#bfe3d0;
  --red:#9b1c1c;
  --red-soft:#fbeceb;
  --red-line:#f0c9c6;
  --shadow:0 1px 2px rgba(43,39,35,.04), 0 6px 20px rgba(43,39,35,.06);
  --r:16px;
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;padding:0}
body{
  font-family:-apple-system,BlinkMacSystemFont,"PingFang SC","Noto Sans CJK SC","Microsoft YaHei",sans-serif;
  background:var(--bg);color:var(--ink);
  font-size:15px;line-height:1.5;
  min-height:100vh;
  display:flex;flex-direction:column;
  -webkit-font-smoothing:antialiased;
}
button{font-family:inherit;font-size:inherit;color:inherit;border:0;background:none;cursor:pointer}
input,select,textarea{font-family:inherit;font-size:16px;color:var(--ink)}
.hide{display:none !important}

/* ============ 顶部 ============ */
.topbar{
  position:sticky;top:0;z-index:30;
  padding:calc(9px + env(safe-area-inset-top)) 12px 9px;
  background:linear-gradient(180deg,#fffdfb 65%,rgba(255,253,251,.97));
  backdrop-filter:saturate(1.4) blur(10px);
  border-bottom:1px solid var(--line);
}
.topbar-row{display:flex;align-items:center;justify-content:space-between;gap:10px}
.brand{display:flex;align-items:center;gap:8px;min-width:0}
.logo{
  width:29px;height:29px;border-radius:9px;flex:0 0 auto;
  background:linear-gradient(150deg,#c9523c,#8f2b1b);
  color:#fff;display:grid;place-items:center;font-weight:700;font-size:14px;
  box-shadow:0 3px 10px rgba(155,28,28,.22);
}
.brand h1{margin:0;font-size:15.5px;font-weight:700;letter-spacing:.3px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;line-height:1.2}
.today-date{font-size:11px;color:var(--ink-3);margin-top:0}
.stats{display:flex;gap:5px;flex:0 0 auto}
.stat{font-size:11px;padding:3px 8px;border-radius:7px;font-weight:700;white-space:nowrap}
.stat.g{background:var(--green-soft);color:var(--green)}
.stat.r{background:var(--red-soft);color:var(--red)}

/* 日期横条 */
.dates{display:flex;gap:7px;overflow-x:auto;margin-top:10px;padding-bottom:1px;
  scrollbar-width:none;scroll-behavior:smooth}
.dates::-webkit-scrollbar{display:none}
.day{
  flex:0 0 auto;width:58px;padding:7px 0 8px;border-radius:13px;
  background:#f4f1ec;border:1px solid transparent;
  display:flex;flex-direction:column;align-items:center;gap:1px;
  transition:.15s;position:relative;
}
.day .w{font-size:11px;color:var(--ink-3);font-weight:550;line-height:1.3}
.day .d{font-size:16px;font-weight:650;letter-spacing:-.2px;line-height:1.15}
.day .m{font-size:10px;color:var(--ink-3);display:block;line-height:1.2}
.day.active{background:var(--brand);border-color:var(--brand);box-shadow:0 5px 14px rgba(184,65,47,.26)}
.day.active .w,.day.active .d,.day.active .m{color:#fff}
.day.active .w{opacity:.82}
.day .dot{position:absolute;top:6px;right:8px;width:5px;height:5px;border-radius:50%;background:var(--red)}
.day.active .dot{background:#fff;opacity:.9}

/* ============ 内容 ============ */
main{padding:16px}
.section-h{display:flex;align-items:baseline;gap:8px;margin:4px 0 10px}
.section-h h2{margin:0;font-size:15px;font-weight:650;letter-spacing:.2px}
.section-h span{font-size:12px;color:var(--ink-3)}
.section-h .refresh{margin-left:auto;font-size:12px;color:var(--brand);font-weight:600;padding:4px 6px}
.section-h .bar{flex:1;height:1px;background:var(--line)}
.hint{font-size:11.5px;color:var(--ink-3);margin:0 0 12px;line-height:1.7}
.lg-dot{display:inline-block;width:8px;height:8px;border-radius:50%;vertical-align:0}
.lg-dot.free{background:var(--green)}
.lg-dot.busy{background:var(--red)}

.slots-bar{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-top:11px}
.slot{
  background:#f4f1ec;border-radius:12px;padding:9px 12px 10px;
  text-align:left;position:relative;overflow:hidden;
  border:1.5px solid transparent;
  transition:.15s;
  display:flex;flex-direction:column;gap:1px;
}
.slot:active{transform:scale(.98)}
.slot .s-top{display:flex;align-items:center;gap:5px;width:100%}
.slot .s-ico{font-size:13px;line-height:1;opacity:.7}
.slot .s-name{font-size:14.5px;font-weight:700;line-height:1.2;flex:1}
.slot .s-time{font-size:10px;color:var(--ink-3);letter-spacing:.1px;margin-left:1px}
.slot .s-num{
  position:absolute;right:11px;bottom:9px;
  font-size:10.5px;font-weight:700;
  padding:2px 7px;border-radius:6px;background:#fff;color:var(--green);
}
.slot .s-num.hot{background:#fff;color:var(--red)}

/* —— 午市：白底黑字 —— */
.slot[data-slot="lunch"]{background:#fff;border-color:#e6e1da}
.slot[data-slot="lunch"] .s-name{color:#26221e}
.slot[data-slot="lunch"] .s-num{background:#f2efe9;color:#5d564e}
/* —— 晚市：黑底白字 —— */
.slot[data-slot="dinner"]{background:#26221e;border-color:#26221e}
.slot[data-slot="dinner"] .s-name{color:#fff}
.slot[data-slot="dinner"] .s-time{color:rgba(255,255,255,.5)}
.slot[data-slot="dinner"] .s-num{background:rgba(255,255,255,.14);color:#fff}
.slot[data-slot="dinner"] .s-num.hot{background:rgba(255,120,110,.24);color:#ffb3ab}

/* 选中态：加粗描边 + 阴影 + 左侧色带，底色不变 */
.slot.active{box-shadow:0 4px 16px rgba(28,24,20,.16);transform:translateY(-1px)}
.slot[data-slot="lunch"].active{border-color:#26221e;box-shadow:0 4px 16px rgba(28,24,20,.18)}
.slot[data-slot="dinner"].active{border-color:#b8412f;box-shadow:0 4px 16px rgba(28,24,20,.3)}
.slot.active::before{
  content:'';position:absolute;left:0;top:0;bottom:0;width:4px;background:var(--brand);
}
.slot[data-slot="dinner"].active::before{background:#ff6b5a}

/* ============ 台位卡 ============ */
.sec-row{display:flex;align-items:baseline;gap:6px;margin:0 1px 8px;flex:0 0 auto}
.sec-row.below{margin-top:12px}
.sec-title{font-size:13.5px;font-weight:700}
.sec-sub{font-size:11px;color:var(--ink-3)}
.sec-row .refresh{font-size:14px;color:var(--ink-3);padding:0 2px;line-height:1}

main{padding:10px 12px 14px}
/* 台位区：JS 算出单行高度写入 --row-h，两段网格按它固定行高 → 必然填满一屏 */
#pageTables{
  display:flex;flex-direction:column;
  flex:1 1 auto;min-height:0;
  padding-bottom:calc(70px + env(safe-area-inset-bottom));
}
.grid{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;flex:0 0 auto}
.grid.rooms{grid-template-columns:repeat(3,1fr)}
#gridTables{grid-template-rows:repeat(3, var(--row-h, 90px))}
#gridRooms{grid-template-rows:repeat(2, var(--row-h, 90px))}
.tile{
  background:var(--card);border-radius:13px;
  padding:9px 10px;
  text-align:left;position:relative;
  border:1.5px solid var(--green-line);
  transition:.14s;
  display:flex;flex-direction:column;
  overflow:hidden;
  min-height:0;
}
.tile:active{transform:scale(.96)}
.tile .t-top{display:flex;align-items:baseline;gap:3px;justify-content:space-between;width:100%}
.tile .t-name{font-size:15px;font-weight:700;letter-spacing:.2px;line-height:1.25;color:var(--green);white-space:nowrap}
.tile .t-seat{font-size:10px;color:var(--ink-3);font-weight:600;flex:0 0 auto}
/* 空闲：桌号居中 + 一行提示 */
.tile.free{justify-content:center;gap:3px}
.tile.free .t-name{font-size:17px}
.tile .t-free-tip{
  font-size:10px;color:#8fbfa5;font-weight:600;letter-spacing:.2px;
}
/* 已预订：深红 */
.tile.busy{background:var(--red);border-color:#7d1616;box-shadow:0 3px 10px rgba(155,28,28,.2)}
.tile.busy .t-name{color:#fff;font-size:15.5px}
.tile.busy .t-seat{color:rgba(255,255,255,.72);font-size:11px}
.tile.busy .t-top{margin-bottom:4px}
.tile .t-guest{min-width:0;flex:1;display:flex;flex-direction:column;justify-content:center;gap:3px}
.tile .t-guest .g-name{
  font-size:15.5px;font-weight:700;color:#fff;line-height:1.25;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
.tile .t-guest .g-dish{
  font-size:14px;line-height:1.28;color:rgba(255,255,255,.96);
  display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;
  word-break:keep-all;
}
.tile .t-guest .g-meta{
  font-size:12.5px;color:rgba(255,255,255,.82);
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}

/* ============ 底部抽屉 ============ */
.mask{
  position:fixed;inset:0;background:rgba(28,24,20,.42);z-index:90;
  opacity:0;pointer-events:none;transition:.22s;
}
.mask.show{opacity:1;pointer-events:auto}

/* 浮层容器：flex 把面板贴到底部，不依赖 fixed 的 bottom 计算 */
.sheet-wrap{
  position:fixed;left:0;right:0;top:0;bottom:0;
  z-index:100;
  display:flex;flex-direction:column;justify-content:flex-end;
  pointer-events:none;visibility:hidden;
  padding-top:calc(30px + env(safe-area-inset-top));
}
.sheet-wrap.show{pointer-events:auto;visibility:visible}
.sheet{
  width:100%;
  background:var(--card);border-radius:22px 22px 0 0;
  padding:6px 18px calc(16px + env(safe-area-inset-bottom));
  max-height:100%;
  overflow-y:auto;
  -webkit-overflow-scrolling:touch;
  overscroll-behavior:contain;
  box-shadow:0 -8px 40px rgba(43,39,35,.16);
  flex:0 1 auto;
  opacity:0;transition:opacity .16s ease;
  visibility:hidden;
}
.sheet-wrap.show .sheet{opacity:1;visibility:visible}
.sheet-head{display:flex;align-items:flex-start;gap:12px;margin-bottom:14px}
.sheet-head>div{flex:1;min-width:0}
.sheet-x{
  width:34px;height:34px;border-radius:50%;flex:0 0 auto;
  background:#f4f1ec;color:var(--ink-2);font-size:15px;
  display:grid;place-items:center;margin-top:2px;
}
.sheet h2{margin:0 0 2px;font-size:18px;font-weight:700;letter-spacing:.2px}
.sheet .sub{font-size:12.5px;color:var(--ink-3);margin:0}
.field{margin-bottom:14px}
.field label{display:block;font-size:12.5px;font-weight:600;color:var(--ink-2);margin-bottom:6px}
.field label .req{color:var(--brand)}
.field label .opt{color:var(--ink-3);font-weight:500;font-size:11px;margin-left:4px}
.inp{
  width:100%;padding:12px 13px;border-radius:11px;border:1.5px solid var(--line);
  background:#fbf9f7;outline:none;transition:.15s;
}
.inp:focus{border-color:var(--brand);background:#fff;box-shadow:0 0 0 3px rgba(184,65,47,.09)}
textarea.inp{resize:none;line-height:1.5}
select.inp{appearance:none;background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M2 4l4 4 4-4' stroke='%23a89f96' stroke-width='1.6' fill='none' stroke-linecap='round'/></svg>");background-repeat:no-repeat;background-position:right 13px center;padding-right:34px}
.row{display:flex;gap:9px}
.row>*{flex:1;min-width:0}
.stepper{display:flex;align-items:center;border:1.5px solid var(--line);border-radius:11px;overflow:hidden;background:#fbf9f7}
.stepper button{width:46px;height:44px;font-size:20px;color:var(--ink-2);display:grid;place-items:center}
.stepper button:active{background:#f0ebe5}
.stepper input{flex:1;width:100%;min-width:0;text-align:center;border:0;background:transparent;height:44px;font-weight:650;outline:none}
.quick{display:flex;gap:6px;margin-top:7px;flex-wrap:wrap}
.quick button{font-size:12px;padding:5px 11px;border-radius:8px;background:#eee9e2;color:var(--ink-2);font-weight:600}
.quick button.on{background:var(--brand);color:#fff}
.quick button:active{opacity:.85}

/* ============ 菜品按钮 ============ */
.dish-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.dish{
  padding:11px 10px;border-radius:11px;border:1.5px solid var(--line);
  background:#fbf9f7;text-align:left;transition:.14s;
  display:flex;align-items:center;gap:8px;min-height:48px;
}
.dish:active{transform:scale(.975)}
.dish .ck{
  width:18px;height:18px;border-radius:5px;flex:0 0 auto;
  border:1.6px solid #d6cec4;background:#fff;
  display:grid;place-items:center;color:#fff;font-size:11px;font-weight:700;
}
.dish .dt{flex:1;min-width:0}
.dish .dt .dn{font-size:13.5px;font-weight:650;line-height:1.25;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.dish .dt .dp{font-size:10.5px;color:var(--ink-3);margin-top:1px;font-weight:600}
.dish.on{border-color:var(--red);background:var(--red-soft)}
.dish.on .dn{color:var(--red)}
.dish.on .ck{background:var(--red);border-color:var(--red)}
.dish-picked{margin-top:8px;font-size:11.5px;color:var(--ink-3);min-height:17px;line-height:1.5}
.dish-picked b{color:var(--red)}

.btn{
  width:100%;padding:14px;border-radius:13px;font-size:15.5px;font-weight:650;
  background:var(--brand);color:#fff;box-shadow:0 6px 18px rgba(184,65,47,.24);
  transition:.15s;letter-spacing:.3px;
}
.btn:active{transform:scale(.98)}
.btn.ghost{background:#f0ebe5;color:var(--ink-2);box-shadow:none}
.btn.danger{background:#fff;color:var(--red);border:1.5px solid var(--red-line);box-shadow:none}
.btn-row{display:flex;gap:9px;margin-top:6px}
.btn-row .btn{flex:1}
.err{color:var(--red);font-size:12.5px;margin:-4px 0 12px;font-weight:600;display:none;background:var(--red-soft);padding:9px 12px;border-radius:9px}
.err.show{display:block}

/* 预订详情 */
.detail-list{border:1.5px solid var(--line);border-radius:14px;overflow:hidden;margin-bottom:16px}
.dl{display:flex;justify-content:space-between;gap:12px;padding:11px 14px;font-size:13.5px;border-bottom:1px solid var(--line)}
.dl:last-child{border-bottom:0}
.dl .k{color:var(--ink-3);flex:0 0 auto}
.dl .v{text-align:right;font-weight:600;word-break:break-all}
.dl .v.dishes{color:var(--red)}

/* 预订列表 */
.list-item{
  display:flex;align-items:center;gap:12px;padding:12px 13px;background:#fff;
  border-radius:14px;margin-bottom:9px;box-shadow:var(--shadow);
  border-left:3px solid var(--red-line);
}
.li-date{width:46px;flex:0 0 auto;text-align:center;border-right:1px solid var(--line);padding-right:10px}
.li-date .d{font-size:18px;font-weight:700;line-height:1.1;letter-spacing:-.5px}
.li-date .w{font-size:10.5px;color:var(--ink-3);margin-top:2px}
.li-main{flex:1;min-width:0}
.li-title{font-size:14px;font-weight:700;display:flex;align-items:center;gap:6px;flex-wrap:wrap}
.li-title .tag{font-size:10px;font-weight:700;padding:2px 6px;border-radius:5px;background:var(--brand-soft);color:var(--brand)}
.li-sub{font-size:11.5px;color:var(--ink-3);margin-top:3px;line-height:1.45}
.li-sub .dishes{color:var(--red);font-weight:600}
.li-act{display:flex;gap:5px;flex:0 0 auto}
.icobtn{width:33px;height:33px;border-radius:10px;background:#f0ebe5;display:grid;place-items:center;color:var(--ink-2)}
.icobtn.del{color:var(--red);background:var(--red-soft)}
.icobtn svg{width:16px;height:16px}
.empty{text-align:center;padding:46px 20px;color:var(--ink-3)}
.empty .big{font-size:40px;opacity:.35;margin-bottom:10px}
.empty p{margin:0;font-size:13.5px}

/* 底部导航 */
.tabbar{
  position:fixed;left:0;right:0;bottom:0;z-index:80;
  display:flex;background:rgba(255,255,255,.97);
  border-top:1px solid var(--line);
  padding:6px 0 calc(4px + env(safe-area-inset-bottom));
}
.tab{flex:1;display:flex;flex-direction:column;align-items:center;gap:3px;padding:6px 0;color:var(--ink-3);font-size:10.5px;font-weight:600;position:relative}
.tab svg{width:21px;height:21px}
.tab.active{color:var(--brand)}
.tab .nb{position:absolute;top:3px;right:calc(50% - 20px);background:var(--red);color:#fff;font-size:9px;padding:0 4px;border-radius:6px;min-width:14px;height:14px;line-height:14px;text-align:center}

/* ============ 应用内确认框 ============ */
.dlg-mask{
  position:fixed;inset:0;z-index:300;
  background:rgba(28,24,20,.46);
  display:flex;align-items:center;justify-content:center;
  padding:28px;
  opacity:0;pointer-events:none;transition:.18s;
}
.dlg-mask.show{opacity:1;pointer-events:auto}
.dlg{
  width:100%;max-width:310px;
  background:#fff;border-radius:18px;
  padding:20px 18px 14px;
  box-shadow:0 16px 48px rgba(28,24,20,.28);
  transform:scale(.94);transition:.18s;
}
.dlg-mask.show .dlg{transform:scale(1)}
.dlg-title{font-size:16.5px;font-weight:700;text-align:center;letter-spacing:.2px}
.dlg-body{font-size:13.5px;color:var(--ink-2);text-align:center;line-height:1.6;margin-top:8px;white-space:pre-line}
.dlg-acts{display:flex;gap:9px;margin-top:18px}
.dlg-btn{flex:1;padding:12px;border-radius:11px;font-size:15px;font-weight:650}
.dlg-btn.ghost{background:#f0ebe5;color:var(--ink-2)}
.dlg-btn.danger{background:var(--red);color:#fff}
.dlg-btn.safe{background:var(--brand);color:#fff}
.dlg-btn:active{transform:scale(.97)}

/* toast */
.toast{
  position:fixed;left:50%;top:50%;transform:translate(-50%,-50%) scale(.94);
  background:rgba(38,33,29,.93);color:#fff;padding:12px 20px;border-radius:12px;
  font-size:14px;z-index:200;opacity:0;pointer-events:none;transition:.2s;font-weight:550;
  max-width:76vw;text-align:center;line-height:1.45;
}
.toast.show{opacity:1;transform:translate(-50%,-50%) scale(1)}

/* 搜索 */
.searchbox{position:relative;margin-bottom:14px}
.searchbox svg{position:absolute;left:13px;top:50%;transform:translateY(-50%);width:16px;height:16px;color:var(--ink-3)}
.searchbox .inp{padding-left:38px}

@media (min-width:640px){
  body{max-width:520px;margin:0 auto;box-shadow:0 0 0 1px var(--line)}
}

/* 矮屏手机（如 360x640）：进一步压缩，保证一屏看全 */
@media (max-height:700px){
  .topbar{padding-top:calc(7px + env(safe-area-inset-top));padding-bottom:7px}
  .dates{margin-top:7px}
  .day{width:40px;padding:3px 0 4px}
  .day .d{font-size:14px}
  .slots-bar{margin-top:7px;gap:6px}
  .slot{padding:6px 9px}
  .slot .s-time{font-size:9px}
  main{padding:7px 10px 12px}
  .grid{gap:6px}
  .sec-row{margin-bottom:5px}
  .tile.free{padding:8px;min-height:44px}
  .tile.free .t-name{font-size:13px}
  .tile.busy{min-height:64px;padding:6px 8px 7px}
  .tile .t-guest .g-dish{-webkit-line-clamp:1}
  #pageTables .sec-row[style]{margin-top:8px !important}
}
