:root {
  --navy-900: #0f1b2d;
  --navy-800: #16263d;
  --navy-700: #1e3350;
  --ink: #16202e;
  --ink-soft: #56657a;
  --line: #e4e9f0;
  --bg: #f4f6fa;
  --card: #ffffff;
  --amber: #e8a13d;
  --amber-deep: #c47f1f;
  --green: #2f9e6b;
  --green-bg: #e6f6ee;
  --red: #d9534f;
  --red-bg: #fdeceb;
  --blue: #3b6fd1;
  --blue-bg: #eaf1fd;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(15, 27, 45, 0.06), 0 1px 2px rgba(15, 27, 45, 0.04);
  font-family: "Noto Sans JP", "Hiragino Kaku Gothic ProN", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; }
.mono { font-family: "DM Mono", monospace; }

.app-shell { display: flex; min-height: 100vh; }

/* ---------------- Sidebar ---------------- */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--navy-900), var(--navy-800));
  color: #cfd9e8;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 22px; border-bottom: 1px solid rgba(255,255,255,0.08); margin-bottom: 18px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 9px;
  background: linear-gradient(135deg, var(--amber), var(--amber-deep));
  color: #1a1305; font-weight: 800; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  font-family: "DM Mono", monospace;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.3; }
.brand-name { font-weight: 800; font-size: 16px; color: #fff; letter-spacing: 0.3px; }
.brand-sub { font-size: 11px; color: #93a3ba; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px; border-radius: 9px; font-size: 14px; font-weight: 500;
  color: #b7c4d8; position: relative;
}
.nav-icon { font-size: 8px; color: var(--amber); }
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active { background: rgba(232,161,61,0.16); color: #fff; }
.nav-item.active .nav-icon { color: var(--amber); }
.nav-badge {
  margin-left: auto; background: var(--amber); color: #1a1305;
  font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 20px;
  font-family: "DM Mono", monospace;
}
.sidebar-footer { border-top: 1px solid rgba(255,255,255,0.08); padding-top: 14px; margin-top: 10px; }
.rate-note { font-size: 11px; color: #93a3ba; font-family: "DM Mono", monospace; margin-bottom: 8px; }
.demo-note { font-size: 10.5px; color: #6b7d97; line-height: 1.6; }

/* ---------------- Main ---------------- */
.main { flex: 1; min-width: 0; }
.topbar {
  height: 64px; background: var(--card); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; position: sticky; top: 0; z-index: 5;
}
.topbar-title { font-size: 18px; font-weight: 700; }
.search-mini input {
  width: 260px; padding: 9px 14px; border-radius: 8px; border: 1px solid var(--line);
  font-size: 13px; background: var(--bg); outline: none;
}
.search-mini input:focus { border-color: var(--amber); background: #fff; }

.view { padding: 26px 28px 60px; max-width: 1240px; }

/* ---------------- Cards / grid ---------------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.stat-label { font-size: 12.5px; color: var(--ink-soft); margin-bottom: 8px; }
.stat-value { font-size: 26px; font-weight: 800; font-family: "DM Mono", monospace; }
.stat-sub { font-size: 12px; margin-top: 6px; font-weight: 600; }
.stat-sub.up { color: var(--green); }
.stat-sub.down { color: var(--red); }
.stat-sub.flat { color: var(--ink-soft); }

.section-title { font-size: 15px; font-weight: 700; margin: 30px 0 12px; display: flex; align-items: center; justify-content: space-between; }
.section-title .link { font-size: 12.5px; font-weight: 600; color: var(--blue); }

.panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }

/* seller cards */
.seller-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.seller-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; display: flex; flex-direction: column; gap: 10px; cursor: pointer;
  border: 1px solid transparent; transition: border-color .15s, transform .15s;
}
.seller-card:hover { border-color: var(--amber); transform: translateY(-2px); }
.seller-head { display: flex; align-items: center; gap: 10px; }
.seller-avatar { width: 42px; height: 42px; border-radius: 50%; background: var(--bg); flex-shrink: 0; }
.seller-name { font-weight: 700; font-size: 14px; }
.seller-cat { font-size: 11.5px; color: var(--ink-soft); }
.seller-stats { display: flex; gap: 14px; font-size: 12px; color: var(--ink-soft); }
.seller-stats b { color: var(--ink); font-family: "DM Mono", monospace; }
.rating-star { color: var(--amber); }

/* table */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; font-size: 11.5px; color: var(--ink-soft); font-weight: 600;
  padding: 12px 16px; border-bottom: 1px solid var(--line); background: #fafbfd;
  white-space: nowrap;
}
tbody td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfd; }
.row-clickable { cursor: pointer; }

.prod-cell { display: flex; align-items: center; gap: 10px; }
.prod-thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; flex-shrink: 0; background: var(--bg); }
.prod-name { font-weight: 600; font-size: 13px; max-width: 260px; }
.prod-name-sub { font-size: 11px; color: var(--ink-soft); }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge.sold { background: var(--red-bg); color: var(--red); }
.badge.active { background: var(--green-bg); color: var(--green); }
.badge.researching { background: var(--blue-bg); color: var(--blue); }
.badge.candidate { background: #fdf3e3; color: var(--amber-deep); }
.badge.purchased { background: var(--green-bg); color: var(--green); }

.medal { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; font-size: 11px; font-weight: 800; color: #fff; }
.medal.m1 { background: #d9a520; }
.medal.m2 { background: #9aa5b1; }
.medal.m3 { background: #b5722f; }
.medal.mx { background: #dbe2ea; color: var(--ink-soft); }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 8px; border: none; font-size: 13px; font-weight: 700; }
.btn-primary { background: var(--amber); color: #1a1305; }
.btn-primary:hover { background: var(--amber-deep); }
.btn-ghost { background: var(--bg); color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover { background: #eceff4; }
.btn-danger { background: var(--red-bg); color: var(--red); }
.btn-sm { padding: 6px 11px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }

/* filters */
.filter-bar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.filter-bar select, .filter-bar input {
  padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line); font-size: 12.5px; background: #fff;
}
.tab-group { display: flex; gap: 6px; background: var(--bg); padding: 4px; border-radius: 9px; }
.tab-btn { padding: 7px 14px; border-radius: 7px; font-size: 12.5px; font-weight: 600; border: none; background: transparent; color: var(--ink-soft); }
.tab-btn.active { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,0.08); }

/* seller detail header */
.seller-hero { display: flex; align-items: center; gap: 18px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 26px; margin-bottom: 22px; }
.seller-hero img { width: 68px; height: 68px; border-radius: 50%; background: var(--bg); }
.seller-hero-meta { flex: 1; }
.seller-hero-name { font-size: 19px; font-weight: 800; }
.seller-hero-cat { font-size: 13px; color: var(--ink-soft); margin-top: 3px; }
.seller-hero-stats { display: flex; gap: 26px; margin-top: 4px; }
.hero-stat { text-align: center; }
.hero-stat .v { font-size: 17px; font-weight: 800; font-family: "DM Mono", monospace; }
.hero-stat .l { font-size: 11px; color: var(--ink-soft); }
.back-link { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-soft); margin-bottom: 14px; font-weight: 600; }
.back-link:hover { color: var(--ink); }

/* modal */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(15,20,30,0.55);
  align-items: center; justify-content: center; z-index: 50; padding: 24px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 760px; max-height: 88vh;
  overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 24px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 2; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-close { background: none; border: none; font-size: 20px; color: var(--ink-soft); line-height: 1; }
.modal-body { padding: 22px 24px 26px; }

.pd-top { display: flex; gap: 18px; margin-bottom: 20px; }
.pd-top img { width: 130px; height: 130px; border-radius: 12px; object-fit: cover; background: var(--bg); flex-shrink: 0; }
.pd-info-row { display: flex; justify-content: space-between; font-size: 12.5px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.pd-info-row span:first-child { color: var(--ink-soft); }

.cn-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 10px; }
.cn-card { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.cn-card img { width: 100%; height: 90px; object-fit: cover; display: block; }
.cn-card-body { padding: 9px 10px; }
.cn-platform { font-size: 10.5px; font-weight: 700; color: var(--blue); }
.cn-title { font-size: 11.5px; margin: 4px 0; line-height: 1.4; height: 30px; overflow: hidden; }
.cn-price { font-size: 13px; font-weight: 800; font-family: "DM Mono", monospace; }
.cn-supplier { font-size: 10px; color: var(--ink-soft); margin-top: 2px; }

.calc-box { background: var(--bg); border-radius: 10px; padding: 16px 18px; margin-top: 8px; }
.calc-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; gap: 10px; }
.calc-row label { font-size: 12.5px; color: var(--ink-soft); flex-shrink: 0; }
.calc-row input, .calc-row select { width: 140px; padding: 7px 10px; border-radius: 7px; border: 1px solid var(--line); font-size: 13px; text-align: right; font-family: "DM Mono", monospace; }
.calc-result { display: flex; justify-content: space-between; align-items: center; padding-top: 12px; margin-top: 6px; border-top: 1px solid var(--line); }
.calc-result .label { font-size: 13px; font-weight: 700; }
.calc-result .value { font-size: 22px; font-weight: 800; font-family: "DM Mono", monospace; }
.calc-result .value.positive { color: var(--green); }
.calc-result .value.negative { color: var(--red); }
.calc-margin { font-size: 12px; color: var(--ink-soft); margin-top: 2px; text-align: right; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--ink-soft); }
.empty-state .icon { font-size: 34px; margin-bottom: 10px; }

.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--navy-900); color: #fff; padding: 12px 22px; border-radius: 30px; font-size: 13px;
  font-weight: 600; opacity: 0; pointer-events: none; transition: all .25s; z-index: 100; box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.list-status-select { padding: 5px 9px; border-radius: 7px; border: 1px solid var(--line); font-size: 12px; background: #fff; }

@media (max-width: 980px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .seller-grid { grid-template-columns: repeat(2, 1fr); }
  .cn-grid { grid-template-columns: repeat(2, 1fr); }
}
