:root{
  --bg:#FAF7F1;
  --surface:#FFFFFF;
  --surface-2:#F1ECE1;
  --ink:#142235;
  --muted:#5B6B7F;
  --line:#DDD5C4;
  --accent:#033B78;
  --accent-2:#D4A338;
  --accent-3:#0EA5E9;
  --good:#2E7D5B;
  --warn:#B9701F;
  --danger:#B3261E;
  --shadow: 0 1px 2px rgba(20,34,53,.06), 0 8px 24px rgba(20,34,53,.06);
}
@media (prefers-color-scheme: dark){
  :root{
    --bg:#0B1420; --surface:#101B2B; --surface-2:#0E1826; --ink:#E7ECF3; --muted:#93A4BA;
    --line:#233248; --accent:#5FA1E8; --accent-2:#E7BE6B; --accent-3:#4FD2FF;
    --good:#6FCBA1; --warn:#E0A45C; --danger:#F2A29B;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 12px 32px rgba(0,0,0,.35);
  }
}
*{box-sizing:border-box;}
body{
  margin:0; background:var(--bg); color:var(--ink);
  font-family:"Noto Sans TC","PingFang TC","Microsoft JhengHei",system-ui,-apple-system,sans-serif;
  line-height:1.6;
}
a{color:inherit;}
.topbar{
  background:var(--accent); color:#F4F0E4; padding:12px 20px;
  display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:8px;
}
.topbar .pill{background:rgba(255,255,255,.14); color:#fff; border-color:rgba(255,255,255,.4); white-space:nowrap;}
.topbar .brand{font-weight:800; font-size:15px; text-decoration:none; color:#fff;}
.topbar .who{font-size:13px; color:#DCE6F2; display:flex; align-items:center; gap:10px; flex-wrap:wrap;}
@media (max-width:640px){
  .topbar{padding:10px 12px;}
  .topbar .who{width:100%; gap:6px; justify-content:flex-start;}
  .topbar .who > a:first-child{flex:1 1 100%; font-size:12.5px;}
}
.topbar button{
  background:rgba(255,255,255,.12); border:1px solid rgba(255,255,255,.25); color:#fff;
  padding:6px 12px; border-radius:6px; font-size:12.5px; cursor:pointer;
}
.topbar button:hover{background:rgba(255,255,255,.22);}
main{max-width:1040px; margin:0 auto; padding:24px 20px 80px;}
h1{font-size:20px; margin:0 0 4px;}
.sub{color:var(--muted); font-size:13.5px; margin:0 0 20px;}

.card{background:var(--surface); border:1px solid var(--line); border-radius:10px; box-shadow:var(--shadow); padding:18px;}
.table-wrap{overflow-x:auto; border:1px solid var(--line); border-radius:10px; background:var(--surface); box-shadow:var(--shadow);}
table{width:100%; border-collapse:collapse; font-size:13.6px;}
th,td{text-align:left; padding:10px 12px; border-bottom:1px solid var(--line); vertical-align:middle;}
thead th{background:var(--surface-2); font-size:12px; text-transform:uppercase; letter-spacing:.03em; color:var(--muted); font-weight:700;}
tbody tr:last-child td{border-bottom:none;}
tbody tr:hover{background:var(--surface-2);}
.mono{font-family:ui-monospace,SFMono-Regular,Consolas,monospace; font-variant-numeric:tabular-nums;}

.btn{
  display:inline-flex; align-items:center; gap:6px; border:1px solid var(--line); background:var(--surface);
  color:var(--ink); padding:8px 14px; border-radius:8px; font-size:13.5px; cursor:pointer; text-decoration:none;
}
.btn:hover{background:var(--surface-2);}
.btn-primary{background:var(--accent); border-color:var(--accent); color:#fff;}
.btn-primary:hover{opacity:.92;}
.btn-sm{padding:5px 10px; font-size:12.5px;}
.btn-danger{color:var(--danger); border-color:var(--danger);}

.pill{font-size:11.5px; padding:4px 10px; border-radius:999px; background:var(--surface-2); border:1px solid var(--line); color:var(--muted); cursor:pointer; text-decoration:none;}
.pill.active{background:var(--accent); color:#fff; border-color:var(--accent);}
.tabs{display:flex; gap:8px; margin-bottom:16px; flex-wrap:wrap;}

.status-badge{white-space:nowrap; font-size:11px; padding:2px 9px; border-radius:999px; font-weight:700;}
.status-草稿{background:rgba(91,107,127,.15); color:var(--muted);}
.status-已送出{background:rgba(212,163,56,.18); color:var(--accent-2);}
.status-訂單{background:rgba(46,125,91,.15); color:var(--good);}
.status-未成交{background:rgba(179,38,30,.12); color:var(--danger);}

.field{margin-bottom:14px;}
.field label{display:block; font-size:12.5px; color:var(--muted); margin-bottom:4px; font-weight:600;}
.field input, .field select, .field textarea{
  width:100%; padding:8px 10px; border:1px solid var(--line); border-radius:6px; background:var(--surface);
  color:var(--ink); font-size:13.8px; font-family:inherit;
}
.field textarea{min-height:64px; resize:vertical;}
.row-2{display:grid; grid-template-columns:1fr 1fr; gap:14px;}
.row-3{display:grid; grid-template-columns:1fr 1fr 1fr; gap:14px;}
@media (max-width:700px){.row-2,.row-3{grid-template-columns:1fr;}}

.login-wrap{
  min-height:100vh; display:flex; align-items:center; justify-content:center; padding:20px;
}
.login-card{width:100%; max-width:360px;}
.login-card h1{text-align:center; color:var(--accent);}
.login-card .sub{text-align:center;}
.error-msg{color:var(--danger); font-size:13px; margin:8px 0 0; min-height:18px;}
.hint{color:var(--muted); font-size:12px; margin-top:16px; text-align:center;}

/* 首頁流程式導覽：兩排、一排四個，不用捲動就看得到全部 */
.pipeline{
  display:grid; grid-template-columns:repeat(4,1fr); gap:12px; padding:6px 2px 16px;
}
@media (max-width:760px){.pipeline{grid-template-columns:repeat(2,1fr);}}
.stage{
  --sc: var(--muted);
  text-decoration:none; color:var(--ink); min-height:104px;
  background:var(--surface); border:1px solid var(--line); border-top:4px solid var(--sc);
  border-radius:10px; padding:14px 14px 12px; box-shadow:var(--shadow);
  display:flex; flex-direction:column; gap:6px;
  transition:transform .1s ease, box-shadow .1s ease;
}
.stage:not(.disabled):hover{transform:translateY(-1px); box-shadow:0 4px 14px rgba(20,34,53,.12);}
.stage.disabled{opacity:.5; cursor:default; pointer-events:none;}
.stage-no{font-size:13px; color:var(--sc); font-weight:800;}
.stage-name{font-size:17px; font-weight:800; line-height:1.3; letter-spacing:.01em;}
.stage-metric{font-size:12px; color:var(--sc); font-weight:700; margin-top:auto;}

.overview-grid{display:grid; grid-template-columns:repeat(auto-fit,minmax(160px,1fr)); gap:14px; margin-top:20px;}
.stat-tile{background:var(--surface); border:1px solid var(--line); border-radius:10px; padding:14px 16px; box-shadow:var(--shadow);}
.stat-tile .n{font-size:24px; font-weight:800; font-variant-numeric:tabular-nums;}
.stat-tile .l{font-size:12.5px; color:var(--muted); margin-top:2px;}

.items-table input, .items-table select{padding:5px 6px; font-size:13px;}
.items-table td{padding:6px 8px;}
.totals-row td{font-weight:700; background:var(--surface-2);}
.toolbar{display:flex; justify-content:space-between; align-items:center; margin-bottom:16px; gap:12px; flex-wrap:wrap;}
.locked-note{font-size:12px; color:var(--muted); font-style:italic;}
