/* 風格：比照放風箏 APP — 深色底、琥珀橘強調、紅漲綠跌 */
:root {
  color-scheme: dark;
  --bg: #121212;
  --bg2: #1a1a1a;
  --card: #1f1f1f;
  --card2: #2a2a2a;
  --ink: #f2f2f2;
  --ink2: #a6a6a6;
  --line: #333333;
  --amber: #f5a623;
  --amber2: #ffc547;
  --kite-blue: #4aa8e8;
  --good: #ff4d4f;      /* 紅＝強／漲 */
  --good-bg: rgba(255, 77, 79, .14);
  --warn: #f5a623;
  --warn-bg: rgba(245, 166, 35, .14);
  --bad: #3ccf7a;       /* 綠＝弱／跌 */
  --bad-bg: rgba(60, 207, 122, .13);
  --muted: #8c8c8c;
  --muted-bg: #2b2b2b;
  --ink-bg: #2b2b2b;
  --radius: 12px;
  --font: "LXGW WenKai TC", "Kaiti TC", "BiauKai", "DFKai-SB", serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font-family: var(--font);
  font-size: 16px; line-height: 1.6; letter-spacing: .02em;
  padding-bottom: calc(78px + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
}
.num, .kv b, .big, input[type=number] { font-variant-numeric: tabular-nums; }

/* 頂部列 */
.top {
  position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: #1b1b1b; border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 20px; color: var(--ink); }
.brand svg { width: 30px; height: 30px; color: var(--ink); }
.brand svg path:first-child { fill: var(--amber); }
.top-right { display: flex; gap: 8px; align-items: center; }
.top input[type=date] {
  background: var(--card2); color: var(--ink); border: 1px solid var(--line); border-radius: 8px;
  padding: 4px 8px; font: inherit; font-size: 14px; width: auto;
}

main { max-width: 760px; margin: 0 auto; padding: 14px 16px; }
h2 { font-size: 21px; margin: 20px 0 10px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
h2::before { content: ""; width: 4px; height: 20px; border-radius: 2px; background: var(--amber); }
h3 { font-size: 17px; margin: 0 0 8px; font-weight: 700; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px;
}
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sub { color: var(--ink2); font-size: 14px; }
.big { font-size: 34px; font-weight: 700; letter-spacing: 2px; line-height: 1.2; }

.badge { display: inline-block; padding: 1px 9px; border-radius: 6px; font-size: 13px; font-weight: 700; white-space: nowrap; border: 1px solid transparent; }
.good { color: var(--good); background: var(--good-bg); border-color: rgba(255, 77, 79, .35); }
.warn { color: var(--warn); background: var(--warn-bg); border-color: rgba(245, 166, 35, .35); }
.bad { color: var(--bad); background: var(--bad-bg); border-color: rgba(60, 207, 122, .3); }
.muted { color: var(--muted); background: var(--muted-bg); }
.up { color: var(--good); } .down { color: var(--bad); }

/* 風度儀表板卡 */
.wind {
  border-radius: var(--radius); padding: 14px; background: var(--card) !important;
  border: 1px solid var(--line); position: relative; overflow: hidden;
}
.wind::after { content: ""; position: absolute; left: 14px; right: 14px; bottom: 0; height: 3px; border-radius: 3px; background: var(--line); }
.wind.good .big { color: var(--good); }
.wind.warn .big { color: var(--warn); }
.wind.bad .big { color: var(--bad); }
.wind.muted .big { color: var(--muted); font-size: 24px; }
.wind.good::after { background: var(--good); } .wind.warn::after { background: var(--amber); } .wind.bad::after { background: var(--bad); }
.wind .big { margin: 2px 0 6px; }

/* 按鈕 */
button, .btn {
  font: inherit; border: 1px solid var(--line); background: var(--card2); color: var(--ink); border-radius: 10px;
  padding: 8px 14px; cursor: pointer; min-height: 40px;
}
button:active { transform: translateY(1px); }
button.primary { background: var(--amber); color: #1a1a1a; border-color: var(--amber); font-weight: 700; }
button.primary:hover { background: var(--amber2); }
button.ghost { background: transparent; }
button.danger { color: var(--good); }
button.sm { padding: 4px 12px; min-height: 32px; font-size: 14px; }

/* 分段按鈕（像 APP 的 櫃買／加權） */
.seg { display: inline-flex; gap: 6px; }
.seg button { border-radius: 8px; min-height: 34px; padding: 4px 12px; font-size: 14px; background: var(--card2); color: var(--ink2); }
.seg button.on { background: #555; color: #fff; border-color: #666; }

label.f { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--ink2); }
label.chk { display: flex; gap: 6px; align-items: center; font-size: 15px; }
input, select, textarea {
  font: inherit; font-size: 16px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--bg2); color: var(--ink); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--amber); outline-offset: 0; border-color: transparent; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--amber); }

.checks { list-style: none; padding: 0; margin: 8px 0 0; }
.checks li { display: flex; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 15px; }
.checks li:first-child { border-top: 0; }
.mark { flex: 0 0 22px; text-align: center; font-weight: 700; }

/* 個股卡：左側色條，像 APP 清單 */
.stock-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.stock-name { font-weight: 700; font-size: 19px; }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(98px, 1fr)); gap: 6px 10px; margin-top: 10px; background: var(--bg2); border-radius: 10px; padding: 10px; }
.kv div { font-size: 13px; color: var(--ink2); }
.kv b { display: block; font-size: 17px; color: var(--ink); }
.kv b.up { color: var(--good); } .kv b.down { color: var(--bad); }
.hit { color: var(--amber); } .nohit { color: var(--muted); }
table.rules { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 15px; }
table.rules td { padding: 7px 4px; border-top: 1px solid var(--line); vertical-align: top; }
table.rules tr.chosen td { background: rgba(245, 166, 35, .08); }

/* 底部分頁：琥珀色底線 */
.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; display: grid; grid-template-columns: repeat(5, 1fr);
  background: #1b1b1b; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabs button { border: 0; border-radius: 0; background: transparent; display: flex; flex-direction: column; align-items: center; font-size: 13px; padding: 8px 0 6px; min-height: 58px; color: var(--ink2); position: relative; }
.tabs button .ic { font-size: 19px; line-height: 1.1; }
.tabs button.on { color: var(--amber); font-weight: 700; }
.tabs button.on::after { content: ""; position: absolute; top: 0; left: 22%; right: 22%; height: 3px; border-radius: 0 0 3px 3px; background: var(--amber); }

dialog { border: 1px solid var(--line); border-radius: 16px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: 88vh; background: var(--card); color: var(--ink); }
dialog::backdrop { background: rgba(0, 0, 0, .65); }
dialog form { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
dialog h3 { font-size: 19px; color: var(--amber); }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; position: sticky; bottom: -16px; background: var(--card); padding: 10px 0 0; }
.toast { position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%); background: var(--amber); color: #1a1a1a; font-weight: 700; padding: 8px 16px; border-radius: 10px; font-size: 15px; z-index: 20; }
.empty { text-align: center; color: var(--ink2); padding: 22px 10px; }
details summary { cursor: pointer; color: var(--amber); font-size: 14px; margin-top: 8px; }
ol.steps { padding-left: 22px; margin: 6px 0; }
ol.steps li { margin: 3px 0; }
.note { font-size: 14px; color: var(--ink2); background: var(--bg2); border-left: 3px solid var(--amber); border-radius: 8px; padding: 8px 10px; margin-top: 10px; }
.section-title { display: flex; align-items: center; gap: 8px; }
.section-title::before { content: ""; width: 4px; height: 18px; border-radius: 2px; background: var(--amber); }
@media (max-width: 420px) { .big { font-size: 28px; } .brand { font-size: 18px; } }

/* 每日排行 */
.rank-list { list-style: none; margin: 8px 0 0; padding: 0; }
.rank-list li { display: grid; grid-template-columns: 30px 1fr auto; gap: 8px; align-items: center; padding: 9px 0; border-top: 1px solid var(--line); }
.rank-list li:first-child { border-top: 0; }
.rank-no { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; font-weight: 700; background: var(--card2); color: var(--ink2); }
.rank-no.r1 { background: var(--amber); color: #1a1a1a; }
.rank-no.r2 { background: #c9c9c9; color: #1a1a1a; }
.rank-no.r3 { background: #b7794a; color: #1a1a1a; }
.rank-meta { font-size: 13px; color: var(--ink2); display: flex; gap: 6px 10px; flex-wrap: wrap; margin-top: 2px; }
.streak { color: var(--amber); font-weight: 700; }
.rank-edit { display: grid; grid-template-columns: 26px 1fr 1fr; gap: 6px; align-items: center; padding: 8px 0; border-top: 1px dashed var(--line); }
.rank-edit .wide { grid-column: 2 / -1; }
.rank-edit input, .rank-edit select { padding: 6px 8px; font-size: 15px; }
.rank-edit .quad { grid-column: 2 / -1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.rank-edit .more { display: none; }
.show-more .rank-edit .more { display: grid; }
.group-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.group-head h3 { margin: 0; }
.tabs button { font-size: 12px; }

/* 紀錄表（試算表樣式） */
.badge.cb, .lg.cb { background: rgba(240, 120, 40, .25); color: #ff9a4d; border-color: rgba(240,120,40,.5); }
.legend { display: flex; gap: 6px; flex-wrap: wrap; }
.lg { font-size: 12px; padding: 1px 8px; border-radius: 5px; border: 1px solid var(--line); }
.lg.unfit { opacity: .45; }
.lg.over { background: rgba(255, 77, 79, .55); color: #fff; }
.tbl-wrap { overflow: auto; max-height: 72vh; border: 1px solid var(--line); border-radius: 10px; -webkit-overflow-scrolling: touch; }
table.sheet { border-collapse: separate; border-spacing: 0; font-size: 13px; white-space: nowrap; }
table.sheet th, table.sheet td { padding: 5px 7px; border-bottom: 1px solid var(--line); border-right: 1px solid #262626; text-align: center; }
table.sheet thead th { position: sticky; top: 0; z-index: 3; background: #262626; color: var(--ink); font-weight: 700; }
table.sheet thead tr:nth-child(2) th { top: 31px; }
table.sheet .th-hint { font-size: 10px; color: var(--good); font-weight: 400; }
table.sheet th.n { font-size: 12px; min-width: 64px; }
.gh-office { background: #6b4e12 !important; }
.gh-boss { background: #17505c !important; }
.gh-hot { background: #333 !important; }
.gh-worker { background: #5c1f1f !important; }
table.sheet .stk { position: sticky; left: 0; z-index: 2; background: var(--card); min-width: 62px; cursor: pointer; }
table.sheet .stk2 { position: sticky; left: 62px; z-index: 2; background: var(--card); min-width: 46px; }
table.sheet thead .stk, table.sheet thead .stk2 { z-index: 4; background: #262626; }
table.sheet .dow { display: block; font-size: 10px; color: var(--ink2); }
table.sheet tr.cur td { box-shadow: inset 0 1px 0 var(--amber), inset 0 -1px 0 var(--amber); }
td.w-強風 { background: #7a2526 !important; color: #fff; }
td.w-陣風 { background: #5a3a3d !important; color: #ffd0d0; }
td.w-亂流 { background: #2d5a3c !important; color: #d9ffe6; }
td.w-無風 { background: #1d3a28 !important; color: #9fd8b3; }
td.cnt { font-variant-numeric: tabular-nums; }
td.cnt.over { background: rgba(255, 77, 79, .55); color: #fff; font-weight: 700; }
td.s { background: rgba(245, 197, 66, .07); cursor: pointer; }
td.s:empty { background: transparent; cursor: default; }
td.s.cb { background: rgba(240, 120, 40, .3); color: #ffc49a; }
td.s.unfit { opacity: .38; }
td.s.hit { background: var(--amber) !important; color: #1a1a1a; font-weight: 700; opacity: 1; }
.cyc { font-size: 12px; padding: 1px 6px; border-radius: 5px; }
.cyc-good { color: var(--good); background: var(--good-bg); }
.cyc-warn { color: var(--warn); background: var(--warn-bg); }
.cyc-bad { color: var(--bad); background: var(--bad-bg); }
.cyc-muted { color: var(--muted); }
tr.cycseg td { text-align: left; white-space: normal; background: #191919; border-left: 4px solid var(--muted); padding: 8px 10px; }
.seg-inner { position: sticky; left: 10px; max-width: min(640px, calc(100vw - 60px)); }
tr.cycseg-good td { border-left-color: var(--good); }
tr.cycseg-warn td { border-left-color: var(--amber); }
tr.cycseg-bad td { border-left-color: var(--bad); }
tr.cycseg .seg-title { font-size: 14px; }
tr.cycseg .sub { font-size: 12px; margin-top: 2px; }
.pill { display: inline-block; padding: 0 7px; margin: 1px 2px; border-radius: 999px; background: var(--card2); color: var(--ink); cursor: pointer; }
.grp-office { border-left: 3px solid #c8941f; } .grp-boss { border-left: 3px solid #2aa3b8; } .grp-hot { border-left: 3px solid #888; } .grp-worker { border-left: 3px solid #c0392b; }

body.wide main { max-width: 1500px; }

/* 風度儀表板（比照 APP） */
.cyc-top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; padding: 12px 10px; }
.cyc-sep { width: 1px; height: 46px; background: var(--line); }
.cyc-head { display: flex; align-items: center; gap: 8px; justify-content: center; }
.ch-l { font-size: 13px; color: var(--ink2); line-height: 1.25; white-space: nowrap; }
.ch-big { font-size: 27px; font-weight: 700; letter-spacing: 1px; line-height: 1.15; white-space: nowrap; }
.cyc-head .sub { font-size: 12px; }
.subtabs { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--line); margin: 4px 0 6px; }
.subtabs button { background: transparent; border: 0; border-radius: 0; font-size: 18px; color: var(--ink2); padding: 8px 0 10px; position: relative; }
.subtabs button.on { color: var(--amber); font-weight: 700; }
.subtabs button.on::after { content: ""; position: absolute; left: 12%; right: 12%; bottom: -1px; height: 4px; border-radius: 2px; background: var(--amber); }
.gauge-hint { text-align: center; font-size: 14px; color: var(--ink); margin: 10px 0 0; line-height: 1.7; }
svg.gauge { display: block; width: 100%; max-width: 420px; margin: 4px auto 0; }
svg.gauge .g-lbl { fill: #bdbdbd; font-size: 13px; font-family: var(--font); }
.legend-row { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; font-size: 14px; color: var(--ink2); margin: 6px 0; }
.legend-row i { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 4px; vertical-align: -1px; }
.legend-row i.sq, .tip i.sq { border-radius: 3px; border: 1px solid transparent; }
.cyc-explain { padding: 4px 14px; margin-top: 12px; }
.cyc-explain .ce { padding: 12px 0; border-top: 1px solid var(--line); }
.cyc-explain .ce:first-child { border-top: 0; }
.cyc-explain .ce-t { font-size: 17px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.cyc-explain .ce-t i { width: 7px; height: 20px; border-radius: 3px; display: inline-block; }
.cyc-explain .ce.on { background: rgba(245,166,35,.06); margin: 0 -14px; padding: 12px 14px; }
.cyc-explain .sub { font-size: 15px; color: var(--ink); opacity: .85; margin-top: 2px; }
.chart-box { background: #141414; border-radius: 10px; padding: 4px 0; }
svg.hist { display: block; width: 100%; height: auto; }
svg.hist .c-lbl { fill: #cfcfcf; font-size: 11px; font-family: var(--font); }
.tip { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; background: var(--card2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin-top: 8px; font-size: 14px; }
.tip i.sq { display: inline-block; width: 10px; height: 10px; margin-right: 3px; }
pre.ex { background: var(--bg2); border-radius: 8px; padding: 8px 10px; font-size: 13px; margin: 0; white-space: pre-wrap; }
