/* ------------------------------------------------------------------
   Theme comes from /branding.json at boot (app.js injects these
   variables). Values below are the pre-boot defaults and match the
   config; do not edit colours here — edit config/branding.json.
   System fonts only. Zero external dependencies.
------------------------------------------------------------------ */
:root{
  --navy:#0F2A43; --amber:#F5A623; --bg:#F6F7F9; --surface:#FFFFFF;
  --text:#1A2733; --muted:#6B7A88; --line:#E3E8ED;
  --green:#1E8E4D; --red:#C0392B; --orange:#D96C00; --blue:#2563EB;
  --radius:12px; --tab-h:60px;
  --font:-apple-system,"PingFang SC","Hiragino Sans GB","Microsoft YaHei",
         "Noto Sans SC","Source Han Sans SC",system-ui,sans-serif;
}
*{box-sizing:border-box}
html{-webkit-text-size-adjust:100%}
body{
  margin:0; background:var(--bg); color:var(--text);
  font-family:var(--font); font-size:15px; line-height:1.5;
  -webkit-tap-highlight-color:transparent;
}
a{color:var(--navy); text-decoration:none}
button{font-family:var(--font); cursor:pointer}
input,select,textarea{font-family:var(--font); font-size:15px; color:var(--text)}
img{max-width:100%}
h1{font-size:20px; margin:0 0 12px}
h2{font-size:17px; margin:20px 0 8px}
h3{font-size:15px; margin:16px 0 6px}

/* ---------- header / layout ---------- */
.offline-bar{
  position:sticky; top:0; z-index:60; background:#B45309; color:#fff;
  text-align:center; font-size:13px; padding:6px 10px;
}
.app-header{
  position:sticky; top:0; z-index:50; background:var(--navy); color:#fff;
  padding-top:env(safe-area-inset-top);
}
.header-inner{
  max-width:720px; margin:0 auto; display:flex; align-items:center;
  justify-content:space-between; padding:10px 14px;
}
.brand-block{display:flex; align-items:center; gap:10px; min-width:0}
.brand-mark{display:flex; flex:none}
.brand-text{display:flex; flex-direction:column; min-width:0}
.brand-name{font-size:17px; font-weight:700; letter-spacing:.2px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
.brand-slogan{font-size:11px; color:#B9C6D2; white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
.header-right{display:flex; align-items:center; gap:8px; flex:none}
.mode-badge{
  font-size:12px; background:rgba(255,255,255,.14); color:#fff;
  padding:5px 10px; border-radius:999px; border:1px solid rgba(255,255,255,.25);
}
.icon-btn{
  width:38px; height:38px; border-radius:50%; border:none;
  background:var(--amber); color:#1A2733; font-size:22px; line-height:1;
  display:flex; align-items:center; justify-content:center; font-weight:700;
}
.app-main{max-width:720px; margin:0 auto; padding:14px 14px calc(var(--tab-h) + 26px);}
.view{min-height:40vh}

/* ---------- tab bar ---------- */
.tabbar{
  position:fixed; left:0; right:0; bottom:0; z-index:50;
  background:var(--surface); border-top:1px solid var(--line);
  padding-bottom:env(safe-area-inset-bottom);
  display:flex; justify-content:space-around;
}
.tab-btn{
  flex:1; border:none; background:none; padding:7px 0 6px;
  display:flex; flex-direction:column; align-items:center; gap:2px;
  color:var(--muted); font-size:11px; min-height:var(--tab-h);
}
.tab-btn svg{width:23px; height:23px}
.tab-btn.active{color:var(--navy); font-weight:700}
.tab-btn.active svg{stroke:var(--navy)}
.tab-btn .tab-dot{
  position:absolute; top:6px; right:calc(50% - 16px);
  min-width:16px; height:16px; border-radius:8px; background:var(--red);
  color:#fff; font-size:10px; line-height:16px; text-align:center; padding:0 4px;
}
.tab-btn{position:relative}

/* ---------- cards / lists ---------- */
.card{
  background:var(--surface); border:1px solid var(--line);
  border-radius:var(--radius); padding:14px; margin-bottom:12px;
  box-shadow:0 1px 2px rgba(16,42,67,.05);
}
.card h3{margin:0 0 6px}
.card-row{display:flex; justify-content:space-between; align-items:center; gap:10px}
.card-title{font-weight:700; font-size:16px}
.muted{color:var(--muted); font-size:13px}
.small{font-size:12px; color:var(--muted)}
.kv{display:flex; justify-content:space-between; gap:12px; padding:5px 0; font-size:14px}
.kv b{font-weight:600; text-align:right}
.list-item{
  display:block; background:var(--surface); border:1px solid var(--line);
  border-radius:var(--radius); padding:13px 14px; margin-bottom:10px; color:var(--text);
}
.list-item:active{background:#EEF2F5}
.stat-grid{display:grid; grid-template-columns:repeat(2,1fr); gap:10px; margin-bottom:12px}
.stat{
  background:var(--surface); border:1px solid var(--line); border-radius:var(--radius);
  padding:12px; text-align:center;
}
.stat .num{font-size:24px; font-weight:800; color:var(--navy); line-height:1.1}
.stat .lbl{font-size:12px; color:var(--muted); margin-top:2px}
.stat.warn .num{color:var(--red)}
.stat.warn{border-color:#F0C6C0}
.chip{
  display:inline-block; font-size:12px; padding:3px 9px; border-radius:999px;
  background:#EDF1F4; color:var(--navy); margin:0 4px 4px 0; white-space:nowrap;
}
.chip.amber{background:#FDF0D5; color:#8A5A00}
.chip.green{background:#E2F3E8; color:var(--green)}
.chip.red{background:#FBE9E7; color:var(--red)}
.chip.navy{background:var(--navy); color:#fff}
.flames{letter-spacing:1px; font-size:16px; color:var(--amber)}
.flames .off{color:#D5DDE3}
.hearts{letter-spacing:1px; font-size:16px; color:#E0245E}
.hearts .off{color:#D5DDE3}
.dot-status{width:10px; height:10px; border-radius:50%; display:inline-block; margin-right:6px; vertical-align:middle}

/* ---------- buttons / forms ---------- */
.btn{
  display:inline-block; border:none; border-radius:10px; padding:12px 18px;
  font-size:15px; font-weight:700; background:var(--navy); color:#fff;
  min-height:44px; text-align:center;
}
.btn.amber{background:var(--amber); color:#1A2733}
.btn.ghost{background:#fff; color:var(--navy); border:1px solid var(--navy)}
.btn.danger{background:#fff; color:var(--red); border:1px solid var(--red)}
.btn.subtle{background:#EDF1F4; color:var(--navy)}
.btn.small{padding:8px 12px; min-height:36px; font-size:13px; border-radius:8px}
.btn.block{width:100%}
.btn:disabled{opacity:.55; cursor:wait}
.btn-row{display:flex; gap:8px; flex-wrap:wrap; margin:10px 0}
.btn-row .btn{flex:1; min-width:120px}
.field{margin-bottom:12px}
.field label{display:block; font-size:13px; font-weight:600; margin-bottom:4px}
.field input,.field select,.field textarea{
  width:100%; border:1px solid #CBD5DD; border-radius:9px; padding:11px 12px;
  background:#fff; min-height:44px;
}
.field textarea{min-height:88px; resize:vertical}
.field .hint{font-size:12px; color:var(--muted); margin-top:3px}
.field-row{display:flex; gap:10px}
.field-row .field{flex:1}
input[type=checkbox],input[type=radio]{width:20px; height:20px; accent-color:var(--navy)}
.check-line{display:flex; align-items:center; gap:8px; padding:7px 0; font-size:15px}
.seg{display:flex; gap:6px; flex-wrap:wrap; margin:8px 0 12px}
.seg button{
  border:1px solid #CBD5DD; background:#fff; border-radius:999px;
  padding:8px 14px; font-size:13px; min-height:36px;
}
.seg button.on{background:var(--navy); color:#fff; border-color:var(--navy)}
.toolbar{display:flex; gap:8px; align-items:center; margin-bottom:12px; flex-wrap:wrap}
.toolbar input[type=search],.toolbar select{
  flex:1; min-width:120px; border:1px solid #CBD5DD; border-radius:9px;
  padding:10px 12px; background:#fff; min-height:42px;
}

/* ---------- states ---------- */
.skeleton{
  border-radius:var(--radius); background:linear-gradient(90deg,#E8EDF1 25%,#F4F7F9 50%,#E8EDF1 75%);
  background-size:200% 100%; animation:shim 1.2s infinite; min-height:76px; margin-bottom:10px;
}
@keyframes shim{to{background-position:-200% 0}}
.error-card{
  background:#FDF0EF; border:1px solid #F0C6C0; border-radius:var(--radius);
  padding:16px; margin-bottom:12px; text-align:center;
}
.empty{
  text-align:center; color:var(--muted); padding:32px 16px;
  background:var(--surface); border:1px dashed var(--line); border-radius:var(--radius);
}
.spin{display:inline-block; width:16px; height:16px; border:2px solid #CBD5DD; border-top-color:var(--navy); border-radius:50%; animation:rot .7s linear infinite; vertical-align:-3px}
@keyframes rot{to{transform:rotate(360deg)}}
.save-state{font-size:12px; color:var(--muted); text-align:right; min-height:18px}
.save-state.err{color:var(--red); font-weight:600}
.progress{height:10px; background:#E8EDF1; border-radius:5px; overflow:hidden}
.progress > div{height:100%; background:var(--amber); transition:width .3s}

/* ---------- photos / gallery ---------- */
.gallery{display:flex; gap:8px; overflow-x:auto; padding-bottom:4px; margin:8px 0}
.gallery img{width:150px; height:110px; object-fit:cover; border-radius:10px; flex:none; border:2px solid transparent}
.gallery img.main{border-color:var(--amber)}
.main-photo{width:100%; height:230px; object-fit:cover; border-radius:var(--radius); display:block}
.photo-placeholder{
  width:100%; height:230px; border-radius:var(--radius); display:flex;
  align-items:center; justify-content:center; color:#fff; font-size:18px; font-weight:700;
  background:linear-gradient(135deg,var(--navy),#2A5A7A);
}
details.extras{border:1px solid var(--line); border-radius:var(--radius); padding:10px 14px; background:#FBFCFD; margin:10px 0}
details.extras summary{font-weight:700; cursor:pointer; min-height:32px}
details.extras summary::-webkit-details-marker{display:none}

/* ---------- map (zero-dependency tiles) ---------- */
.map-wrap{position:relative; height:62vh; min-height:380px; border-radius:var(--radius); overflow:hidden; border:1px solid var(--line); background:#DDE5E9; touch-action:none}
.map-tiles{position:absolute; inset:0}
.map-tiles img{position:absolute; width:256px; height:256px; user-select:none; -webkit-user-drag:none; pointer-events:none}
.map-marker{
  position:absolute; transform:translate(-50%,-100%); cursor:pointer; z-index:5;
  font-size:22px; line-height:1; text-shadow:0 1px 3px rgba(0,0,0,.4);
}
.map-marker.sel{font-size:30px; z-index:6}
.map-center{position:absolute; left:50%; top:50%; transform:translate(-50%,-50%); font-size:20px; pointer-events:none; z-index:4; opacity:.7}
.map-controls{position:absolute; right:10px; top:10px; z-index:10; display:flex; flex-direction:column; gap:6px}
.map-controls button{
  width:38px; height:38px; border-radius:8px; border:1px solid var(--line);
  background:#fff; font-size:18px; font-weight:700; box-shadow:0 1px 4px rgba(0,0,0,.2);
}
.map-radius{position:absolute; left:10px; top:10px; z-index:10; display:flex; gap:4px}
.map-radius button{
  border:1px solid var(--line); background:#fff; border-radius:999px;
  padding:6px 11px; font-size:12px; font-weight:700; box-shadow:0 1px 4px rgba(0,0,0,.15);
}
.map-radius button.on{background:var(--navy); color:#fff}
.map-attrib{position:absolute; right:6px; bottom:4px; z-index:10; font-size:10px; color:#555; background:rgba(255,255,255,.75); padding:1px 5px; border-radius:4px}

/* ---------- sheet / toast ---------- */
.sheet-backdrop{
  position:fixed; inset:0; background:rgba(10,25,40,.5); z-index:80;
  display:flex; align-items:flex-end; justify-content:center;
}
.sheet{
  background:#fff; border-radius:16px 16px 0 0; width:100%; max-width:720px;
  max-height:86vh; overflow-y:auto; padding:18px 16px calc(20px + env(safe-area-inset-bottom));
}
.sheet h2{margin-top:0}
.toast-root{position:fixed; left:0; right:0; bottom:calc(var(--tab-h) + 18px); z-index:100; display:flex; flex-direction:column; align-items:center; gap:6px; pointer-events:none}
.toast{
  background:var(--navy); color:#fff; border-radius:999px; padding:10px 18px;
  font-size:14px; box-shadow:0 4px 14px rgba(0,0,0,.3); max-width:90vw; text-align:center;
}
.toast.err{background:var(--red)}

/* ---------- misc ---------- */
.badge-count{
  background:var(--red); color:#fff; border-radius:999px; font-size:11px;
  padding:2px 7px; font-weight:700; vertical-align:middle; margin-left:4px;
}
.timeline{border-left:2px solid var(--line); margin:8px 0 8px 6px; padding-left:14px}
.timeline-item{margin-bottom:12px; font-size:14px}
.timeline-item .t{font-size:12px; color:var(--muted)}
.countdown{font-variant-numeric:tabular-nums; font-weight:800; color:var(--red)}
.countdown.ok{color:var(--green)}
.login-wrap{max-width:420px; margin:8vh auto 0}
.login-wrap .logo-big{text-align:center; margin-bottom:18px}
.qr-box{text-align:center; padding:12px}
.qr-box img{width:200px; height:200px; image-rendering:pixelated}
table.preview{width:100%; border-collapse:collapse; font-size:13px}
table.preview th,table.preview td{border:1px solid var(--line); padding:6px 8px; text-align:left}
table.preview th{background:#EDF1F4}
.diff-old{color:var(--muted); text-decoration:line-through}
.diff-new{color:var(--green); font-weight:700}
@media (min-width:768px){
  .stat-grid{grid-template-columns:repeat(4,1fr)}
  .two-col{display:grid; grid-template-columns:1fr 1fr; gap:12px}
}
