@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800&family=IBM+Plex+Sans+JP:wght@400;500;600;700&display=swap');

:root {
  --carbon: #18181b;
  --carbon-soft: #27272a;
  --neon: #4ade80;
  --neon-dim: #22c55e;
  --bg: #fbfbfa;
  --paper: #fff;
  --ink: #1a201e;
  --muted: #9aa4a0;
  --line: #eeeeea;
  --red: #f43f5e;
  --pos: #16a34a;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { touch-action: manipulation; }

body {
  font-family: 'IBM Plex Sans JP', -apple-system, "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
}

a { color: var(--neon-dim); }

/* ---------- Login ---------- */
.auth-box {
  max-width: 360px;
  margin: 64px auto;
  background: var(--paper);
  padding: 40px 32px;
  border-radius: 18px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.08);
  border: 1px solid var(--line);
}
.auth-box h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--carbon);
  text-align: center;
}
.auth-box h1::after { content: '.'; color: var(--neon-dim); }
.tagline { text-align: center; font-size: 13px; color: var(--muted); margin-bottom: 28px; }

form { display: flex; flex-direction: column; gap: 10px; }
label { font-size: 13px; color: var(--muted); margin-top: 6px; }

input, select, textarea {
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 16px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  background: var(--paper);
  font-family: inherit;
  color: var(--ink);
}
input[type="date"] { -webkit-appearance: none; appearance: none; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--neon-dim); border-color: transparent; }
input[readonly] { background: #f4f4f1; color: #8a8a85; }

button, .btn {
  display: inline-block;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  font-family: inherit;
}
.btn-primary, button[type=submit] { background: var(--carbon); color: #fff; border-color: var(--carbon); }
.btn-secondary, button.secondary { background: var(--paper); color: var(--ink); }

.error {
  background: #fef2f2; color: #b91c1c;
  padding: 12px; border-radius: 10px; font-size: 14px;
  margin-bottom: 16px; text-align: center;
}

/* ---------- Top bar (carbon signature) ---------- */
.topbar {
  background: var(--carbon);
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky; top: 0; z-index: 10;
}
.topbar .logo {
  font-family: 'Outfit', sans-serif;
  font-size: 22px; font-weight: 700;
  color: #fff; text-decoration: none;
  padding: 15px 0; letter-spacing: -0.5px;
}
.topbar .logo::after { content: '.'; color: var(--neon); }
.nav { display: flex; gap: 2px; align-items: center; }
.nav a {
  padding: 17px 11px; font-size: 13px;
  color: #a1a1aa; text-decoration: none;
  border-bottom: 2px solid transparent; font-weight: 500;
}
.nav a.active { color: #fff; border-bottom-color: var(--neon); font-weight: 600; }
.nav a.logout { color: #71717a; }

.container { max-width: 720px; margin: 22px auto; padding: 0 16px; }

.page-head { margin-bottom: 16px; }
.page-head h2 { font-size: 20px; color: var(--ink); font-family: 'Outfit', sans-serif; font-weight: 700; }

/* ---------- Cards ---------- */
.card {
  background: var(--paper);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
}
.card h3 { font-size: 16px; margin-bottom: 12px; font-family: 'Outfit', sans-serif; }
.card.summary { background: #f6f6f3; border: none; margin-top: 16px; }
.card.summary p { font-size: 14px; }

/* ---------- Dashboard balance ---------- */
.stats-row { display: flex; gap: 12px; margin-bottom: 16px; }
.stat {
  flex: 1; display: flex; flex-direction: column; gap: 2px;
  margin-bottom: 0; padding: 18px 20px;
}
.stat-label { font-size: 12px; color: var(--muted); }
.stat-value {
  font-family: 'Outfit', sans-serif;
  font-size: 28px; font-weight: 700;
  color: var(--ink); font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
}
.stat-value small { font-size: 14px; font-weight: 400; color: var(--muted); }
.stat:first-child .stat-value { color: var(--ink); }
.stat:first-child::after {
  content: ''; display: block; width: 36px; height: 3px;
  background: var(--neon); border-radius: 2px; margin-top: 8px;
}

.actions { display: flex; flex-direction: column; gap: 9px; margin-bottom: 20px; }

/* ---------- Item / ledger lists ---------- */
.item-list, .history-list { list-style: none; }
.item-list li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 13px 0; border-bottom: 1px solid var(--line);
}
.item-list li:last-child { border-bottom: none; }
.item-info { display: flex; flex-direction: column; }
.item-name { font-weight: 500; }
.item-name small { color: var(--muted); font-weight: 400; }
.item-meta { font-size: 13px; color: var(--muted); white-space: nowrap; }

.item-actions { display: flex; gap: 8px; align-items: center; white-space: nowrap; }
.action-edit, .action-delete {
  font-size: 13px; padding: 6px 12px; border-radius: 8px;
  text-decoration: none; border: none; cursor: pointer; font-weight: 500;
  font-family: inherit;
}
.action-edit { background: #f3f3f0; color: var(--ink); }
.action-delete { background: #fef2f2; color: #b91c1c; }

/* ---------- History ---------- */
.history-list li { padding: 14px 0; border-bottom: 1px solid var(--line); }
.history-list li:last-child { border-bottom: none; }
.history-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.history-profit { font-family: 'Outfit', sans-serif; font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums; }
.history-profit.pos { color: var(--pos); }
.history-profit.neg { color: var(--red); }
.history-detail { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--muted); }
.note-readonly { font-size: 12px; color: #b0b0aa; text-align: center; margin-top: 4px; }

/* ---------- Filter tabs ---------- */
.filter-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.filter-tabs a {
  padding: 8px 16px; background: var(--paper); border: 1px solid var(--line);
  border-radius: 20px; font-size: 14px; color: var(--muted); text-decoration: none;
}
.filter-tabs a.active { background: var(--carbon); color: #fff; border-color: var(--carbon); }

.item-select { padding: 6px; }
.item-select option { padding: 8px; }

.status { font-size: 14px; color: var(--muted); margin-top: 10px; }
.empty { color: var(--muted); font-size: 14px; }
.link { font-size: 14px; display: inline-block; margin-top: 12px; color: var(--neon-dim); }

@media (max-width: 480px) {
  .topbar { padding: 0 12px; }
  .topbar .logo { font-size: 18px; }
  .stats-row { flex-direction: column; }
}

/* Dashboard hero balance */
.balance-card { padding: 22px 20px; }
.balance-big {
  display: block;
  font-family: 'Outfit', sans-serif;
  font-size: 40px; font-weight: 700;
  color: var(--ink); font-variant-numeric: tabular-nums;
  letter-spacing: -1px; line-height: 1.1; margin-top: 2px;
}
.balance-accent { width: 38px; height: 3px; background: var(--neon); border-radius: 2px; margin: 14px 0 16px; }
.mini-stats { display: flex; gap: 26px; }
.mini-stats div { font-size: 13px; color: var(--muted); }
.mini-stats strong { color: var(--ink); font-family: 'Outfit', sans-serif; font-weight: 600; }

/* Mode tabs (読み取り / 手動) */
.mode-tabs { display: flex; gap: 0; margin-bottom: 16px; background: #f3f3f0; border-radius: 12px; padding: 4px; }
.mode-tab {
  flex: 1; padding: 10px; border: none; background: transparent;
  border-radius: 9px; font-size: 14px; font-weight: 600; cursor: pointer;
  color: var(--muted); font-family: inherit;
}
.mode-tab.active { background: var(--paper); color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,0.08); }

/* Account / danger zone */
.danger-zone { border: 1px solid #fecaca; }
.danger-zone h3 { color: #b91c1c; }
.danger-text { font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.btn-danger { background: #dc2626; color: #fff; border-color: #dc2626; width: 100%; }

/* Account page sections */
.account-section-title { font-family: 'Outfit', sans-serif; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 14px; }
.account-section-title.danger { color: #b91c1c; }
.plan-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.plan-name { display: block; font-family: 'Outfit', sans-serif; font-size: 18px; font-weight: 700; color: var(--ink); }
.plan-desc { font-size: 12px; color: var(--muted); }
.muted-note { font-size: 13px; color: var(--muted); }
.info-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.info-row:last-child { border-bottom: none; }
.info-label { color: var(--muted); }
.info-value { font-weight: 500; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

/* Account menu list */
.menu-list { padding: 0; overflow: hidden; }
.menu-item { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; text-decoration: none; color: var(--ink); border-bottom: 1px solid var(--line); }
.menu-item:last-child { border-bottom: none; }
.menu-label { font-weight: 500; font-size: 15px; }
.menu-label small { display: block; font-size: 12px; color: var(--muted); font-weight: 400; margin-top: 2px; }
.menu-arrow { color: var(--muted); font-size: 20px; }
.menu-item.danger .menu-label { color: #b91c1c; }

.back-link { font-size: 13px; color: var(--muted); text-decoration: none; display: inline-block; margin-bottom: 6px; }

.email-reveal { display: flex; justify-content: space-between; align-items: center; }
.email-reveal span { font-weight: 500; font-variant-numeric: tabular-nums; }
.btn-text { background: none; border: none; color: var(--neon-dim); font-weight: 600; cursor: pointer; font-size: 14px; font-family: inherit; padding: 4px 8px; }

.success { background: #f0fdf4; color: #15803d; padding: 12px; border-radius: 10px; font-size: 14px; margin-bottom: 16px; text-align: center; }

/* Big register button + bottom sheet */
.btn-lg { font-size: 16px; padding: 16px; width: 100%; }
.sheet-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: flex-end; justify-content: center; z-index: 100; }
.sheet { background: var(--paper); width: 100%; max-width: 720px; border-radius: 20px 20px 0 0; padding: 20px 20px 28px; animation: sheetUp 0.22s ease; }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-handle { width: 40px; height: 4px; background: #ddd; border-radius: 2px; margin: 0 auto 18px; }
.sheet-title { font-family: 'Outfit', sans-serif; font-weight: 600; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 14px; text-align: center; }
.sheet .btn { margin-bottom: 10px; }
.sheet .btn:last-child { margin-bottom: 0; }

/* ===== Dashboard panel (3 blocks + eyes + activity) ===== */
.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.card-top.mb-small { margin-bottom: 4px; }
.eye-sm { background: none; border: none; cursor: pointer; color: #c4ccc8; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; padding: 0; flex-shrink: 0; }
.eye-sm svg { width: 18px; height: 18px; }
.eye-sm:hover { color: var(--muted); }

.year-card { background: linear-gradient(100deg, #18181b, #27272a); border: none; }
.year-card .year-label { font-size: 11px; color: #a1a1aa; }
.year-card .year-value { font-family: 'Outfit', sans-serif; font-size: 26px; font-weight: 700; color: var(--neon); margin-top: 4px; font-variant-numeric: tabular-nums; }
.year-card .eye-sm { color: #52525b; }
.year-card .eye-sm:hover { color: #a1a1aa; }

.period-tabs { display: flex; flex: 1; background: #f3f3f0; border-radius: 10px; padding: 3px; }
.period-tab { flex: 1; padding: 8px; border: none; background: transparent; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--muted); font-family: inherit; }
.period-tab.active { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,0.08); }

.stats-page-tabs { display: flex; gap: 0; background: #f3f3f0; border-radius: 10px; padding: 3px; margin-bottom: 16px; }
.stats-page-tabs .period-tab { flex: 1; text-align: center; text-decoration: none; display: block; }

.kpi-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
.kpi { display: flex; flex-direction: column; gap: 6px; padding: 16px; }
.kpi-label { font-size: 12px; color: var(--muted); }
.kpi-value { font-size: 22px; font-weight: 700; color: var(--ink); }
.kpi-value small { font-size: 13px; font-weight: 400; color: var(--muted); }

.chart-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 768px) { .chart-pair { grid-template-columns: 1fr; } }

.chart-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.chart-head h3 { margin: 0; }
.mini-switch { display: flex; background: #f3f3f0; border-radius: 8px; padding: 2px; }
.mini-switch-btn { padding: 5px 14px; border: none; background: transparent; border-radius: 6px; font-size: 12px; font-weight: 600; cursor: pointer; color: var(--muted); font-family: inherit; }
.mini-switch-btn.active { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,0.08); }

.big-profit { display: block; font-family: 'Outfit', sans-serif; font-size: 34px; font-weight: 700; letter-spacing: -1px; margin-top: 4px; color: var(--ink); font-variant-numeric: tabular-nums; }
.big-accent { width: 38px; height: 3px; background: var(--neon); border-radius: 2px; margin: 12px 0 16px; }
.sub-stats { display: flex; }
.sub-stats div { flex: 1; font-size: 12px; color: var(--muted); }
.sub-stats strong { display: block; font-family: 'Outfit', sans-serif; font-size: 18px; font-weight: 600; color: var(--ink); margin-top: 3px; font-variant-numeric: tabular-nums; }

.inv-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.inv-row:last-child { border-bottom: none; }
.inv-label { font-size: 13px; color: var(--muted); }
.inv-val { font-family: 'Outfit', sans-serif; font-size: 17px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.inv-val small { font-size: 12px; font-weight: 400; color: var(--muted); }

.reg-wrap { position: relative; margin-bottom: 14px; }
.reg-menu { margin-top: 8px; display: none; }
.reg-menu.open { display: block; animation: regDrop 0.18s ease; }
.reg-menu .btn { margin-bottom: 8px; }
.reg-menu .btn:last-child { margin-bottom: 0; }
@keyframes regDrop { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
.arrow { display: inline-block; transition: transform 0.2s; }
.arrow.up { transform: rotate(180deg); }

.activity-list { list-style: none; }
.activity-list li { display: flex; justify-content: space-between; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line); }
.activity-list li:last-child { border-bottom: none; }
.act-left { display: flex; align-items: center; gap: 10px; }
.act-icon { width: 28px; height: 28px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.act-icon.buy { background: #eef2f0; color: #64748b; }
.act-icon.sell { background: #f0fdf4; color: var(--pos); }
.act-name { font-size: 14px; font-weight: 500; }
.act-name small { display: block; font-size: 11px; color: var(--muted); }
.act-amt { font-family: 'Outfit', sans-serif; font-weight: 600; font-size: 14px; font-variant-numeric: tabular-nums; }
.act-amt.pos { color: var(--pos); }
.act-amt.neg { color: var(--red); }
.act-amt.cost { color: var(--muted); }

/* Listing info fields (copy/paste) */
.listing-field { margin-bottom: 18px; }
.listing-field:last-child { margin-bottom: 0; }
.listing-field-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.listing-field-head label { margin: 0; }
.sim-head { display: flex; justify-content: space-between; align-items: center; }
.listing-field input, .listing-field textarea { width: 100%; }
.listing-field textarea { resize: vertical; font-family: inherit; line-height: 1.6; min-height: 120px; }
.copy-btn { padding: 6px 14px; background: var(--carbon); color: #fff; border: none; border-radius: 8px; font-size: 12px; font-weight: 600; cursor: pointer; font-family: inherit; white-space: nowrap; }
.copy-btn:hover { background: #000; }
.copy-btn.copied { background: var(--neon-dim); }

/* Calculator results */
.calc-result { background: #f6f6f3; border: none; }
.calc-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.calc-row:last-child { border-bottom: none; }
.calc-row span { color: var(--muted); }
.calc-row strong { font-family: 'Outfit', sans-serif; font-weight: 600; font-size: 16px; color: var(--ink); font-variant-numeric: tabular-nums; }
.calc-row.total { padding: 14px 0; }
.calc-row.total span { color: var(--ink); font-weight: 600; }
.calc-row.total strong { font-size: 22px; }
.calc-row strong.pos { color: var(--pos); }
.calc-row strong.neg { color: var(--red); }

/* ===== Navigation: desktop top menu vs mobile tabbar+drawer ===== */
.hamburger { display: none; background: none; border: none; cursor: pointer; padding: 8px; flex-direction: column; gap: 4px; }
.hamburger span { width: 22px; height: 2px; background: #fff; border-radius: 2px; }

.tabbar { display: none; }
.tab-reg-menu, .tab-reg-overlay { display: none; }

.drawer-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: none; z-index: 200; }
.drawer-overlay.open { display: block; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 78%; max-width: 320px; background: var(--paper); box-shadow: -4px 0 20px rgba(0,0,0,0.15); transform: translateX(100%); transition: transform 0.22s ease; display: flex; flex-direction: column; }
.drawer.open { transform: translateX(0); }
.drawer-head { background: var(--carbon); padding: 16px 20px; display: flex; justify-content: space-between; align-items: center; }
.drawer-head .logo { font-size: 20px; }
.drawer-close { background: none; border: none; color: #fff; font-size: 26px; cursor: pointer; line-height: 1; }
.drawer-items { padding: 8px 0; }
.drawer-item { display: block; padding: 15px 20px; text-decoration: none; color: var(--ink); font-size: 15px; font-weight: 500; }
.drawer-item.active { background: #f6f6f3; color: var(--carbon); font-weight: 600; border-right: 3px solid var(--neon); }
.drawer-item.sep { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 18px; }

@media (max-width: 768px) {
  .nav-desktop { display: none; }
  .hamburger { display: flex; }

  .tabbar { display: flex; position: fixed; bottom: 0; left: 0; right: 0; height: 64px; background: var(--paper); border-top: 1px solid var(--line); align-items: center; justify-content: space-around; padding-bottom: env(safe-area-inset-bottom, 0); z-index: 100; }
  .tab { display: flex; flex-direction: column; align-items: center; gap: 3px; text-decoration: none; color: var(--muted); font-size: 10px; flex: 1; }
  .tab.active { color: var(--carbon); }
  .tab.active .tab-ico { color: var(--neon-dim); }
  .tab-ico { width: 22px; height: 22px; }
  .tab-center { flex: 0 0 auto; }
  .tab-plus { width: 52px; height: 52px; border-radius: 50%; background: var(--carbon); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 30px; box-shadow: 0 4px 14px rgba(24,24,27,0.35); border: 3px solid var(--bg); margin-top: -24px; cursor: pointer; }
  .tab-plus span { color: var(--neon); line-height: 1; }

  .tab-reg-overlay { display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.3); z-index: 90; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
  .tab-reg-overlay.open { opacity: 1; pointer-events: auto; }
  .tab-reg-menu { display: block; position: fixed; bottom: 80px; left: 16px; right: 16px; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 10px; box-shadow: 0 8px 30px rgba(0,0,0,0.18); z-index: 95; transform: translateY(12px); opacity: 0; pointer-events: none; transition: all 0.2s; }
  .tab-reg-menu.open { transform: translateY(0); opacity: 1; pointer-events: auto; }
  .tab-reg-menu .btn { margin-bottom: 8px; }
  .tab-reg-menu .btn:last-child { margin-bottom: 0; }

  .container { padding-bottom: 84px; }
}

/* Page title: hidden on mobile for bottom-bar pages, shown on PC */
@media (max-width: 768px) {
  .page-head.hide-mobile { display: none; }
}
