:root {
  --bg: #f4efe7;
  --panel: #fff9f0;
  --ink: #1f1a14;
  --muted: #6f6459;
  --accent: #9c2f2f;
  --accent-2: #0f6b5f;
  --warning: #b5452a;
  --grid: rgba(31, 26, 20, 0.08);
  --shadow: rgba(31, 26, 20, 0.12);
  --font-title: "Noto Serif SC", "Source Han Serif SC", "Songti SC", serif;
  --font-body: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-body);
  background: radial-gradient(circle at top, #fff7ea 0%, #f0e6d8 45%, #efe2d0 100%);
  color: var(--ink);
}

.app {
  max-width: 1200px;
  margin: 32px auto 64px;
  padding: 0 20px 60px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--grid);
  padding-bottom: 18px;
}

h1 {
  font-family: var(--font-title);
  font-size: 32px;
  margin: 0;
}

#updatedAt {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

#dataStatus {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.actions {
  display: flex;
  gap: 12px;
}

.btn {
  font-family: var(--font-body);
  border: 1px solid var(--ink);
  background: transparent;
  padding: 10px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px var(--shadow);
}

.btn.primary {
  background: var(--accent);
  color: #fffaf2;
  border-color: transparent;
}

.btn.ghost {
  background: #fff7ea;
}

.panel {
  background: var(--panel);
  border-radius: 18px;
  box-shadow: 0 12px 28px var(--shadow);
  padding: 20px 22px;
  margin-top: 24px;
}

.panel-title {
  font-weight: 600;
  font-size: 16px;
  color: var(--muted);
  margin-bottom: 14px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
}

.metric {
  background: #fffdf8;
  border: 1px solid var(--grid);
  border-radius: 12px;
  padding: 12px 14px;
  min-height: 92px;
}

.metric .label {
  font-size: 12px;
  color: var(--muted);
}

.metric .value {
  font-size: 20px;
  margin-top: 6px;
}

.metric .note {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

.highlight {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 12px;
  background: #f7efe3;
  border: 1px dashed rgba(156, 47, 47, 0.4);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
}

.highlight.danger {
  background: #fff1e6;
  color: var(--warning);
  border-color: rgba(181, 69, 42, 0.6);
}

.highlight.safe {
  background: #e7f4f0;
  color: var(--accent-2);
  border-color: rgba(15, 107, 95, 0.4);
}

.chart-wrapper {
  background: #fffef9;
  border: 1px solid var(--grid);
  border-radius: 12px;
  padding: 10px;
  margin-top: 12px;
}

.chart-wrapper canvas {
  width: 100%;
  display: block;
}

.chart-wrapper.small {
  padding: 6px 10px;
}

.chart-info {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

.segmented {
  display: inline-flex;
  background: #fffdf8;
  border-radius: 999px;
  border: 1px solid var(--grid);
  overflow: hidden;
}

.segmented button {
  border: none;
  background: transparent;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
}

.segmented button.active {
  background: var(--accent);
  color: #fffaf2;
}

.form-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.form-row input {
  flex: 1 1 160px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--grid);
  font-size: 14px;
}

#holdings {
  margin-top: 18px;
  display: grid;
  gap: 16px;
}

.holding-card {
  background: #fffdf7;
  border: 1px solid var(--grid);
  border-radius: 16px;
  padding: 14px 16px;
}

.holding-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.holding-title {
  font-weight: 600;
}

.holding-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.holding-actions button {
  border: 1px solid var(--grid);
  background: #fff;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(19, 14, 10, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.modal.hidden {
  display: none;
}

.modal-card {
  background: #fffaf2;
  padding: 22px;
  border-radius: 14px;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.18);
}

.modal-card h2 {
  margin-top: 0;
  color: var(--warning);
}

@media (max-width: 900px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}
