:root {
  --ink: #22303a;
  --muted: #5c6b75;
  --teal: #2f6f6a;
  --teal-dark: #245650;
  --gold: #f2c14e;
  --bg: #f4f6f5;
  --card: #ffffff;
  --line: #dde5e2;
  --plus: #1d7a3a;
  --minus: #c0392b;
  --radius: 14px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", "Yu Gothic", sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.7;
  -webkit-text-size-adjust: 100%;
}

.wrap {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 16px;
}

.site-header {
  background: linear-gradient(135deg, #245650 0%, #2f6f6a 60%, #3d8a72 100%);
  color: #fff;
  padding: 34px 0 28px;
}

.site-header .series {
  margin: 0 0 4px;
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  color: var(--gold);
  font-weight: 700;
}

.site-header h1 {
  margin: 0 0 8px;
  font-size: 1.9rem;
  line-height: 1.3;
}

.site-header .lead {
  margin: 0;
  font-size: 0.98rem;
  opacity: 0.95;
}

main.wrap { padding-top: 20px; padding-bottom: 8px; }

.notice {
  background: #fdf6e0;
  border: 1px solid #e8d48b;
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 0.9rem;
  margin-bottom: 18px;
}
.notice p { margin: 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: 0 1px 3px rgba(34, 48, 58, 0.05);
}

.card h2 {
  margin: 0 0 14px;
  font-size: 1.15rem;
  border-left: 5px solid var(--teal);
  padding-left: 10px;
  line-height: 1.4;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.stat {
  background: var(--bg);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat.accent { background: #eef6f1; border: 1px solid #cfe3d4; }
.stat-label { font-size: 0.8rem; color: var(--muted); }
.stat-value { font-size: 1.35rem; font-weight: 700; line-height: 1.35; }
.stat-sub { font-size: 0.85rem; color: var(--muted); }
.stat-value.plus { color: var(--plus); }
.stat-value.minus { color: var(--minus); }

.fineprint { font-size: 0.82rem; color: var(--muted); margin: 12px 0 0; }

.chart-flex {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.chart-box { position: relative; width: 220px; height: 220px; flex: none; margin: 0 auto; }
.chart-center {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-weight: 700;
  font-size: 0.95rem;
  margin: 0;
  pointer-events: none;
  padding: 0 52px;
}

.legend { list-style: none; margin: 0; padding: 0; flex: 1 1 240px; }
.legend li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 0.92rem;
}
.legend li:last-child { border-bottom: none; }
.legend .swatch { width: 14px; height: 14px; border-radius: 4px; flex: none; }
.legend .l-name { flex: 1; }
.legend .l-pct { font-weight: 700; }
.legend .l-val { color: var(--muted); font-size: 0.85rem; }

.empty { color: var(--muted); font-size: 0.92rem; margin: 8px 0 0; }

table.holdings {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
table.holdings th, table.holdings td {
  border-bottom: 1px solid var(--line);
  padding: 9px 8px;
  text-align: right;
  vertical-align: top;
}
table.holdings th { color: var(--muted); font-weight: 600; font-size: 0.8rem; white-space: nowrap; }
table.holdings td.name, table.holdings th.name { text-align: left; }
td .code { color: var(--muted); font-size: 0.8rem; display: block; }
td .gain-plus { color: var(--plus); font-weight: 700; }
td .gain-minus { color: var(--minus); font-weight: 700; }
td .sub { color: var(--muted); font-size: 0.8rem; display: block; }
.row-actions { white-space: nowrap; }

.mini-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 0.82rem;
  cursor: pointer;
  color: var(--ink);
}
.mini-btn:hover { border-color: var(--teal); color: var(--teal-dark); }
.mini-btn.del:hover { border-color: var(--minus); color: var(--minus); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px 16px;
}
.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.88rem;
  font-weight: 600;
}
.form-grid input {
  font: inherit;
  font-weight: 400;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  width: 100%;
}
.form-grid input:focus { outline: 2px solid var(--teal); outline-offset: 1px; border-color: var(--teal); }

.form-actions { margin-top: 16px; display: flex; gap: 10px; flex-wrap: wrap; }
.form-error { color: var(--minus); font-size: 0.9rem; margin: 10px 0 0; min-height: 1em; }

.btn {
  display: inline-block;
  border: 1px solid var(--teal);
  background: #fff;
  color: var(--teal-dark);
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
}
.btn:hover { background: #eef6f1; }
.btn.primary { background: var(--teal); color: #fff; }
.btn.primary:hover { background: var(--teal-dark); }
.btn.ghost { border-color: var(--line); color: var(--muted); }
.btn.danger { border-color: #e3b6b0; color: var(--minus); }
.btn.danger:hover { background: #fdf0ee; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.file-btn { margin: 0; }

.howto { margin: 0; padding-left: 1.4em; }
.howto li { margin-bottom: 6px; font-size: 0.95rem; }

.disclaimer ul { margin: 0; padding-left: 1.3em; }
.disclaimer li { font-size: 0.9rem; margin-bottom: 6px; }

.site-footer {
  padding: 22px 0 34px;
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
}
.site-footer p { margin: 2px 0; }
.site-footer a { color: var(--teal-dark); }

@media (max-width: 640px) {
  .site-header h1 { font-size: 1.55rem; }
  .card { padding: 16px; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-value { font-size: 1.15rem; }
  .form-grid { grid-template-columns: 1fr; }
  .chart-flex { flex-direction: column; gap: 12px; }
  .legend { width: 100%; }

  table.holdings, table.holdings tbody, table.holdings tr, table.holdings td { display: block; width: 100%; }
  table.holdings thead { display: none; }
  table.holdings tr {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 10px;
  }
  table.holdings td {
    border-bottom: none;
    padding: 3px 0;
    text-align: left;
    display: flex;
    justify-content: space-between;
    gap: 12px;
  }
  table.holdings td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.8rem;
    flex: none;
  }
  table.holdings td.name { display: block; font-weight: 700; }
  table.holdings td.name::before { content: none; }
  table.holdings td.row-actions { justify-content: flex-end; }
  table.holdings td.row-actions::before { content: none; }
}
