/* iOS の作法に寄せたクリーンな UI。
   system font / Large Title / grouped inset list / 浮くガラスのタブバー / ライト・ダーク両対応。
   アクセントは iOS の systemIndigo を tint として 1 色だけ使う。 */
:root {
  --bg: #F2F2F7;
  --card: #FFFFFF;
  --fill: rgba(118, 118, 128, 0.12);
  --label: #000000;
  --label-2: rgba(60, 60, 67, 0.6);
  --label-3: rgba(60, 60, 67, 0.3);
  --sep: rgba(60, 60, 67, 0.18);
  --tint: #5856D6;
  --green: #248A3D;
  --red: #D70015;
  --bar: rgba(249, 249, 249, 0.78);
  --thumb: #FFFFFF;
  --shadow-bar: 0 8px 32px rgba(0, 0, 0, 0.12), 0 0 0 0.5px rgba(0, 0, 0, 0.08);
  --r-card: 16px;
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN',
    'Helvetica Neue', system-ui, sans-serif;
  color-scheme: light;
  --sidebar: rgba(246, 246, 248, 0.9);
}


/* ---------------------------------------------------------------- テーマ
   既定はライト。設定で「ダーク」「自動(デバイスに合わせる)」を選べる(html[data-theme])。 */
:root[data-theme="dark"] {
  color-scheme: dark;
  --sidebar: rgba(28, 28, 30, 0.9);
  --bg: #000000;
  --card: #1C1C1E;
  --fill: rgba(118, 118, 128, 0.24);
  --label: #FFFFFF;
  --label-2: rgba(235, 235, 245, 0.6);
  --label-3: rgba(235, 235, 245, 0.3);
  --sep: rgba(84, 84, 88, 0.6);
  --tint: #5E5CE6;
  --green: #30D158;
  --red: #FF453A;
  --bar: rgba(30, 30, 30, 0.72);
  --thumb: #636366;
  --shadow-bar: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 0 0.5px rgba(255, 255, 255, 0.08);
  --s1: #6e6ade; --s2: #12a594; --s3: #c08400; --s4: #de51a8;
  --s-other: #545458; --ink-series: #f5f5f7; --spark: rgba(235, 235, 245, 0.3);
  --grid: #2c2c2e; --axis-base: #48484a; --axis-text: #8e8e93;
  --up: #30d158; --down: #ff6961;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    color-scheme: dark;
    --sidebar: rgba(28, 28, 30, 0.9);
    --bg: #000000;
    --card: #1C1C1E;
    --fill: rgba(118, 118, 128, 0.24);
    --label: #FFFFFF;
    --label-2: rgba(235, 235, 245, 0.6);
    --label-3: rgba(235, 235, 245, 0.3);
    --sep: rgba(84, 84, 88, 0.6);
    --tint: #5E5CE6;
    --green: #30D158;
    --red: #FF453A;
    --bar: rgba(30, 30, 30, 0.72);
    --thumb: #636366;
    --shadow-bar: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 0 0.5px rgba(255, 255, 255, 0.08);
    --s1: #6e6ade; --s2: #12a594; --s3: #c08400; --s4: #de51a8;
    --s-other: #545458; --ink-series: #f5f5f7; --spark: rgba(235, 235, 245, 0.3);
    --grid: #2c2c2e; --axis-base: #48484a; --axis-text: #8e8e93;
    --up: #30d158; --down: #ff6961;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--label); font-family: var(--font);
  font-size: 17px; line-height: 1.35; letter-spacing: -0.01em;
  font-feature-settings: 'palt' 1; font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
p, h1, h2, ul { margin: 0; }
ul { list-style: none; padding: 0; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
.icon { display: block; flex: none; }

/* ---------------------------------------------------------------- screen */
.screen {
  max-width: 640px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px calc(env(safe-area-inset-bottom, 0px) + 112px);
}
@media (min-width: 700px) { .screen { padding-left: 24px; padding-right: 24px; } }

.large-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 16px 4px 12px; }
.large-title h1 { font-size: 34px; line-height: 1.12; font-weight: 700; letter-spacing: -0.02em; }
.eyebrow { font-size: 13px; font-weight: 600; color: var(--label-2); margin-bottom: 2px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--fill); color: var(--label-2);
  font-size: 15px; font-weight: 600; display: grid; place-items: center; margin-bottom: 4px;
  position: relative;
}
.avatar::after { content: ''; position: absolute; inset: -4px; } /* 44px のタップ領域 */
.avatar.sm { width: 30px; height: 30px; font-size: 13px; margin: 0; flex: none; }
.avatar.sm::after { display: none; }
.pad-seg { padding: 12px; }
.danger { color: var(--red); justify-content: center; font-size: 17px; }
.env-badge {
  font-size: 13px; color: var(--label-2); background: var(--fill); border-radius: 10px;
  padding: 8px 12px; margin: 0 0 12px;
}

/* ---------------------------------------------------------------- cards & text */
.card { background: var(--card); border-radius: var(--r-card); overflow: hidden; }
.pad { padding: 16px; }
.caption { font-size: 13px; color: var(--label-2); }
.secondary { font-size: 13px; color: var(--label-2); margin-top: 2px; }
.muted { color: var(--label-3) !important; }
.neg { color: var(--red) !important; }
.footnote { font-size: 13px; color: var(--label-2); padding: 8px 16px 0; line-height: 1.45; }
.empty { font-size: 15px; color: var(--label-2); padding: 14px 16px; background: var(--card); border-radius: var(--r-card); }
.link { font-size: 15px; color: var(--tint); padding: 10px 0 10px 12px; }

.hero { padding: 20px 20px 18px; }
.hero.compact { margin-top: 4px; }
.hero-num { font-size: clamp(34px, 10vw, 44px); font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; margin-top: 4px; }
.hero-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.pill {
  font-size: 13px; font-weight: 600; color: var(--tint);
  background: color-mix(in srgb, var(--tint) 12%, transparent); border-radius: 999px; padding: 5px 10px;
}

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.tile { padding: 14px 16px 16px; min-width: 0; }
.tile-num { font-size: clamp(18px, 5.4vw, 22px); white-space: nowrap; font-weight: 700; letter-spacing: -0.02em; margin-top: 4px; overflow-wrap: anywhere; }
.tile-sub { font-size: 12px; color: var(--label-2); margin-top: 2px; line-height: 1.4; white-space: nowrap; }
.tile-num + .tile-sub { margin-top: 6px; }

/* ---------------------------------------------------------------- groups */
.group { margin-top: 28px; }
.group-head { display: flex; align-items: center; justify-content: space-between; min-height: 44px; padding: 0 4px 2px 4px; }
.group-head h2 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }

.summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 16px 16px 4px; gap: 8px; }
.sum-num { font-size: clamp(15px, 4.4vw, 19px); font-weight: 700; letter-spacing: -0.02em; margin-top: 2px; white-space: nowrap; }
.seg-wrap { padding: 12px 16px 8px; }
.seg-top { margin: 4px 0 16px; }
.seg-top.right { display: flex; justify-content: flex-end; }

.sync { display: flex; align-items: center; gap: 6px; font-size: 13px; padding: 10px 16px 0; color: var(--label-2); }
.sync.good .icon { color: var(--green); }
.sync.bad { color: var(--red); }

/* ---------------------------------------------------------------- list rows (iOS inset grouped) */
.list > li { position: relative; }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  min-height: 52px; padding: 10px 16px;
}
.list > li + li::before, .rows > li + li::before {
  content: ''; position: absolute; top: 0; left: 16px; right: 0; height: 0.5px; background: var(--sep);
}
.row-main { flex: 1; min-width: 0; }
.row-main > p:first-child { font-size: 17px; }
.row-value { font-size: 17px; font-weight: 500; white-space: nowrap; }
.tap { transition: background-color 0.15s; }
.tap:active { background: var(--fill); }
.chev { color: var(--label-3); transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1); margin-right: -4px; }
.chev.open { transform: rotate(90deg); }
.tag { font-size: 11px; font-weight: 600; color: var(--tint); vertical-align: 2px; margin-left: 4px; }

.sub { background: color-mix(in srgb, var(--fill) 45%, transparent); padding: 4px 0; }
.sub li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 16px 8px 32px; font-size: 15px; color: var(--label-2); }
.sub li .row-value { font-size: 15px; font-weight: 400; color: var(--label); }

li.total { display: flex; justify-content: space-between; align-items: center; min-height: 48px; padding: 10px 16px; font-weight: 600; }
li.total .row-value { font-weight: 700; }

.datechip {
  flex: none; width: 44px; height: 44px; border-radius: 10px; background: var(--fill);
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1;
}
.datechip span { font-size: 10px; font-weight: 600; color: var(--tint); }
.datechip b { font-size: 17px; font-weight: 600; }

/* ---------------------------------------------------------------- segmented control */
.segmented {
  --pad: 2px; position: relative; display: grid; grid-template-columns: repeat(var(--n), 1fr);
  background: var(--fill); border-radius: 9px; padding: var(--pad); height: 36px;
}
.segmented .thumb {
  position: absolute; top: var(--pad); bottom: var(--pad); left: var(--pad);
  width: calc((100% - var(--pad) * 2) / var(--n));
  transform: translateX(calc(100% * var(--i)));
  background: var(--thumb); border-radius: 7px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 3px 1px rgba(0, 0, 0, 0.04);
  transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.segmented button { position: relative; font-size: 14px; font-weight: 500; border-radius: 7px; }
.segmented button.on { font-weight: 600; }

/* ---------------------------------------------------------------- month picker (native select を iOS の pull-down 風に) */
.picker {
  position: relative; display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 2px 0 12px;
  font-size: 15px; color: var(--tint); font-weight: 500;
}
.picker select { position: absolute; inset: 0; opacity: 0; font-size: 16px; cursor: pointer; }

/* ---------------------------------------------------------------- table (PL 推移) */
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.grid { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; font-size: 15px; }
.grid th, .grid td { padding: 12px 14px; text-align: right; white-space: nowrap; border-bottom: 0.5px solid var(--sep); }
.grid thead th { font-size: 13px; font-weight: 600; color: var(--label-2); padding-top: 14px; }
.grid tbody th {
  text-align: left; font-weight: 400; position: sticky; left: 0; background: var(--card); z-index: 1;
  width: 9.5em; min-width: 9.5em; max-width: 9.5em; white-space: normal;
  box-shadow: 0.5px 0 0 var(--sep);
}
.grid thead th:first-child { position: sticky; left: 0; background: var(--card); z-index: 1; }
.grid tr.total th, .grid tr.total td { font-weight: 600; }
.grid tr.strong th, .grid tr.strong td { font-weight: 700; border-bottom: 0; }
.grid tr:last-child th, .grid tr:last-child td { border-bottom: 0; }

/* ---------------------------------------------------------------- tab bar (浮くガラス) */
.tabbar {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 10px); transform: translateX(-50%);
  width: min(calc(100% - 24px), 520px); height: 64px; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center; padding: 0 6px;
  background: var(--bar); border-radius: 32px; box-shadow: var(--shadow-bar);
  -webkit-backdrop-filter: saturate(180%) blur(24px); backdrop-filter: saturate(180%) blur(24px);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  height: 52px; border-radius: 26px; color: var(--label-2); font-size: 10px; font-weight: 500;
  transition: color 0.2s, background-color 0.2s;
}
.tabbar a.on { color: var(--tint); background: var(--fill); }

/* ---------------------------------------------------------------- sign in / states */
.signin {
  min-height: 100dvh; display: flex; flex-direction: column; justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 20vh) 24px calc(env(safe-area-inset-bottom, 0px) + 32px);
  max-width: 440px; margin: 0 auto; text-align: center;
}
.app-icon { width: 72px; height: 72px; border-radius: 16px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12); }
.signin h1 { font-size: 34px; font-weight: 700; letter-spacing: -0.02em; margin-top: 20px; }
.signin-body p { color: var(--label-2); margin-top: 6px; }
.btn-primary {
  width: 100%; height: 52px; border-radius: 14px; background: var(--label); color: var(--bg);
  font-size: 17px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 10px;
}
.btn-primary:active { opacity: 0.8; }
.btn-plain { color: var(--tint); font-size: 17px; margin-top: 16px; min-height: 44px; }
.fine { font-size: 13px; color: var(--label-2); margin-top: 12px; }

.center { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.notice { background: var(--card); border-radius: var(--r-card); padding: 20px; max-width: 360px; text-align: center; }
.notice p { color: var(--label-2); font-size: 15px; margin-top: 6px; }
.spinner {
  width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--fill); border-top-color: var(--label-2);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

:focus-visible { outline: 2px solid var(--tint); outline-offset: 2px; border-radius: 8px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation-duration: 0.001ms !important; } }

/* ================================================================
   Phase 2: 受信箱・立替・通知
   ================================================================ */
.tab-icon { position: relative; display: block; }
.badge {
  position: absolute; top: -4px; right: -9px; min-width: 17px; height: 17px; padding: 0 5px; border-radius: 9px;
  background: var(--red); color: #fff; font-size: 11px; font-weight: 700; line-height: 17px; text-align: center;
}
.fab {
  position: fixed; right: 16px; bottom: calc(env(safe-area-inset-bottom, 0px) + 86px); z-index: 31;
  width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center;
  background: var(--tint); color: #fff; box-shadow: 0 8px 24px color-mix(in srgb, var(--tint) 40%, transparent), 0 2px 6px rgba(0, 0, 0, 0.12);
  transition: transform 0.15s;
}
.fab:active { transform: scale(0.94); }

/* 撮影エリア */
.capture {
  width: 100%; min-height: 180px; display: grid; place-items: center; overflow: hidden; padding: 0;
  border: 1.5px dashed color-mix(in srgb, var(--label) 18%, transparent); background: var(--card);
}
.capture.has { border-style: solid; border-color: transparent; }
.capture img { width: 100%; max-height: 420px; object-fit: contain; background: var(--fill); display: block; }
.capture-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--tint); padding: 28px; }
.capture-empty b { font-size: 16px; }
.capture-file { padding: 28px; font-weight: 600; }

/* フォーム(iOS の設定行) */
.form .field + .field { border-top: 0.5px solid var(--sep); }
.field { display: flex; align-items: center; gap: 12px; min-height: 50px; padding: 0 16px; position: relative; }
.field > span { flex: none; width: 5.5em; font-size: 15px; color: var(--label); }
.field input, .field select {
  flex: 1; min-width: 0; font: inherit; font-size: 17px; color: var(--label); background: transparent;
  border: 0; outline: none; text-align: right; padding: 12px 0; -webkit-appearance: none; appearance: none;
}
.field select { direction: rtl; cursor: pointer; }
.field select option { direction: ltr; }
.field input::placeholder { color: var(--label-3); }
.field em { font-style: normal; font-size: 12px; color: var(--label-2); position: absolute; right: 16px; bottom: 2px; }
.field.compact { min-height: 44px; padding: 0 12px; background: var(--fill); border-radius: 10px; }
.field.compact > span { width: auto; font-size: 13px; color: var(--label-2); }
.field.compact select { font-size: 15px; padding: 8px 0; }
.form-actions { margin-top: 20px; }
.form-error { color: var(--red); font-size: 14px; margin-top: 12px; padding: 0 4px; }
.btn-primary.tint { background: var(--tint); color: #fff; }
.btn-primary:disabled, .btn-secondary:disabled { opacity: 0.4; cursor: default; }
.btn-secondary {
  height: 48px; border-radius: 12px; background: var(--fill); color: var(--label); font-size: 16px; font-weight: 600;
  padding: 0 18px;
}

/* 受信箱 */
.cards { display: flex; flex-direction: column; gap: 12px; }
.approval { padding: 16px; }
.approval-body { display: flex; gap: 14px; align-items: flex-start; }
.thumb {
  flex: none; width: 76px; height: 96px; border-radius: 10px; overflow: hidden; background: var(--fill);
  display: grid; place-items: center; color: var(--label-2); font-size: 13px; font-weight: 700;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.approval-main { min-width: 0; }
.approval-amt { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; margin: 2px 0; }
.approval-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.approval-actions { display: grid; grid-template-columns: auto 1fr; gap: 10px; margin-top: 14px; }
.approval-actions .btn-primary { margin-top: 0; height: 48px; }
.footnote.tight { padding: 8px 0 0; }
.alert-card { padding: 16px; border-left: 3px solid var(--label-3); }
.alert-card.high { border-left-color: var(--red); }
.alert-title { display: flex; gap: 8px; align-items: center; font-weight: 600; }
.alert-card.high .alert-title .icon { color: var(--red); }
.alert-card .approval-actions { grid-template-columns: auto; justify-content: start; }
.empty-state {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  padding: 40px 16px 8px; color: var(--label-2);
}
.empty-state .icon { color: var(--green); }
.empty-state b { color: var(--label); font-size: 17px; }
.row-end { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.status-chip { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--fill); color: var(--label-2); white-space: nowrap; }
.status-chip.wait { color: var(--tint); background: color-mix(in srgb, var(--tint) 12%, transparent); }
.status-chip.good { color: var(--green); background: color-mix(in srgb, var(--green) 12%, transparent); }
.status-chip.bad { color: var(--red); background: color-mix(in srgb, var(--red) 12%, transparent); }

/* 通知の設定 */
.steps { margin: 0 0 8px; padding-left: 20px; line-height: 1.8; }
.notify-on { display: flex; align-items: center; gap: 8px; color: var(--green); font-weight: 600; }
.card.pad .btn-primary { margin-top: 0; }

/* ================================================================
   チャート(dataviz: 検証済みパレットをライト/ダークで別ステップ)
   ================================================================ */
:root {
  /* Radix step9 系の4色(indigo / teal / amber / plum)+ その他はニュートラル。validate_palette.js で検証済み */
  --s1: #5b5bd6; --s2: #12a594; --s3: #ce8a00; --s4: #d6409f;
  --s-other: #c7c7cc; --ink-series: #1d1d1f; --spark: rgba(60, 60, 67, 0.28);
  --grid: #ececef; --axis-base: #c7c7cc; --axis-text: #8e8e93;
  --up: #1f7a34; --down: #c4262e;
}

.viz { position: relative; width: 100%; }
.viz svg { display: block; overflow: visible; touch-action: pan-y; }
.grid-line { stroke: var(--grid); stroke-width: 1; }
.base-line { stroke: var(--axis-base); stroke-width: 1; }
.axis { font-size: 11px; fill: var(--axis-text); font-variant-numeric: tabular-nums; }
.axis-sel { fill: var(--label); font-weight: 600; }
.crosshair { stroke: var(--axis-base); stroke-width: 1; }
.ring { stroke: var(--card); stroke-width: 2; }
.hit { fill: transparent; cursor: pointer; outline: none; }
.col path { transition: opacity 0.15s; }
.col.on path { opacity: 0.82; }
.viz-tip {
  position: absolute; transform: translate(-50%, calc(-100% - 6px)); pointer-events: none; z-index: 5;
  background: var(--card); border-radius: 10px; padding: 8px 10px; min-width: 140px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.14), 0 0 0 0.5px var(--sep);
}
.viz-tip-title { font-size: 12px; color: var(--label-2); margin-bottom: 4px; }
.viz-tip-row { display: flex; align-items: center; gap: 6px; font-size: 13px; line-height: 1.5; white-space: nowrap; }
.viz-tip-row b { font-weight: 600; font-variant-numeric: tabular-nums; }
.viz-tip-row span:last-child { color: var(--label-2); }
.viz-tip-row .key { width: 10px; height: 2px; border-radius: 1px; flex: none; }

.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; justify-content: flex-end; font-size: 12px; color: var(--label-2); }
.legend li { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.key-rect { width: 8px; height: 8px; border-radius: 2px; }
.key-line { width: 12px; height: 2px; border-radius: 1px; }

/* hero: 現預金 + 推移 */
.hero-cash { padding: 18px 16px 10px; }
.hero-head { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.hero-cash .hero-num { margin-top: 2px; }
.delta { font-size: 13px; color: var(--label-2); margin-top: 4px; min-height: 18px; }
.delta-val { font-weight: 600; font-variant-numeric: tabular-nums; }
.delta-val.up { color: var(--up); }
.delta-val.down { color: var(--down); }
.delta-val.flat { color: var(--label-2); }
.hero-side { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.runway { font-size: 17px; font-weight: 700; letter-spacing: -0.02em; }
.runway small { font-size: 13px; font-weight: 600; margin-left: 2px; color: var(--label-2); }

/* 統計タイル */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.stat { padding: 14px 14px 12px; min-width: 0; }
.stat-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 6px; margin-top: 4px; }
.stat-num { font-size: clamp(17px, 4.8vw, 22px); font-weight: 700; letter-spacing: -0.02em; white-space: nowrap; }
.stat .spark { flex: none; width: 56px; }
.stat-foot { font-size: 12px; color: var(--label-2); margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* チャートカード */
.chart-card { padding: 16px 16px 12px; }
.chart-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.chart-num { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; margin-top: 2px; }
.chart-note { font-size: 12px; color: var(--label-2); margin-top: 6px; }
.pl-chart { margin-top: 4px; }
.table-seg { margin-top: 24px; }
.group.tight { margin-top: 0; }

/* 費用の内訳(横棒) */
.breakdown .bd-row { align-items: center; padding-top: 12px; padding-bottom: 12px; }
.bd-main { flex: 1; min-width: 0; }
.bd-top { display: flex; align-items: baseline; gap: 8px; }
.bd-name { flex: 1; min-width: 0; display: inline-flex; align-items: center; gap: 8px; font-size: 16px; }
.bd-name i { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.bd-share { font-size: 13px; color: var(--label-2); font-variant-numeric: tabular-nums; }
.bd-track { height: 6px; border-radius: 3px; background: var(--fill); margin: 8px 0 6px; overflow: hidden; }
.bd-track span { display: block; height: 100%; border-radius: 3px; }

/* ================================================================
   SP / PC の出し分け
   SP(〜1023px): 上の iOS レイアウト(Large Title + 浮くタブバー)
   PC(1024px〜): 左サイドバー + 横に広い段組み(macOS / Web ダッシュボードの作法)
   ================================================================ */
.sidebar, .pc-only, .side-new { display: none; }
.grid td.l { text-align: left; }
.grid td.muted { color: var(--label-3); }

@media (min-width: 1024px) {
  :root { --side-w: 232px; }

  body { font-size: 15px; }
  .tabbar, .sp-only, .large-title .avatar, .fab { display: none; }
  .side-new {
    display: flex; align-items: center; justify-content: center; gap: 6px; height: 36px; margin: 0 4px 14px;
    border-radius: 8px; background: var(--tint); color: #fff; font-size: 14px; font-weight: 600;
  }
  .side-nav .count { margin-left: auto; font-size: 12px; font-weight: 700; color: #fff; background: var(--red); border-radius: 9px; padding: 0 7px; line-height: 18px; }
  .cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); }
  .form, .capture { max-width: 640px; }
  .form-actions { max-width: 640px; }
  .pc-only { display: block; }

  /* ---- sidebar */
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--side-w); z-index: 30;
    display: flex; flex-direction: column; padding: 20px 12px 16px;
    background: var(--sidebar); border-right: 0.5px solid var(--sep);
    -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  }
  .side-brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 20px; }
  .side-brand img { border-radius: 7px; }
  .side-brand b { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
  .side-env { font-size: 10px; font-weight: 700; color: var(--tint); background: color-mix(in srgb, var(--tint) 12%, transparent); padding: 2px 6px; border-radius: 5px; }
  .side-nav { display: flex; flex-direction: column; gap: 2px; }
  .side-nav a {
    display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border-radius: 8px;
    font-size: 14px; font-weight: 500; color: var(--label); transition: background-color 0.15s;
  }
  .side-nav a .icon { color: var(--label-2); }
  .side-nav a:hover { background: var(--fill); }
  .side-nav a.on { background: var(--card); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 0 0 0.5px var(--sep); }
  .side-nav a.on .icon { color: var(--tint); }
  .side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding: 0 6px; }
  .side-sync { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--label-2); padding: 0 4px; }
  .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--label-3); }
  .dot.good { background: var(--green); }
  .dot.bad { background: var(--red); }
  .side-user { display: flex; align-items: center; gap: 10px; padding: 8px 8px; border-radius: 8px; transition: background-color 0.15s; }
  .side-user:hover { background: var(--fill); }
  .side-user.on { background: var(--card); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 0 0 0.5px var(--sep); }
  .side-gear { margin-left: auto; color: var(--label-2); }
  .pad-seg .segmented { max-width: 360px; }
  .side-user-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
  .side-user-text b { font-size: 13px; }
  .side-user-text span { font-size: 11px; color: var(--label-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* ---- canvas */
  .screen { margin: 0 0 0 var(--side-w); max-width: calc(1240px + var(--side-w)); padding: 28px 40px 56px; }
  .large-title { padding: 4px 0 20px; }
  .large-title h1 { font-size: 28px; }
  .env-badge { display: inline-block; }

  /* ---- home: KPI 横一列 + 2カラム */
  .dash { display: grid; grid-template-columns: 1.35fr 1fr 1fr; gap: 16px; align-items: stretch; }
  .dash .tiles { display: contents; }
  .dash .tile { margin: 0; padding: 20px; }
  .hero { padding: 20px 24px; }
  .hero-num { font-size: 40px; }
  .tile-num { font-size: 26px; }
  .cols { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 0 24px; align-items: start; }
  .hero-cash { padding: 22px 24px 12px; }
  .hero-head { flex-direction: row; justify-content: space-between; align-items: flex-start; gap: 16px; }
  .hero-side { display: block; text-align: right; flex: none; }
  .runway { font-size: 22px; margin: 2px 0; }
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
  .stat { padding: 16px 18px 14px; }
  .stat .spark { width: 72px; }
  .stat-num { font-size: 22px; }
  .chart-card { padding: 20px 20px 14px; }
  .pl-chart { padding: 22px 24px 16px; }

  .group-head h2 { font-size: 19px; }
  .row { min-height: 48px; padding: 9px 16px; }
  .row-main > p:first-child, .row-value { font-size: 15px; }
  .datechip { width: 40px; height: 40px; }
  .datechip b { font-size: 15px; }
  .sum-num { font-size: 22px; }
  .tap:hover { background: color-mix(in srgb, var(--fill) 60%, transparent); }

  .seg-top { max-width: 320px; }
  .seg-top.right { max-width: none; }
  .seg-wrap .segmented { max-width: 280px; }

  /* ---- tables */
  .grid { font-size: 14px; }
  .grid tbody th { width: 12em; min-width: 12em; max-width: 12em; }
  .grid tbody tr:hover th, .grid tbody tr:hover td { background: color-mix(in srgb, var(--fill) 50%, var(--card)); }
  .grid.wide { width: 100%; }
  .grid.wide th, .grid.wide td { text-align: left; }
  .grid.wide th:last-child, .grid.wide td:last-child { text-align: right; }
  .grid.wide tbody th { width: auto; min-width: 0; max-width: none; position: static; box-shadow: none; font-weight: 600; }
  .grid.wide thead th:first-child { position: static; }

  /* ---- 資産・負債 / 予定: 2カラム */
  .bs-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; align-items: start; }
  .bs-cols > div > .group:first-child { margin-top: 0; }
  .cal-cols { columns: 2; column-gap: 24px; }
  .cal-cols > .group { break-inside: avoid; margin-top: 0; padding-bottom: 28px; }
  .seg-top.right { margin-top: -56px; }
  .hero.compact { max-width: 420px; }
}

@media (min-width: 1440px) {
  .screen { padding-left: 56px; padding-right: 56px; }
}
