@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@600&display=swap");
/* o4510 — family components. Loads after tokens.css. Every class starts with .o- */

/* Service layer: set data-service on <html>. Only the accent changes; everything else is shared. */
[data-service="link"] { --accent: var(--accent-link); --accent-strong: var(--accent-link-strong); --accent-soft: var(--accent-link-soft); --on-accent: var(--on-accent-link); }
[data-service="grow"] { --accent: var(--accent-grow); --accent-strong: var(--accent-grow-strong); --accent-soft: var(--accent-grow-soft); --on-accent: var(--on-accent-grow); --action: var(--accent-grow); --on-action: var(--on-accent-grow); }
[data-service="safe"] { --accent: var(--accent-safe); --accent-strong: var(--accent-safe-strong); --accent-soft: var(--accent-safe-soft); --on-accent: var(--on-accent-safe); --action: var(--accent-safe); --on-action: var(--on-accent-safe); }
[data-service="card"] { --accent: var(--accent-card); --accent-strong: var(--accent-card-strong); --accent-soft: var(--accent-card-soft); --on-accent: var(--on-accent-card); }

.o-root, body.o-root { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font-sans); font-size: 15px; line-height: 26px; letter-spacing: 0.01em; -webkit-font-smoothing: antialiased; }
.o-root *, .o-root *::before, .o-root *::after { box-sizing: border-box; }
.o-num { font-variant-numeric: tabular-nums; }
.o-root :focus-visible { outline: var(--focus-width) solid var(--ring); outline-offset: var(--focus-offset); }
@media (prefers-reduced-motion: reduce) { .o-root * { transition: none !important; animation: none !important; } }

/* ---------- Button ---------- */
.o-btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: var(--control-height); padding: 0 var(--space-4); border-radius: var(--radius-control); border: 1px solid transparent; font: 600 15px/1 var(--font-sans); letter-spacing: 0.01em; text-decoration: none; cursor: pointer; transition: background-color 120ms, border-color 120ms; white-space: nowrap; }
.o-btn--primary { background: var(--action); color: var(--on-action); }
.o-btn--primary:hover { background: var(--fg-soft); }
[data-service="grow"] .o-btn--primary:hover, [data-service="safe"] .o-btn--primary:hover { background: var(--accent-strong); }
.o-btn--secondary { background: var(--bg); color: var(--fg); border-color: var(--control-border); }
.o-btn--secondary:hover { background: var(--bg-inset); }
.o-btn--quiet { background: transparent; color: var(--fg); }
.o-btn--quiet:hover { background: var(--bg-inset); }
.o-btn--danger { background: var(--danger); color: var(--on-danger); }
.o-btn--compact { min-height: var(--control-height-compact); padding: 0 var(--space-3); font-size: 14px; }
.o-btn[disabled], .o-btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }

/* ---------- Field ---------- */
.o-field { display: grid; gap: var(--space-1); align-content: start; max-width: var(--reading-width); }
.o-field__label { font-size: 13px; line-height: 18px; font-weight: 600; letter-spacing: 0.02em; color: var(--fg); }
.o-field__hint { font-size: 13px; line-height: 20px; color: var(--muted); }
.o-field__error { font-size: 13px; line-height: 20px; color: var(--danger); }
.o-input { width: 100%; min-height: var(--control-height); padding: 0 var(--space-3); border: 1px solid var(--control-border); border-radius: var(--radius-control); background: var(--bg); color: var(--fg); font: 400 15px/1.5 var(--font-sans); }
.o-input::placeholder { color: var(--faint); }
.o-input[aria-invalid="true"] { border-color: var(--danger); }
@media (pointer: coarse) { .o-input { font-size: 16px; } }

/* ---------- StatusBadge ---------- */
.o-badge { display: inline-flex; align-items: center; gap: var(--space-1); padding: 1px 10px; border-radius: var(--radius-pill); font-size: 13px; line-height: 20px; font-weight: 600; background: var(--bg-inset); color: var(--fg-soft); white-space: nowrap; }
.o-badge::before { content: attr(data-mark); }
.o-badge--success { background: var(--success-bg); color: var(--success); }
.o-badge--warning { background: var(--warning-bg); color: var(--warning); }
.o-badge--danger { background: var(--danger-bg); color: var(--danger); }
.o-badge--info { background: var(--info-bg); color: var(--info); }

/* ---------- Notice ---------- */
.o-notice { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-3) var(--space-4); border-radius: var(--radius-panel); background: var(--info-bg); color: var(--info); }
.o-notice__title { font-weight: 600; }
.o-notice a { color: inherit; font-weight: 600; }
.o-notice--success { background: var(--success-bg); color: var(--success); }
.o-notice--warning { background: var(--warning-bg); color: var(--warning); }
.o-notice--danger { background: var(--danger-bg); color: var(--danger); }

/* ---------- Panel ---------- */
.o-panel { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-panel); padding: var(--space-4); }
.o-panel--subtle { background: var(--bg-subtle); }
.o-panel__title { margin: 0 0 var(--space-2); font-size: 15px; line-height: 24px; font-weight: 600; }

/* ---------- Stat ---------- */
.o-stats { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.o-stat { display: grid; gap: 2px; padding: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-panel); background: var(--bg); }
.o-stat__label { font-size: 13px; line-height: 18px; font-weight: 600; letter-spacing: 0.02em; color: var(--muted); }
.o-stat__value { font-family: var(--font-brand); font-size: 28px; line-height: 32px; font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.o-stat__note { font-size: 13px; line-height: 20px; color: var(--muted); }

/* ---------- DataTable ---------- */
.o-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-record); }
.o-table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 22px; }
.o-table th { text-align: left; font-size: 13px; line-height: 18px; font-weight: 600; color: var(--muted); background: var(--bg-subtle); padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; vertical-align: middle; }
.o-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); color: var(--fg-soft); vertical-align: middle; }
/* 表の中の操作は compact にそろえ、行の高さを一定にする */
.o-table .o-input { min-height: var(--control-height-compact); padding-block: 0; font-size: 14px; }
.o-table .o-btn { min-height: var(--control-height-compact); padding: 0 var(--space-3); font-size: 14px; }
.o-table form { display: inline-flex; gap: var(--space-1); align-items: center; margin: 0; vertical-align: middle; }
.o-table code, .o-table .o-badge { vertical-align: middle; }
/* 数字・ID・日付は折り返さない。列の多い表は横に流す */
.o-table td.num, .o-table th.num, .o-table code, .o-table .o-nowrap { white-space: nowrap; }
.o-table--wide td, .o-table--wide th { white-space: nowrap; }
.o-nowrap { white-space: nowrap; }
.o-table td:has(> form), .o-table td:has(> .o-btn) { white-space: nowrap; }
/* スマホでは1行を「ラベル：値」の縦積みにする。各 td に data-label を付ける（safe の stackable を共通化） */
@media (max-width: 640px) {
  .o-table--stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .o-table--stack, .o-table--stack tbody, .o-table--stack tr, .o-table--stack td { display: block; width: 100%; }
  .o-table--stack tr { padding: var(--space-2) 0; border-bottom: 1px solid var(--border); }
  .o-table--stack tbody tr:last-child { border-bottom: 0; }
  .o-table--stack td { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: var(--space-1) var(--space-2); padding: 6px var(--space-4); border: 0; text-align: right; white-space: normal; }
  .o-table--stack td::before { content: attr(data-label); flex: none; margin-right: auto; padding-right: var(--space-3); text-align: left; font-size: 13px; font-weight: 600; color: var(--muted); }
  .o-table--stack td:first-child { font-weight: 600; color: var(--fg); }
  .o-table--stack td.num { text-align: right; }
  .o-table--stack tbody tr:hover td { background: transparent; }
}
.o-table tr:last-child td { border-bottom: 0; }
.o-table tbody tr:hover td { background: var(--bg-inset); }
.o-table .o-num, .o-table td.num, .o-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.o-table tfoot td { color: var(--fg); font-weight: 600; background: var(--bg-subtle); }

/* ---------- AppHeader ---------- */
.o-header { display: flex; align-items: center; gap: var(--space-4); min-height: var(--header-height); padding: 0 var(--space-5); background: var(--bg); border-bottom: 1px solid var(--border); }
.o-header__brand { display: inline-flex; align-items: center; text-decoration: none; color: var(--fg); }
.o-header__brand img { height: 36px; width: auto; display: block; }
.o-header__nav { display: flex; gap: 2px; flex-wrap: wrap; }
.o-header__nav a { display: inline-flex; align-items: center; min-height: 36px; padding: 0 var(--space-3); border-radius: var(--radius-control); color: var(--fg-soft); text-decoration: none; font-size: 14px; }
.o-header__nav a:hover { background: var(--bg-inset); }
.o-header__nav a[aria-current="page"] { background: var(--accent-soft); color: var(--fg); font-weight: 600; box-shadow: inset 0 -2px 0 var(--accent); }
.o-header__end { margin-left: auto; display: flex; align-items: center; gap: var(--space-2); }
.o-avatar { width: 36px; height: 36px; border-radius: var(--radius-pill); background: var(--bg-inset); color: var(--fg-soft); display: inline-grid; place-items: center; font-size: 14px; font-weight: 600; border: 0; }

/* ---------- ServiceSwitcher ---------- */
.o-switcher { width: 320px; max-width: 100%; padding: var(--space-2); background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-panel); box-shadow: var(--shadow-overlay); }
.o-switcher__label { padding: var(--space-2) var(--space-3) var(--space-1); font-size: 13px; line-height: 18px; font-weight: 600; color: var(--muted); }
.o-switcher__item { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 0 var(--space-2); min-height: var(--control-height); padding: 6px var(--space-3); border-radius: var(--radius-control); text-decoration: none; color: var(--fg); }
.o-switcher__item:hover { background: var(--bg-inset); }
.o-switcher__item[aria-current="true"] { background: var(--bg-inset); }
.o-switcher__name { font-family: var(--font-brand); font-weight: 600; font-size: 15px; letter-spacing: -0.015em; }
.o-switcher__purpose { grid-column: 1; font-size: 13px; line-height: 18px; color: var(--muted); }
.o-switcher__state { grid-row: 1 / span 2; grid-column: 2; font-size: 12px; color: var(--muted); }
.o-switcher__divider { height: 1px; margin: var(--space-2) 0; background: var(--border); }

/* ---------- ServiceTile ---------- */
.o-tiles { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.o-tile { display: flex; flex-direction: column; gap: var(--space-1); padding: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-panel); background: var(--bg); }
.o-tile--off { border-style: dashed; background: var(--bg-subtle); }
.o-tile__head { display: flex; align-items: center; gap: var(--space-2); }
.o-tile__dot { width: 10px; height: 10px; border-radius: var(--radius-pill); background: var(--accent); flex: none; }
.o-tile__name { font-family: var(--font-brand); font-weight: 600; font-size: 17px; letter-spacing: -0.015em; }
.o-tile__purpose { font-size: 13px; line-height: 20px; color: var(--muted); }
.o-tile__meta { font-size: 14px; color: var(--fg-soft); }
.o-tile__actions { margin-top: auto; padding-top: var(--space-2); display: flex; gap: var(--space-2); flex-wrap: wrap; }

/* ---------- NextSteps ---------- */
.o-next { padding: var(--space-4); border-radius: var(--radius-panel); background: var(--accent-soft); }
.o-next__title { margin: 0 0 var(--space-2); font-size: 15px; font-weight: 600; }
.o-next ol { margin: 0; padding: 0; list-style: none; display: grid; gap: var(--space-2); counter-reset: step; }
.o-next li { display: grid; grid-template-columns: 24px 1fr; gap: var(--space-2); align-items: start; counter-increment: step; }
.o-next li::before { content: counter(step); width: 24px; height: 24px; border-radius: var(--radius-pill); background: var(--bg); color: var(--fg); border: 1px solid var(--control-border); display: grid; place-items: center; font-size: 13px; font-weight: 600; }
.o-next li[data-done]::before { content: "✓"; background: var(--success); border-color: var(--success); color: var(--bg); }
.o-next li[data-done] { color: var(--fg-soft); }
.o-next a { color: var(--fg); font-weight: 600; }

/* ---------- EmptyState ---------- */
.o-empty { display: grid; justify-items: start; gap: var(--space-2); padding: var(--space-6) var(--space-5); border: 1px dashed var(--border-strong); border-radius: var(--radius-panel); max-width: var(--reading-width); }
.o-empty__title { margin: 0; font-size: 16px; font-weight: 600; }
.o-empty__text { margin: 0; color: var(--fg-soft); }

/* ---------- PageHead ---------- */
.o-page-head { display: grid; gap: var(--space-1); margin-bottom: var(--space-5); }
.o-page-head__back { width: fit-content; font-size: 14px; color: var(--muted); text-decoration: none; }
.o-page-head__back:hover { color: var(--fg); text-decoration: underline; }
.o-page-head__row { display: flex; gap: var(--space-4); align-items: flex-end; justify-content: space-between; flex-wrap: wrap; }
.o-page-head__text { min-width: 0; }
.o-page-head__title { margin: 0; font-size: 24px; line-height: 34px; font-weight: 600; text-wrap: balance; }
@media (min-width: 640px) { .o-page-head__title { font-size: 28px; line-height: 38px; } }
.o-page-head__lead { margin: var(--space-1) 0 0; color: var(--fg-soft); display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }
.o-page-head__actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }

/* ---------- Delta（差額の表示。PlanCard・QuantityStepper・ConfirmChange で使う） ---------- */
.o-delta { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--muted); }
.o-delta--up { color: var(--warning); }
.o-delta--down { color: var(--success); }

/* ---------- PlanCard ---------- */
.o-plans { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.o-plan { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-panel); background: var(--bg); }
.o-plan--current { border-color: var(--fg); box-shadow: inset 0 0 0 1px var(--fg); }
.o-plan__head { display: flex; justify-content: space-between; gap: var(--space-2); align-items: center; font-weight: 600; }
.o-plan__price { display: flex; align-items: baseline; gap: var(--space-1); flex-wrap: wrap; }
.o-plan__amount { font-family: var(--font-brand); font-size: 24px; line-height: 30px; font-weight: 600; font-variant-numeric: tabular-nums; }
.o-plan__unit { font-size: 13px; color: var(--muted); }
.o-plan__facts { margin: 0; padding-left: 1.1em; display: grid; gap: 2px; font-size: 14px; line-height: 22px; color: var(--fg-soft); }
.o-plan__action { margin-top: auto; padding-top: var(--space-2); }

/* ---------- QuantityStepper ---------- */
.o-quantity { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; padding: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-panel); background: var(--bg); }
.o-stepper { display: inline-flex; align-items: stretch; }
.o-stepper .o-btn { min-width: var(--control-height); padding: 0; font-size: 18px; }
.o-stepper .o-btn:first-child { border-radius: var(--radius-control) 0 0 var(--radius-control); }
.o-stepper .o-btn:last-child { border-radius: 0 var(--radius-control) var(--radius-control) 0; }
.o-stepper .o-input { width: 84px; text-align: center; border-radius: 0; border-left: 0; border-right: 0; font-variant-numeric: tabular-nums; -moz-appearance: textfield; }
.o-stepper .o-input::-webkit-outer-spin-button, .o-stepper .o-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.o-quantity__preview { flex: 1; min-width: 200px; display: flex; gap: var(--space-2); align-items: baseline; flex-wrap: wrap; }
.o-quantity__amount { font-family: var(--font-brand); font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- ConfirmChange ---------- */
.o-compare { display: grid; grid-template-columns: 1fr auto 1fr; gap: var(--space-3); align-items: center; max-width: var(--reading-width); }
.o-compare__col { display: grid; gap: 2px; padding: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-panel); background: var(--bg); }
.o-compare__col--next { border-color: var(--fg); box-shadow: inset 0 0 0 1px var(--fg); }
.o-compare__arrow { font-size: 22px; color: var(--muted); }
@media (max-width: 520px) { .o-compare { grid-template-columns: 1fr; } .o-compare__arrow { justify-self: center; transform: rotate(90deg); } }
.o-facts { margin: var(--space-5) 0; padding-left: 1.2em; display: grid; gap: var(--space-2); max-width: var(--reading-width); color: var(--fg-soft); }
.o-facts strong { color: var(--fg); }
.o-facts .o-delta--up { color: var(--warning); }
.o-facts .o-delta--down { color: var(--success); }
.o-confirm-actions { display: flex; gap: var(--space-3); flex-wrap: wrap; align-items: center; }

/* ---------- Disclosure ---------- */
.o-disclosure > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; min-height: var(--control-height-compact); font-size: 14px; color: var(--fg-soft); }
.o-disclosure > summary::-webkit-details-marker { display: none; }
.o-disclosure > summary::before { content: "▸"; transition: transform 120ms; }
.o-disclosure[open] > summary::before { transform: rotate(90deg); }
.o-disclosure > summary:hover { color: var(--fg); }
.o-disclosure__body { padding-top: var(--space-2); }

/* ---------- CopyField ---------- */
.o-copy { display: flex; gap: var(--space-2); max-width: var(--reading-width); }
.o-copy .o-input { font-family: var(--font-mono); font-size: 13px; }
.o-copy__done { font-size: 13px; color: var(--success); }

/* ---------- ListLink ---------- */
.o-listlinks { display: grid; gap: var(--space-2); max-width: var(--reading-width); }
.o-listlink { display: grid; grid-template-columns: 40px 1fr auto; gap: var(--space-3); align-items: center; padding: var(--space-3) var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-panel); background: var(--bg); color: var(--fg); text-decoration: none; transition: background-color 120ms, border-color 120ms; }
.o-listlink:hover { background: var(--bg-subtle); border-color: var(--border-strong); }
.o-listlink__initial { width: 40px; height: 40px; border-radius: var(--radius-control); background: var(--bg-inset); display: grid; place-items: center; font-weight: 600; }
.o-listlink__title { display: block; font-weight: 600; }
.o-listlink__sub { display: block; font-size: 13px; color: var(--muted); }
.o-listlink__go { color: var(--muted); }

/* ---------- 共通: 操作のあとの結果・リンクの Stat ---------- */
.o-flash .o-notice { animation: o-flash-in 160ms ease-out; }
@keyframes o-flash-in { from { transform: translateY(-4px); opacity: .4; } to { transform: none; opacity: 1; } }
a.o-stat { color: inherit; text-decoration: none; transition: border-color 120ms, background-color 120ms; }
a.o-stat:hover { border-color: var(--border-strong); background: var(--bg-subtle); }
a.o-stat .o-stat__note { text-decoration: underline; text-underline-offset: 3px; }
.o-stat__of { font-family: var(--font-sans); font-size: 15px; font-weight: 400; color: var(--muted); }
