:root {
  --bg: #f5f6f8;
  --card-bg: #ffffff;
  --text: #1a1b1e;
  --text-dim: #6b7280;
  --border: #e5e7eb;
  --accent: #4c6ef5;
  --pos: #12b886;
  --neg: #e03131;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --card-bg: #1a1d24;
    --text: #e8e8ea;
    --text-dim: #9aa0ab;
    --border: #2a2e37;
    --accent: #7c9bff;
    --pos: #3ddc97;
    --neg: #ff6b6b;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
}

body {
  padding-bottom: 64px; /* タブバー分 */
}

.topbar {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--card-bg);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar h1 {
  margin: 0 0 4px;
  font-size: 18px;
}
.topbar .hint {
  margin: 0;
}

#app {
  padding: 12px;
  max-width: 720px;
  margin: 0 auto;
}

.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  z-index: 10;
}
.tabbar button {
  flex: 1;
  padding: 10px 4px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 13px;
}
.tabbar button.active {
  color: var(--accent);
  font-weight: bold;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 14px;
}
.card h2 {
  margin: 0 0 10px;
  font-size: 15px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.chart-box {
  position: relative;
  height: 280px;
  margin-bottom: 14px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
}
.chart-box.tall {
  height: 340px;
}
.chart-title {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
}

.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  overflow-x: auto;
  display: block;
}
.tbl thead, .tbl tbody { display: table; width: 100%; table-layout: fixed; }
.tbl th, .tbl td {
  text-align: left;
  padding: 6px 4px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.tbl.editable input {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px;
  font-size: 13px;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
}

.pos { color: var(--pos); }
.neg { color: var(--neg); }

.list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.list .value {
  font-weight: bold;
}

.hint {
  color: var(--text-dim);
  font-size: 12px;
  margin: 4px 0;
}

#untrackedBox details {
  margin-top: 4px;
}
#untrackedBox summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--accent);
}
#untrackedBox .list.small {
  max-height: 200px;
  overflow-y: auto;
  margin-top: 6px;
}
#untrackedBox .list.small li {
  font-size: 12px;
  padding: 4px 0;
}
.error { color: var(--neg); }

.empty, .loading {
  color: var(--text-dim);
  text-align: center;
  padding: 40px 0;
}

.row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0;
  align-items: center;
}

button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
}
button.secondary {
  background: none;
  color: var(--accent);
  border: 1px solid var(--accent);
}

select, input[type="password"] {
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
}
