:root {
  --bg: #0e0e10;
  --panel: #17171a;
  --panel-2: #1f1f24;
  --line: #2a2a31;
  --text: #ececef;
  --muted: #8b8b95;
  --gold: #d4af37;
  --gold-2: #f4d35e;
  --silver: #c0c0c8;
  --plat: #e5e4e2;
  --up: #34d399;
  --down: #f87171;
  --accent: #d4af37;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Microsoft JhengHei", "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

#app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

/* Topbar */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo {
  font-size: 36px;
  color: var(--gold);
  text-shadow: 0 0 16px rgba(212, 175, 55, 0.5);
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0.5px;
}

.brand .subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.status {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
}

.status .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #555;
}

.status .dot.live {
  background: var(--up);
  box-shadow: 0 0 8px var(--up);
  animation: pulse 1.5s ease-in-out infinite;
}

.status .next {
  font-variant-numeric: tabular-nums;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Panels */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px 24px;
  margin-bottom: 20px;
}

.panel h2 {
  margin: 0 0 16px;
  font-size: 16px;
  letter-spacing: 0.3px;
  color: var(--gold-2);
}

.panel h3 {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Price Cards */
.price-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.price-card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  position: relative;
  overflow: hidden;
}

.price-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 4px; height: 100%;
}

.price-card.au::before { background: var(--gold); }
.price-card.ag::before { background: var(--silver); }
.price-card.pt::before { background: var(--plat); }

.price-card .metal {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}

.price-card .symbol {
  font-size: 20px;
  font-weight: 700;
  color: var(--gold-2);
}

.price-card.ag .symbol { color: var(--silver); }
.price-card.pt .symbol { color: var(--plat); }

.price-card .name {
  font-size: 12px;
  color: var(--muted);
}

.price-card .value {
  font-size: 26px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin: 4px 0;
}

.price-card .value .unit {
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
  margin-left: 4px;
}

.price-card .meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
}

.price-card .change.up { color: var(--up); }
.price-card .change.down { color: var(--down); }

.price-card .updated {
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
}

/* Actions */
.actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.actions .hint {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
}

button {
  background: var(--gold);
  color: #1a1a1a;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  font-size: 13px;
  transition: opacity 0.15s;
}

button:hover { opacity: 0.85; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

button.secondary {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
}

/* Calc Grid */
.calc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 18px;
  margin-bottom: 22px;
}

.col {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
}

.col label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin: 10px 0 4px;
}

.col input, .col select {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
}

.col input:focus, .col select:focus {
  outline: none;
  border-color: var(--gold);
}

.row {
  display: flex;
  gap: 10px;
}

.row .field { flex: 1; }

.slider-row {
  margin-bottom: 14px;
}

.slider-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.slider-label strong {
  color: var(--gold-2);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--gold);
}

.formula {
  margin-top: 16px;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: 6px;
  font-size: 12px;
  color: var(--muted);
}

.formula code {
  color: var(--gold-2);
  font-family: "Cascadia Code", "Consolas", monospace;
}

/* Result */
.result-line {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
  border-bottom: 1px dashed var(--line);
  font-variant-numeric: tabular-nums;
}

.result-line:last-child { border: none; }

.result-line.total {
  margin-top: 8px;
  padding-top: 12px;
  border-top: 2px solid var(--gold);
  border-bottom: none;
  font-size: 17px;
  font-weight: 700;
  color: var(--gold-2);
}

/* Member Table */
.member-title { margin-top: 8px; }

.member-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: var(--panel-2);
  border-radius: 8px;
  overflow: hidden;
}

.member-table th {
  background: var(--bg);
  padding: 10px 14px;
  text-align: left;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.5px;
}

.member-table td {
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}

.member-table tr:hover { background: rgba(212, 175, 55, 0.05); }

.member-table .price {
  color: var(--gold-2);
  font-weight: 600;
}

.member-table .save { color: var(--down); }

.member-table code {
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  color: var(--muted);
}

/* Push */
.push .desc {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 14px;
}

.push .desc strong {
  color: var(--gold-2);
  font-size: 15px;
}

.push .desc code {
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--text);
  font-family: "Cascadia Code", "Consolas", monospace;
}

.push-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.log {
  background: #0a0a0c;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  max-height: 280px;
  overflow-y: auto;
  font-family: "Cascadia Code", "Consolas", monospace;
  font-size: 12px;
}

.log .empty {
  color: var(--muted);
  text-align: center;
  padding: 20px;
}

.log-line {
  display: flex;
  gap: 10px;
  padding: 4px 0;
  border-bottom: 1px solid var(--line);
  align-items: center;
}

.log-line:last-child { border: none; }

.log-line .time { color: var(--muted); width: 80px; }
.log-line .method { color: var(--gold-2); font-weight: 600; width: 32px; }
.log-line .path { color: var(--text); flex-shrink: 0; }
.log-line .payload { color: var(--muted); flex: 1; }
.log-line .status-tag {
  background: rgba(52, 211, 153, 0.15);
  color: var(--up);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
}

.log-line.pending .status-tag {
  background: rgba(212, 175, 55, 0.15);
  color: var(--gold-2);
}

footer {
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}

footer p { margin: 4px 0; }

@media (max-width: 900px) {
  .price-grid { grid-template-columns: 1fr; }
  .calc-grid { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: flex-start; gap: 10px; }
  .actions .hint { margin-left: 0; width: 100%; }
}
