/* ===== SAGAWA 商城 — 主樣式 ===== */
:root{
  --brand:#0e8a4f;
  --brand-dark:#0a6b3d;
  --brand-soft:#e8f5ee;
  --bg:#f2f3f5;
  --card:#ffffff;
  --border:#e2e5ea;
  --text:#2c3038;
  --muted:#8a9099;
  --danger:#d94436;
  --warn:#b8860b;
  --radius:10px;
}
*{margin:0;padding:0;box-sizing:border-box}
html{-webkit-text-size-adjust:100%}
body{
  font-family:"PingFang TC","Microsoft JhengHei","Noto Sans TC",-apple-system,"Segoe UI",sans-serif;
  background:var(--bg);color:var(--text);font-size:15px;line-height:1.65;
}
a{color:var(--brand);text-decoration:none}
a:hover{text-decoration:underline}
.wrap{max-width:900px;margin:0 auto;padding:0 16px}
.main{min-height:60vh;padding:24px 16px 40px}

/* 頂欄 */
.topbar{background:linear-gradient(90deg,#0e8a4f,#12a862);color:#fff;position:sticky;top:0;z-index:50;box-shadow:0 2px 8px rgba(0,0,0,.08)}
.topbar-inner{display:flex;align-items:center;justify-content:space-between;height:58px}
.brand{display:flex;align-items:center;gap:10px;color:#fff;font-weight:700;font-size:18px}
.brand:hover{text-decoration:none}
.logo-mark{width:30px;height:30px;background:#fff;color:var(--brand);border-radius:8px;display:flex;align-items:center;justify-content:center;font-weight:800}
.nav{display:flex;gap:4px;align-items:center;flex-wrap:wrap}
.nav a{color:#fff;font-size:14px;padding:6px 10px;border-radius:6px;position:relative}
.nav a:hover,.nav a.on{background:rgba(255,255,255,.18);text-decoration:none}
.badge{display:inline-block;min-width:18px;height:18px;line-height:18px;padding:0 5px;margin-left:5px;background:#fff;color:var(--brand);border-radius:9px;font-size:11px;font-weight:800;text-align:center;vertical-align:middle}

/* 卡片 */
.card{background:var(--card);border:1px solid var(--border);border-radius:var(--radius);margin-bottom:20px;overflow:hidden}
.card-head{padding:16px 20px;border-bottom:1px solid var(--border);display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}
.card-head h1,.card-head h2{font-size:18px;color:var(--brand-dark);font-weight:700}
.card-body{padding:20px}
.card-head .sub{font-size:13px;color:var(--muted)}

/* 商品網格 */
.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(210px,1fr));gap:16px}
.product{background:var(--card);border:1px solid var(--border);border-radius:var(--radius);overflow:hidden;display:flex;flex-direction:column;transition:box-shadow .15s,transform .15s}
.product:hover{box-shadow:0 4px 16px rgba(0,0,0,.08);transform:translateY(-2px)}
.product .thumb{height:150px;background:linear-gradient(135deg,#f7f9fa,#eceff2);display:flex;align-items:center;justify-content:center;font-size:56px;border-bottom:1px solid var(--border)}
.product .thumb img{max-width:100%;max-height:100%;object-fit:cover}
.product .info{padding:14px;display:flex;flex-direction:column;gap:6px;flex:1}
.product .name{font-weight:700;font-size:15px;line-height:1.4}
.product .subtitle{font-size:12px;color:var(--muted)}
.product .price{color:var(--danger);font-weight:800;font-size:18px;margin-top:auto}
.product .stock{font-size:12px;color:var(--muted)}

/* 表單 */
.field{margin-bottom:16px}
.field label{display:block;font-size:14px;font-weight:600;margin-bottom:6px}
.field label .req{color:var(--danger)}
.field input[type=text],.field input[type=tel],.field input[type=email],
.field input[type=number],.field input[type=password],.field select,.field textarea{
  width:100%;padding:11px 12px;border:1px solid var(--border);border-radius:8px;font-size:15px;
  font-family:inherit;background:#fff;color:var(--text);transition:border-color .15s;
}
.field input:focus,.field select:focus,.field textarea:focus{outline:none;border-color:var(--brand)}
.field .hint{font-size:12px;color:var(--muted);margin-top:4px}
.row2{display:grid;grid-template-columns:1fr 1fr;gap:14px}

/* 按鈕 */
.btn{display:inline-block;padding:11px 20px;border:none;border-radius:8px;font-size:15px;font-weight:700;cursor:pointer;font-family:inherit;text-align:center;transition:background .15s,opacity .15s}
.btn:hover{text-decoration:none;opacity:.92}
.btn-primary{background:var(--brand);color:#fff}
.btn-primary:hover{background:var(--brand-dark)}
.btn-block{display:block;width:100%}
.btn-lg{padding:15px;font-size:17px}
.btn-ghost{background:#fff;border:1px solid var(--border);color:var(--text)}
.btn-danger{background:var(--danger);color:#fff}
.btn-sm{padding:6px 12px;font-size:13px}
.btn:disabled{opacity:.5;cursor:not-allowed}

/* 表格 */
.table-wrap{overflow-x:auto}
table.tbl{width:100%;border-collapse:collapse;font-size:14px;min-width:560px}
table.tbl th{background:#f7f8fa;color:#5a6068;padding:11px 10px;border-bottom:2px solid var(--border);font-weight:600;text-align:center;white-space:nowrap}
table.tbl td{padding:12px 10px;border-bottom:1px solid #f0f1f3;text-align:center;vertical-align:middle}
table.tbl td.left{text-align:left}
table.tbl tr:last-child td{border-bottom:none}
.mini-thumb{width:52px;height:52px;background:#f5f6f8;border:1px solid var(--border);border-radius:6px;display:flex;align-items:center;justify-content:center;font-size:24px;margin:0 auto;overflow:hidden}
.mini-thumb img{width:100%;height:100%;object-fit:cover}
.qty-box{display:inline-flex;align-items:center;border:1px solid var(--border);border-radius:6px;overflow:hidden}
.qty-box button{width:28px;height:28px;border:none;background:#f7f8fa;cursor:pointer;font-size:16px;line-height:1;color:var(--text)}
.qty-box button:hover{background:#eceff2}
.qty-box input{width:44px;height:28px;border:none;border-left:1px solid var(--border);border-right:1px solid var(--border);text-align:center;font-size:14px;font-family:inherit}
.amount{color:var(--danger);font-weight:700}

/* 金額小結 */
.summary{margin-top:18px;border-top:1px dashed var(--border);padding-top:6px}
.summary-row{display:flex;justify-content:space-between;align-items:center;padding:9px 0;font-size:14px}
.summary-row.total{border-top:1px solid var(--border);margin-top:6px;padding-top:14px;font-size:17px;font-weight:800;color:var(--danger)}
.summary-row.total .price{font-size:24px}

/* 付款 / 配送 選項 */
.option{display:flex;align-items:flex-start;gap:12px;border:1px solid var(--border);border-radius:8px;padding:13px 15px;margin-bottom:10px;cursor:pointer;transition:.15s}
.option:hover{border-color:var(--brand);background:#f7fdfa}
.option.selected{border-color:var(--brand);background:var(--brand-soft)}
.option .radio{width:19px;height:19px;border-radius:50%;border:2px solid #c2c7cf;flex-shrink:0;margin-top:2px;display:flex;align-items:center;justify-content:center}
.option.selected .radio{border-color:var(--brand)}
.option.selected .radio::after{content:"";width:9px;height:9px;border-radius:50%;background:var(--brand)}
.option .oname{font-weight:700;font-size:15px}
.option .odesc{font-size:12px;color:var(--muted)}
.option input[type=radio]{position:absolute;opacity:0;pointer-events:none}

/* 注意事項 */
.notice{background:#fffdf5;border:1px solid #f0e2be;border-radius:8px;padding:16px 18px}
.notice h3{color:#8a6d3b;font-size:15px;margin:0 0 10px}
.notice h3:not(:first-child){margin-top:16px}
.notice ol{padding-left:20px}
.notice li{font-size:13px;color:#6b5b3e;margin-bottom:7px;line-height:1.75}

/* 提示條 */
.flash{padding:12px 16px;border-radius:8px;margin-bottom:18px;font-size:14px}
.flash.ok{background:#e8f5ee;border:1px solid #b7e0c8;color:#0a6b3d}
.flash.err{background:#fdeceb;border:1px solid #f5c2bd;color:#a63228}

/* 徽章 / 狀態 */
.tag{display:inline-block;background:var(--brand-soft);color:var(--brand);border-radius:4px;padding:2px 8px;font-size:12px}
.status{display:inline-block;padding:3px 10px;border-radius:12px;font-size:12px;font-weight:700}
.st-pending{background:#fff4e5;color:#b8860b}
.st-paid{background:#e8f5ee;color:#0a6b3d}
.st-shipped{background:#e8f0fd;color:#2a5db0}
.st-done{background:#eceff2;color:#5a6068}
.st-cancel{background:#fdeceb;color:#a63228}

.empty{text-align:center;padding:50px 20px;color:var(--muted)}
.empty .ico{font-size:52px;margin-bottom:12px}

/* 後台 */
.admin-bar{display:flex;justify-content:space-between;align-items:center;gap:12px;flex-wrap:wrap;margin-bottom:18px}
.stats{display:grid;grid-template-columns:repeat(auto-fit,minmax(130px,1fr));gap:12px;margin-bottom:20px}
.stat{background:var(--card);border:1px solid var(--border);border-radius:var(--radius);padding:14px 16px}
.stat .n{font-size:24px;font-weight:800;color:var(--brand-dark)}
.stat .l{font-size:12px;color:var(--muted)}
.admin-login{max-width:380px;margin:60px auto}
.filters{display:flex;gap:10px;flex-wrap:wrap;margin-bottom:16px}
.filters input,.filters select{padding:9px 11px;border:1px solid var(--border);border-radius:8px;font-size:14px;font-family:inherit;background:#fff}
.kv{display:grid;grid-template-columns:120px 1fr;gap:8px 12px;font-size:14px}
.kv .k{color:var(--muted)}
.hl{background:#fffbe6;padding:2px 6px;border-radius:4px;font-family:ui-monospace,Menlo,Consolas,monospace;font-size:16px;letter-spacing:1px}

/* 頁尾 */
.footer{background:#fff;border-top:1px solid var(--border);padding:24px 0 40px;text-align:center;font-size:13px;color:var(--muted)}
.muted{color:var(--muted)}

/* RWD */
@media(max-width:600px){
  .row2{grid-template-columns:1fr}
  .topbar-inner{height:auto;padding:10px 0;flex-direction:column;gap:8px;align-items:flex-start}
  .nav{gap:2px}
  .nav a{padding:5px 8px;font-size:13px}
  .card-head{padding:14px 16px}
  .card-body{padding:16px}
  .grid{grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:12px}
  .kv{grid-template-columns:1fr}
}
