
:root{
  --green:#2f7d57;
  --green-dark:#225f43;
  --green-soft:#edf6eb;
  --green-line:#d7e7d4;
  --bg:#f2f5f1;
  --text:#27372e;
  --muted:#7b8a80;
  --panel:#fff;
  --danger:#d66a5b;
  --shadow:0 9px 28px rgba(43,78,56,.10);
}
*{box-sizing:border-box}
html,body{margin:0;min-height:100%;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Microsoft YaHei",Arial,sans-serif;background:var(--bg);color:var(--text)}
body{padding:14px}
button,input,select,textarea{font:inherit}
button{cursor:pointer}
.shell{max-width:1180px;margin:0 auto}
.topbar{display:flex;align-items:center;justify-content:space-between;gap:14px;padding:8px 5px 16px}
.topbar h1{margin:0;font-size:24px}.topbar p{margin:4px 0 0;color:var(--muted);font-size:13px}
.top-actions{display:flex;gap:8px}
.primary,.secondary,.danger{border:0;border-radius:12px;padding:10px 14px;font-weight:750}
.primary{background:var(--green);color:white}
.secondary{background:white;border:1px solid var(--green-line);color:var(--green-dark)}
.danger{background:#fff0ed;color:var(--danger);border:1px solid #f1c7bf}

.menu-panel{display:grid;grid-template-columns:190px minmax(0,1fr);background:var(--panel);border:1px solid var(--green-line);border-radius:18px;overflow:hidden;box-shadow:var(--shadow);min-height:620px}
.sidebar{padding:18px 12px;background:linear-gradient(180deg,#edf7ea,#fafcf9);border-right:1px solid var(--green-line)}
.side-title{padding:0 8px 12px}.side-title strong,.side-title span{display:block}.side-title strong{font-size:18px}.side-title span{font-size:12px;color:var(--muted);margin-top:3px}
.category-nav{display:flex;flex-direction:column;gap:7px}
.cat-btn{width:100%;border:0;background:transparent;display:flex;justify-content:space-between;align-items:center;padding:11px 12px;border-radius:12px;color:#5f7166}
.cat-btn.active{background:var(--green);color:white;font-weight:750}.cat-btn small{opacity:.8}
.selected-bubble{margin:24px auto 0;width:78px;height:78px;border-radius:50%;border:0;background:var(--green);color:white;display:flex;flex-direction:column;align-items:center;justify-content:center;box-shadow:0 10px 24px rgba(47,125,87,.25)}
.selected-bubble strong{font-size:28px;line-height:1}.selected-bubble span{font-size:13px}

.content{padding:18px}.mobile-categories{display:none}
.toolbar{display:flex;align-items:end;justify-content:space-between;gap:12px;margin-bottom:14px}
.toolbar h2{margin:0;font-size:20px}.toolbar span{display:block;color:var(--muted);font-size:12px;margin-top:3px}
.toolbar input{width:220px;max-width:42vw;border:1px solid var(--green-line);border-radius:12px;padding:10px 12px;outline:none;background:#fbfdfb}
.toolbar input:focus{border-color:#94bd8d;box-shadow:0 0 0 3px rgba(148,189,141,.16)}

.dish-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px}
.card{border:1px solid var(--green-line);border-radius:14px;overflow:hidden;background:white;box-shadow:0 3px 12px rgba(45,80,58,.07)}
.card-img{position:relative;aspect-ratio:1.48/1;background:#edf1eb;overflow:hidden}
.card-img img{width:100%;height:100%;object-fit:cover;display:block}
.badge{position:absolute;right:8px;top:8px;background:rgba(47,125,87,.94);color:white;min-width:30px;height:30px;border-radius:999px;padding:0 8px;display:flex;align-items:center;justify-content:center;font-weight:750}
.card-body{padding:10px}.dish-name{font-weight:780;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.card-bottom{display:flex;justify-content:flex-end;align-items:center;margin-top:9px}
.qty{display:flex;align-items:center;gap:7px}.qty button{width:31px;height:31px;border-radius:9px;border:1px solid var(--green-line);background:#f7fbf5;color:var(--green);font-size:18px;font-weight:900}.qty .plus{background:var(--green);border-color:var(--green);color:white}.qty span{min-width:18px;text-align:center;font-weight:750}

.empty{grid-column:1/-1;text-align:center;padding:55px 18px;border:1px dashed var(--green-line);border-radius:14px;color:var(--muted);background:#fbfdfb}
.pager{display:flex;align-items:center;justify-content:center;gap:18px;padding:20px 0 2px}.pager button{border:0;border-radius:11px;padding:9px 13px;background:#b7cdb5;color:white;font-weight:700}.pager .next{background:var(--green)}.pager button:disabled{opacity:.45;cursor:not-allowed}.pager span{font-weight:700;color:#637368}


.modal{position:fixed;inset:0;z-index:50;background:rgba(21,37,27,.40);display:flex;align-items:center;justify-content:center;padding:18px;backdrop-filter:blur(3px)}
.modal[hidden]{display:none}.modal-card{width:min(700px,100%);max-height:88vh;overflow:auto;background:white;border-radius:20px;padding:18px;box-shadow:0 30px 80px rgba(0,0,0,.20)}
.modal-head{display:flex;justify-content:space-between;align-items:flex-start;gap:12px;margin-bottom:12px}.modal-head h2{margin:0}.modal-head p{margin:4px 0 0;color:var(--muted);font-size:12px}.icon-btn{width:38px;height:38px;border:0;border-radius:50%;background:#eef4ef;font-size:24px;color:#56675c}
.cart-items{display:flex;flex-direction:column;gap:8px}.cart-row{display:grid;grid-template-columns:64px minmax(0,1fr) auto;align-items:center;gap:10px;border:1px solid var(--green-line);border-radius:13px;padding:8px}.cart-row img{width:64px;height:54px;object-fit:cover;border-radius:9px}.cart-row h4{margin:0;font-size:14px}
.order-meta{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin-top:14px}.order-meta label,.dish-form label{font-size:12px;color:#617168;font-weight:700}.order-meta input,.order-meta select,.order-meta textarea,.dish-form input,.dish-form select{width:100%;display:block;margin-top:5px;border:1px solid var(--green-line);border-radius:10px;padding:10px 11px;background:white;outline:none}.order-meta .full,.dish-form .full{grid-column:1/-1}
.modal-actions{display:flex;gap:10px;margin-top:13px}.modal-actions button{flex:1}

.dish-form{display:grid;grid-template-columns:1fr 1fr;gap:10px;background:#f8fbf7;border-radius:14px;padding:12px}.dish-form small{display:block;color:var(--muted);font-weight:400;margin-top:5px;line-height:1.4}.preview-wrap{display:flex;justify-content:center}.preview-wrap img{width:210px;aspect-ratio:1.48/1;object-fit:cover;border-radius:12px;border:1px solid var(--green-line)}
.manage-section{margin-top:16px}.manage-title{display:flex;align-items:center;justify-content:space-between}.manage-title h3{margin:0 0 9px;font-size:15px}.text-danger{border:0;background:transparent;color:var(--danger);font-size:12px}.added-list{display:flex;flex-direction:column;gap:7px}.added-row{display:grid;grid-template-columns:52px minmax(0,1fr) auto;gap:9px;align-items:center;border:1px solid var(--green-line);border-radius:11px;padding:7px}.added-row img{width:52px;height:44px;object-fit:cover;border-radius:8px}.added-row small{color:var(--muted)}.added-row button{border:0;border-radius:8px;background:#fff0ed;color:var(--danger);padding:6px 9px}

.toast{position:fixed;left:50%;bottom:26px;transform:translate(-50%,12px);opacity:0;pointer-events:none;z-index:100;background:#26382d;color:white;padding:10px 15px;border-radius:11px;transition:.2s;box-shadow:0 10px 30px rgba(0,0,0,.18)}.toast.show{opacity:1;transform:translate(-50%,0)}

@media(max-width:820px){
  body{padding:8px}.menu-panel{grid-template-columns:150px minmax(0,1fr)}.content{padding:13px}.dish-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.toolbar input{width:175px}
}
@media(max-width:620px){
  body{padding:0}.topbar{position:sticky;top:0;z-index:20;background:white;border-bottom:1px solid var(--green-line);padding:11px 10px}.topbar h1{font-size:20px}.topbar p{display:none}.top-actions{gap:6px}.primary,.secondary{padding:9px 10px;font-size:13px}
  .menu-panel{display:block;border:0;border-radius:0;box-shadow:none;min-height:auto}.sidebar{display:none}.content{padding:10px}.mobile-categories{display:flex;gap:8px;overflow-x:auto;padding-bottom:5px;margin-bottom:9px;scrollbar-width:none}.mobile-categories::-webkit-scrollbar{display:none}.mobile-cat{flex:0 0 auto;border:1px solid var(--green-line);background:white;border-radius:999px;padding:8px 12px;font-weight:700;color:#596b60}.mobile-cat.active{background:var(--green);color:white;border-color:var(--green)}
  .toolbar{align-items:center;margin-bottom:10px}.toolbar h2{font-size:17px}.toolbar input{width:135px;max-width:none;padding:8px 9px}.dish-grid{gap:9px}.card-body{padding:8px}.dish-name{font-size:14px}.qty{gap:5px}.qty button{width:29px;height:29px}.records{margin-top:8px;border-left:0;border-right:0;border-radius:0;padding:13px 10px}.records-head{align-items:flex-start}.records-head .primary{font-size:12px}
  .modal{padding:0;align-items:flex-end}.modal-card{width:100%;max-height:91vh;border-radius:22px 22px 0 0;padding:15px}.order-meta,.dish-form{grid-template-columns:1fr}.order-meta .full,.dish-form .full{grid-column:auto}.top-actions .secondary{font-size:0}.top-actions .secondary::after{content:"＋ 菜品";font-size:13px}
}


/* 菜品图片点击放大 */
.card-img img,
.cart-row img,
.added-row img {
  cursor: zoom-in;
}

.image-modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(0,0,0,.82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(5px);
}

.image-modal[hidden] {
  display: none;
}

.image-modal-inner {
  position: relative;
  width: min(1000px, 96vw);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.image-modal-inner img {
  display: block;
  max-width: 100%;
  max-height: 82vh;
  object-fit: contain;
  border-radius: 14px;
  background: #111;
  box-shadow: 0 18px 60px rgba(0,0,0,.35);
  cursor: zoom-out;
}

.image-close-btn {
  position: absolute;
  top: -8px;
  right: 0;
  z-index: 2;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,.94);
  color: #26382d;
  font-size: 30px;
  line-height: 1;
  font-weight: 400;
}

.large-dish-name {
  margin-top: 12px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255,255,255,.94);
  color: #26382d;
  font-size: 16px;
  font-weight: 750;
  text-align: center;
}

@media(max-width:620px){
  .image-modal {
    padding: 10px;
  }

  .image-modal-inner {
    width: 100%;
  }

  .image-modal-inner img {
    max-height: 78vh;
    border-radius: 10px;
  }

  .image-close-btn {
    top: 4px;
    right: 4px;
  }

  .large-dish-name {
    font-size: 15px;
  }
}


.image-preview-actions{
  display:flex;
  gap:9px;
  justify-content:center;
  flex-wrap:wrap;
  margin-top:10px;
}

.replace-image-btn,
.restore-image-btn{
  min-height:42px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:9px 14px;
  border-radius:11px;
  font-weight:750;
  font-size:14px;
}

.replace-image-btn{
  background:var(--green);
  color:#fff;
  cursor:pointer;
}

.restore-image-btn{
  border:1px solid rgba(255,255,255,.45);
  background:rgba(255,255,255,.95);
  color:#4f6055;
}

.restore-image-btn:disabled{
  opacity:.45;
  cursor:not-allowed;
}

.image-help-text{
  margin-top:8px;
  color:rgba(255,255,255,.82);
  font-size:12px;
  text-align:center;
}

@media(max-width:620px){
  .image-preview-actions{
    width:100%;
  }

  .replace-image-btn,
  .restore-image-btn{
    flex:1;
    min-width:120px;
  }
}


/* ===== Supabase 云端版 ===== */
.cloud-status{
  display:inline-flex;
  align-items:center;
  min-height:38px;
  padding:0 11px;
  border-radius:999px;
  background:#eef3ef;
  color:#65756a;
  font-size:12px;
  font-weight:700;
  white-space:nowrap;
}
.cloud-status.ok{
  background:#e7f5e9;
  color:#2f7552;
}
.cloud-status.syncing{
  background:#f6f2df;
  color:#817137;
}
.cloud-status.error{
  background:#fff0ed;
  color:#b95548;
}

.card-edit-btn{
  position:absolute;
  left:8px;
  top:8px;
  z-index:3;
  min-height:32px;
  padding:0 10px;
  border:0;
  border-radius:999px;
  background:rgba(255,255,255,.94);
  color:#2f6f50;
  font-size:12px;
  font-weight:800;
  box-shadow:0 3px 10px rgba(0,0,0,.10);
}

.small-modal-card{
  width:min(460px,100%);
}

.dish-form.one-column{
  grid-template-columns:1fr;
}

.edit-form-actions{
  display:flex;
  gap:10px;
}
.edit-form-actions button{
  flex:1;
}

.top-actions{
  align-items:center;
  justify-content:flex-end;
}

@media(max-width:820px){
  .top-actions{
    flex-wrap:wrap;
  }
}

@media(max-width:620px){
  .topbar{
    align-items:flex-start;
  }

  .top-actions{
    justify-content:flex-end;
    max-width:66%;
  }

  .cloud-status{
    order:10;
    min-height:30px;
    padding:0 9px;
    font-size:11px;
  }

  #refreshCloudBtn{
    display:none;
  }

  #adminLoginBtn,
  #adminLogoutBtn{
    font-size:0;
  }
  #adminLoginBtn::after{
    content:"管理";
    font-size:13px;
  }
  #adminLogoutBtn::after{
    content:"退出";
    font-size:13px;
  }

  .card-edit-btn{
    min-height:29px;
    padding:0 8px;
    font-size:11px;
  }

  .edit-form-actions{
    flex-direction:column;
  }
}
