/* ============================================================
   WH-控制台 · style.css
   主色：黑　輔色：金 / 白
   ============================================================ */

:root {
  /* 底色階梯（近黑 → 微亮） */
  --bg:        #060709;
  --bg-soft:   #0A0C10;
  --panel:     #0E1116;
  --panel-2:   #13171E;
  --panel-3:   #191E27;
  --line:      #1E232C;
  --line-2:    #2B323D;

  /* 金 */
  --gold:      #E9C46A;
  --gold-lt:   #F7E3B0;
  --gold-dk:   #A87F2A;
  --gold-ghost: rgba(233,196,106,0.10);
  --gold-glow: rgba(233,196,106,0.22);

  /* 白階 */
  --txt:       #F3F6FA;
  --txt-2:     #9AA5B3;
  --txt-3:     #616C7B;

  /* 狀態 */
  --ok:        #35D0A5;
  --warn:      #E9C46A;
  --bad:       #FF5E6B;
  --idle:      #6B7684;

  --r-sm: 8px;
  --r:    12px;
  --r-lg: 18px;

  --shadow:    0 1px 0 rgba(255,255,255,0.03) inset, 0 18px 40px -24px rgba(0,0,0,0.9);
  --shadow-gold: 0 0 0 1px var(--gold-glow), 0 10px 34px -18px var(--gold-glow);

  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC",
          "Noto Sans TC", "Microsoft JhengHei", sans-serif;

  --sidebar-w: 244px;
  --topbar-h: 64px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--txt);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  background-image:
    radial-gradient(900px 500px at 12% -8%, rgba(233,196,106,0.055), transparent 60%),
    radial-gradient(700px 420px at 92% 0%, rgba(233,196,106,0.035), transparent 62%),
    linear-gradient(180deg, #08090C 0%, #060709 40%);
  background-attachment: fixed;
}

a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-lt); }

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
::selection { background: var(--gold-glow); color: #fff; }

/* 捲軸 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #232A34; border-radius: 99px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #333C49; background-clip: content-box; }

:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 4px; }

/* ============================================================
   佈局
   ============================================================ */

.app { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(19,23,30,0.85), rgba(6,7,9,0.9));
  backdrop-filter: blur(8px);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  z-index: 40;
}

.brand {
  display: flex; align-items: center; gap: 11px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--line);
}
.brand-mark {
  width: 38px; height: 38px; flex: 0 0 38px;
  border-radius: 11px;
  background: linear-gradient(145deg, #1b1f27, #0b0d11);
  border: 1px solid var(--line-2);
  display: grid; place-items: center;
  font-family: var(--mono); font-weight: 700; font-size: 14px;
  color: var(--gold);
  box-shadow: 0 0 0 1px var(--gold-ghost), 0 6px 18px -10px var(--gold-glow);
  letter-spacing: 0.5px;
}
.brand-text { min-width: 0; }
.brand-name {
  font-size: 15px; font-weight: 700; letter-spacing: 0.5px;
  background: linear-gradient(92deg, #fff 10%, var(--gold-lt) 55%, var(--gold) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  white-space: nowrap;
}
.brand-sub { font-size: 11px; color: var(--txt-3); letter-spacing: 2px; text-transform: uppercase; font-family: var(--mono); }

.nav { padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-label {
  font-size: 10px; letter-spacing: 1.6px; text-transform: uppercase;
  color: var(--txt-3); font-family: var(--mono);
  padding: 14px 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: var(--r-sm);
  color: var(--txt-2); cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s, color .15s, border-color .15s;
  background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: var(--panel-2); color: var(--txt); }
.nav-item.active {
  background: linear-gradient(90deg, var(--gold-ghost), rgba(233,196,106,0.03));
  color: var(--gold-lt);
  border-color: rgba(233,196,106,0.22);
}
.nav-item.active .nav-ico { color: var(--gold); }
.nav-ico { width: 18px; flex: 0 0 18px; color: var(--txt-3); display: grid; place-items: center; }
.nav-txt { flex: 1; font-size: 13.5px; font-weight: 500; }
.nav-count {
  font-family: var(--mono); font-size: 11px; color: var(--txt-3);
  background: var(--panel-3); border-radius: 99px; padding: 1px 7px;
}
.nav-item.active .nav-count { color: var(--gold); background: var(--gold-ghost); }

.sidebar-foot {
  border-top: 1px solid var(--line);
  padding: 12px 14px 14px;
  font-size: 11px; color: var(--txt-3);
  display: flex; flex-direction: column; gap: 8px;
}
.sysline { display: flex; align-items: center; gap: 7px; font-family: var(--mono); }

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h);
  flex: 0 0 var(--topbar-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(8,9,12,0.72);
  backdrop-filter: blur(14px);
  position: sticky; top: 0; z-index: 30;
}
.topbar h1 {
  margin: 0; font-size: 16px; font-weight: 700; letter-spacing: .3px;
  white-space: nowrap;
}
.topbar .crumb { color: var(--txt-3); font-size: 12px; font-family: var(--mono); }
.topbar-spacer { flex: 1; }

.searchbox {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 99px; padding: 6px 12px; width: 260px;
  transition: border-color .15s, box-shadow .15s;
}
.searchbox:focus-within { border-color: var(--gold-dk); box-shadow: 0 0 0 3px var(--gold-ghost); }
.searchbox input { flex: 1; background: none; border: none; outline: none; font-size: 13px; min-width: 0; }
.searchbox input::placeholder { color: var(--txt-3); }
.searchbox kbd {
  font-family: var(--mono); font-size: 10px; color: var(--txt-3);
  border: 1px solid var(--line-2); border-radius: 4px; padding: 0 4px;
}

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px; border-radius: var(--r-sm);
  background: var(--panel-2); color: var(--txt-2);
  border: 1px solid var(--line); cursor: pointer;
  font-size: 13px; font-weight: 500; white-space: nowrap;
  transition: all .15s;
}
.btn:hover { background: var(--panel-3); color: var(--txt); border-color: var(--line-2); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(180deg, #F0D288, var(--gold));
  color: #1A1408; border-color: var(--gold-dk); font-weight: 700;
  box-shadow: 0 6px 18px -10px var(--gold-glow);
}
.btn-primary:hover { background: linear-gradient(180deg, #F7E3B0, #EFCF80); color: #1A1408; }
.btn-ghost { background: none; }
.btn-danger:hover { color: var(--bad); border-color: rgba(255,94,107,0.4); background: rgba(255,94,107,0.08); }
.btn-icon { padding: 7px; width: 32px; height: 32px; justify-content: center; }
.btn[disabled] { opacity: .45; pointer-events: none; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 11px; letter-spacing: .4px;
  padding: 4px 10px; border-radius: 99px;
  border: 1px solid var(--line-2); background: var(--panel-2); color: var(--txt-2);
}
.pill.ok   { color: var(--ok);   border-color: rgba(53,208,165,.32); background: rgba(53,208,165,.08); }
.pill.warn { color: var(--warn); border-color: rgba(233,196,106,.32); background: var(--gold-ghost); }
.pill.bad  { color: var(--bad);  border-color: rgba(255,94,107,.32); background: rgba(255,94,107,.08); }

.dot { width: 7px; height: 7px; border-radius: 99px; background: var(--idle); flex: 0 0 7px; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px rgba(53,208,165,.14); }
.dot.bad { background: var(--bad); box-shadow: 0 0 0 3px rgba(255,94,107,.14); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 3px rgba(233,196,106,.14); }
.dot.idle { background: var(--idle); box-shadow: 0 0 0 3px rgba(107,118,132,.14); }
.dot.pulse { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* ---------- Views ---------- */
.views { padding: 22px; flex: 1; }
.view { display: none; animation: fade .25s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.section-head {
  display: flex; align-items: center; gap: 12px;
  margin: 26px 0 13px;
}
.section-head:first-child { margin-top: 0; }
.section-head h2 {
  margin: 0; font-size: 13px; font-weight: 700;
  letter-spacing: 1.6px; text-transform: uppercase;
  color: var(--txt-2); font-family: var(--mono);
}
.section-head .rule { flex: 1; height: 1px; background: linear-gradient(90deg, var(--line-2), transparent); }
.section-head .count { font-family: var(--mono); font-size: 11px; color: var(--txt-3); }

/* ============================================================
   KPI
   ============================================================ */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); gap: 12px; }

.kpi {
  background: linear-gradient(160deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 15px 16px 14px;
  position: relative; overflow: hidden;
  box-shadow: var(--shadow);
}
.kpi::before {
  content: ""; position: absolute; inset: 0 auto auto 0;
  width: 100%; height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-glow), transparent);
}
.kpi-label {
  font-size: 11px; color: var(--txt-3); font-family: var(--mono);
  letter-spacing: 1.2px; text-transform: uppercase;
  display: flex; align-items: center; gap: 6px;
}
.kpi-val {
  font-size: 30px; font-weight: 700; line-height: 1.15; margin-top: 6px;
  font-variant-numeric: tabular-nums; letter-spacing: -0.5px;
}
.kpi-val .unit { font-size: 13px; color: var(--txt-3); font-weight: 500; margin-left: 3px; }
.kpi-val.gold { color: var(--gold); }
.kpi-val.ok { color: var(--ok); }
.kpi-val.bad { color: var(--bad); }
.kpi-foot { font-size: 11.5px; color: var(--txt-3); margin-top: 4px; font-family: var(--mono); }

/* ============================================================
   Panels
   ============================================================ */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 16px; border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,0.014);
}
.panel-head h3 { margin: 0; font-size: 13px; font-weight: 700; letter-spacing: .4px; }
.panel-head .spacer { flex: 1; }
.panel-body { padding: 16px; }

.two-col { display: grid; grid-template-columns: minmax(0,1.05fr) minmax(0,1fr); gap: 14px; align-items: start; }
@media (max-width: 1080px) { .two-col { grid-template-columns: 1fr; } }

/* Donut */
.donut-wrap { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.donut { position: relative; width: 148px; height: 148px; flex: 0 0 148px; }
.donut svg { transform: rotate(-90deg); display: block; }
.donut-mid {
  position: absolute; inset: 0; display: grid; place-content: center; text-align: center;
}
.donut-pct { font-size: 27px; font-weight: 700; color: var(--gold); font-variant-numeric: tabular-nums; line-height: 1; }
.donut-cap { font-size: 10.5px; color: var(--txt-3); font-family: var(--mono); letter-spacing: 1.4px; text-transform: uppercase; margin-top: 4px; }

.legend { display: flex; flex-direction: column; gap: 9px; flex: 1; min-width: 160px; }
.legend-row { display: flex; align-items: center; gap: 9px; font-size: 12.5px; }
.legend-row .sw { width: 9px; height: 9px; border-radius: 3px; flex: 0 0 9px; }
.legend-row .nm { flex: 1; color: var(--txt-2); }
.legend-row .vl { font-family: var(--mono); color: var(--txt); font-variant-numeric: tabular-nums; }
.legend-row .pc { font-family: var(--mono); color: var(--txt-3); width: 44px; text-align: right; }

/* Bars */
.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 108px 1fr 34px; align-items: center; gap: 10px; font-size: 12.5px; }
.bar-name { color: var(--txt-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { display: block; height: 7px; background: #0B0E12; border-radius: 99px; overflow: hidden; box-shadow: inset 0 0 0 1px var(--line); }
.bar-fill {
  display: block; height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--gold-dk), var(--gold));
  box-shadow: 0 0 10px -2px var(--gold-glow);
  transition: width .5s cubic-bezier(.22,1,.36,1);
}
.bar-num { font-family: var(--mono); color: var(--txt-3); text-align: right; font-variant-numeric: tabular-nums; }

/* ============================================================
   站點卡片
   ============================================================ */
.toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 5px 11px; border-radius: 99px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line);
  color: var(--txt-2); font-size: 12.5px; transition: all .15s;
}
.chip:hover { border-color: var(--line-2); color: var(--txt); }
.chip.active {
  background: var(--gold-ghost); border-color: rgba(233,196,106,0.32); color: var(--gold-lt);
}
.chip .n { font-family: var(--mono); font-size: 10.5px; opacity: .65; margin-left: 4px; }

.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 2px; }
.seg button {
  padding: 5px 11px; border: none; background: none; cursor: pointer;
  color: var(--txt-3); font-size: 12.5px; border-radius: 6px; transition: all .15s;
}
.seg button.active { background: var(--panel-3); color: var(--gold-lt); }

.site-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(288px, 1fr)); gap: 13px; }

.site-card {
  background: linear-gradient(165deg, var(--panel-2) 0%, var(--panel) 70%);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 15px 16px 13px;
  position: relative; overflow: hidden;
  cursor: pointer;
  transition: border-color .18s, transform .18s, box-shadow .18s;
  box-shadow: var(--shadow);
}
.site-card::after {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--accent, var(--gold)); opacity: .55;
}
.site-card::before {
  content: ""; position: absolute; inset: -1px -1px auto -1px; height: 90px;
  background: radial-gradient(220px 90px at 12% 0%, var(--accent-glow, var(--gold-ghost)), transparent 70%);
  pointer-events: none;
}
.site-card:hover { border-color: var(--line-2); transform: translateY(-2px); box-shadow: 0 22px 44px -26px rgba(0,0,0,.95); }
.site-card:hover::after { opacity: 1; }
.site-card.pinned { border-color: rgba(233,196,106,0.3); }

.sc-top { display: flex; align-items: flex-start; gap: 10px; position: relative; }
.sc-icon {
  width: 38px; height: 38px; flex: 0 0 38px; border-radius: 10px;
  display: grid; place-items: center;
  font-weight: 700; font-size: 14px; font-family: var(--mono);
  background: var(--panel-3); border: 1px solid var(--line-2);
  color: var(--accent, var(--gold));
  letter-spacing: .5px;
}
.sc-title { min-width: 0; flex: 1; }
.sc-name {
  font-size: 14px; font-weight: 700; letter-spacing: .2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; align-items: center; gap: 6px;
}
.sc-pin { color: var(--gold); font-size: 11px; }
.sc-url {
  font-family: var(--mono); font-size: 11px; color: var(--txt-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; align-items: center; gap: 4px;
}
.sc-desc {
  font-size: 12.5px; color: var(--txt-2); margin: 10px 0 0;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; min-height: 2.7em;
}
.sc-meta { display: flex; align-items: center; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.tag {
  font-size: 10.5px; font-family: var(--mono); letter-spacing: .3px;
  padding: 2px 7px; border-radius: 5px;
  background: var(--panel-3); border: 1px solid var(--line); color: var(--txt-2);
}
.tag.cat { color: var(--gold-lt); border-color: rgba(233,196,106,0.25); background: var(--gold-ghost); }
.sc-foot {
  display: flex; align-items: center; gap: 8px; margin-top: 12px;
  padding-top: 11px; border-top: 1px solid var(--line);
}
.sc-status { display: flex; align-items: center; gap: 6px; font-size: 11.5px; font-family: var(--mono); color: var(--txt-3); }
.sc-lat { color: var(--txt-3); }
.sc-actions {
  position: absolute; top: -6px; right: -6px;
  display: flex; gap: 3px;
  padding: 3px; border-radius: 10px;
  background: linear-gradient(180deg, rgba(19,23,30,.97), rgba(14,17,22,.97));
  border: 1px solid var(--line-2);
  box-shadow: 0 10px 24px -14px #000;
  opacity: 0; pointer-events: none;
  transition: opacity .18s;
}
.site-card:hover .sc-actions { opacity: 1; pointer-events: auto; }
.spark { display: inline-block; vertical-align: middle; }

/* 列表模式 */
.site-list { display: flex; flex-direction: column; gap: 6px; }
.sl-row {
  display: grid;
  grid-template-columns: 22px 34px minmax(0,1.4fr) minmax(0,1.5fr) 100px 92px 88px 34px;
  align-items: center; gap: 12px;
  padding: 10px 13px; border-radius: var(--r);
  background: var(--panel); border: 1px solid var(--line);
  cursor: pointer; transition: border-color .15s, background .15s;
}
.sl-row:hover { border-color: var(--line-2); background: var(--panel-2); }
.sl-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; gap: 6px; align-items: center; }
.sl-url { font-family: var(--mono); font-size: 11.5px; color: var(--txt-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sl-cell { font-family: var(--mono); font-size: 11.5px; color: var(--txt-2); }
.sl-icon {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  background: var(--panel-3); border: 1px solid var(--line);
  font-family: var(--mono); font-size: 11px; font-weight: 700; color: var(--accent, var(--gold));
}
@media (max-width: 900px) {
  .sl-row { grid-template-columns: 22px 30px minmax(0,1fr) 34px; }
  .sl-url, .sl-cell, .sl-row .tag { display: none; }
}

/* ============================================================
   活動記錄
   ============================================================ */
.log { display: flex; flex-direction: column; max-height: 340px; overflow-y: auto; }
.log-item {
  display: flex; gap: 11px; padding: 9px 2px;
  border-bottom: 1px dashed var(--line);
  font-size: 12.5px; align-items: flex-start;
}
.log-item:last-child { border-bottom: none; }
.log-time { font-family: var(--mono); font-size: 11px; color: var(--txt-3); flex: 0 0 82px; padding-top: 2px; white-space: nowrap; }
.log-msg { flex: 1; color: var(--txt-2); min-width: 0; word-break: break-word; }
.log-msg b { color: var(--txt); font-weight: 600; }
.log-badge { font-size: 10px; font-family: var(--mono); padding: 1px 6px; border-radius: 4px; flex: 0 0 auto; }
.log-badge.ok { color: var(--ok); background: rgba(53,208,165,.1); }
.log-badge.bad { color: var(--bad); background: rgba(255,94,107,.1); }
.log-badge.gold { color: var(--gold); background: var(--gold-ghost); }

/* ============================================================
   空狀態
   ============================================================ */
.empty {
  padding: 54px 20px; text-align: center;
  border: 1px dashed var(--line-2); border-radius: var(--r-lg);
  background: rgba(255,255,255,0.008);
}
.empty-ico { color: var(--txt-3); opacity: .5; margin-bottom: 10px; }
.empty h3 { margin: 0 0 6px; font-size: 15px; }
.empty p { margin: 0 0 16px; color: var(--txt-3); font-size: 13px; }

/* ============================================================
   Modal
   ============================================================ */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(3,4,6,0.76);
  backdrop-filter: blur(6px);
  display: none; align-items: center; justify-content: center;
  padding: 22px;
}
.overlay.open { display: flex; animation: fade .18s ease; }
.modal {
  width: 100%; max-width: 660px; max-height: 88vh;
  background: linear-gradient(180deg, var(--panel-2), var(--panel) 30%);
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  box-shadow: 0 40px 90px -40px #000, 0 0 0 1px rgba(233,196,106,0.06);
  display: flex; flex-direction: column; overflow: hidden;
  animation: pop .2s cubic-bezier(.22,1,.36,1);
}
.modal.wide { max-width: 820px; }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }
.modal-head {
  display: flex; align-items: center; gap: 12px;
  padding: 15px 18px; border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,0.016);
}
.modal-head h3 { margin: 0; font-size: 15px; font-weight: 700; }
.modal-head .spacer { flex: 1; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot {
  display: flex; align-items: center; gap: 9px;
  padding: 13px 18px; border-top: 1px solid var(--line);
  background: rgba(0,0,0,0.22);
}
.modal-foot .spacer { flex: 1; }

/* Detail */
.detail-hero { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 16px; }
.detail-icon {
  width: 54px; height: 54px; flex: 0 0 54px; border-radius: 14px;
  display: grid; place-items: center; font-family: var(--mono);
  font-size: 18px; font-weight: 700;
  background: var(--panel-3); border: 1px solid var(--line-2);
  color: var(--accent, var(--gold));
}
.detail-name { font-size: 18px; font-weight: 700; letter-spacing: .2px; display: flex; align-items: center; gap: 8px; }
.detail-sub { font-family: var(--mono); font-size: 12px; color: var(--txt-3); margin-top: 3px; word-break: break-all; }
.detail-desc { font-size: 13px; color: var(--txt-2); margin: 12px 0 0; }

.kv { display: grid; grid-template-columns: 96px 1fr; gap: 8px 12px; margin: 16px 0; font-size: 13px; }
.kv dt { color: var(--txt-3); font-size: 12px; }
.kv dd { margin: 0; color: var(--txt); word-break: break-all; font-family: var(--mono); font-size: 12.5px; }
.kv dd.plain { font-family: var(--sans); font-size: 13px; }

.notes-box {
  background: rgba(233,196,106,0.045);
  border: 1px solid rgba(233,196,106,0.18);
  border-left: 2px solid var(--gold);
  border-radius: var(--r-sm);
  padding: 11px 13px; font-size: 12.5px; color: var(--txt-2);
  white-space: pre-wrap; line-height: 1.7;
}
.qr-box {
  background: #fff; border-radius: var(--r-sm); padding: 8px;
  width: 148px; height: 148px; display: grid; place-items: center; flex: 0 0 148px;
}
.qr-box img { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.qr-fail { color: #666; font-size: 11px; text-align: center; font-family: var(--mono); }
.detail-right { display: flex; flex-direction: column; gap: 12px; align-items: flex-end; }

/* ============================================================
   Form
   ============================================================ */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 620px) { .form-grid { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 11.5px; color: var(--txt-3); font-family: var(--mono); letter-spacing: .8px; text-transform: uppercase; }
.field label .req { color: var(--gold); }
.input, textarea.input, select.input {
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 8px 11px; outline: none;
  font-size: 13px; width: 100%; transition: border-color .15s, box-shadow .15s;
  font-family: var(--sans);
}
.input.mono { font-family: var(--mono); font-size: 12.5px; }
textarea.input { resize: vertical; min-height: 66px; line-height: 1.6; }
.input:focus { border-color: var(--gold-dk); box-shadow: 0 0 0 3px var(--gold-ghost); }
.input::placeholder { color: var(--txt-3); }
select.input { cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%239AA5B3' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; padding-right: 30px;
}
.hint { font-size: 11.5px; color: var(--txt-3); line-height: 1.6; }
.hint code { font-family: var(--mono); background: var(--panel-3); padding: 1px 5px; border-radius: 4px; color: var(--gold-lt); }

.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch {
  width: 26px; height: 26px; border-radius: 7px; cursor: pointer;
  border: 2px solid transparent; transition: transform .12s, border-color .12s;
}
.swatch:hover { transform: scale(1.12); }
.swatch.active { border-color: #fff; }

/* ============================================================
   設定頁
   ============================================================ */
.set-list { display: flex; flex-direction: column; }
.set-row {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.set-row:last-child { border-bottom: none; }
.set-info { flex: 1; min-width: 0; }
.set-info h4 { margin: 0; font-size: 13.5px; font-weight: 600; }
.set-info p { margin: 3px 0 0; font-size: 12px; color: var(--txt-3); line-height: 1.6; }
.set-ctl { flex: 0 0 auto; display: flex; gap: 8px; align-items: center; }
.set-ctl .input { width: 210px; }
@media (max-width: 720px) {
  .set-row { flex-direction: column; align-items: stretch; }
  .set-ctl .input { width: 100%; }
}

.codebox {
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 13px;
  font-family: var(--mono); font-size: 11.5px; line-height: 1.75;
  color: var(--txt-2); overflow-x: auto; white-space: pre;
}
.codebox .k { color: var(--gold); }
.codebox .s { color: #7FD1C0; }
.codebox .n { color: #D9A3C7; }

/* ============================================================
   快捷鍵表
   ============================================================ */
.keys { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 9px 22px; }
.key-row { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--txt-2); }
.key-row kbd {
  font-family: var(--mono); font-size: 11px; color: var(--gold-lt);
  background: var(--panel-3); border: 1px solid var(--line-2);
  border-bottom-width: 2px; border-radius: 5px; padding: 2px 7px; min-width: 26px; text-align: center;
}

/* ============================================================
   Toast
   ============================================================ */
.toast-wrap {
  position: fixed; right: 20px; bottom: 20px; z-index: 200;
  display: flex; flex-direction: column; gap: 9px; align-items: flex-end;
}
.toast {
  display: flex; align-items: center; gap: 9px;
  background: linear-gradient(180deg, var(--panel-3), var(--panel));
  border: 1px solid var(--line-2); border-left: 2px solid var(--gold);
  border-radius: var(--r-sm); padding: 10px 15px; font-size: 13px;
  box-shadow: 0 18px 40px -20px #000; animation: slidein .22s cubic-bezier(.22,1,.36,1);
  max-width: 380px;
}
.toast.ok { border-left-color: var(--ok); }
.toast.bad { border-left-color: var(--bad); }
.toast.out { animation: slideout .2s ease forwards; }
@keyframes slidein { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes slideout { to { opacity: 0; transform: translateX(24px); } }

/* ============================================================
   進度 / 骨架
   ============================================================ */
.bar-prog { height: 2px; background: var(--panel-3); border-radius: 99px; overflow: hidden; opacity: 0; transition: opacity .3s; }
.bar-prog.show { opacity: 1; }
.bar-prog i {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--gold-dk), var(--gold-lt));
  transition: width .3s ease;
}
.bar-prog.done i { background: linear-gradient(90deg, #1E9B79, var(--ok)); }

.skeleton {
  background: linear-gradient(90deg, var(--panel-2), var(--panel-3), var(--panel-2));
  background-size: 200% 100%; animation: shimmer 1.3s infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ============================================================
   響應式
   ============================================================ */
@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%; flex: none; height: auto; position: static;
    border-right: none; border-bottom: 1px solid var(--line);
  }
  .nav { flex-direction: row; overflow-x: auto; padding: 8px; }
  .nav-label { display: none; }
  .nav-item { white-space: nowrap; width: auto; }
  .sidebar-foot { display: none; }
  .topbar { padding: 0 14px; gap: 10px; }
  .topbar h1 { font-size: 14px; }
  .searchbox { width: 100%; max-width: 200px; }
  .views { padding: 14px; }
}
@media (max-width: 560px) {
  .searchbox { display: none; }
  .kpi-val { font-size: 25px; }
  .donut { width: 118px; height: 118px; flex-basis: 118px; }
}

/* 列印 */
@media print {
  .sidebar, .topbar, .toolbar, .sc-actions { display: none !important; }
  body { background: #fff; color: #000; }
}