:root {
  --bg: #0e1218; --panel: #161b24; --panel2: #1d2430; --line: #2a3342;
  --text: #e7ecf3; --muted: #8b97a8; --accent: #f0b429;
  --up: #ff5c5c; --down: #2fbf71;              /* Taiwan convention: profit red, loss green */
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-size: 15px; line-height: 1.45; padding-bottom: 32px; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea {
  font-size: 16px; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 10px; min-height: 40px;
}
input[type="color"] { padding: 2px; width: 46px; }
button {
  min-height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2);
  padding: 0 14px; cursor: pointer;
}
button.primary { background: var(--accent); color: #1b1300; border-color: var(--accent); font-weight: 600; }
button.danger { background: transparent; color: #ff8a8a; border-color: #6b2b2b; }
button.ghost { background: transparent; }
.hidden { display: none !important; }

.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 16px; background: rgba(14,18,24,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; gap: 10px; align-items: center; }
.logo {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, #f0b429, #e8590c); color: #1b1300; font-weight: 800;
}
.title { font-weight: 700; }
.sub { font-size: 12px; color: var(--muted); }
.tabs { display: flex; gap: 4px; background: var(--panel); padding: 4px; border-radius: 12px; }
.tabs button { border: 0; background: transparent; }
.tabs button.on { background: var(--panel2); color: var(--accent); font-weight: 600; }

.filters { padding: 12px 16px 4px; display: grid; gap: 8px; max-width: 1200px; margin: 0 auto; }
.chips { display: flex; gap: 6px; }
.chips button { white-space: nowrap; border-radius: 999px; }
.chips button.on { border-color: var(--accent); color: var(--accent); }
.chips .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.range { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.dates { display: flex; gap: 6px; align-items: center; color: var(--muted); }
.dates input { width: 150px; }

.tab, .msg { max-width: 1200px; margin: 0 auto; padding: 8px 16px; }
.msg { color: #ffb4b4; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.card-h { font-weight: 600; margin-bottom: 10px; display: flex; justify-content: space-between; gap: 8px; }
.hint, .hint-p, .foot { color: var(--muted); font-size: 12px; font-weight: 400; }
.foot { margin: 4px 2px 20px; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 12px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.kpi .k { color: var(--muted); font-size: 12px; }
.kpi .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.kpi .s { color: var(--muted); font-size: 12px; margin-top: 2px; }
.kpi.big { grid-column: span 2; }
.kpi.big .v { font-size: 30px; }
.up { color: var(--up); } .down { color: var(--down); } .na { color: var(--muted); }

.chart-box { position: relative; height: 300px; }
.chart-box.short { height: 200px; }

.tbl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.tbl th { color: var(--muted); font-weight: 500; font-size: 13px; position: sticky; top: 0; background: var(--panel); }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl td.note { text-align: left; white-space: normal; min-width: 220px; color: #c9d2de; font-size: 14px; }
.tbl.list tbody tr { cursor: pointer; }
.tbl.list tbody tr:hover { background: var(--panel2); }
.tbl .tag { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 0 5px; margin-left: 4px; }
.tbl .m-note { display: none; }
.list-bar { display: flex; gap: 8px; margin-bottom: 10px; }
.list-bar input { flex: 1; }
.more { text-align: center; padding: 12px; }

.brk { display: flex; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brk input[name="name"] { flex: 1; min-width: 120px; }
.brk .bal { color: var(--muted); font-size: 13px; min-width: 120px; text-align: right; font-variant-numeric: tabular-nums; }
.row-form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; align-items: center; }
.row-form input[name="name"] { flex: 1; min-width: 160px; }
.w-s { width: 80px; } .w-c { width: 52px; }
code { background: var(--panel2); padding: 1px 5px; border-radius: 5px; }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 16px; padding: 18px; width: min(520px, 94vw); }
dialog::backdrop { background: rgba(0,0,0,.55); }
dialog h3 { margin: 0 0 12px; }
dialog label { display: grid; gap: 4px; color: var(--muted); font-size: 13px; margin-bottom: 10px; }
dialog label input, dialog label select, dialog label textarea { color: var(--text); width: 100%; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.raw { font-size: 12px; color: var(--muted); background: var(--panel2); border-radius: 8px; padding: 8px; margin-bottom: 10px; white-space: pre-wrap; }
.dlg-btns { display: flex; gap: 8px; align-items: center; } .sp { flex: 1; }

@media (max-width: 760px) {
  .top { flex-direction: column; align-items: stretch; }
  .tabs { justify-content: stretch; } .tabs button { flex: 1; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi .v { font-size: 18px; } .kpi.big .v { font-size: 26px; }
  .range { display: grid; grid-template-columns: minmax(0, 1fr); }
  .dates { width: 100%; min-width: 0; } .dates input { flex: 1 1 0; width: 0; min-width: 0; }
  .chips { min-width: 0; }
  .chart-box { height: 240px; }
  .tbl.list .c-settle, .tbl.list .c-note { display: none; }
  .tbl.list tr[data-id]:has(+ .m-note) td { border-bottom: 0; padding-bottom: 2px; }
  .tbl .m-note { display: table-row; }
  .tbl .m-note td { text-align: left; white-space: normal; color: var(--muted); font-size: 13px; padding-top: 0; }
  .tbl th, .tbl td { padding: 8px 6px; }
}
