:root {
  --bg: #f6f7f9; --panel: #ffffff; --line: #e4e7ec; --text: #101828; --muted: #667085;
  --accent: #16a34a; --up: #16a34a; --down: #dc2626; --hover: #f2f4f7; --chip: #eef2f6;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0e13; --panel: #12161d; --line: #232a35; --text: #e6e9ef; --muted: #8b95a5;
    --accent: #22c55e; --up: #22c55e; --down: #ef4444; --hover: #1a2029; --chip: #1c232d;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0e13; --panel: #12161d; --line: #232a35; --text: #e6e9ef; --muted: #8b95a5;
  --accent: #22c55e; --up: #22c55e; --down: #ef4444; --hover: #1a2029; --chip: #1c232d;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Segoe UI", sans-serif;
}
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.pad { padding: 0 14px; }

.top {
  position: sticky; top: 0; z-index: 10; display: flex; gap: 12px; align-items: center;
  padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.logo { width: 22px; height: 22px; border-radius: 6px; background: var(--accent); display: inline-block; }
.search { position: relative; flex: 1; max-width: 520px; }
.search input { width: 100%; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.results {
  position: absolute; top: 42px; left: 0; right: 0; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,.18); overflow: hidden; max-height: 60vh; overflow-y: auto;
}
.res { display: flex; align-items: center; gap: 10px; padding: 8px 12px; cursor: pointer; }
.res:hover { background: var(--hover); }
.res .grow { flex: 1; min-width: 0; }
.pill { display: flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.on { background: var(--up); }

.layout { display: grid; grid-template-columns: 260px 1fr; min-height: calc(100vh - 55px); }
.side { border-right: 1px solid var(--line); background: var(--panel); }
.side-h { padding: 14px 14px 6px; font-weight: 600; color: var(--muted); font-size: 12px; }
.watch { list-style: none; margin: 0; padding: 0 6px 12px; }
.watch li { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; cursor: pointer; }
.watch li:hover, .watch li.on { background: var(--hover); }
.watch .grow { flex: 1; min-width: 0; }
.watch .sym { font-weight: 600; }
.watch .r { text-align: right; font-variant-numeric: tabular-nums; }
.art { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: var(--chip); flex: none; }
.art.lg { width: 48px; height: 48px; }
.ell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { padding: 16px; min-width: 0; }
.empty { text-align: center; padding: 80px 16px; }
.tok-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.tok-id { flex: 1; min-width: 0; }
.tok-name { font-size: 20px; font-weight: 700; }
.tok-addr { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--chip); color: var(--muted); vertical-align: middle; }
.badge.grad { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.star { font-size: 22px; background: none; border: 1px solid var(--line); border-radius: 10px; width: 42px; height: 42px; }
.star.on { color: #f59e0b; }
#btnBell { filter: grayscale(1); opacity: .6; }
#btnBell.on { filter: none; opacity: 1; }
.note { background: var(--chip); border-radius: 10px; padding: 8px 12px; font-size: 13px; margin: 8px 0 0; }

.stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; min-width: 0; }
.stat span { font-size: 12px; color: var(--muted); }
.stat b { font-size: 16px; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat i { font-style: normal; font-size: 12px; font-variant-numeric: tabular-nums; }
.up { color: var(--up); } .down { color: var(--down); }
.bar { height: 4px; background: var(--chip); border-radius: 4px; margin-top: 6px; overflow: hidden; }
.bar div { height: 100%; background: var(--accent); width: 0; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 12px; }
.chart-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.seg { display: inline-flex; background: var(--chip); border-radius: 9px; padding: 2px; }
.seg button { border: 0; background: none; padding: 4px 10px; border-radius: 7px; color: var(--muted); font-size: 13px; }
.seg button.on { background: var(--panel); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.15); }
.chart { height: 420px; width: 100%; }
.chart.sm { height: 280px; }

.tabs { display: flex; gap: 4px; margin: 4px 0 8px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--text); border-color: var(--accent); font-weight: 600; }

.hold-sum { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; font-size: 13px; }
.tbl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tbl th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 6px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 6px; border-bottom: 1px solid var(--line); }
.tbl .r { text-align: right; }
.tbl tr.dim td { color: var(--muted); }
.share { display: inline-block; height: 6px; background: var(--accent); border-radius: 3px; margin-right: 6px; vertical-align: middle; opacity: .7; }
.tag { font-size: 11px; padding: 1px 6px; border-radius: 6px; background: var(--chip); color: var(--muted); margin-left: 4px; }

.rule-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.rule-form select, .rule-form input, .dlg input { padding: 7px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--bg); }
.rule-form #rValue { width: 130px; }
.rule-form .inline input { width: 70px; }
.rule-form #rNote { flex: 1; min-width: 140px; }
.inline { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.primary { background: var(--accent); color: #fff; border: 0; padding: 7px 14px; border-radius: 9px; font-weight: 600; }
.rule-list, .log-list { list-style: none; margin: 8px 0 0; padding: 0; }
.rule-list li { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.rule-list .grow { flex: 1; min-width: 0; }
.rule-list button { border: 1px solid var(--line); background: none; border-radius: 8px; padding: 4px 10px; font-size: 12px; }
.state { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--chip); color: var(--muted); }
.state.hit { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.log-list li { padding: 10px 4px; border-bottom: 1px solid var(--line); white-space: pre-wrap; font-size: 13px; }
.log-list .t { color: var(--muted); font-size: 12px; }

dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--text); padding: 0; width: min(440px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.45); }
.dlg { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.dlg h3 { margin: 0; }
.dlg label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.dlg .row { display: flex; gap: 8px; flex-wrap: wrap; }
.dlg .row button:not(.primary) { border: 1px solid var(--line); background: none; border-radius: 9px; padding: 7px 14px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 50; max-width: calc(100vw - 32px); }

@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .top { flex-wrap: wrap; padding: 10px 16px; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .brand { flex: 1; }
  .layout { grid-template-columns: 1fr; }
  .side { border-right: 0; border-bottom: 1px solid var(--line); }
  .watch { display: flex; overflow-x: auto; gap: 4px; }
  .watch li { flex: none; }
  .watch .r { display: none; }
  #watchEmpty { padding-bottom: 12px; }
  .main { padding: 12px 16px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart { height: 340px; }
  .tbl .hide-m { display: none; }
}
