:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-soft: #f9fafb;
  --ink: #344057;
  --ink-strong: #1e2940;
  --muted: #6f7a92;
  --line: #e1e5ee;
  --primary: #4d67d2;
  --primary-deep: #3f57bc;
  --success: #71dd37;
  --danger: #ff3e5b;
  --warning: #ffab00;
  --radius-lg: 14px;
  --radius-md: 12px;
  --shadow-card: 0 4px 12px rgba(58, 75, 111, 0.06);
  --shadow-soft: 0 3px 10px rgba(58, 75, 111, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow-x: hidden;
}

body {
  font-family: "Noto Sans JP", "Hiragino Sans", "Yu Gothic", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

.app-body {
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  height: 100vh;
}

.sidebar-panel {
  border-right: 1px solid var(--line);
  background: #fff;
  padding: 1rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.4rem;
}

.brand strong {
  color: var(--ink-strong);
  display: block;
  line-height: 1.2;
}

.brand small {
  color: var(--muted);
  font-size: 0.78rem;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  background: var(--primary);
  box-shadow: var(--shadow-soft);
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.side-nav-secondary {
  margin-bottom: 0.8rem;
}

.side-link {
  border-radius: 10px;
  color: #53607f;
  font-weight: 600;
  font-size: 0.92rem;
  padding: 0.63rem 0.8rem;
  transition: all 0.2s ease;
}

.side-link:hover {
  background: #ecefff;
  color: var(--primary);
}

.side-link.active {
  background: #e9edfd;
  color: var(--primary-deep);
  box-shadow: none;
}

.side-link-logout {
  width: 100%;
  text-align: left;
  border: 0;
  background: #f3f5fa;
  color: #495672;
}

.side-link-logout:hover {
  background: #e8ecf5;
  color: #35425f;
}

.sidebar-user {
  background: #f7f9fc;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 0.85rem;
}

.sidebar-bottom {
  margin-top: auto;
}

.user-label,
.user-role {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.user-name {
  margin: 0.3rem 0 0.15rem;
  color: var(--ink-strong);
  font-weight: 700;
}

.app-main {
  padding: 1rem;
  min-width: 0;
  height: 100vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.mobile-appbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.brand-compact {
  padding: 0;
}

.brand-compact strong {
  font-size: 1.05rem;
}

.top-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 0.4rem 0.2rem 1rem;
}

.page-title {
  margin: 0;
  color: var(--ink-strong);
  font-weight: 800;
  letter-spacing: 0.01em;
  font-size: 1.45rem;
}

.page-subtitle {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.page-subtitle:empty {
  display: none;
}

.header-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.page-content {
  display: grid;
  gap: 1rem;
}

.flash-stack {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 2500;
  display: grid;
  gap: 0.55rem;
  width: min(420px, calc(100vw - 28px));
  pointer-events: none;
}

.flash-message {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 16px 34px rgba(33, 41, 66, 0.16);
  padding: 0.7rem 0.85rem;
  color: var(--ink-strong);
  background: #f7f9fc;
  transform: translateY(0);
  opacity: 1;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.flash-message.is-closing {
  opacity: 0;
  transform: translateY(-6px);
}

.flash-body {
  font-size: 0.92rem;
  line-height: 1.45;
}

.flash-close {
  border: 0;
  background: transparent;
  color: #4e5d7a;
  font-size: 1.2rem;
  line-height: 1;
  padding: 0;
  margin-top: -1px;
  cursor: pointer;
}

.flash-close:hover {
  color: #25314a;
}

.flash-success {
  border-color: #cfe6da;
  background: #eaf7f0;
}

.flash-info {
  border-color: #d7e1f2;
  background: #edf3ff;
}

.flash-warning {
  border-color: #f2e2be;
  background: #fff8ea;
}

.flash-error,
.flash-danger {
  border-color: #f2c7d0;
  background: #fff0f4;
}

.panel,
.card,
.tool-card,
.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.panel {
  padding: 1.1rem;
}

.narrow {
  max-width: 470px;
  margin: 0 auto;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 1rem;
}

.span-8 {
  grid-column: span 8;
}

.span-7 {
  grid-column: span 7;
}

.span-5 {
  grid-column: span 5;
}

.span-4 {
  grid-column: span 4;
}

.span-6 {
  grid-column: span 6;
}

.hero-panel {
  background: #fff;
}

.hero-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.28rem 0.65rem;
  color: var(--primary-deep);
  background: #eef1fb;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.stat-card {
  padding: 0.85rem;
}

.stat-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.stat-value {
  margin: 0.35rem 0 0;
  color: var(--ink-strong);
  font-size: 1.15rem;
  font-weight: 800;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.9rem;
}

.tool-card {
  padding: 0.95rem;
  transition: border-color 0.2s ease;
}

.tool-card:hover {
  box-shadow: var(--shadow-card);
  border-color: #ccd3e4;
}

.tool-meta {
  color: var(--muted);
  font-size: 0.88rem;
  margin-bottom: 1rem;
}

input,
textarea,
select,
.form-control,
.form-select {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 0.58rem 0.72rem;
  color: var(--ink);
}

textarea {
  min-height: 120px;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus,
.form-control:focus,
.form-select:focus {
  border-color: #9ea7ff;
  box-shadow: 0 0 0 0.2rem rgba(105, 108, 255, 0.16);
  outline: 0;
}

form .form-text {
  color: var(--muted);
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.auth-main {
  width: min(470px, 100%);
}

.note-list {
  display: grid;
  gap: 0.75rem;
}

.note-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  padding: 0.85rem;
}

.note-item h3 {
  margin: 0 0 0.45rem;
  color: var(--ink-strong);
  font-size: 1rem;
}

.note-item p {
  margin: 0;
  white-space: pre-wrap;
}

.note-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.result-box {
  border-radius: var(--radius-md);
  border: 1px dashed #a7b0ff;
  background: #f8f9ff;
  padding: 0.9rem;
}

.result-box-danger {
  border-color: #f2c7d0;
  background: #fff0f4;
  color: #842337;
}

.codex-form {
  display: grid;
  gap: 1rem;
}

.codex-answer {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  padding: 1rem;
  line-height: 1.75;
  white-space: normal;
}

.codex-image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.codex-image-card {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  padding: 0.75rem;
}

.codex-image-card img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  background: #fff;
}

.codex-image-card figcaption {
  margin-top: 0.65rem;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.5;
}

.codex-warnings {
  border: 1px solid #f2e2be;
  border-radius: var(--radius-md);
  background: #fff8ea;
  padding: 0.85rem 1rem;
  color: #72520b;
}

.result-value {
  margin: 0.35rem 0 0;
  color: var(--ink-strong);
  font-size: 1.3rem;
  font-weight: 800;
}

.table-wrap {
  overflow-x: auto;
}

.table {
  --bs-table-bg: transparent;
  --bs-table-striped-bg: #f8f9ff;
  margin: 0;
}

.badge-soft {
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.28rem 0.55rem;
}

.badge-role-admin {
  color: #453bce;
  background: #e7e8ff;
}

.badge-role-user {
  color: #3f506d;
  background: #edf1fb;
}

.badge-state-active {
  color: #256c0d;
  background: #eafadf;
}

.badge-state-disabled {
  color: #7a2433;
  background: #ffe8ec;
}

.table-link {
  color: var(--primary-deep);
  text-decoration: none;
  font-weight: 600;
}

.table-link:hover {
  text-decoration: underline;
}

.table-link.active {
  color: var(--ink-strong);
  text-decoration: underline;
}

.subtool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.9rem;
}

.subtool-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  padding: 1rem;
}

.subtool-card h3,
.info-list h3 {
  margin: 0 0 0.45rem;
  color: var(--ink-strong);
  font-size: 1rem;
}

.subtool-card p,
.info-list p,
.info-list li {
  color: var(--muted);
}

.subtool-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.info-list {
  display: grid;
  gap: 0.9rem;
}

.info-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  padding: 0.9rem;
}

.stock-detail-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 1rem;
  height: calc(100vh - 190px);
  min-height: 620px;
  overflow: hidden;
}

.stock-switcher,
.stock-detail-main {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.stock-switcher {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100%;
}

.stock-switcher-list {
  display: grid;
  gap: 0.55rem;
}

.stock-switcher-list-mobile {
  display: none;
}

.stock-switcher-accordion {
  display: none;
}

.stock-action-bar {
  padding: 0.9rem 1.1rem;
}

.stock-action-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: space-between;
}

.stock-action-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.stock-action-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.stock-search-form {
  flex: 1;
  min-width: 200px;
}

.stock-search-form input[name='code'] {
  min-width: 0;
  width: 100%;
}

.stock-switcher-item {
  display: grid;
  gap: 0.12rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  padding: 0.75rem;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.stock-switcher-item:hover {
  border-color: #c7d0f5;
  background: #f4f6ff;
  transform: translateY(-1px);
}

.stock-switcher-item.active {
  border-color: var(--primary);
  background: #eef2ff;
}

.stock-switcher-code {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.stock-switcher-name {
  color: var(--ink-strong);
  font-weight: 800;
  line-height: 1.35;
}

.stock-switcher-meta {
  color: var(--muted);
  font-size: 0.78rem;
}

.stock-detail-main {
  display: grid;
  align-content: start;
  gap: 1rem;
  padding-right: 0.15rem;
}

.stock-tabs-panel {
  padding-top: 0;
}

.stock-detail-tabs {
  position: sticky;
  top: 0;
  z-index: 20;
  padding-top: 1rem;
  background: var(--surface);
}

.stock-detail-tabs .nav-link {
  color: var(--muted);
  font-weight: 700;
}

.stock-detail-tabs .nav-link.active {
  color: var(--primary-deep);
  background: #f8faff;
  border-color: var(--line) var(--line) var(--surface);
}

.stock-detail-tab-content {
  padding-top: 1rem;
}

.stock-overview {
  display: grid;
  gap: 0.85rem;
}

.stock-identity {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  flex-wrap: wrap;
}

.analysis-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  font-weight: 700;
  font-size: 0.8rem;
}

.analysis-badge-success {
  background: #e8f7eb;
  color: #22693b;
}

.analysis-badge-danger {
  background: #fde9ec;
  color: #a02f44;
}

.analysis-badge-warning {
  background: #fff3df;
  color: #946200;
}

.analysis-summary {
  border-radius: var(--radius-md);
  padding: 0.95rem 1rem;
  border: 1px solid var(--line);
}

.analysis-summary-success {
  background: #f1fbf3;
  border-color: #d7eedc;
}

.analysis-summary-danger {
  background: #fff2f4;
  border-color: #f3d5db;
}

.analysis-summary-warning {
  background: #fff9ee;
  border-color: #f1e2ba;
}

.signal-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.9rem;
}

.chart-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 1rem;
}

.chart-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.chart-box {
  min-height: 520px;
}

.chart-box-medium {
  min-height: 260px;
}

.help-dot {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  margin-left: 0.35rem;
  border: 0;
  border-radius: 999px;
  background: #e9edfd;
  color: var(--primary-deep);
  font-size: 0.74rem;
  font-weight: 700;
  vertical-align: middle;
}

.help-dot:hover {
  background: #dfe5ff;
}

.help-popover {
  position: absolute;
  z-index: 2000;
  max-width: 280px;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 16px 40px rgba(33, 41, 66, 0.16);
  color: var(--ink);
  font-size: 0.86rem;
  line-height: 1.55;
}

.help-inline {
  position: relative;
  display: inline-block;
  margin-left: 0.35rem;
}

.help-inline summary {
  list-style: none;
}

.help-inline summary::-webkit-details-marker {
  display: none;
}

.help-inline[open] .help-popover-static {
  display: block;
}

.help-popover-static {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 2000;
  width: min(280px, 70vw);
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 16px 40px rgba(33, 41, 66, 0.16);
  color: var(--ink);
  font-size: 0.86rem;
  line-height: 1.55;
}

.chart-svg {
  width: 100%;
  height: auto;
  display: block;
}

.chart-axis-label {
  fill: #6f7a92;
  font-size: 11px;
}

.chart-empty {
  display: grid;
  place-items: center;
  min-height: 180px;
  color: var(--muted);
  font-size: 0.92rem;
}

.stock-code {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.stock-name {
  margin: 0.2rem 0 0;
  color: var(--ink-strong);
  font-size: 1.25rem;
  font-weight: 800;
}

.stock-market {
  margin: 0.25rem 0 0;
  color: var(--muted);
}

.stock-price {
  margin: 0;
  color: var(--ink-strong);
  font-size: 1.4rem;
  font-weight: 800;
}

.stock-price-note {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.stock-description {
  margin: 0;
  color: var(--ink);
}

.school-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.school-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, #ffffff 0%, #f7f9fd 100%);
  padding: 1rem;
}

.school-card h3 {
  margin: 0 0 0.45rem;
  color: var(--ink-strong);
  font-size: 1rem;
}

.school-card p {
  margin: 0;
  color: var(--muted);
}

.school-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 0.9rem;
}

.school-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.28rem 0.6rem;
  background: #edf4ff;
  color: #2e5bb8;
  font-size: 0.76rem;
  font-weight: 700;
}

.portfolio-list {
  display: grid;
  gap: 0.85rem;
}

.portfolio-card {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  padding: 1rem;
}

.portfolio-card h3 {
  margin: 0 0 0.35rem;
  color: var(--ink-strong);
  font-size: 1rem;
}

.portfolio-card p {
  margin: 0;
  color: var(--ink);
}

.portfolio-meta {
  color: var(--muted) !important;
  font-size: 0.84rem;
  margin-bottom: 0.35rem !important;
}

.finance-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-bottom: 0.9rem;
}

.finance-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--ink-strong);
  font-weight: 700;
  font-size: 0.9rem;
}

.finance-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  display: inline-block;
}

.finance-dot-invest,
.finance-marker-invest {
  background: #a33d21;
}

.finance-dot-fund,
.finance-marker-fund {
  background: #2f74aa;
}

.finance-dot-operate,
.finance-marker-operate {
  background: #3a9923;
}

.finance-visual-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.finance-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  padding: 0.9rem;
}

.finance-diagram {
  position: relative;
  border: 1px solid #cbd3e3;
  background: #f7f9fd;
  border-radius: 10px;
  overflow: hidden;
  min-height: 220px;
}

.finance-card-title {
  margin: 0.75rem 0 0.4rem;
  color: #f27b1b;
  font-size: 1.25rem;
  font-weight: 800;
  text-align: center;
}

.finance-card-meta {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.55;
}

.finance-pl {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 0.2rem;
}

.finance-pl-top,
.finance-pl-bottom {
  color: #3a9923;
  font-weight: 800;
  font-size: 1.1rem;
}

.finance-pl-arrow {
  color: #aeb9d1;
  font-size: 72px;
  line-height: 1;
}

.finance-marker {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: inline-block;
}

.finance-pl .finance-marker {
  position: absolute;
  right: 28px;
  top: 52%;
}

.finance-bs {
  display: grid;
  grid-template-columns: 1fr 0.85fr;
}

.finance-bs-assets {
  position: relative;
  display: grid;
  place-items: center;
  border-right: 1px solid #cbd3e3;
}

.finance-bs-right {
  display: grid;
  grid-template-rows: 1fr 1fr;
}

.finance-bs-liability,
.finance-bs-equity {
  position: relative;
  min-height: 88px;
  display: grid;
  place-items: center;
}

.finance-bs-liability {
  border-bottom: 1px solid #cbd3e3;
}

.finance-bs-assets .finance-block-label {
  color: #a33d21;
}

.finance-bs-liability .finance-block-label,
.finance-bs-equity .finance-block-label {
  color: #2f74aa;
}

.finance-bs-assets .finance-marker {
  position: absolute;
  right: 22%;
  top: 56%;
}

.finance-block-label {
  font-size: 1.1rem;
  font-weight: 800;
}

.finance-cs {
  display: grid;
  grid-template-rows: 1fr 1fr 1fr;
}

.finance-cs-row {
  position: relative;
  min-height: 72px;
  border-bottom: 1px solid #cbd3e3;
  display: flex;
  align-items: center;
  justify-content: center;
}

.finance-cs-row:last-child {
  border-bottom: 0;
}

.finance-cs-operate .finance-block-label {
  color: #3a9923;
}

.finance-cs-invest .finance-block-label {
  color: #a33d21;
}

.finance-cs-fund .finance-block-label {
  color: #2f74aa;
}

.finance-cs-row .finance-marker {
  position: absolute;
  right: 20%;
}

/* ── household badge system ────────────────────────────────────────────────── */
.hh-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  white-space: nowrap;
}

/* カテゴリ */
.hh-cat-infra         { background: #ddeeff; color: #1a5c8a; }
.hh-cat-subscription  { background: #ecdeff; color: #6a1fb5; }
.hh-cat-tax           { background: #ffe0e0; color: #b01c1c; }
.hh-cat-investment    { background: #dff5e3; color: #1a6b2e; }
.hh-cat-car           { background: #e8eaf0; color: #3d4460; }
.hh-cat-insurance     { background: #ffe8d0; color: #8a4200; }
.hh-cat-education     { background: #fff8d0; color: #6b5500; }
.hh-cat-utility       { background: #d8f5f5; color: #0d6b6b; }
.hh-cat-communication { background: #dde8ff; color: #1a2e8a; }

/* 支払い方法 */
.hh-pay-bank        { background: #d9f5e5; color: #0d6633; }
.hh-pay-credit_card { background: #fff2d9; color: #7a4800; }

/* 頻度 */
.hh-freq-monthly    { background: #e3ebff; color: #1a3d8a; }
.hh-freq-semiannual { background: #ecdeff; color: #5b1a8a; }
.hh-freq-yearly     { background: #fff2d9; color: #7a4800; }
.hh-freq-biennial   { background: #ffe0e0; color: #8a1a1a; }
.hh-freq-triennial  { background: #f5d9d9; color: #6b0d0d; }

/* モバイル用カードリスト */
.mobile-card-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

/* カード外形のみ - 内部レイアウトはBootstrapユーティリティで */
.mobile-list-card {
  background: var(--surface);
  border: 1px solid #c8d0e3;
  border-radius: var(--radius-md);
  padding: 0.75rem 0.9rem;
}

/* バッジ行 */
.mlc-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

/* ツールバー（一覧ヘッダー） */
.list-toolbar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* 支払い先（neutral）・金額タグ */
.hh-account { background: #f0f2f7; color: #444b63; }

@media (max-width: 920px) {
  .app-body {
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
  }

  .sidebar-panel {
    display: none;
  }

  .mobile-appbar {
    display: flex;
  }

  .top-header {
    flex-direction: column;
  }

  .app-main {
    padding: 0.75rem;
    height: auto;
    overflow: visible;
  }

  .page-title {
    font-size: 1.3rem;
  }

  .flash-stack {
    top: 10px;
    right: 10px;
    width: min(400px, calc(100vw - 20px));
  }

  .dashboard-grid,
  .metric-grid,
  .stock-detail-shell {
    grid-template-columns: 1fr;
  }

  .stock-detail-shell {
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .stock-switcher,
  .stock-detail-main {
    height: auto;
    overflow: visible;
  }

  .stock-switcher {
    position: static;
  }

  .stock-switcher-list-desktop {
    display: none;
  }

  .stock-switcher-list-mobile {
    display: grid;
  }

  .stock-switcher-accordion {
    display: block;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: #fff;
    padding: 0.5rem;
  }

  .stock-switcher-accordion summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    list-style: none;
    color: var(--ink-strong);
    font-weight: 700;
    font-size: 0.9rem;
    padding: 0.45rem 0.35rem;
  }

  .stock-switcher-accordion summary::-webkit-details-marker {
    display: none;
  }

  .stock-switcher-accordion summary::after {
    content: "+";
    color: var(--primary-deep);
    font-size: 1.1rem;
    line-height: 1;
  }

  .stock-switcher-accordion[open] summary::after {
    content: "-";
  }

  .stock-switcher-accordion[open] summary {
    margin-bottom: 0.45rem;
  }

  .stock-switcher-accordion:not([open]) .stock-switcher-list {
    display: none;
  }

  .stock-action-row {
    flex-direction: column;
    align-items: stretch;
  }

  .stock-action-nav {
    width: 100%;
  }

  .stock-action-form {
    width: 100%;
  }

  .stock-action-form .btn {
    white-space: nowrap;
  }

  .span-8,
  .span-7,
  .span-6,
  .span-5,
  .span-4 {
    grid-column: auto;
  }

  .subtool-nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.25rem;
  }

  .subtool-nav .btn {
    flex-shrink: 0;
    font-size: 0.8rem;
    padding: 0.3rem 0.65rem;
  }

  .portfolio-card {
    flex-direction: column;
  }

  .finance-card-title {
    font-size: 1.1rem;
  }

  .finance-block-label,
  .finance-pl-top,
  .finance-pl-bottom {
    font-size: 1rem;
  }
}

@media (max-width: 700px) {
  .header-actions {
    width: 100%;
  }

  .header-actions .btn,
  .header-actions form,
  .header-actions form button {
    width: 100%;
  }
}
